akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

bool checkPrimeNumber( int x ) {
	for( int i = 3; i < x; i+=2 ) {
		if( x % i == 0 ) {
			return false;
		}
	}
	return true;
}

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

	if ( x <= 2 ) {
		x = 2;
		cout << x << endl;
		return 0;
	}
	if ( x%2 == 0 ) x+=1;

	bool isFound = false;
	int limit = 20000000;
	while( !isFound ) {

		if ( x > limit ) break;

		isFound = checkPrimeNumber(x);
		if( isFound ) break;

		x += 2;
	}

	cout << x << endl;
	return 0;

}

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

int main(){
    int a,b,c,d;
    cin >>a >>b>>c>>d;
    while(a > 0 || c > 0){
        c -= b;
        if(c <= 0)break;
        a -= d;
        if(a <= 0)break;
    }
    if(c <= 0) cout << "Yes" << endl;
    else if(a <= 0)cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3568
import sys
input = sys.stdin.readline

N, K, Q = [int(x) for x in input().strip().split()]

A = [0] * N

for q in range(Q):
    a = int(input().strip())
    A[a-1] += 1

for a in A:
    if a > Q - K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 4680
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
	int n;
	int hit[4],blow[4];
	int h=0,b=0;
	int hcount = 0,bcount = 0;

	while(cin >> n){
		if(h < 4){
			hit[h] = n;
			h++;
		}else if(b < 4){
			blow[b] = n;
			b++;
		}
		if(b == 4){
			for(int i=0;i<4;i++){
				if(hit[i] == blow[i]){
					hcount++;
				}
			}

			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if((hit[i] == blow[j]) && (hit[j] != blow[j])){
						bcount++;
					}
				}
			}

			printf("%d %d\n",hcount,bcount);
			h = b = hcount = bcount = 0;
			
		}
	}
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;
int main()
{
    ft
    ll t,i,j,k,n,m,l,r,p,s=LLONG_MAX;
    cin>>n>>m>>l;
    if(n>0)
    {
        r=n/l;
        p=min(m,r);
        if((m-p)%2==0)
        {
            s=min(s,abs(n-(p*l)));
        }
        else
        {
            s=min(s,abs(n-(p*l)+l));
            s=min(s,abs(n-(p*l)-l));
        }
        r=ceil(n*1.0/l);
        p=min(m,r);
        if((m-p)%2==0)
        {
            s=min(s,abs(n-p*l));
        }
        else
        {
            s=min(s,abs(n-(p*l)+l));
            s=min(s,abs(n-(p*l)-l));
        }
    }
    else
    {
        r=(n*(-1))/l;
        p=min(m,r);
        if((m-p)%2==0)
        {
            s=min(s,abs(n+(p*l)));
        }
        else
        {
            s=min(s,abs(n+(p*l)+l));
            s=min(s,abs(n+(p*l)-l));
        }
        r=ceil(n*(-1.0)/l);
        p=min(m,r);
        if((m-p)%2==0)
        {
            s=min(s,abs(n+p*l));
        }
        else
        {
            s=min(s,abs(n+(p*l)+l));
            s=min(s,abs(n+(p*l)-l));
        }
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int n,d,x,j=0,cnt=0;
  cin >> n >> d >> x;
  vector<int>num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  for (int i = 0; i < n; i++) {
    j=0;
    while (num.at(i)*j + 1 <= d) {
      cnt++;
      j++;
    }
  }
  cout << cnt + x << endl;
}  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main(){

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

  sort(a, a+n, greater<int>());

  int Alice=0, Bob=0;
  for(int i=0; i<n; i+=2){
    Alice+=a[i];
    Bob+=a[i+1];
  }

  cout << Alice-Bob << endl;

  return 0;
}

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

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

    string str;
    int K;
    cin >> str >> K;

    for(int i=0; i<str.size() - 1; i++){
        if(str[i] != 'a' && str[i]-'a' + K >= 26){
            K -= ('z' - str[i] + 1);
            str[i] = 'a';
        }
    }
    int i = (str.back() - 'a' + K) % 26;
    str.back() = 'a' + i;
    cout << str << endl;

	return 0;
}


Measured memory_bytes: 592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String a = in.next();
        String b = in.next();
        int[][] dp = new int[a.length() + 1][b.length() + 1];
        for (int i = 1; i <= a.length(); i++) {
            for (int j = 1; j <= b.length(); j++) {
                if (a.charAt(i - 1) == b.charAt(j - 1)) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - 1] + 1);
                }
                dp[i][j] = Math.max(dp[i][j], dp[i - 1][j]);
                dp[i][j] = Math.max(dp[i][j], dp[i][j - 1]);
            }
        }
        int i = a.length();
        int j = b.length();

        String result = "";
        while (i > 0 && j > 0) {
            if (a.charAt(i - 1) == b.charAt(j - 1) && dp[i][j] == dp[i - 1][j - 1] + 1) {
                result =  a.charAt(i - 1) + result;
                --j;
                --i;
            } else if (dp[i][j] == dp[i][j - 1]) {
                --j;
            } else{
                --i;
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 87492
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := scanNums(n)
	max1 := a[0]
	max2 := 0
	index1 := 0
	for i := 0; i < n; i++ {
		if i == 0 {
			max1 = a[i]
			index1 = 0
		} else {
			if max1 <= a[i] {
				max2 = max1
				max1 = a[i]
				index1 = i
			} else if max1 > a[i] && max2 <= a[i] {
				max2 = a[i]
			}
		}
	}
	for i := 0; i < n; i++ {
		if i == index1 {
			fmt.Println(max2)
		} else {
			fmt.Println(max1)
		}
	}
}


Measured memory_bytes: 11284
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 300001
using namespace std;
inline int read()
{
   int f=1,s=0,ch=getchar();
   while(ch!='-'&&!isdigit(ch)) ch=getchar();
   ch=='-' ? f=-1:s=ch-'0',ch=getchar();
   while(isdigit(ch)) s=s*10+ch-'0',ch=getchar();
   return s*f;
}
int n,m;
struct xian
{
	int y,p;
	int num;
	int cnt;
}a[100005];
bool cmp1(xian u,xian v)
{
	if(u.p==v.p) return u.y<v.y;
	else return u.p<v.p;
}
bool cmp2(xian u,xian v)
{
	return u.num<v.num;
}
void print(int x)
{
	int o=6;
	int num=0;
	int tmp=x;
	while(x)
	{
		x/=10;
		num++;
	}
	for(int i=1;i<=o-num;i++) cout<<'0';
	cout<<tmp;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;i++)
	{
		a[i].p=read();a[i].y=read();
		a[i].num=i;
	}
	sort(a+1,a+m+1,cmp1);
	int mmp=1;
	a[1].cnt=mmp;
	for(int i=2;i<=m;i++)
	{
		mmp++;
		if(a[i].p==a[i-1].p)
		{
			a[i].cnt=mmp;
		}
		else 
		{
			mmp=1;
			a[i].cnt=mmp;
		}
		//cout<<a[i].y<<" "<<a[i].cnt<<endl;
	}
	sort(a+1,a+m+1,cmp2);
	for(int i=1;i<=m;i++)
	{
		//cout<<a[i].p<<" "<<a[i].cnt<<endl;
		print(a[i].p);print(a[i].cnt);
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
def gcd(a,b):
    while b:a,b=b,a%b
    return a

def f(n,m):
    if m==1:return 0
    x=1
    for i in range(m):
        x=(x*n)%m
        if x==1:return i+1
        
while 1:
    a,b=map(int,input().split())
    if a==0:break
    c=gcd(a,b)
    a//=c;b//=c
    cnt=0;d=gcd(b,10)
    while d!=1:
        b//=d
        cnt+=1
        d=gcd(b,10)
    print(cnt,f(10,b))

Measured memory_bytes: 7772
using System;
using System.Linq;
using System.Numerics;

   class Program
    {
        static void Main()
        {
            var ar = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = ar[0];
            var W = ar[1];
            var dp = Enumerable.Range(0, N + 1).Select(_ => Enumerable.Repeat((long)0, (int)1e5 + 100).ToArray()).ToArray();

            for (int i = 0; i < N; i++)
            {
                ar = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var _w = ar[0];
                var v = ar[1];
                for (int w = 0; w <= W; w++)
                {
                    if (w - _w >= 0)
                    {
                        dp[i + 1][w] = Math.Max(dp[i + 1][w], dp[i][w - _w]+v);
                    }
                    dp[i + 1][w] = Math.Max(dp[i+1][w], dp[i][w]);
                }
            }
            Console.WriteLine(dp[N][W]);
        }
    }

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    string s;
    cin >> s;
    sort(all(s));
    if (s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int area = a * b;
int length = 2*a + 2*b;
System.out.println(area + " " + length);
sc.close();
}
} 


Measured memory_bytes: 26060
#include <cstdio>
using namespace std;
int main() {
  int n, k, q, a, b = 0, s[100000];
  scanf("%d%d%d", &n, &k, &q);
  for (int i = 0; i < n; i++) {
    s[i] = k;
  }
  for (int i = 0; i < q; i++) {
    scanf("%d", &a);
    a--;
    s[a]++;
    b++;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] > b) {
      printf("Yes\n");
    } else {
      printf("No\n");
    }
  }
}

Measured memory_bytes: 896
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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() {
    ll h[110000];
    ll dp[110000];
    int N;
    cin >> N;
    rep(i, 0, N) {
        cin >> h[i];
    }
    rep(i, 0, 110000) {
        dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, 0, N) {
        dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1]);
        dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+2]);
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int T = Integer.parseInt(sc.next());
	static int X = Integer.parseInt(sc.next());
	public static void main(String[] args) {
		float t = (float) T;
		System.out.println(t/X);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.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;}
const ll INF = 1LL << 60;

int main() {
    int d, n; cin >> d >> n;
    ll ans = pow(100, d) * n;
    if(n == 100) ans = pow(100, d) * 101;
    cout << ans << endl;
}

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

using namespace std;

#define endl           '\n'
#define LL             long long
#define ULL            unsigned long long
#define all(x)         x.begin(), x.end()


const LL Mod = 1000000007;
const int N = 1e5 + 5;


int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1) a = 14;
    if (b == 1) b = 14;
    if (a == b) puts("Draw");
    else if (a > b) puts("Alice");
    else puts("Bob");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int v;
  int c;
};
bool operator<(const ST& a, const ST& b){
  return a.c > b.c;
}

int main(){
  int N;
  cin >> N;
  map<int,int> odd, even;
  rep(i,N){
    int v;
    cin >> v;
    if(i%2==0) even[v]++;
    else odd[v]++;
  }

  vector<ST> vodd, veven;
  FOR(it,odd){
    vodd.push_back((ST){it->first, it->second});
  }
  FOR(it,even){
    veven.push_back((ST){it->first, it->second});
  }
  sort(ALLOF(vodd));
  sort(ALLOF(veven));

  if(vodd[0].v != veven[0].v){
    cout << N - (vodd[0].c + veven[0].c) << endl;
  }else{
    int a = (veven.size()>=2)?veven[1].c:0;
    int b = (vodd.size()>=2)?vodd[1].c:0;
    int mx = max(vodd[0].c + a, b + veven[0].c);
    cout << N - mx << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6136
#include <bits/stdc++.h>
using namespace std;
int h, w;
vector<vector<char>> s;
vector<vector<bool>> sb;
vector<int> dx = {-1, 0, 1, 0};
vector<int> dy = {0, -1, 0, 1};

struct xydata {
    int x, y, d;
};

void refresh() {
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            sb.at(i).at(j) = false;
        }
    }
}

int bfs(int sx, int sy, int gx, int gy) {
    xydata first;
    first.x = sx;
    first.y = sy;
    first.d = 0;
    queue<xydata> que;
    que.push(first);

    int depth = 0;
    while(!que.empty()) {
        xydata now = que.front();
        que.pop();
        if(now.x == gx && now.y == gy) {
            depth = now.d;
            break;
        }
        for(int i = 0; i < 4; ++i) {
            xydata next;
            next.x = now.x+dx.at(i);
            next.y = now.y+dy.at(i);
            if(next.x >= 0 && next.x < w && next.y >= 0 && next.y < h) {
                if(s.at(next.y).at(next.x) == '.' && !sb.at(next.y).at(next.x)) {
                    next.d = now.d+1;
                    sb.at(next.y).at(next.x) = true;
                    que.push(next);
                }
            }
        }
    }
    return depth;
}

int main() {
    cin >> h >> w;
    s = vector<vector<char>>(h, vector<char>(w, '.'));
    sb = vector<vector<bool>>(h, vector<bool>(w, false));
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            cin >> s.at(i).at(j);
        }
    }

    int maxlen = 0;
    for(int i = 0; i < h; ++i) {
        for(int j = 0; j < w; ++j) {
            if(s.at(i).at(j) == '.') {
                for(int k = 0; k < h; ++k) {
                    for(int l = 0; l < w; ++l) {
                        if(i != k || j != l) {
                            if(s.at(k).at(l) == '.') {
                                // cout << j << i << l << k << " ";
                                int len = bfs(j, i, l, k);
                                // cout << len << endl;
                                maxlen = max(maxlen, len);
                                refresh();
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << maxlen << endl;
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) FILE* aasckmasl=freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i < r; ++i)
#define E(i, l, r) for(auto i = l; i <= r; ++i)
#define DF(i, l, r) for(auto i = l; i >= r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define sz(a) ((int)(a).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)1e9 + 7;
const dbl eps = (dbl)1e-8;
const int maxn = (int)1e5 + 5;
const dbl pi = acos(-1);

int n, k, ans;
string s;
int d[303][303][303];

int main() {
//    fin("t.in");
    sync;
    cin >> s;
    n = sz(s);
    cin >> k;
    clean(d);
    ans = 0;
    E(i, 0, n) {
    	E(j, 0, n) {
    		if (i + j > n)
    			break;
			int x = i, y = n - 1 - j;
    		E(q, 0, k) {
   				ans = max(ans, 2 * d[i][j][q] + (i + j < n));
				if (x >= y)
					cont;
   				if (s[x] == s[y]) {
   					d[i + 1][j + 1][q] = max(d[i + 1][j + 1][q], d[i][j][q] + 1);
   				}
				d[i + 1][j + 1][q + 1] = max(d[i + 1][j + 1][q + 1], d[i][j][q] + 1);
   				d[i + 1][j][q] = max(d[i + 1][j][q], d[i][j][q]);
   				d[i][j + 1][q] = max(d[i][j + 1][q], d[i][j][q]);
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 109056
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

int solve(int N, vector<int> A)
{
    vector<vector<int>> T(N, vector<int>(N, -N));
    T[A[0]][A[1]] = 0;

    int M = 0;  // M = max(T)
    vector<int> M1(N, -N);  // M1[x] = max(T[i][x])
    vector<int> M2(N, -N);  // M2[x] = max(T[x][i])
    M1[A[1]] = 0;
    M2[A[0]] = 0;

    int base = 0;

    for (int i=2; i+2<3*N; i+=3)
    {
        sort(A.begin()+i, A.begin()+i+3);

        if (A[i]==A[i+1] && A[i]==A[i+2])
        {
            base++;
            continue;
        }

        vector<pair<pair<int, int>, int>> U;

        if (A[i]==A[i+1] || A[i+1]==A[i+2])
        {
            int a = A[i+1];
            int r = a==A[i] ? A[i+2] : A[i];
            for (int j=0; j<N; j++)
                U.push_back({{j, r}, max(T[j][a]+1, T[a][j]+1)});
        }

        U.push_back({{A[i], A[i+1]}, T[A[i+2]][A[i+2]]+1});
        U.push_back({{A[i], A[i+2]}, T[A[i+1]][A[i+1]]+1});
        U.push_back({{A[i+1], A[i+2]}, T[A[i]][A[i]]+1});

        U.push_back({{A[i], A[i+1]}, M});
        U.push_back({{A[i], A[i+2]}, M});
        U.push_back({{A[i+1], A[i+2]}, M});

        for (int j=0; j<N; j++)
        {
            U.push_back({{A[i], j}, max(M1[j], M2[j])});
            U.push_back({{A[i+1], j}, max(M1[j], M2[j])});
            U.push_back({{A[i+2], j}, max(M1[j], M2[j])});
        }

        for (auto u: U)
        {
            int x = u.first.first;
            int y = u.first.second;
            int v = u.second;
            T[x][y] = max(T[x][y], v);
            M = max(M, v);
            M1[y] = max(M1[y], v);
            M2[x] = max(M2[x], v);
        }
    }

    int ans = 0;
    for (int x=0; x<N; x++)
        for (int y=0; y<N; y++)
            ans = max(ans, T[x][y]+base+(x==y && x==A[3*N-1] ? 1 : 0));
    return ans;
}

int main()
{
    int N;
    cin>>N;
    vector<int> A(3*N);
    for (int &a: A)
        cin>>a, a--;

    int ans = solve(N, A);

    cout<<ans<<endl;
}


Measured memory_bytes: 19124
# デフォルトだと再帰の上限が設定されている(1000)、足りない場合があるので上げる
import sys
sys.setrecursionlimit(10**9)


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

G = [[] for _ in range(N + 1)]
for i in range(M):
    x, y = map(int, input().split())
    G[x] += [y]
# print(G)

dp = [-1] * (N + 1)


def func(n):
    if dp[n] != -1:
        return dp[n]
    cnt = 0
	# 先にノードが存在する場合
	# ノードが存在しない場合は、cnt=0のままforをすっ飛ばす
    for m in G[n]:
        cnt = max(cnt, func(m) + 1)
    dp[n] = cnt
    return cnt


for i in range(1, N + 1):
    func(i)

# print(dp)
print(max(dp))


Measured memory_bytes: 117936
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();
        for(int i=a;i>=1;i--){
            if(a%i == 0 && b%i==0){
                count++;
            }
            if(count==k){
                System.out.println(i);
                return;
            }
        }
        
    }
    
}

Measured memory_bytes: 21716
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , k ;

int main ( ){
 scanf("%d %d",&n,&k);
 if ( k == 0 ){
    printf("%lld",1LL*n*n);
    return 0 ;
 }
 /*if ( k == 1 ){
     printf("%lld",(1LL*n*n)-n);
    return 0 ;

 }*/

 ll ANS =0  ;
 for ( int i = k ; i <= n-1 ; i ++ ){
    ANS += (n-i);
 }
 for ( int i = k+1 ; i <= n-1 ; i ++ ){
    int add = n/i ;

    add-- ;
    if ( add  < 0 ) add = 0 ;
    ANS += (1LL*add*(i-k)) ;
    int rem = n%i ;
    if ( rem < k ) continue ;
    ANS += (rem-k+1);
 }
 printf("%lld",ANS);
return 0 ;
}


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

int main(){
  string s; cin>>s; int an=0; int n=s.size();
  for(int i=0;i<n;i++) {
    for(int j=i;j<n;j++) {
      bool ok=true;
      for(int k=i;k<=j&&ok;k++) {
        if (s[k] != 'A' && s[k] != 'C' && s[k] != 'G' && s[k] != 'T') ok=false;
      }
      if (ok) an = max(an,j-i+1);
    }
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  
  printf( "%lf ", W * H / 2.0 ); 

  if( x == W/2.0 && y == H/2.0 ) cout << 1;
  else cout << 0;
  return 0;
}



Measured memory_bytes: 256
def printing(m, G, cnt, A):
    print(m)
    for i in range(len(G)):
        if i != len(G) - 1:
            print(G[i], end=' ')
        else:
            print(G[i])

    print(cnt)
    for i in A:
        print(i)

def insertionSort(A, n, g, cnt):
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt


def shellSort(A, n, cnt):

    m = 0
    G = [1]
    while True:
        formulate = 3 * G[m] + 1
        if N > formulate:
            G.append(formulate)
        else:
            break
        m += 1

    for i in range(len(G) // 2):
        G[i], G[-1 - i] = G[-1 - i], G[i]

    for i in range(m + 1):
        cnt = insertionSort(A, n, G[i], cnt)

    printing(m + 1, G, cnt, A)


N = int(input())
inputList = []
for i in range(N):
    inputList.append(int(input()))

# inputList = list(map(int, '''5
# 5 1 4 3 2'''.split()))
# N = inputList.pop(0)

cnt = 0
shellSort(inputList, N, cnt)


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

int main(void) {
	string s, t;
	cin >> s >> t;
	int n = 0;

	for(int i = 0; i < 3; i++){
		if(s[i] == t[i]) n++;
	}
	cout << n << endl;
	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;




int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    Sort(a);Sort(b);

    if(n%2==0){
        cout<<b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1<<endl;
    }
    else{
        cout<<b[n/2]-a[n/2]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  string str[a];
  for(int i=0;i<a;i++)cin>>str[i];
  for(int i=0;i<str[0].size()+2;i++)
    cout<<"#";
  cout<<endl;
  for(int i=0;i<a;i++)
    cout<<"#"<<str[i]<<"#"<<endl;
  for(int i=0;i<str[0].size()+2;i++)
    cout<<"#";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
"use strict";
function main(input) {
  const kari = input[0].trim().split(" ").map(i => parseInt(i));
  const k = kari[0];
  const x = kari[1];
 
  if(k*500>=x){
    console.log("Yes");
  }else{
    console.log("No");
  }
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 20808
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var t = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int d = Math.Min(t[1], t[3]) - Math.Max(t[2], t[0]);
            Console.WriteLine(d > 0 ? d : 0);


            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    long K = sc.nextLong();
    long[] num = new long[100010];

    for (int i = 0; i < N; i++) {
      int a = sc.nextInt();
      long b = sc.nextLong();
      num[a] += b;
    }

    sc.close();

    for (int i = 0; i < num.length; i++) {
      K = K - num[i];
      if (K <= 0) {
        System.out.println(i);
        break;
      }
    }

  }

}

Measured memory_bytes: 81416
#include<stdio.h>
#include<math.h>
#define PI 3.14159265358979323



int main()
{
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);
    double D1,D2,dD;
    D1=(H+M/60)*30,D2=M*6;
    dD=fabs(D1-D2);
    double S;
    S=cos(PI*dD/180);
    double ans;
    ans=sqrt(A*A+B*B-2*A*B*S);
    printf("%.11lf",ans);





    return 0;



}


Measured memory_bytes: 2544
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		if((c>a && c>b) || (c<a && c<b)) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		  }
		}

Measured memory_bytes: 35540
#include<bits/stdc++.h>
using namespace std;
int c[100010][3],f[100010][3];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	   cin>>c[i][0]>>c[i][1]>>c[i][2];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(k!=j){
					f[i+1][k]=max(f[i+1][k],f[i][j]+c[i+1][k]);
				}
			}
		}
	}
	cout<<max(f[n][0],max(f[n][1],f[n][2]));
	return 0;
}


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

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

  vector<int> min(N);
  std::vector<int> max(N);

  double a, b;
  int ans;

  for (int i=0; i<N; i++){
    cin >> min[i] >> max[i];
  }

  sort(min.begin(), min.end());
  sort(max.begin(), max.end());

  if(N%2 == 0){
    a = (min[N/2 - 1] + min[N/2]) / 2.0;
    b = (max[N/2 - 1] + max[N/2]) / 2.0;

    ans = 2*b - 2*a + 1;
  }else{
    a = min[(N+1)/2 - 1];
    b = max[(N+1)/2 - 1];

    ans = b - a + 1;
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    vector<int> x(n),y(n),h(n);
    int xt,yt,ht;
    rep(i,n){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]!=0){
            xt=x[i];
            yt=y[i];
            ht=h[i];
        }
    }

    rep(X,101){
        rep(Y,101){
            int Ht=ht+abs(xt-X)+abs(yt-Y);
            bool ok=true;
            rep(i,n){
                if(h[i]!=max(0,Ht-abs(X-x[i])-abs(Y-y[i]))) ok=false;
            }
            if(ok){
                cout<<X<<" "<<Y<<" "<<Ht<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("trapv")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pi = pair<ll, ll>;
const ll mod = 1e9 + 7;
int n, pos[200200], num[200200], sz;
vi a;
bool check(int x) {
	sz = 0;
	for(int i = 1; i < a.size(); i++) {
		if(a[i]>a[i-1]) continue;
		int j = a[i];
		while(j) {
			if(pos[sz-1]>j) {--sz; continue;}
			if(!sz||pos[sz-1]<j) {
				pos[sz]=j;
				num[sz]=0;
				sz++;
			}
			if(++num[sz-1]>=x) {
				sz--;
				j--;
			} else
				break;
		}
		if(!j) return false;
	}
	return true;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	a.resize(n);
	for(auto &i : a) cin >> i;
	ll ans = 0;
	for(int i = 1<<17; i; i>>=1)
		if(!check(ans+i)) ans += i;
	cout << 1+ans;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
    int H,W,h,w;
    int allTrout,result,ret;
    ret = scanf("%d %d",&H,&W);
    ret = scanf("%d %d",&h,&w);

    allTrout = H*W;
    result = H*W - (h*W+w*H - h*w);
    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
r, c = gets.split.map(&:to_i)

table = []
r.times do |i|
	table[i] = gets.split.map(&:to_i)
end

row_sum = 0
r.times do |i|
	c.times do |j|
		row_sum += table[i][j]
	end
	table[i].push(row_sum)
	row_sum = 0
end

column_sum = 0
table.push([])
(c+1).times do |j|
	r.times do |i|
		column_sum += table[i][j]
	end
	table[-1].push(column_sum)
	column_sum = 0
end

(r+1).times do |i|
	(c+1).times do |j|
		print "#{table[i][j]}"
		print ' ' if j < c
	end
	print "\n"
end

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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

//ofstream out("debug.txt");

const int MxN = 1e5, md = 1e9 + 7;

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

    ll a, b, c, d, x, y;
    cin >> a >> b >> c >> d;
    cout << max(a * c, max(a * d, max(b * c, b*d)));
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<set>
using namespace std;

int p,q,a,n;


int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }//Ååöñ
int lcm(int a, int b){ return a/gcd(a,b)*b; }//Å¬ö{

class Fraction{
public:
	int bo,shi;
	Fraction(int shi,int bo):bo(bo),shi(shi){};
	Fraction(){};
};

Fraction my_plus(Fraction a,Fraction b){
	if(a.shi==0) return b;
	int new_bo=a.bo*b.bo;
	int new_shi=a.shi*(new_bo/a.bo)+b.shi*(new_bo/b.bo);
	return Fraction(new_shi,new_bo);
}
int ans=0;

void dfs(int num,int now_bo,int mul,Fraction now){
	if(p*now.bo<q*now.shi) return;
	if(num>n) return;
	if(mul>a) return;
	if(p*now.bo==q*now.shi){
		ans++;
		return;
	}
	for(int i=now_bo;i<=12000;i++){
		
		if(mul*i>a) break;
		dfs(num+1,i,mul*i,my_plus(now,Fraction(1,i)));
	}
}


int main()
{
	while(cin>>p>>q>>a>>n && p!=0 && q!=0 && a!=0 && n!=0){
		ans=0;
		dfs(0,1,1,Fraction(0,2));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
5 2
---+/
/+---test
3 -1
---+/
/+---test
30 -50
---+/

void main(string[] args) {
  long N, L;
  readf(" %d %d ", &N, &L);

  const s = clamp(-L + 1, 1, N);

  long ans;
  foreach (i; 1..N+1) {
    if (i != s) ans += L + i - 1;
  }
  ans.writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
char a[20];
int CharNumber;
int z = 0;
char temp;

int main()
{
        cin >> a;
        CharNumber = strlen(a);

    for(int x = 0; x < CharNumber; x++)
    {
                for(z = 0; z < CharNumber-x-1; z++)
        {
            temp = a[z+1];
            a[z+1] = a[z];
            a[z] = temp;
        }
    }



        cout << a << endl;


}

Measured memory_bytes: 1136
from collections import defaultdict
n = int(input())
d = defaultdict(list)
for i in range(n):
  d[i] = list(map(int,input().split()))
mp = [[0,0,0] for i in range(n)] #maxpoint
mp[0] = d[0]
for i in range(1,n):
  mp[i][0] = max(mp[i-1][1],mp[i-1][2]) + d[i][0]
  mp[i][1] = max(mp[i-1][0],mp[i-1][2]) + d[i][1]
  mp[i][2] = max(mp[i-1][1],mp[i-1][0]) + d[i][2]
print(max(mp[n-1]))

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

const int N = 2123;
int resp[N];

int dist(int a, int b) {
	return abs(a - b);
}

int dist(int a, int b, int x, int y) {
	return min({
		dist(a, b),
		dist(a, x) + dist(b, y) + 1,
		dist(a, y) + dist(b, x) + 1
	});
}

int main() {
	int n, x, y; scanf("%d %d %d", &n, &x, &y);
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			resp[dist(i+1, j+1, x, y)]++;
		}
	}
	for (int i = 1; i < n; i++) {
		printf("%d\n", resp[i]);
	}
}

Measured memory_bytes: 256
#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>
typedef long long ll;
using namespace std;
void TravelingPlan() {

	int n;
	cin >> n;
	int t[100002];
	ll sum = 0;
	t[0] = 0;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> t[i];
		sum += abs(t[i] - t[i - 1]);
	}
	t[n + 1] = 0;
	sum += abs(0 - t[n]);
	for (size_t i = 1; i <= n; i++)
	{
		int temp = sum + abs(t[i + 1] - t[i - 1]);
		temp -= abs(t[i] - t[i - 1]);
		temp -= abs(t[i + 1] - t[i]);
		cout << temp << endl;
	}

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

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
#define vl vector<long long>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const long long INF = 1LL << 60;
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() {
    ll N;
    cin>>N;
    map<string,ll> K;
    rep(i,N){
        string A;
        cin>>A;
        K[A]=1;
    }
    cout<<K.size()<<endl;
}


Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N;
    cin >> N;
    vector<bool> ok(N, false);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        if (a == b) ok[i] = true;
    }
    bool res = false;
    for (int i = 0; i + 2 < N; ++i) {
        if (ok[i] && ok[i+1] && ok[i+2]) res = true;
    }
    if (res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

















Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n; cin >> n;
    vector<int> cnt(n + 1, 0);
    rep(i, 1, n + 1)
    {
        int tmp = i;
        while (tmp % 2 == 0)
        {
            cnt[i]++;
            tmp /= 2;
        }
    }

    int ans = 1;
    rep(i, 2, n + 1)
    {
        if (cnt[ans] < cnt[i]) ans = i;
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,n,a,sum=0;
    cin>>h>>n;
    for(int i=0;i<n;i++){
        cin>>a;sum+=a;
    }
    cout << ((sum>=h)?"Yes":"No")<<endl;
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> t.at(i);
    cin >> x.at(i);
    cin >> y.at(i);
  }
  int s = 0;
  for(i = 0; i < n; i++)
  {
    if(i == 0)
    {
      if((t.at(i) < (x.at(i) + y.at(i))) || ((x.at(i) + y.at(i) - t.at(i)) % 2 != 0))
      {
        s = 1;
        break;
      }
    }
    else
    {
      if(((t.at(i) - t.at(i-1)) < (x.at(i) - x.at(i-1) + y.at(i) - y.at(i-1))) || ((x.at(i) - x.at(i-1) + y.at(i) - y.at(i-1) - t.at(i) + t.at(i-1)) % 2 != 0))
      {
        s = 1;
        break;
      }
    }
  }
  if(s == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define mi(x,y) (x<y?x:y)
#define N 100009
int main() {
	int n,k,h[N]={0},dp[N]={0};
	scanf("%d%d",&n,&k);
	rep(i,n)scanf("%d",&h[i+1]);
	dp[0]=N;
	rep(i,n)dp[i+2]=abs(h[2]-h[1]);
	Rep(i,3,n+1){
		int m=dp[i-1]+abs(h[i]-h[i-1]);
		Rep(j,1,mi(k,i))m=mi(m,dp[i-1-j]+abs(h[i]-h[i-1-j]));
		dp[i]=m;
	}
	printf("%d",dp[n]);
}

Measured memory_bytes: 896
din = list(map(int,input().split()))
NN = din[0]
YY = din[1]

found = 0
for n10000 in range(NN+1):
    if found == 1: break
    n_rem = NN - n10000
    n5000 = 0
    while ((n5000<=n_rem) and (found == 0)):
        n1000 = NN-n10000-n5000
        if YY - n10000*10000 - n5000*5000 - n1000*1000 == 0:
            line = "{} {} {}".format(n10000,n5000,n1000)
            print(line)
            found = 1;
        else:
            n5000 += 1
if found == 0:
    print("-1 -1 -1")

Measured memory_bytes: 64552
#include<cstdio>
#include<iostream>
#define LL long long
using namespace std;
int main(){
    LL n,A,B;
    cin>>n>>A>>B;
    LL last,cur,ans=0;
    cin>>last;
    for(int i=1;i<n;i++){
        scanf("%lld",&cur);
        if(A*(cur-last)<B) ans+=A*(cur-last);
        else ans+=B;
        last = cur;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 100000

int G[100][100],n;

int prim(){
  int v,i,u,minv,d[100],p[100],color[100];

  for(i=0;i<n;i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(i = 0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] != INF){
        if(d[v] > G[u][v]){
        d[v] = G[u][v];
          p[v] = u;
        color[v] = GRAY;
      }
    }
  }
  }
  int sum=0;

  for(i=0;i<n;i++) if(p[i] != -1) sum += G[i][p[i]];

  return sum;

}

int main(){

  int i,j,x;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&x);
      if(x==-1) G[i][j] = INF;
      else G[i][j] = x;
    }
  }

  printf("%d\n",prim());

  return 0;

}




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

using namespace std;

int main()
{
    deque<int> a;
    int sum=0;
    int mx = 0;
    for(int i=0; i<5; i++){
        int x;
        cin>>x;
        if(!a.empty()){
            if(x%10 == 0) a.push_front(x);
            else {
                if(x%10 < a.back()%10 ) a.push_back(x);
                else a.push_front(x);
            }
        }else{
            a.push_back(x);
        }
    }
    for(int i=0; i<5; i++){
        sum+=a.front();
        a.pop_front();
        if(sum%10 < 10 && sum%10 > 0 && i<4) sum+=(10-sum%10);
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int arr[3];
	for(int i = 0; i < 3; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + 3);
	if(arr[0] == arr[2]) {
		cout << "No\n"; return 0;
	}
	if(arr[0] == arr[1] || arr[1] == arr[2]) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(k%2 == 0) ans = a - b;
    else ans = b - a;
    if(abs(ans) > INF) cout << "Unfair" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int, input().split(' ')))
Q = tuple(map(int, input().split(' ')))
ls = [ x for x in itertools.permutations(range(1, N + 1)) ]
a = [ key for key, val in enumerate(ls) if P == val ][0] + 1
b = [ key for key, val in enumerate(ls) if Q == val][0] + 1
print(abs(a - b))

Measured memory_bytes: 13860
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    string s;
    cin >> s;
    int n = sz(s);
    vi v(n);
    rep(i, n)v[i] = s[i] - '0';
    ll ans = 0;
    rep(i, 1<<(n-1)) {
        int mask = i << 1;
        ll val = 0;
        rep(j, n) {
            if(mask >> j & 1) {
                ans += val;
                val = v[j];
            } else {
                val = val * 10 + v[j];
            }
        }
        ans += val;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);

  long A, B, K;
  cin >> A >> B >> K;

  vector<long> a;

  for (long i = 1; i <= min(A, B); i++) {
    if (A % i == 0 and B % i == 0) {
      a.push_back(i);
    }
  }

  reverse(a.begin(), a.end());

  cout << a[K-1] << endl;

  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>


int main(void){
    int w,h,x,y,a=0;
    double s;
    scanf("%d%d%d%d",&w,&h,&x,&y);
    s = (double) w*h/2;
    if(w==2*x && h==2*y) a=1;
    printf("%.10f %d\n",s,a);
    return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int N,M; cin>>N>>M;
    vector<bool>b(N+1,true);
    rep(i,M){
        int m; cin>>m;
        b[m]=false;
    }
    vector<ll>dp(N+1);
    dp[0]=1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j <= min(N,i+2);j++){
            if(b[j]){
                dp[j]+=dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 1024
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var x = long.Parse(_[0]);
            var y = long.Parse(_[1]);
            var z = long.Parse(_[2]);

            var ans = (x - z) / (y + z);
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140