akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include<stack>
#include <unordered_map>

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
int abs(int a) { return a < 0 ? -a : a; }

int combi(int n, int r) {
	int num = 1;
	for (int i = 1; i <= r; i++) {
		num = num * (n - i + 1) / i;
	}
	return num;
}
using namespace std;

int main() {
	int N;
	cin >> N;
	int x = N * 800;
	int y = (N / 15) * 200;
	cout << x - y;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;

int num[30];
int gcd(int x,int y){
  if(y>x){
    int tmp=x;
    x=y;
    y=tmp;
  }
  if(y==0) return x;
  return gcd(y,x%y);
}

int main(){
  string s;
  cin>>s;

  int sum=0,cnt=0;
  for(int i=0;i<s.size();i++)num[s[i]-'a']++;
  for(int i=0;i<26;i++){
    if(num[i]&1) cnt++;
      num[i]/=2;
      sum+=num[i];
  }
  if(cnt>1){
    cout<<0<<endl;
    return 0;
  }else{
    vector<int> up;
    for(int i=2;i<=sum;i++)up.push_back(i);
    for(int i=0;i<26;i++){
      for(int j=2;j<=num[i];j++){
	int tmp=j;
	for(int k=0;k<up.size() && tmp!=1;k++){
	  int g=gcd(tmp,up[k]);
	  tmp/=g;
	  up[k]/=g;
	}
      }
    }
    long long ans=1;
    for(int i=0;i<up.size();i++)ans*=up[i];
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
import java.util.*;

class Main {
	static int[][] map;
	static int[][] cx;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while (true) {
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if (n == 0 && m == 0){
				break;
			}	
			map = new int[n][n];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					map[i][j] = stdIn.nextInt();
				}
			}
			cx = new int[m][m];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < m; j++) {
					cx[i][j] = stdIn.nextInt();
				}
			}
			int GX = 999999;
			int GY = 999999;
			for (int i = 0; i < 5; i++) {
				if (check()) {
					if(GY > y) {
						GX = x;
						GY = y;
					}
					else if(GY == y) {
						if(GX > x) {
							GX = x;
						}
					}
					
				}
				rotate(cx);
			}
			if(GX == 999999 && GY == 999999) {
				System.out.println("NA");
			}
			else {
				System.out.println((GX+1) + " " + (GY+1));
			}
			
		}
		
		
	}
	static void rotate(int[][] a) {
		int[][] newMap = new int[a.length][a.length];
		for(int i = 0; i < a.length; i++) {
			for(int j = 0; j < a.length; j++) {
				newMap[a.length - j - 1][i] = a[i][j];
			}
		}
		cx = newMap;
	}
	static int x;
	static int y;
	static boolean check() {
		x = -1;
		y = -1;
		for(int i = 0; i < map.length; i++) {
			for(int j = 0; j < map.length; j++) {
				boolean check = true;
				int lasty = -1;
				int lastx = -1;
				OUT:for(int k = 0; k < cx.length; k++) {
					for(int l = 0; l < cx.length; l++) {
						if(cx[k][l] == -1) continue;
						if(lasty == -1 && lastx == -1) {
							lasty = k;
							lastx = l;
						}
						if(i+k >= map.length || j + l >= map.length) {
							check = false;
							break OUT;
						}
						if(map[i+k][j+l] != cx[k][l]) {
							check = false;
							break OUT;
						}
					}
				}
				if(check) {
					y = i+lasty;
					x = j+lastx;
					return true;
				}
			}
		}
		return false;
	}
}

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

int main()
{
    int N, M; cin >> N >> M;
    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        G[l].push_back(make_pair(r, d));
        G[r].push_back(make_pair(l, -d));
    }
    vector<int> dist(N, INT_MAX);
    for (int start = 0; start < N; start++) {
        if (dist[start] != INT_MAX) continue;
        queue<int> q;
        q.push(start);
        dist[start] = 0;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            for (const auto& e : G[v]) {
                int u = e.first, d = e.second;
                if (dist[u] == INT_MAX) {
                    dist[u] = dist[v] + d;
                    q.push(u);
                } else {
                    if (dist[u] != dist[v] + d) {
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
struct Input{
        int degree;
        vector <int> children;
};
struct Tree{
        int parent;
        int depth;
        string type;
};
int N;
map <int,Input> info;
map <int,int> dp;
map <int,Tree> tree;
string Get_type(int now,int degree){
        if(tree[now].parent==-1)
                return "root";
        else if(degree!=0)
                return "internal node";
        else
                return "leaf";
}
void recursion(int now,int depth){
        tree[now].depth=depth;
        for(int i=0 ; i<info[now].degree ; i++ )
                recursion(info[now].children[i],depth+1);
        return;
}
int main(){
        cin >> N;
        for(int i=0 ; i<N ; i++ )
                tree[i].parent=-1;
        for(int i=0 ; i<N ; i++ ){
                int node;
                cin >> node;
                cin >> info[node].degree;
                for(int j=0; j<info[node].degree;j++){
                        int tmp;
                        cin >> tmp;
                        info[node].children.push_back(tmp);
                        tree[tmp].parent=node;
                }
                dp[i]=-2;
        }
        int s;
        for(int i=0 ; i<N ; i++ )
                if(tree[i].parent==-1){
                        s=i;
                        break;
                }
        recursion(s,0);
        for(int i=0 ; i<N ; i++ ){
                cout<<"node "<<i<<": parent = "<<tree[i].parent;
                cout<<", depth = "<<tree[i].depth<<", ";
                cout<<Get_type(i,info[i].degree)<<", [";
                for(int j=0 ; j<info[i].degree ; j++ ){
                        cout<<info[i].children[j];
                        if(j!=info[i].degree-1)
                                cout<<", ";
                }
                cout<<"]"<<endl;
        }
        return 0;
}


Measured memory_bytes: 22596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;cin>>N;
    ll ah=0, an=0, aw=0;
    for(ll h=1; h<=3500; h++){
        for(ll n=1; n<= 3500; n++){
            ll l = h*n*N;
            ll bunshi = 4*h*n-n*N-N*h;
            // cerr<<l<<" "<<bunshi<<endl;
            if(bunshi == 0) continue;
            if(l%bunshi==0 && l/bunshi > 0){
                ah = h; an = n; aw = l/bunshi;
                break;
            }
        }
    }
    cout<<ah<<" "<<an<<" "<<aw<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    double xa, ya, ra, xb, yb, rb;
    while (n--) {
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double dd = (xb - xa) * (xb - xa) + (yb - ya) * (yb - ya);
        double d = sqrt(dd);
        if ((ra + rb) * (ra + rb) < dd) {
            cout << 0 << endl;
        } else if (d + ra < rb) {
            cout << -2 << endl;
        } else if (d + rb < ra) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
w,h,n=map(int,input().split())
l,r,u,d=0,w,h,0
for _ in [0]*n:
  x,y,a=map(int,input().split())
  l=max(l,x) if a==1 else l
  r=min(r,x) if a==2 else r
  d=max(d,y) if a==3 else d
  u=min(u,y) if a==4 else u
print(max(0,r-l)*max(0,u-d))

Measured memory_bytes: 3064
N = int(input())

V = set()

if N % 2 == 0:
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if i + j == N + 1:
                V.add((i, j))
else:
    for i in range(1, N):
        for j in range(i + 1, N):
            if i + j == N:
                V.add((i, j))

ans = []
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if not (i, j) in V:
            ans.append((i, j))

print(len(ans))
for a in ans:
    print(*a)


Measured memory_bytes: 3996
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			char[] s = in.nextString().toCharArray();

			int ans = 0;
			int tmp = 0;
			for (int i = 0; i < n; i++) {
				if (s[i] == 'I') {
					tmp++;
				} else {
					tmp--;
				}
				ans = Math.max(ans, tmp);
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
  int A, B;
  cin >> A >> B;
  cout << (A * B % 2 == 1 ? "Yes" : "No") << endl;
}

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

int main(){
  string s;
  cin >> s;
  
  if(s=="MON") cout << 6 << endl;
  if(s=="TUE") cout << 5 << endl;
  if(s=="WED") cout << 4 << endl;
  if(s=="THU") cout << 3 << endl;
  if(s=="FRI") cout << 2 << endl;
  if(s=="SAT") cout << 1 << endl;
  if(s=="SUN") cout << 7 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i, 1, n + 1) { ans += i * (n - i + 1); }
  REP(i, n - 1) {
    ll a, b;
    cin >> a >> b;
    if (a > b) {
      swap(a, b);
    }
    ans -= a * (n - b + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
from collections import deque
import sys
input = sys.stdin.readline

S = deque(input().rstrip())
Q = int(input())
lst = deque()
 
for i in range(Q):
    tmp = list(input().split())
    lst.append(tmp)

reverse = 0
c = 1
for i in range(Q):
 
    if int(lst[i][0]) == 1:
        reverse += 1
        c += 1
    
    if int(lst[i][0]) == 2:
        if c%2 == 1:
            if int(lst[i][1]) == 1:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])
        else:
            if int(lst[i][1]) == 2:
                S.appendleft(lst[i][2])
            else:
                S.append(lst[i][2])
 
if reverse%2 == 1:
    S.reverse()
 
ans = "".join(S)
print(ans)

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int l, r;
	cin >> l >> r;
	if (r - l > 2019){
		cout << 0 << endl;
		return 0;
	}
	int res = INF;
	FOR(i, l, r){
		FOR(j, i + 1, r + 1){
			res = min(res, ((i % 2019) * (j % 2019)) % 2019);
		}
	}
	cout << res << endl;
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >>a >> b;

    if(a >= 13){
        ppp(b);
    }
    else if(a >= 6){
        ppp(b/2);
    }
    else{
        ppp(0);
    }



    return 0;
}


Measured memory_bytes: 256
N=input()
A,B=map(int, raw_input().split() )
P=map(int, raw_input().split() )

P.sort()


p1=0
p2=0
p3=0

for x in P:
	if x<=A:
		p1+=1
	elif A+1<=x<=B:

		p2+=1
	elif B+1<=x:
		p3+=1

print min(p1, p2, p3)


Measured memory_bytes: 28012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

ll N,M;
string S;

    int calcNumOfCombination(int n, int r){
        int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main(){
  ll a;
  cin>>N>>M;
  if((N==1)&&(M==1)){
    print(0);
    return 0;
  }
  else if(N==1){
    a=calcNumOfCombination(M,2);
    print(a)
    return 0;
  }
  else if(M==1){
    a=calcNumOfCombination(N,2);
    print(a)
    return 0;
  }
  else {
    a=calcNumOfCombination(N,2)+calcNumOfCombination(M,2);;
    print(a)
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);

    int N, K;
    std::string S;
    std::cin >> N >> K;
    std::cin >> S;

    //連続して直立、逆立ちしてる人数を数えて保存する。
    //0を許して直立始まり直立終わりにしておく。
    std::vector<int> counts;

    counts.reserve(N);//push_back高速化
    int count = 1;//連続した人数
    if (S.front() == '0')counts.push_back(0);//直立始まりにする
    for (int i = 1; i < N; i++) {
        if (S[i - 1] == S[i])++count;//連続していればカウントを増やす
        else {
            //連続していなければ保存して次のカウントへ
            counts.push_back(count);
            count = 1;
        }
    }
    counts.push_back(count);//最後をもれなく追加
    if (S.back() == '0')counts.push_back(0);//直立終わりにする

    int size = counts.size();//後で使うのでサイズ保存
    std::vector<int> sum(size + 1, 0);//累積和 sum[0] = 0 であることに注意
    for (int i = 0; i < size; i++) sum[i + 1] = sum[i] + counts[i];//計算する
    int ans = 0;
    for (int i = 0; i < size; i += 2)
        ans = std::max(ans, sum[std::min(i + 2 * K + 1, size)] - sum[i]);//iから連続して直立にしたときの最大値

    std::cout << ans << std::endl;
}

Measured memory_bytes: 1232
n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]

ans = 0
for i in range(k):
    ans += 1/2*(2+(seq[i]-1)) 
score = ans
for i in range(n-k):
  score -= 1/2*(2+(seq[i]-1)) 
  score += 1/2*(2+(seq[i+k]-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))

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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> A;

    vector<int> H(A);
    for(int i = 0; i < A; i++){
        cin >> H.at(i);
    }
    K = H.at(0);
    for(int i = 0; i < A; i++){
        if(K <= H.at(i)) {
            t++;
            K = H.at(i);
        }
    }
//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

    cout << t << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<string>
#include<cassert>
using namespace std;
#define N 4
#define N2 16
#define LIMIT 100

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r','u','l','d'};
int MDT[N2] [N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
	int sum = 0;
	for ( int i = 0; i < N2; i++ ) {
		if ( pz.f[i] == N2 ) continue;
		sum += MDT[i][pz.f[i] - 1];
	}
	return sum;
}

bool isSolved() {
	for (int i = 0; i < N2; i++ ) if ( state.f[i] != i + 1 ) return false;
		return true;
}

bool dfs(int depth, int prev) {
	if ( state.MD == 0 ) return true;
	if ( depth + state.MD > limit ) return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;

	for ( int r = 0; r < 4; r++ ) {
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if ( tx < 0 || ty < 0 || tx >= N || ty >= N ) continue;
		if ( max(prev, r)-min(prev, r) == 2 ) continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state. f[tx * N + ty] - 1];
		swap(state. f[tx * N + ty], state. f[sx * N + sy]);
		state.space = tx * N + ty;
		if ( dfs(depth + 1, r) ) { path[depth] = r; return true; }
		state = tmp;
	}

	return false;
}
string iterative_deepening(Puzzle in) {
	in.MD = getAllMD(in);

	for ( limit = in.MD; limit <= LIMIT; limit++ ) {
		state = in;
		if ( dfs(0, -100)) {
			string ans = "";
			for (int i = 0; i < limit; i++ ) ans += dir[path[i]];
				return ans;
		}
	}

	return "unsolvable";
}

int main() {
	for ( int i = 0; i < N2; i++ )
		for (int j = 0; j < N2; j++ )
			MDT[i][j] = abs(i / N-j/N) + abs(i % N - j % N);

		Puzzle in;

		for ( int i = 0; i < N2; i++ ) {
			cin >> in.f[i];
			if ( in.f[i] == 0 ) {
				in.f[i] = N2;
				in.space = i;
			}
		}
		string ans = iterative_deepening(in);
		cout << ans.size() << endl;

		return 0;
	}


Measured memory_bytes: 3208
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 068 CatSnukeAndAVoyage c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;
  
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;

  set< int > a;
  queue< int > q; 
  REP(i, M) {
    int x, y;
    cin >> x >> y;
    if (x == 1) q.push(y);
    if (y == N) {
      if (!a.erase(x)) a.insert(x);
    }
  }

  bool ok = false;
  while(!q.empty()) {
    int from = q.front();
    q.pop();
    if (a.count(from)) ok = true;
    if (ok) break;
  }

  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    //(1,1)から(100,100)までで矛盾が生じないものが1つある
    int x[N],y[N],h[N];
    int taller_zero = -1;
    rep(i, N){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0) taller_zero = i;
    }
    assert(taller_zero != -1);
    int must_height[N];
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            bool ok = true;
            int ch = h[taller_zero] + abs(i-x[taller_zero]) + abs(j-y[taller_zero]);
            rep(k, N){
                must_height[k] = max(0, ch - abs(i-x[k]) - abs(j-y[k]));
                if(h[k] != must_height[k]) ok = false;
            }
            if(ok){
                cout << i << " " << j << " " << ch << endl;
                return 0;
            }  
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    char cx,cy;
    cin >> cx >> cy;

    int x = (int)cx;
    int y = (int)cy;
    if(x > y){
        cout << ">" << endl;
    } else if(x < y){
        cout << "<" << endl;
    } else {
        cout << "=" << endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int A,B,C;
	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	
	if(A>=B && A>=C){
		printf("%d", A*10+B+C);
	}
	else if(B>=A && B>=C){
		printf("%d", B*10+A+C );
	}
	else{
		printf("%d", C*10+B+A);
		
	}
	return 0;
}

Measured memory_bytes: 128
S=list(input())
for i in range(len(S)):
    #奇数処理
    if i%2==0:
        if S[i]=="L":
            print("No")
            exit()
    #偶数処理　
    if i%2==1:
        if S[i]=="R":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int R[200000],L[200000];
int cnt[200000];
int main(){
	string s;cin>>s;
	int lastR=-1;
	rep(i,s.size()){
		if(s[i]=='R')lastR=i;
		R[i]=lastR;
	}
	//~ int lastL=es.size();
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='L')lastR=i;
		L[i]=lastR;
	}
	rep(i,s.size()){
		if(s[i]=='L'){
			int c=i-R[i];
			cnt[R[i]+c%2]++;
		}
		else{
			int c=L[i]-i;
			cnt[L[i]-c%2]++;
		}
	}
	rep(i,s.size()){
		cout<<cnt[i]<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    private static final Scanner scn = new Scanner(System.in);
    
    public static void main(String[] args) {
        while(scn.hasNextInt()) {
            int a = scn.nextInt(), b = scn.nextInt();
            int c = euclid(a > b ? a : b, a < b ? a : b);
            System.out.println(c + " " + (long)a * b / c);
        }
    }
    
    private static int euclid(int x, int y) {
        if(y > 0) {
            return euclid(y, x % y);
        } else {
            return x;
        }
    }
}

Measured memory_bytes: 25988
import itertools

n = int(input())
town_map = []
for i in range(n):
    town_map.append(list(map(int, input().split())))

town_name = []
for i in range(n):
    tmp_str_town_name = str(i)
    town_name.append(tmp_str_town_name)

p = list(itertools.permutations(town_name, n))

distance = 0
for i in range(len(p)):
    one_path = p[i]
    for j in range(n - 1):
        l = int(one_path[j])
        r = int(one_path[j + 1])
        lx, ly = town_map[l]
        rx, ry = town_map[r]
        distance += ((rx - lx)**2 + (ry - ly)**2) ** (1/2)

print(distance / len(p))

Measured memory_bytes: 74672
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = "NNNNWNNNWNNNENNNENNNWNNN"

    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == "E":
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == "N":
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == "S":
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == "W":
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
    
    def query(self,top_num,front_num):
        self.save_data =[i for i in range(6)]

        for i in range(len(self.number)):
            self.save_data[i] = self.number[i]

        ret = -1
        
        for i in range(len(self.order)):
            self.roll(self.order[i])
            if self.number[0] == top_num and self.number[1] == front_num:
                ret = self.number[2]
                break

        for i in range(len(self.number)):
            self.number[i] = self.save_data[i]
        
        return ret
    def get_Top(self):
        return self.number[0]
    
    def equals(self,another):
        ret = False
        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG =False
                    break
            if FLG :
                return True
        return ret
        
N = int(input())
DICE =[]
for i in range(N):
    
    table = list(map(int,input().split()))
    tmp_dice =Dice()
    tmp_dice.setNumber(table[0],table[1],table[2],table[3],table[4],table[5])
    DICE.append(tmp_dice)
FLG = True

for i in range(N-1):
    for k in range(i+1,N):
        if DICE[i].equals(DICE[k]) == True:
            FLG = False
            break

if FLG:
    print("Yes")
else:
    print("No")



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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)

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

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

#define MAX_N 100001

ll N, L, T;
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> L >> T;
    vector<ll> ans;
    ll diff = 0;
    REP(i, N) {
        ll x, w;
        cin >> x >> w;
        ll pos;
        if(w==1) {
            pos = (x+T)%L;
            diff += (x+T)/L;
        } else {
            pos = ((x-T)%L+L)%L;
            diff -= (T-x+L-1)/L;
        }
        ans.push_back(pos);
    }
    sort(ans.begin(),ans.end());
    diff=(diff%N+N)%N;
    rotate(ans.begin(), ans.begin()+diff, ans.end());
    REP(i,N) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

mint dp[3000][3000];
mint s[3000][3000];
int main() {
  int n, m;
  cin >> n >> m;
  vi x(n), y(m);
  rep(i, n) cin >> x[i];
  rep(i, m) cin >> y[i];
  rep(i, n) {
    rep(j, m) {
      if (x[i] == y[j])
        dp[i + 1][j + 1] = s[i][j] + 1;
      else
        dp[i + 1][j + 1] = 0;
      s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + dp[i+1][j+1];
    }
  }
  mint ans = 1;
  rep(i, n + 1) rep(j, m + 1) ans += dp[i][j];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 144208
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll n;
    	cin>>n;
    	ll x;
    	mll cnt;
    	ll ans = 0;
    	rep(i, n){
    		cin>>x;
    		ans += cnt[i - x];
    		cnt[i + x]++;
    	}
    	cout<<ans;
    }
}

Measured memory_bytes: 26388
#include <cstdio>
#include <string>
using namespace std;

int main() {
    int n;
    scanf(" %d", &n);

    for(int i = 3; i <= n; i++) {
        if( i%3 == 0 || (int)(to_string(i).find("3")) != -1 ) printf(" %d", i);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 2852
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

#define rep(i,n) for((i)=0;i<(int)(n);i++)
using namespace std;

int main() {
	int N;
	cin >> N ;
	int i;
	double ans = 0;
	rep(i, N) {
		double tmp;
		cin >> tmp;
		ans += 1.0 / tmp;
	}
	ans = 1.0 / ans;
	printf("%f", ans);
	return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int vx = y1 - y2;
  int vy = x2 - x1;

  cout << x2 + vx << " " << y2 + vy << " ";
  cout << x1 + vx << " " << y1 + vy;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここに追記
  string S = "";
  int I = 0;
  cin >> S;
  I = stoi(S);
  cout << I / 100 + (I / 10) % 2 + (I % 2) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

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

    int res = -10000;
    res = max(res, a + b);
    res = max(res, a - b);
    res = max(res, a * b);
    cout << res << endl;

    return 0;
}


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

using namespace std;
long long MAXN = 2*(1e5)+1;
/*
long double pi = 3.1415926536;

long long mod = 1e9+7;

bool secgreat(pair<int, int> a, pair<int, int> b){
    return a.second<b.second;
}


long long fact(long long n){
    n%=mod;
    if(n==0){
        return 1;
    }
    else if(n == 1){
        return 1;
    }
    else{
        return ((n%mod)*(fact(n-1)%mod))%mod;
    }
}

long long power(long long n, long long pow){
    n%=mod;
    long long res = 1;
    while(pow){
        if(pow%2){
            res = ((res%mod)*(n%mod))%mod;
        }
        pow/=2;
        n= ((n%mod)*(n%mod))%mod;
    }
    res%=mod;
    return res;

}

long long inversemod(long long n){
    return power(n, mod-2)%mod;
}
*/
/*
struct node{
    long long key;
    node* left;
    node* right;
};

struct node* newnode(long long item){
    struct node* temp = new struct node;
    temp->key = item;
    temp->left = NULL;
    temp->right = NULL;
    return temp;
};

struct node* insert(struct node* root, long long key){
    if(root == NULL){
        return newnode(key);
    }

    if (key<root->key){
        root->left = insert(root->left, key);
    }
    else if(key>root->key){
        root->right = insert(root->right, key);
    }
};
*/

string binary(int a){
    string s;
    int x = 9;
    while(x>0){
        s.push_back(48+a%2);
        a/=2;
        x--;
    }
    reverse(s.begin(), s.end());

    return s;
}

int strtoi(string s){
    int n = s.length();
    int i;
    int sum = 0;
    for(i = 0; i<n; i++){
        sum+=pow(2, i)*s[i];
    }
    return sum;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a;
    cin>>a;
    int n = a.length();
    if(a[n-1] == 's'){
        cout<<a<<"es";
    }
    else{
        cout<<a<<'s';
    }

}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;
signed main() {
  int64_t n;
  cin >> n;

  cout << (n/500)*1000 + ((n%500)/5)*5 << endl;
  
  return 0;
}



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

int main() {
    long long a,b;
    cin >>a>>b;
    if(a>b){
        long long d=1;
        for(long long i=1; i<=b; ++i){
            if(a%i==0 && b%i==0){
                d=i;
            }
        }
        cout << a*b/d <<endl;
    }
    if(a<b){
        long long d=1;
        for(long long i=1; i<=a; ++i){
            if(b%i==0 && a%i==0){
                d=i;
            }
        }
        cout << a*b/d <<endl;
    }
}

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

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }



int n;
const int MX = 100005;
int v[MX];
int memo[MX]; //  initialise as -1
int min_Cost(int i){
	if(i >= n-1) return 0;

	if(memo[i] != -1){
		return memo[i];
	}
	int step1 , step2;
	if(i+1 < n) step1 = abs(v[i] - v[i+1]) + min_Cost(i+1);
	else step1 = INT_MAX;

	if(i+2 < n) step2  = abs(v[i] - v[i+2]) + min_Cost(i+2);
	else step2 = INT_MAX;

	memo[i] = min(step1 , step2);
	return memo[i];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//int n;
	cin>>n;
	//std::vector<int> v(n);
	//memset(memo , -1, sizeof(memo));
	REP(i,n) cin>>v[i];
	REP(i,n) memo[i] = -1;
	cout<<min_Cost(0);
	return 0;
}


Measured memory_bytes: 9068
package main
import (
  "fmt"
)
 
func main(){
  var n, g, a, sum, small int
  fmt.Scan(&n)
  fmt.Scan(&g)
  costs := make([]int, n)
  count := n
  for i:= 0; i < n; i++ {
    fmt.Scan(&a)
    sum += a
    if a < small || small == 0 {
      small = a
    }
    costs[i] = a
  }
  g = g - sum
  for g >= small {
    count++
    g -= small
  }
  fmt.Printf("%d\n", count)
}

Measured memory_bytes: 1840
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll temp = a * c;
	chmax(temp, a * d);
	chmax(temp, b * c);
	chmax(temp, b * d);

	cout << temp << endl;

	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    for(int i = 1;i < s.size();i++)
    {
        if(s[i - 1] == s[i])
        {
            cout << "no";
            return 0;
        }
    }
    cout << "yes";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
typedef long long ll;
const ll MAXN=1e5+5;
const ll MAXR=60000;
const ll INF=1e18;
const ll MOD=1e9+7;
ll n,a[MAXN],o1,o2,e1,e2;
map<ll,ll> mo,me;
void getvalue()
{
    for(auto it=mo.begin();it!=mo.end();it++)
    {
        if(it->second>=mo[o1])
        {
            o2=o1;
            o1=it->first;
        }
        else if(it->second>mo[o2])
        {
            o2=it->first;
        }
    }

    for(auto it=me.begin();it!=me.end();it++)
    {
        if(it->second>=me[e1])
        {
            e2=e1;
            e1=it->first;
        }
        else if(it->second>me[e2])
        {
            e2=it->first;
        }
    }

}
ll calc(ll odd,ll eve)
{
    return n/2-mo[odd]+n/2-me[eve];
}
void solve()
{
    getvalue();
    if(e1!=o1)
    {
        ll ans=calc(o1,e1);
        printf("%lld\n",ans);
    }
    else
    {
        ll ans1=calc(o1,e2);
        ll ans2=calc(o2,e1);
        printf("%lld\n",min(ans1,ans2));
    }
}
int main()
{
//    freopen("c://duipai//data.txt","r",stdin);
//    freopen("c://duipai//wa.txt","w",stdout);
    while(~scanf("%lld",&n))
    {
//        string str2;
//        cin>>str2;
//      cout<<str2<<endl
        for(ll i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
            if(i&1)
            {
                mo[a[i]]++;
                //updodd(a[i]);
            }
            else
            {
                me[a[i]]++;
              //  updeven(a[i]);
            }
        }
        solve();
    }
}
/*
*/


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int N = s.size();
  int l = -1, r = -1;
  for (int i = 0; i + 1 < N; ++i) {
    if (s[i] == s[i + 1]) {
      l = i + 1;
      r = i + 1 + 1;
      break;
    }
    else if (i + 2 < N and s[i] == s[i + 2]) {
      l = i + 1;
      r = i + 2 + 1;
      break;
    }
  }
  printf("%d %d\n", l, r);
  return 0;
}


Measured memory_bytes: 512
fn main(){
  loop {
    let nc: Vec<usize> = read_vec();
    let n = nc[0];
    let c = nc[1];

    if n == 0 && c == 0 { break; }

    let mut lt: Vec<usize> = Vec::new();
    let mut bt: Vec<usize> = Vec::new();
    
    for _ in 0 .. n {
      let a: Vec<usize> = read_vec();
      let an: usize = a.iter().fold(0, |acc, x| acc * 2 + x);
      lt.push(an);
    }

    for _ in 0 .. c {
      let b: Vec<usize> = read_vec();
      let bn: usize = b.iter().fold(0, |acc, x| acc * 2 + x);
      bt.push(bn);
    }

    let mut pt: Vec<isize> = vec![-1 ; 65536];
    pt[0] = 0;
    
    for h in 0 .. n {
      let mut npt: Vec<isize> = vec![-1 ; 65536];
      
      for i in 0 .. 65536 {
        if pt[i] >= 0 {
          let ni: usize = i | lt[h];
          
          for j in 0 .. c {
            let mut p: isize = 0;
            let mut nni: usize = 0;
            
            for k in (0 .. 16).rev() {
              if bt[j] & (1 << k) > 0 && ni & (1 << k) > 0 {
                p += 1;
                nni *= 2;
              } else if ni & (1 << k) > 0 {
                nni = nni * 2 + 1;
              } else {
                nni *= 2;
              }
            }

            if pt[i] + p > npt[nni] {
              npt[nni] = pt[i] + p;
            }
          }
        }
      }
      pt = npt;
    }
    let ans: &isize = pt.iter().max().unwrap();
    println!("{}", *ans);
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 7848
from functools import reduce

n, k = map(int, input().split())
mod = 10**9 + 7


def ncrf(i, j):
    num = reduce(lambda x, y: x * y % mod, range(i, i - j, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, j + 1))
    return num * pow(den, mod - 2, mod) % mod


for d in range(1, k + 1):
    if d == 1:
        print(ncrf(n - k + 1, d))
    elif d > n - k + 1:
        print(0)
    else:
        print(ncrf(n - k + 1, d) * ncrf(k - 1, d - 1) % mod)


Measured memory_bytes: 3940
import math

N, M = map(int, input().split())

c = 0

if(N > 1):
    c +=  math.factorial(N)/(math.factorial(N-2)*math.factorial(2))
if(M > 1):
    c += math.factorial(M)/(math.factorial(M-2)*math.factorial(2))

print(int(c))

Measured memory_bytes: 3060
/**
class cfmaster {
 public:
  struct code {
  	see the details down there !
  };
};
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
  	cin >> a[i];
	}
	vector<bool> state(k + 1, false);
	for (int i = 1; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= a[j]) {
				if (state[i - a[j]] == false) {
					state[i] = true;
				}
			}
		}
	}
	cout << (state[k] ? "First" : "Second") << '\n';
  return 0;
}



Measured memory_bytes: 256