akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;

int n;
int ans = 0;
void dfs(int x, int a, int b, int c) {
	if (x > n)return;
	if (a&&b&&c) {
		ans++;
	}
	dfs(x * 10 + 3, 1, b, c);
	dfs(x * 10 + 5, a, 1, c);
	dfs(x * 10 + 7, a, b, 1);
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	dfs(0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;

  long X=-1, Y=2, Z;
  for (int i=1; i<=N; i++){
    Z = X + Y;
    X = Y;
    Y = Z;
  }
  cout << Z << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    ll N;
    cin >> N;
    
    auto get_state = [](int i) {
        cout << i << "\n" << flush;
        string s;
        cin >> s;
        if ( s == "Male" ) return 0;
        else if ( s == "Female" ) return 1;
        else return -1;
    };

    int ls = get_state(0);
    if ( ls < 0 ) return;
    int rs = 1 - ls; 
    int l = 0, r = N;
    while ( r - l > 0 ) {
        int m = (l+r)/2;
        int ms = get_state(m);
        if ( ms < 0 ) return;
        if ( (ms^ls) == ((m^l)&1) ) {
            l = m;
            ls = ms;
        } else {
            r = m;
            rs = ms;
        }
    }
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 852
s = input().split()
max_c = 0
max_l = 0
c = ''
l = ''
for i in s:
  if s.count(i) > max_c:
    max_c = s.count(i)
    c = i
  if len(i) > max_l:
    max_l = len(i)
    l = i
print(c+' '+l)

Measured memory_bytes: 7352
#include <stdio.h>

int parent(int);
int left(int);
int right(int);

int main()
{
  int H[250];
  int n,v,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&H[i]);
    }
  for(i=1;i<=n;i++)
    {
      printf("node %d: ",i);
      printf("key = %d, ",H[i]);
      if(parent(i) >=1)
	printf("parent key = %d, ",H[parent(i)]);
      if(left(i) <= n)
	printf("left key = %d, ",H[left(i)]);
      if(right(i) <= n)
	printf("right key = %d, ",H[right(i)]);
      printf("\n");
    }
  return 0;
}

int parent(int i)
{
  return i/2;
}

int left(int i)
{
  return i * 2;
}

int right(int i)
{
  return i * 2 + 1;
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;
	cin>>n;
	ll a;
	vector<ll> A;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	int max_abs = 0;
	int max_i = 0;
	rep(i,n){
		if(abs(A[i]) > max_abs){
			max_abs = abs(A[i]);
			max_i = i;
		}
	}

	cout<<2*n-2<<endl;
	rep(i,n){
		if(i==max_i) continue;
		cout<<max_i+1<<" "<<i+1<<endl;
		A[i+1] += A[max_i+1];
	}
	if(A[max_i] >= 0){
		reps(i,n-1){
			cout<<i<<" "<<i+1<<endl;
			A[i+1] += A[i];
		}
	}else{
		REPS(i,n-1){
			cout<<i+1<<" "<<i<<endl;
			A[i] += A[i+1];
		}
	}
	rep(i,n){
		//cout<<A[i]<<" ";
	}
	//cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string T;
ll from[3030],to[3030];
ll S[3030];

ll mo=1000000007;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cin>>T;
	
	FOR(i,N) from[i]=1;
	
	FOR(i,N-1) {
		ZERO(to);
		FOR(x,N+1) S[x]=((x?S[x-1]:0)+from[x])%mo;
		FOR(x,N-1-i) {
			if(T[i]=='>') to[x]=(S[N]+mo-S[x])%mo;
			else to[x]=S[x];

		}
		swap(from,to);
	}
	cout<<from[0]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
void solve(int n){
	bool exist = false;
	for(int i = 0 ; i < 11; i++){
		if(n & 1 << i){
			if(exist)cout << " ";
			cout << (1 << i);
			exist = true;
		}
	}
	cout << endl;
}
int main(){
	int n;
	while(cin >> n){
		solve(n);
	}

	return 0;
}

Measured memory_bytes: 1160
module app;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.stdio;
import std.string;

void main()
{
	auto input = parseInput();
    auto result = main2(input);	
	writefln("%d", result);
}

int main2(Input input)
{
    struct Player
    {
        bool done;
        int[] rest;
    }

    Player[] players;
    players.length = input.n + 1;
    for (int i = 0; i < input.a.length; i++)
        players[i+1].rest = input.a[i];

    int[] cache;
    foreach (i; 1..input.n+1)
        cache ~= i;

    int days = 0;
    while (true)
    {
        int[] lastDay = cache;
        cache.length = 0;
        days++;

        bool found = false;

        void tryMatch(int i)
        {
            if (players[i].done)
                return;

            if (players[i].rest.length == 0)
                return;

            auto nextOpponent = players[i].rest[0];
            if (!players[nextOpponent].done && players[nextOpponent].rest[0] == i)
            {
                players[nextOpponent].done = true;
                players[nextOpponent].rest = players[nextOpponent].rest[1..$];
                players[i].done = true;
                players[i].rest = players[i].rest[1..$];

                cache ~= [i, nextOpponent];
            }
        }

        foreach (i; lastDay)
        {
            tryMatch(i);
        }

        if (cache.length == 0)
            return -1;

        bool playerExists;

        for (int i = 1; i < players.length; i++)
        {
            if (players[i].rest.length != 0)
            {
                players[i].done = false;
                playerExists = true;
            }
        }

        if (!playerExists)
            return days;
    }
}


unittest
{
    Input input = {3,[[2,3],[1,3],[1,2]]};
    auto result = main2(input);
    assert(result == 3);
}
unittest
{
    Input input = {4,[[2,3,4],[1,3,4],[4,1,2],[3,1,2]]};
    auto result = main2(input);
    assert(result == 4);
}
unittest
{
    Input input = {3,[[2,3],[3,1],[1,2]]};
    auto result = main2(input);
    assert(result == -1);
}


struct Input
{
	int n;
    int[][] a;
}

Input parseInput()
{
	Input input;
	input.n = readln().strip().to!int;
    input.a = new int[][input.n];
    for (int i = 0; i < input.n; i++)
    {
    	input.a[i] = readln().strip().split().map!(a => a.to!int).array;
    }
	return input;
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    vector<int> v(3);
    for(auto x : s){
        rep(i, 3){
            v[i] += x == 'a' + i;
        }
    }
    SORT(v);
    if(v[2] - v[0] <= 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

N = int(input())
A = []
X = []
for i in range(N) :
    A.append(int(input()))
    x = [list(map(int,input().split())) for _ in range(A[i])]
    X.append(x)
#print(A)
#print(X)

# bit all search
P = []
for i in range(2 ** N): # 全パターン数を1つずつ作っていく
    pat = [0] * N
    for j in range(N): 
        if ((i >> j) & 1) : #もとの数iを2進数表記でみて、1が立ってる箇所をチェックしていく  
            pat[N - 1 - j] = 1 
    P.append(pat)
#print(P)

# 正直 or 偽物の条件にマッチするやつチェック
ans = 0
flag = 'Y'
for p in P :
    for i in range(N) :
        if p[i] == 1 : # 正直者である人の意見を見に行く
            for x in X[i] :
                if x[1] != p[x[0]-1] :
                    flag = 'N'
    if flag == 'Y' : # flag = Y を維持したなら矛盾なしということで判定
        c = sum(p)
        if c > ans :
            ans = c
    flag = 'Y' # 初期化
print(ans)


Measured memory_bytes: 9460
#include<iostream>
#include<vector>
#include<utility>
#include<bitset>
#include<functional>
using namespace std;
int main(int argc, char *argv[])
{
  for(int t = 1;; t++) {
    int n, m;
    cin >> m >> n;
    if(n == 0) break;
    vector<int> os;
    for(int i = 0; i < n; i++) {
      string str;
      cin >> str;
      int o = 0;
      for(int k = 0; k < m; k++) {
        o = (o << 1) | (str[k] == '1');
      }
      os.push_back(o);
    }
    const int M = 1 << m;
    // dp: state = a set of objects to be determined (too big, in general)
    //           = m bits of fixed (asked so far) or not yet fixed
    //              i.e., each bit = 0 | 1 | not_fixed_yet = 10,11,0x (2bit)
    //           = O(3^m) (or O(4^m) for the 2bit representation)
    vector<vector<int>> memo(M, vector<int>(M,-1));
    function<int(int, int)> rec = [&rec,&os,&memo,&m,&M](const int fixed, const int bits) {
      // memo
      if(memo[fixed][bits] >= 0) return memo[fixed][bits];
      int n = 0; // # of objects to be determined
      for(int o : os) {
        n += ((o & fixed) == bits) ? 1 : 0;
      }
      if(n == 1) { // already determined
        memo[fixed][bits] = 0;
        return memo[fixed][bits];
      }
      // try all possible choices of next bits
      int mn = m;
      int bs = (~fixed)&(M-1);
      while(bs != 0) {
        int b = -bs&bs;
        bs ^= b;
        mn = min(mn, 1+max(rec(fixed | b, bits), rec(fixed | b, bits | b)));
      }
      memo[fixed][bits] = mn;
      return memo[fixed][bits];
    };
    cout << rec(0,0) << endl;
  }
  return 0;
}

/*
This is wrong.
    // greedy algo.; choosing the most informative bit to split the object set 
    function<int(const vector<int>&, int)> rec = [&rec](const vector<int> &os, const int bits) {
      int n = os.size();
      if(n == 1) return 0;
      int bit = 0;
      int mx = 0;
      int bs = bits;
      while(bs != 0) {
        int b = -bs&bs;
        bs ^= b;
        int cnt = 0;
        for(int i = 0; i < n; i++) {
          if(os[i] & b) { cnt ++; }
        }
        cnt = min(n - cnt, cnt);
        if(cnt > mx) {
          mx = cnt;
          bit = b;
        }
      }
      vector<int> ones, zeros;
      for(int i = 0; i < n; i++) {
        if(os[i] & bit) { ones.push_back(os[i]); }
        else            { zeros.push_back(os[i]); }
      }
      return 1+max(rec(ones, bits ^ bit), rec(zeros, bits ^ bit));
    };
    cout << rec(os, (1<<m) - 1) << endl;
*/

Measured memory_bytes: 19212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
///#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 1000000007

int main() {
	ll n;
	cin>>n;
	ll sum=0;
	for (ll i=1;i<=n;i++) {
		ll x=floor(n*1.0L/i);
		sum+=i*x*(x+1)/2;
	}
	cout<<sum;
}


Measured memory_bytes: 3540
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
#include<iomanip>
#include<tuple>
#include<stack>

#define _USE_MATH_DEFINES
#include<math.h>


using namespace std;
typedef long long ll;

typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef tuple<int, int, int> ti3;

const ll MOD_CONST = 1000000007;
//const ll MOD_CONST = 998244353;


const int BIG_NUM = 1000000005;
const ll INF = 1000000000000000000;

//const vector<vector<int>> DIR{ {1,0},{0,1},{-1,0},{0,-1} };

//const double EPS = 1e-10;


int main() {
	int n, m, d;
	cin >> n >> m >> d;
	double p = (d == 0) ? 1.0 / n : (2.0 * (n - d)) / n / n;
	std::cout << setprecision(20) << p * (m - 1) << endl;
} 




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    string s,s2;
    int flag=1;
    cin >> s;
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int x,f;
        char c[2];
        scanf("%d",&x) ;
        if(x==1) flag=!flag;
        else
        {
            scanf("%d%s",&f,c);
            f--;
            if(flag^f)s2.push_back(c[0]);
            else s.push_back(c[0]);
        }
    }
    if(flag)
    {
        reverse(s2.begin(),s2.end());
        cout << s2 << s << endl;
    }
    else
    {
        reverse(s.begin(),s.end());
        cout << s << s2 << endl;
    }
    return 0;
}

Measured memory_bytes: 960
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    private static int N;
    private static int A[][];

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        A = new int[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        System.out.println(solve());
    }

    static long solve() {

        boolean[][] indirect = new boolean[N][N];

        for (int i = 0; i < N-1 ; i++) {
            for (int j = i+1; j < N ; j++) {
                for (int k = 0; k < N; k++) {
                    if( k == i || k == j ) continue;
                    int ikj = A[i][k] + A[k][j];
                    int ij = A[i][j];
                    if( ikj < ij ) {
                        return -1;
                    } else if( ikj == ij ) {
                        indirect[i][j] = true;
                    }
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < N-1 ; i++) {
            for (int j = i+1; j < N ; j++) {
                if( !indirect[i][j] ) {
                    ans += A[i][j];
                }
            }
        }

        return ans;
    }

    static class FastScanner {

        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 32672
#include <iostream>
#include <algorithm>
using namespace std;

long long a[100000];

int main(void)
{
	long long N;
	cin >> N;

	int bi_2 = 0;
	int bi_4 = 0;
	
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		if (a[i] % 4 == 0) ++bi_4;
		else if (a[i] % 2 == 0) ++bi_2;
	}

	if (bi_2 != 0 && bi_2 != N) --bi_2;

	if (bi_4 > 0) bi_4 = bi_4 * 2 + 1;

	if (bi_2 + bi_4 >= N) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1024
n,y = map(int,input().split())

for i in range(y // 10000 + 1):
    for j in range(y // 5000 + 1):
        k = n - i - j
        if 0 <= k and 10000 * i + 5000 * j + 1000 * k == y:
            print(i,j,k,sep=" ")
            exit()
print("-1 " + "-1" + " -1")

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, sum;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int L, R;
    cin >> L >> R;
    
    sum += R - L + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x) { int k, m = 0; *x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { *x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; *x = (*x) * 10 + k - '0'; }if (m)(*x) = -(*x); }
void reader(int *x, int *y) { reader(x); reader(y); }
void reader(int *x, int *y, int *z) { reader(x); reader(y); reader(z); }
void writer(int x, char c) { int i, sz = 0, m = 0; char buf[10]; if (x<0)m = 1, x = -x; while (x)buf[sz++] = x % 10, x /= 10; if (!sz)buf[sz++] = 0; if (m)mypc('-'); while (sz--)mypc(buf[sz] + '0'); mypc(c); }

int a[1000][1000], dp[1000][1000];
int main() {
	int h, w, n;
	while (reader(&h, &w, &n), h) {
		rep(i, h)rep(j, w) {
			if (i || j)getchar_unlocked(); a[i][j] = getchar_unlocked() - '0';
		}
		memset(dp, 0, sizeof(dp));
		dp[0][0] = n - 1;
		rep(i, h)rep(j, w) {
			if (i) {
				if (a[i - 1][j])dp[i][j] += dp[i - 1][j] >> 1;
				else dp[i][j] += (dp[i - 1][j] + 1) >> 1;
			}
			if (j) {
				if (a[i][j - 1])dp[i][j] += (dp[i][j - 1] + 1) >> 1;
				else dp[i][j] += dp[i][j - 1] >> 1;
			}
		}
		int x = 0, y = 0;
		while (x < h&&y < w) {
			if ((dp[x][y] ^ a[x][y]) & 1)y++;
			else x++;
		}
		writer(x + 1, ' '); writer(y + 1, '\n');
	}
}

Measured memory_bytes: 10896
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

X, N = getNM()
P = sorted(getList())
P = set(P)

for i in range(500):
    opt1 = X + i
    ans = []
    if not opt1 in P:
        ans.append(opt1)
    opt2 = X - i
    if not opt2 in P:
        ans.append(opt2)
    if len(ans) > 0:
        print(min(ans))
        break

Measured memory_bytes: 78084
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; ++i) cin >> S[i];

  int x[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int y[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (S[i][j] == '#') continue;
      int num = 0;
      for (int k = 0; k < 8; ++k) {
	int dx = j - x[k];
	int dy = i - y[k];
	if (dx < 0 || dx >= W) continue;
	if (dy < 0 || dy >= H) continue;
	if (S[dy][dx] == '#') num++;
      }
      S[i][j] = num + '0';
    }
  }

  for (int i = 0; i < H; ++i) {
    cout << S[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//agc001_a.cpp
//Fri Nov  2 23:05:36 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;

	int l[2*n];
	for (int i=0;i<2*n;i++){
		cin >> l[i];
	}

	sort(l,l+2*n);
	int ans = 0;
	for (int i=0;i<2*n;i=i+2){
		ans += l[i];
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;
char tmp[MAXN];

int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int l = a + b;
    int r = c + d;
    if (l < r) printf("Right\n");
    else if (l > r) printf("Left\n");
    else printf("Balanced\n");
    return 0;
}


Measured memory_bytes: 256
n=int(input())
lst=[]

for i in range(n):
  a=list(map(int,input().split()))
  lst.append(a)
  
lst.sort(key=lambda x:x[1])

time=0

for i in lst:
  time+=i[0]
  if time>i[1]:
    print('No')
    exit()
    
    
print('Yes')

Measured memory_bytes: 47032
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    string a, b, c;
    cin >> a >> b >> c;
    int idx1 = 0, idx2 = 0, idx3 = 0;
    char s = 'a';
    while (1)
    {

        if (s == 'a')
        {
            if (idx1 == a.size())
            {
                cout << "A" << endl;
                break;
            }
            s = a[idx1];
            idx1++;
        }
        else if (s == 'b')
        {
            if (idx2 == b.size())
            {
                cout << "B" << endl;
                break;
            }
            s = b[idx2];
            idx2++;
        }
        else if (s == 'c')
        {
            if (idx3 == c.size())
            {
                cout << "C" << endl;
                break;
            }
            s = c[idx3];
            idx3++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  ll n;
  cin >> n;
  ll a = ceil(pow(n, 0.5));

  while(true)
  {
    if(n % a == 0) 
    {
      string s = to_string(n / a);
      string s2 = to_string(a);
      // cout << s << endl;
      cout << max(s.size(), s2.size()) << endl;
      return 0;
    }
    // cout << (a - (n % a)) << endl;
    // a += (a - (n % a));
    // cout << a << endl;
    // cout << "=========" <<endl;
    // cout << n / a << endl;
    a--;
  }
}

Measured memory_bytes: 512
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    int n=s.length();
    for(int i=0;i<n;i+=2){
        if(s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(int i=1;i<n;i+=2){
        if(s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  for (int i = 1; i < n; i++) a.at(i) += a.at(i - 1);
  for (int i = n - 2; i >= 0; i--) b.at(i) += b.at(i + 1);
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, a.at(i) + b.at(i));
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int large = 1e9+7;

int main() {
  long long int n, k;
  cin >> n >> k;
  long long int sum = 0;
  for (long long int i = k; i <= n+1; i++) {
    sum += i*(n-i+1)+1;
    sum %= large;
  }

  cout << sum << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef pair<ll, ll> pll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define foro(i, n) for(i=0; i<n; i++)
#define forl(i, n) for(i=1; i<=n; i++)
#define x first
#define y second
constexpr int INF = 1e9 + 1;
constexpr ll LLINF = 1e18 + 1;


int main()
{
	int i, j, k, l, tmp;
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	deque<char> q;
	string s;
	cin >> s;
	for(auto k:s)
		q.push_back(k);
	int qq;
	cin >> qq;
	int t, f;
	char c;
	bool rev = false;
	while(qq--){
		cin >> t;
		if(t==1)
			rev = !rev;
		else{
			cin >> f >> c;
			if(rev==(f!=2))
				q.push_back(c);
			else
				q.push_front(c);
		}
	}
	if(!rev){
		while(!q.empty()){
			printf("%c", q.front());
			q.pop_front();
		}
	}
	else{
		while(!q.empty()){
			printf("%c", q.back());
			q.pop_back();
		}
	}
}



Measured memory_bytes: 976
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N_MAX = 105;
int arr[N_MAX];

int jud(const int &n) {
	int tmp=0;
	while(tmp<n && arr[tmp] == arr[0])
		tmp++;
	if(tmp>2)
		return 0;
	int flag = arr[n-1]-arr[0]*2;
	if(flag != 1-tmp)
		return 0;
	return tmp;
}

int main() {
	int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
		scanf("%d", arr+i);
	sort(arr, arr+n);
	int cen = jud(n);
	if(!cen) {
		puts("Impossible");
		return 0;
	}
	int tmp=0;
	arr[n]=arr[n-1]+1;
	VI vec;
	for(int i=0; i<=n; i++) {
		if(!i || arr[i]==arr[i-1])
			tmp++;
		else if(arr[i]-arr[i-1]>1 || (i!=1 && tmp<2)) {
			puts("Impossible");
			return 0;
		} else
			tmp=1;
	}

	puts("Possible");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int count[4]={};
    int a,b;
    for(int i=0; i<3; i++){
        scanf("%d %d", &a, &b);
        count[a-1]++;
        count[b-1]++;
    }
    for(int i=0; i<4; i++)
        if(count[i] >= 3 || count[i]==0){
            printf("NO\n");
            return 0;
        }
    
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mod 1000000007
#define lim 15000005
using namespace std;
typedef long long int ll;
typedef pair<int,int> pi;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;ll x;
    cin>>n>>x;
    ll a[n];
    for (int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    int ct=0;
    for (int i=0;i<n;i++) {
        if (a[i]<=x) ct++;
        x-=a[i];
    }
    if (x>0) ct--;
    cout<<ct;
}


Measured memory_bytes: 256
package main

import "fmt"

func pf(n int) (r map[int]int) {
	t := n
	r = make(map[int]int, 0)
	for i := 2; i*i <= n; i++ {
		for t%i == 0 {
			r[i]++
			t /= i
		}
	}
	if t > 1 {
		r[t]++
	}
	return r
}

func num(m map[int]int, n int) int { // mapの要素のうちn個以上あるもの
	r := 0
	for _, v := range m {
		if v >= n {
			r++
		}
	}
	return r
}

func main() {
	var N int
	fmt.Scan(&N)
	pfs := make(map[int]int, 0) // N!の素因数分解の結果を格納するmap
	for i := 1; i <= N; i++ {
		for k, v := range pf(i) {
			pfs[k] += v
		}
	}
	// 約数が75個になる組み合わせは以下の4パターン
	// 1. a^74
	// 2. a^2*b^24
	// 3. a^4*b^14
	// 4. 2^2*b^4*c^4
	v2, v4, v14, v24, v74 := num(pfs, 2), num(pfs, 4), num(pfs, 14), num(pfs, 24), num(pfs, 74)
	fmt.Println(v74 + v24*(v2-1) + v14*(v4-1) + v4*(v4-1)/2*(v2-2))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

using namespace std;

int main() {
    int k = 0;
    int n = 0;
    cin >> k >> n;

    int sum = 0;

    int array[n];

    for(int i = 0; i < n ; i++){
        cin >> array[i];
    }

    int last = array[n - 1];
    int first = array[0];

    for(int i = n - 1 ;i > 0 ; i--){
        array[i] -= array[i - 1];
    }

    array[0] += k - last;

    
    sort(array,array + n);

    for(int i = 0 ; i < n - 1 ; i++){
        sum += array[i];
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll l(n);
    REP(i,n) cin >> l[i];
    sort(ALL(l));
    ll ans = 0;
    for(int i=n-1;i>=2;i--){
        for(int j=i-1;j>=1;j--){
            ll ok = j;
            ll ng = -1;
            while(abs(ok-ng)>1){
                ll mid = (ok+ng)/2;
                if(l[i]-l[j]<l[mid]){
                    ok = mid;
                }else{
                    ng = mid;
                }
            }
            ans += (ll)j-ok;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  int oddcounter = 0;
  for(int i = 0; i < N; i++){
    if(A[i] % 2 == 1) oddcounter++;    
  }
  
  if(oddcounter % 2 == 0) cout << "YES";
  else cout << "NO";
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
string a,b,c,d,e;
ll x,y,z,count;

count=0;
c="";
d="";
cin >> a >> x;
vector<ll> v(x);

for(ll i=0 ; i<x ;i++){

  cin >> v[i];

  if(v[i]==1){
    count+=1;
  }

  if(count%2==0){
    if(v[i]==2){
      cin >> y >> b;
      if(y==1){
      a.insert(0,b);
    }else{
      a.append(b);
    }
    }
    }else{
    if(v[i]==2){
      cin >> y >> b;
      if(y==1){
      a.append(b);
    }else{
      a.insert(0,b);
    }
  }
  }
}
if(count%2==0){

cout << a << endl;

}else{

reverse(a.begin(),a.end());
cout << a << endl;

}

}




Measured memory_bytes: 2564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//スキャナー
		Scanner s = new Scanner(System.in);

		int numx = s.nextInt();
		int numy = s.nextInt();
		
		s.close();
		
		//true=Yes
		boolean ans = true;
		
		if(numy % 2 == 1) {
			ans = false;
		}
		if(numy < numx * 2 || numy > numx * 4 ) {
			ans = false;
		}
		
		if(ans) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35748
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;


using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (int i=a; i<b; i++)
#define pb push_back
#define vvi vector<vector<int>> 
#define vi vector<int>
#define vb vector<bool>
#define vvb vector<vector<bool>> 

vi visit, pos;
int nxt = 1;
void dfs_visit(vvi & adj, int i) {
	visit[i] = 1;
	for (int j : adj[i]) {
		if (!visit[j]) {
			dfs_visit(adj, j);
		}
	}
	pos[i] = nxt++;
}

void dfs(vvi & adj, int n) {
		visit.assign(n+1, 0);
		pos.assign(n+1, 0);
		for(int i=1; i<=n; i++) {
			if (!visit[i]) {
				dfs_visit(adj, i);
			}
		}
}

int main() {
	int n, m;
	cin >> n >> m;

	vvi adj;
	vi lista;
	lista.clear();
	adj.assign(n+1, lista);
	for (int i=1; i<=m; i++) { 
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}

	dfs(adj, n);

	vector<pair<int, int>> v(n+1);
	for(int i=1; i<=n; i++) {
		v[i].first = pos[i];
		v[i].second = i;
	}
	sort(v.rbegin(), v.rend());
	vector<int> path(n+1, 0);
	for(int i=0; i<n; i++) {
		int node = v[i].second;
		for(auto j : adj[node]) path[j] = max(path[j], path[node]+1);
	}
	int ans = 0;
	for(int i=1; i<=n; i++) {
		ans = max(ans, path[i]);	
	}

	cout << ans << endl;
   return 0;

}


Measured memory_bytes: 9728
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

int main(void){
	char s[500001];
	scanf("%s", s+200000);
	int l=200000, r=200000+strlen(s+200000);
	int f=1;

	int q, i;
	scanf("%d", &q);
	for(i=0; i<q; i++){
		int Q, F;
		char c;
		scanf("%d", &Q);
		if(Q==1){
			f=(f==1?2:1);
		}else{
			scanf("%d %c", &F, &c);
			if(F==f){
				s[--l]=c;
			}else{
				s[r++]=c;
			}
		}
	}
	if(f==1){
		s[r]=0;
		printf("%s\n", s+l);
	}else{
		for(i=r-1; i>=l; i--){
			putchar(s[i]);
		}
		putchar(10);
	}
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n,c,k;cin >> n >>c>>k;
  vector<int> t(n);
  for(int i=0;i<n;++i) cin >> t[i];
  sort(all(t));
  int cnt =0;
  int start = t[0];
  int cnt_pas = 1;
  for(int i=1;i<n;++i){
    if((t[i]-start<=k) && (cnt_pas<c)){
      ++cnt_pas;
    } else if((cnt_pas==c) || (t[i]-start>k)) {
      ++cnt;
      cnt_pas = 1;
      start = t[i];
    }
  }
  if(cnt_pas!=0) ++cnt;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD=1e9+7;
string s;
ll dp[200005];
ll a[200005];
map<ll,ll> mp;
map<ll,ll>mpp;
ll n;
ll solve(ll i)
{
    if (dp[i]!=-1)
        return dp[i];
    if(i==n-1)
        return 0;
    if(i>=n)
    return 1e18;
    return dp[i] = min (fabs(a[i+1]-a[i])+solve(i+1),fabs(a[i+2]-a[i])+solve(i+2));
}

int main()
{
    memset(dp,-1,sizeof dp);
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    ll ans=0;
    cout<<solve(0);
    return 0;
}


Measured memory_bytes: 8260
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if (a > b) { swap(a, b); }
	int c = b - a;
	if (c % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	} else {
		cout << a + c / 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define int long long int
int mod = INT_MAX;
int memo[3005][3005];
int n;
string LCSstr(string &s1, string &s2 , int i, int j, int len)
{
	//base cases
	if ((i >= s1.size()) or (j >= s2.size()) or (len == 0))
		return "";
	//selfwork
	string ans;
	while (len > 0)
	{
		if (s1[i] == s2[j])
		{
			ans.push_back(s1[i]);
			i++; j++; len--;
		}
		else
		{
			if (memo[i + 1][j] > memo[i][j + 1])
				i++;
			else
				j++;
		}
	}
	return ans;
}
int LCSlen(string &s1, string &s2 , int i, int j)//pass string by reference
{
	//base cases
	if ((i >= s1.size()) or (j >= s2.size()))
		return 0;
	int &ans = memo[i][j];
	//memoizatiion
	if (ans != -1)
		return ans;
	//self work
	if (s1[i] == s2[j])
		return ans = 1 + LCSlen(s1, s2, i + 1, j + 1);
	else
		return ans = max(LCSlen(s1, s2, i + 1, j), LCSlen(s1, s2, i, j + 1));
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(memo, -1, sizeof(memo));
	string s1, s2;
	cin >> s1 >> s2;
	int len = LCSlen(s1, s2, 0, 0);
	//cout << len << endl;
	cout << LCSstr(s1, s2, 0, 0, len);
	return 0;
}
// 3 8
// 3 30
// 4 50
// 5 60

Measured memory_bytes: 71040
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,A,B;
vector<ll> vec;

//解法
void solve() {

	cout << min(A * N, B);

	return;
}

int main() {
	//入力

	cin >> N >> A >> B;


	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


using namespace std;



int main(){
    int N, Y;
    cin >> N >> Y;
    
    int n_1, n_5, n_10;
    
    int y = Y / 1000;
    
    n_10 = (y - N) / 9;
    n_5 = 10000009;
    
    int flag = 0;
    
    while(true){
        if(n_10 < 0){
            flag = 1;
            break;
        }
        
        if((y - N - 9 * n_10) % 4 == 0){
            n_5 = (y - N - 9 * n_10) / 4;
            break;
        } else {
            --n_10;
        }
    }
    
    n_1 = N - n_5 - n_10;
    
    if(flag == 1 | n_1 < 0 | n_5 < 0 | n_10 < 0){
        n_1 = -1; n_5 = -1; n_10 = -1;
    }
    
    cout << n_10 << " " << n_5 << " " << n_1 << endl;
//    cout << "sum = " << n_10 * 10000 + n_5 * 5000 + n_1 * 1000 << endl;
    return 0;

}


Measured memory_bytes: 256
n, m = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
DX = [X[i+1] - X[i] for i in range(n-1)]
DY = [Y[i+1] - Y[i] for i in range(m-1)]
mod = 10 ** 9 + 7

SUM_X = 0
SUM_Y = 0

for i in range(n-1):
    SUM_X += (i+1) * (n-1-i) * DX[i]
    SUM_X %= mod

for i in range(m-1):
    SUM_Y += (i+1) * (m-1-i) * DY[i]
    SUM_Y %= mod

ans = (SUM_X * SUM_Y) % mod

print(ans)

Measured memory_bytes: 19088
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#define pb push_back
#define fi first
#define se second
#define sz(x)  x.size()
#define cl(x)  x.clear()
#define all(x)  x.begin() , x.end()
#define r(x)  scanf("%d", &x)
#define rr(x , y)  scanf("%d%d" , &x , &y)
#define rst(s)  scanf("%s" , s)
#define rl(x)  scanf("%lld" , &x)
#define rrl(x , y)  scanf("%lld%lld" , &x , &y)
#define w(x)  printf("%d" , x)
#define ww(x , y)  printf("%d %d" , x , y)
#define wl(x)  printf("%lld" , x)
#define wwl(x , y)  printf("%lld %lld" , x , y)
#define sp()  printf(" ")
#define en()  puts("")
#define rep(i , x , n)  for(int i = x ; i <= n ; i ++) 
#define per(i , n , x)  for(int i = n ; i >= x ; i --) 
#define mem0(x)  memset(x , 0 , sizeof(x))
#define mem_1(x)  memset(x , -1 , sizeof(x))
#define mem_inf(x)  memset(x , inf , sizeof(x))
#define mem__inf(x)  memset(x , -inf , sizeof(x))
#define p_queue priority_queue
#define debug(x)  cout << x << '\n'
#define ddebug(x , y)  cout << x << ' ' << y << '\n'
using namespace std ;
//mt19937  rnd(chrono::high_resolution_clock::now().time_since_epoch().count()) ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair<int , int> pii ;
typedef pair<ll , ll> pll ;
typedef pair<int , ll> pil ;
typedef pair<ll , int> pli ;
const int inf = 0x3f3f3f3f ;
const int maxn = 105 ;
const int maxm = 30 ;
const ll mod = 1e9 + 7 ; 
int main()
{
	double pi = acos(-1.0) ;
	int r ;
	r(r) ;
	printf("%.12f\n" , double(r) * pi * 2) ;
	return 0 ;
}


Measured memory_bytes: 3824
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define amari (x) x % 1000000007;

#define fillInt(xs, x)        \
  for (int i = 0; i < x; i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < x; i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < x; i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end());
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>());
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin();
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin();

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N, M;
int sx, sy;
int gx, gy;
char maze[500][500];
int d[500][500];

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  char A;
  cin >> A;

  if (A == 'A') {
    printf("T\n");
  } else if (A == 'T') {
    printf("A\n");
  }else if (A == 'C') {
        printf("G\n");
  }
else if (A == 'G') {
        printf("C\n");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main()
{
    string s,t;
    int ans;

    cin >> s >> t;

    ans = 0;
    for (int i = 0;i < s.size();++i) {
        if (s[i] != t[i]) {
            ++ans;
        }
    }

    cout << ans << endl;

    return(0);
}


Measured memory_bytes: 3916