akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int x1,y1,x2,y2;

	cin >> x1 >> y1 >> x2 >> y2;

	int x = x2;
	int y = y2;
	int dx = x2 - x1;
	int dy = y2 - y1;

	rep(i, 0, 2) {

		int _dx = -dy;
		int _dy = dx;

		dx = _dx;
		dy = _dy;

		x = x + dx;
		y = y + dy;

		cout << x << " " << y << " ";
	}

	
	
	
}
	

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;

  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;

  return x;
}

Node treeSearch(Node u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key)
      u = u->left;

    else
      u = u->right;
  }

  return u;
}

Node treeSuccessor(Node x){
  Node y;

  if(x->right != NIL)
    return treeMinimum(x->right);
  
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }

  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;

  else
    x = y->right;
  
  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;

  else if(y == y->parent->left)
    y->parent->left = x;

  else
    y->parent->right = x;

  if(y != z)
    z->key = y->key;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;

    if(z->key < x->key)
      x = x->left;

    else
      x = x->right;
  }

  z->parent = y;

  if(y==NIL)
    root = z;

  else if(z->key < y->key)
    y->left = z;

  else
    y->right = z;
}

void inorder(Node u){
  if(u == NIL)
    return;

  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    return;
  
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      
      if ( t != NIL ) printf("yes\n");
      
      else printf("no\n");
      
    }

    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }

    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }

    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> cnt(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++, cnt[b]++;
    }

    bool ans = true;
    rep(i, N) {
        ans &= !(cnt[i] % 2);
    }

    if (ans) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 768
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] nums=new int[3];
        for(int i=0;i<3;i++)nums[i]=sc.nextInt();
        Arrays.sort(nums);
        int t=nums[2]*2-nums[1]-nums[0];
        System.out.println(t%2==0?t/2:t/2+2);
    }

}


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

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF){
    if( s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }else{
      push(atoi(s));
    }
  }

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

  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
typedef long long ll;
#define MOD 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int now_min = v[0];
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(now_min >= v[i]) {
            ans++;
        }
        now_min = min(now_min, v[i]);
    }
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void){

    int a[3][3];
    bool f[3][3];

    for(int y = 0;y < 3;y++){
        for(int x = 0;x < 3;x++){
            cin >> a[y][x];
            f[y][x] = false;
        }
    }
    int n;
    cin >> n;

    for(int i = 0;i < n;i++){
        int b;
        cin >> b;

        for(int y = 0;y < 3;y++){
            for(int x = 0;x < 3;x++){
                if(a[y][x] == b){
                    f[y][x] = true;
                }
            }
        }
    }

    for(int i = 0;i < 3;i++){
        if((f[i][0] && f[i][1] && f[i][2]) ||
            (f[0][i] && f[1][i] && f[2][i])){
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (f[0][0] && f[1][1] && f[2][2]){
        cout << "Yes" << endl;
        return 0;
    }

    
    if (f[0][2] && f[1][1] && f[2][0]){
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
 
namespace example
{
  class plactis
  {
    static void Main()
    {
      
      string line = System.Console.ReadLine();
      string[] l=line.Split(' ');
      
      long []data=new long[l.Length];
      
	  for(int i=0;i<l.Length;i++)
      {
      	data[i]=long.Parse(l[i]);
      }
          
      if((data[0]+data[1])-data[2]<=0)
         {
           Console.WriteLine("0 0");
         }
         
       else if(data[0]-data[2]<=0)
       {
         Console.WriteLine("0 " + ((data[0]-data[2]) + data[1]));
       }
      
      else if(data[0]-data[2]>0)
      {
        Console.WriteLine((data[0]-data[2]) + " " + data[1]);
      }
      
      
    }
  }
}

Measured memory_bytes: 11092
a = []
3.times do
  a << gets.split(' ').map(&:to_i)
end

b = []
gets.to_i.times do
  b << gets.to_i
end

b.length.times do |k|
  3.times do |i|
    3.times do |j|
      a[i][j] = 0 if b[k] == a[i][j]
    end
  end
end

sum = []
a.map do |e|
  sum << e.inject(:+)
end

a.transpose.map do |e|
  sum << e.inject(:+)
end

sum << a[0][0] + a[1][1] + a[2][2]
sum << a[2][0] + a[1][1] + a[0][2]

puts sum.include?(0) ? 'Yes' : 'No'

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

signed main(void)
{
	int tab[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};	
	int k;
	cin >> k;
	cout << tab[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int arr[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        {
            arr[i]=-1;
            arr[i+1]=-1;
        }
    }

    
    long long int cnt=0;

    for(int i=0;i<n;i++)
    {
        if(arr[i]!=-1)
        {
            cnt++;
        }
    }

    cout<<cnt<<endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c,d;
cin >> a >> b >> c >> d;
string ans = "No";
if(abs(a-c)<=d) {
  ans = "Yes";
}
if(abs(a-b)<=d&&abs(c-b)<=d) {
  ans = "Yes";
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=2e5+5;
vector<int> g[N];
int c[N];
void dfs(int v,int w=1){
    c[v]=w;
    for(int to:g[v])if(!c[to])dfs(to,3-w);
}
int32_t main(){
    int n;
    cin>>n;
    for(int i=1;i<n;++i){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs(1);
    int c1=0,c2=0;
    for(int i=1;i<=n;++i)if(c[i]==1)c1++;else c2++;
    if(c1<c2){
        swap(c1,c2);
        for(int i=1;i<=n;++i)c[i]=3-c[i];
    }
    vector<int> ans;
    if(c2<=n/3){
        int p3=3,n3=1;
        for(int i=1;i<=n;++i){
            if(c[i]==2){
                ans.pb(p3);
                p3+=3;
            }else{
                if(n3<=n){
                    ans.pb(n3);
                    if((++n3)%3==0)++n3;
                }else{
                    ans.pb(p3);
                    p3+=3;
                }
            }
        }
    }else{
        int p1=1,p2=2,p3=3;
        for(int i=1;i<=n;++i){
            if(c[i]==1){
                if(p1<=n){
                    ans.pb(p1);
                    p1+=3;
                }else if(p3<=n){
                    ans.pb(p3);
                    p3+=3;
                }else{
                    assert(0);
                    //ans.pb(p2);
                    // p2+=3;
                }
            }else{
                if(p2<=n){
                    ans.pb(p2);
                    p2+=3;
                }else if(p3<=n){
                    ans.pb(p3);
                    p3+=3;
                }else{
                    assert(0);
                    //ans.pb(p1);
                    // p1+=3;
                }
            }
        }
    }
    for(int i:ans)cout<<i<<' ';
    cout<<'\n';

    return 0;
}


Measured memory_bytes: 19304
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

h,w = inm()
if h%3==0 or w%3==0:
    print(0)
    exit()
# both vert or both horiz
mn = min(h,w)

# h/3, then v
hh = h//3
s1 = hh*w # < S/3
ww = w//2 + w%2
s2 = (h-hh)*ww # > S/3
mn = min(mn, s2-s1)
#ddprint(f"1. hh {hh} ww {ww} dif {s2-s1}")

# h/3+1, then v
hh = h//3+1
s1 = hh*w # > S/3
ww = w//2
s2 = (h-hh)*ww # < S/3
mn = min(mn, s1-s2)
#ddprint(f"2. hh {hh} ww {ww} dif {s1-s2}")

# w/3, then h
ww = w//3
s1 = ww*h # < S/3
hh = h//2 + h%2
s2 = (w-ww)*hh # > S/3
mn = min(mn, s2-s1)
#ddprint(f"3. hh {hh} ww {ww} dif {s2-s1}")

# w/3+1, then h
ww = w//3+1
s1 = ww*h # > S/3
hh = h//2
s2 = (w-ww)*hh # < S/3
mn = min(mn, s1-s2)
#ddprint(f"4. hh {hh} ww {ww} dif {s1-s2}")

print(mn)


Measured memory_bytes: 38256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

ll N;

int main()
{
	cin >> N;

	FOR(h, 1, 3501) {
		FOR(n, 1, 3501) {
			ll a = N*h*n;
			ll b = 4LL * h * n - N*n - N*h;
			if (b == 0)continue;
			if (a % b != 0)continue;
			ll w = a / b;
			if (0 < w && w <= 3500) {
				printf("%lld %lld %lld\n", h, n, w);
				return 0;
			}
		}
	}
	return 0;
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = 8

row = [-1 for i in range(N)]
col = [False for i in range(N)]
board = [[False for i in range(N)] for j in range(N)]
pos = [False for i in range(2*N-1)]
neg = [False for i in range(2*N-1)]

num = int(input())

for i in range(num):
  x, y = list(map(int, input().split()))
  board[x][y] = True
  
def priboard():
  for i in range(N):
    for j in range(N):
      if board[i][j] and row[i] != j:
        return
  for i in range(N):
    for j in range(N):
      char = 'Q' if row[i] == j else '.'
      print(char, end="")
    print()
      
def back_track(k):
  if k == N:
    priboard()
    return 0
  for i in range(N):
    if (not col[i]) and (not pos[k+i]) and (not neg[k-i+N-1]):
      row[k] = i
      col[i] = True
      pos[k+i] = True
      neg[k-i+N-1] = True
      
      back_track(k+1)
      row[k] = -1
      col[i] = False
      pos[k+i] = False
      neg[k-i+N-1] = False

back_track(0)




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

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

	ll res = 0;
	if (c <= a + b) {
		res = b + c;
	} else {
		res = 2 * b + a + 1;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    int n= scan.nextInt();
    ArrayList<Integer> a = new ArrayList<>();
    for(int i =0 ; i < n ; i++){
      a.add(scan.nextInt());
    }
    int max = a.remove(a.indexOf(Collections.max(a, null))) / 2;
    int sum = max;
    for(int x : a){
      sum+=x;
    }
	System.out.println(sum);
  }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s, t;
    cin >> s >> t;
    cout << (t+s) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    ll A, B;
    cin >> A >> B;

    vector<ll> P(N);
    FOR(i, 0, N){
        cin >> P.at(i);
    }

    map<ll, int> mp;

    FOR(i, 0, N){
        ll p = P[i];

        if(p <= A){
            mp[0]++;
        }
        else if(A+1 <= p && p <= B){
            mp[1]++;
        }
        else{
            mp[2]++;
        }
    }

    int ans = min(mp[0], mp[1]);
    ans = min(ans, mp[2]);
    p(ans);
    
    return 0;
}

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

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

    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }

    int counter = 0;
    int num = 0;

    vector<int> B(N);
    while(true){
        if(num == 1){
            cout << counter << endl;
            return 0;
        }

        if (B[num] != 0){
            cout << -1 << endl;
            return 0;
        }

        B[num]++;
        num = A[num] - 1;
        counter++;
    }
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int result =0;
		result += n/100==1? 900:100;
		result += (n/10)%10==1? 90:10;
		result += n%10==1? 9:1;

		System.out.println(result);



	}

}

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


int main() {
    int N;
    int ans = 0;
    int s,t;

    cin >> N >> s; ans += s;
    for(int i=0;i<N-2;++i){
      cin >> t;
      ans += min(s,t);
      s = t;
    }
    cout << ans + s << endl;
    return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
	"math"
)

func main() {
	var X int
	fmt.Scan(&X)

	ans := func() int {
		if X == 2 {
			return 2
		}

		for {
			i := 2
			for {
				if X%i == 0 {
					break
				}
				if float64(i) > math.Sqrt(float64(X)) {
					return X
				}
				i++
			}
			X++
		}

	}()

	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while (true) {

			final int n = sc.nextInt();
			final int k = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && k == 0 && m == 0){
				break;
			}
			
			int ans = 0;
			for(int i = 2; i < n; i++){
				ans += k;
				ans %= i;
			}
			
			ans += m;
			ans %= n;
			
			ans++;
			
			System.out.println(ans);
			
		}
	}

}

Measured memory_bytes: 20508
#include<stdio.h>
int main(){
  int unused __attribute__((unused));
  int a, b, c, min = 100000000;
  unused = scanf("%d %d %d", &a, &b, &c);

  if(min > a+b) min = a+b;
  if(min > a+c) min = a+c;
  if(min > b+c) min = b+c;
  printf("%d", min);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    ll N; cin >> N;
    vll G(N, vl(N));
    vll dp(N, vl(N));
    rep(i, 0, N){
        rep(j, 0, N){
            cin >> G[i][j];
            dp[i][j] = G[i][j];
        }
    }
    rep(i, 0, N){
        rep(j, 0, N){
            rep(k, 0, N){
                if(G[i][j] > G[i][k] + G[k][j]){
                    cout << -1 << endl;
                    return 0;
                }
            }
        }
    }
    rep(k, 0, N){
        rep(i, 0, N){
            rep(j, 0, N){
                if(j==k || i==k) continue;
                if(dp[i][k] == 0 || dp[i][j] == 0 || dp[k][j] == 0) continue;
                if(G[i][j] == G[i][k] + G[k][j]) dp[i][j] = 0;
            }
        }
    }
    ll cnt=0;
    rep(i, 0, N){
        rep(j, 0, N){
            cnt += dp[i][j];
        }
    }
    cout << cnt / 2 << endl;

    return 0;
}




Measured memory_bytes: 1664
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

long long N ,k;
long long res;

long long max_ (long long a, long long b) {return a < b ? b : a;}

int main () {
    scanf("%lld%lld", &N, &k);N++;
    for (long long b = k + 1;b < N; ++b) {
	long long x = b - k;
	res += N / b * x + max_(0, N - N / b * b - k);
    }
    printf("%lld\n", res - (!k) * (N - 1));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>

using namespace std;

int main() {
	int n, s[200] = {}, num[200] = {}, result = 0, lamp = 1, in, ax, h, w, m, a, b, c, d, r, tmp;
	string str ,str2;
	cin >>a>>b>>c;
	if (max(b, c) - a < min(b, c)) { cout << 0; }
	else { cout << max(b, c) - a-min(b,c); }
	
	

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int a[n],b[n],c=0;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    if(a[i]>=h&&b[i]>=w)c++;
  }
  cout << c;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define SORTA(v,n) sort(v, v + n)
#define SZ(v) (int) v.size()
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int main(void){
	int n,c,k;
	sc(n);sc(c);sc(k);
	int arr[100010];
	FOR(i,n){
		sc(arr[i]);
	}

	sort(arr, arr + n);
	int cur = 1;
	int earliest = arr[0];
	int tot = 0;
	for(int i = 1;i<n;i++){
		
		if(earliest + k < arr[i] || cur == c){
			earliest = arr[i];
			cur = 1;
			tot++;
		}else cur++;
	}

	tot++;

	printf("%d\n", tot);
    return 0;
}




Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	int N = stoi(s+t);
	
	for(int i = 0; i<1000; i++)
	{
		if(i*i == N){ cout << "Yes" << endl; return 0;}
	}
	cout << "No" << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> vSize;

    UnionFind(int N) : par(N), vSize(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++)
        {
            par[i] = i;
            vSize[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        vSize[ry] += vSize[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x){    // データxが属する木の頂点数を得る
        int rx = root(x);
        return vSize[rx];
    }
};

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> fr[N], bl[N];
    UnionFind uf(N);
    REP(i, M)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        fr[a].push_back(b);
        fr[b].push_back(a);
        uf.unite(a, b);
    }

    REP(i, K)
    {
        ll c, d;
        cin >> c >> d;
        c--;
        d--;
        /*
        if (uf.same(c, d))
        {
            bl[c].push_back(d);
            bl[d].push_back(c);
        }
        */
        bl[c].push_back(d);
        bl[d].push_back(c);
    }

    REP(i, N)
    {
        ll ans = uf.size(i) - fr[i].size() - 1;
        REPV(iter, bl[i])
        {
            if (uf.same(i, *iter)) ans--;
        }
        cout << ans << " ";
    }
}


Measured memory_bytes: 14068
#pragma gcc optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
//#include <unordered_map>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
using namespace std;
#define maxn 200007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;

const double eps = 1e-8;
const double pi = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
int n;
string s;
int has1 = 0;
int sum = 0;
int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/1.in", "rb+");
	/*int n, m;
	cin >> n >> m;
	int res = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << res << endl;*/
	string s;
	cin >> s;
	int isok = 1;
	string s2 = s, s3, s4,s5,s6;
	reverse(s2.begin(), s2.end());
	if (s != s2) {
		isok = 0;
	}
	else {
		s3 = s.substr(0, s.length() / 2);
		s4 = s.substr(s.length() / 2 + 1);
		s5 = s3, s6 = s4;
		reverse(s5.begin(), s5.end());
		reverse(s6.begin(), s6.end());
		if (s5 != s3 || s6 != s4)
			isok = 0;
	}
	if (isok)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n, l;
    cin >> n >> l;
    int a[110];
    int minabs = 9999;
    imfor(i, n) {
        a[i] = l + i + 1 - 1;
        minabs = min(abs(a[i]), minabs);
    }
    int ans = 0;
    imfor(i, n) {
        if (abs(a[i]) == minabs) {
            continue;
        }
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

long long min(long long x,long long y){
	if(x<y)return x;
	return y;
}

long long ab(long long x){
	if(x<0)return -x;
	return x;
}

int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	long long h[N];
	for(int i=0;i<N;i++)scanf("%lld",&h[i]);
	
	long long cost[N];
	cost[0]=0;
	for(int i=1;i<N;i++)cost[i]=99999999999999;
	
	for(int i=0;i<N;i++){
		for(int k=1;k<=K;k++)if(i+k<N)cost[i+k]=min(cost[i+k],cost[i]+ab(h[i]-h[i+k]));
	}
	
	printf("%lld\n",cost[N-1]);
	
	return 0;
}

Measured memory_bytes: 1664
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0)
				return;

			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = sc.nextInt();
			int M = a[0];
			int[] dp = new int[n];
			dp[0] = a[0];

			for (int i = 1; i < n; i++) {
				dp[i] = Math.max(dp[i - 1] + a[i], a[i]);
				M = Math.max(M, dp[i]);
			}
			System.out.println(M);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26268
#include <stdio.h>
int main(void) {
	int i,N,x,y,z,count=0,formula;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		count = 0;
		for (x = 1; x <=100; x++) {
			if (x > i) {
				break;
			}
			for (y = 1; y <= 100; y++) {
				for (z = 1; z <= 100; z++) {
					formula=x* x + y * y + z * z + x * y + y * z + z * x;
					if (formula > i) {
						break;
					}
					if (formula == i) {
						count++;
					}
				}
			}
		}


		printf("%d\n", count);
	}




	return 0;
}

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

const int MAXN = 3010;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
int f[2][MAXN][2], n, m;
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> m;
	int ans = 0, now = 1, lst = 0;
	for (int i = 0; i <= n; ++i) f[now][i][i == 0] = 1;
	for (int i = 0; i < m * 2; ++i) {
		std::swap(now, lst);
		memset(f[now], 0, sizeof f[now]);
		int ax = i % 2 == 0, up = n + (!ax);
		for (int j = 0; j <= up; ++j) 
		for (int k = 0; k != 2; ++k) if (int t = f[lst][j][k]) {
			if (j)
			reduce(f[now][j - 1 + ax][k | (j == 1)] += t - mod);
			if (j < up)
			reduce(f[now][j + ax][k] += t - mod);
		}
	}
	for (int i = 0; i <= n; ++i) reduce(ans += f[now][i][1] - mod);
	std::cout << ans << std::endl;
	return 0;
}


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

int main(){
	int w[10],k[10];
	int W,K;
	for(int i=0;i<10;i++) cin>>w[i];
	for(int i=0;i<10;i++) cin>>k[i];
	sort(w,w+10);
	sort(k,k+10);
	W=w[9]+w[8]+w[7];
	K=k[9]+k[8]+k[7];
	cout<<W<<' '<<K<<endl;
return 0;
}

Measured memory_bytes: 1176
A,B,C,D=map(int,input().split())
if A<=C:
    if B<=C:
        print(0)
    else:
        if B>=D:
            print(D-C)
        else:
            print(B-C)
else:
    if D<=A:
        print(0)
    else:
        if B<=D:
            print(B-A)
        else:
            print(D-A)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int num_prime(int n, int p) {
	int c = 0;
	while(n % p == 0) {
		c++;
		n /= p;
	}

	return c;
}

int main() {
	vector<int> p;
	vector<int> pc;
	bool pf[1001] = { false };
	pf[0] = pf[1] = true;
	for(int i = 2; i <= 1000; i++) {
		if(! pf[i]) {
			for(int j = i + i; j <= 1000; j += i) {
				pf[j] = true;
			}
		p.push_back(i);
		pc.push_back(0);
		}
	}
	
	int N;
	cin >> N;
	for(int i = 2; i <= N; i++) {
		for(int j = 0, SIZE = p.size(); j < SIZE; j++) {
			if(p[j] > i) break;
			pc[j] += num_prime(i, p[j]);
		}
	}
	
	long long ans = 1;
	for(int j = 0, SIZE = p.size(); j < SIZE; j++) {
		ans *= pc[j] + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
	
	return 0;
}



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

int main(int argc, char const *argv[]) {
  int N;
  long int K;
  std::cin >> N >> K;
  int a, b;
  std::vector<long int> v(1E5 + 1);
  for (size_t i = 0; i < N; i++) {
    std::cin >> a >> b;
    v[a] += b;
  }
  long int sum = 0;
  for (size_t i = 1; i < 1E5 + 1; i++) {
    sum += v[i];
    if (sum >= K) {
      std::cout << i << '\n';
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
vals = list(map(int, input().split(' ')))
vals.sort(reverse=True)

res = 0

for i, v in enumerate(vals, 1):
    if i < N:
        res = res + v / 2 ** i
    else:
        res = res + v / 2 ** (N - 1)

print(res)    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, a[55] = {}, b[55] = {}, c[55] = {}, d[55] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> c[i] >> d[i];
    for (int i = 1; i <= m; i++) cin >> a[i] >> b[i];
    for (int i = 1; i <= n; i++) {
        int x = mod, y = 0;
        for (int j = 1; j <= m; j++) if (abs(a[j] - c[i]) + abs(b[j] - d[i]) < x) x = abs(a[j] - c[i]) + abs(b[j] - d[i]), y = j;
        cout << y << '\n';
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        string s = to_string(i);
        if (s.at(0) == s.at(4) && s.at(1) == s.at(3))
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

const int64_t C = 998244353;

int64_t power(int x, int y){
  int64_t ans = 1;
  for(int i=0; i<y; i++){
    ans = (ans * x) % C;
  }
  return ans;
}

int main(){
  int N;
  vi count(100010); //count[i] = 距離iの点の個数

  cin >> N; int maximum = 0;
  for(int i=0; i<N; i++){
    int tmp; cin >> tmp;

    if((i==0 && tmp != 0) || (i != 0 && tmp == 0)){
      cout << 0 << endl;
      return 0;
    }

    count[tmp]++;
    maximum = max(maximum,tmp);
  }

  int64_t ans = 1;
  for (int i=1; i<=maximum; i++){
    ans = (ans * power(count[i-1], count[i])) % C;
  }

  cout << ans << endl;
}

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

int main() {
  int N, x;
  cin >> N;
  
 for (int i = 0; i < N; i++) {
   int l, r;
   cin >> l >> r;
   x += r - l + 1;
 }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define PI 3.14159265358979323846
using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (s == t) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

int main(){
    string s,t; cin >> s >> t;
    ll ans = 0;
    rep(i,0,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3912
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int k, t, mx = 0;
	cin >> k >> t;
	vector<int> a(t);
	rep(i, t){
		cin >> a.at(i);
		mx = max(a.at(i), mx);
	}

	if(mx <= k/2) cout << 0 << endl;
	else cout << mx - (k-mx) - 1 << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	// 4 * x + 7 * y == N
	bool ans = false;	
	int x = N / 4;
	int y = N / 7;
	for (int i=0; i<=x; ++i) {
		for (int j=0; j<=y; ++j) {
			if (N == (4*i + 7*j)) {
				ans = true;
				break;
			}
		}
		if (ans) break;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define NIL (-1)
#define m 1046527
char T[m][14];
int h1(int key) {return key%m;}
int h2(int key) {return key%(m-1);}


int getChar(char ch){
    if (ch=='A') return 1;
    else if (ch=='C') return 2;
    else if (ch=='G') return 3;
    else if (ch=='T') return 4;
    else return 0;
}

long long getKey(char moji[]){
    long long sum=0,p=1,i;
    for(i=0;i<strlen(moji);i++){
        sum+=p*(getChar(moji[i]));
        p*=5;
    }
    return sum;
}


int search(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0) return 0;
    }
    return 0;
}

int insert(char moji[]){
    long long key,i,h;
    key=getKey(moji);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%m;
        if(strcmp(T[h],moji)==0) return 1;
        else if(strlen(T[h])==0){
            strcpy(T[h],moji);
            return 0;
        }
    }
    return 0;
}


int main(void){
    int i,n;
    char order[9],moji[14];
     for ( i = 0; i < m; i++ ) T[i][0] = '\0';
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%s%s",order,moji);
        if(order[0]=='i') insert(moji);
        else if(search(moji)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 16040
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int Syakutori(vector<long> &d, int n, int k){
  int len = 0;
  long tmp = 1;
  for(int s=0,t=0; t<n; t++){ //
    //tmp *= d.at(t);
    //tmp += d.at(t);
    while(tmp < k && s <= t){
      tmp /= d.at(s);
      s++;
    }
    len = max(len, t-s+1);
  }
  return len;
}


int main(){
  int n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a.at(i);
  long sum = 0;
  long xsum = 0;
  long ans = 0;
  for(int s=0,t=0; t<n; t++){
    sum += a.at(t);
    xsum = (xsum ^ a.at(t));
    while(sum != xsum && s <= t){
      sum -= a.at(s);
      xsum = (xsum ^ a.at(s));
      s++;
    }
    ans += t-s+1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll x[100001] = {};
	ll n, a, b; cin >> n >> a >> b;
	repe(i, 1, n)cin >> x[i];

	ll ans = 0;
	repe(i, 2, n) {
		ans += min((x[i] - x[i - 1])*a, b);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#include<stdlib.h>
#include<stdio.h>
  
struct trie{
    int mx;
    int cnt;
    trie *ar[26];
};


void insert(trie * t,string s,int i){
    if(s.size()==i){
        t->cnt++;
        if(t->cnt>t->mx){
            t->mx=t->cnt;
        }
        return ;
    }
    
    if(t->ar[s[i]-'a']==0){
        t->ar[s[i]-'a'] = new trie();
        t->ar[s[i]-'a']->cnt=0;
        t->ar[s[i]-'a']->mx=0;
        for(int j=0;j<26;j++){
            t->ar[s[i]-'a']->ar[j]=0;
        }
    }
    insert(t->ar[s[i]-'a'], s, i+1);
    if(t->ar[s[i]-'a']->mx > t->mx){
        t->mx=t->ar[s[i]-'a']->mx;
    }
}

void search(trie *t,int v,string s){
    if(t==0)
    {
        //cout<<"\n";
        return ;
    }
    if(t->mx==t->cnt){
        cout<<s<<"\n";
    }
    
    for(int i=0;i<26;i++){
        if(t->ar[i]){
            if(t->ar[i]->mx==v){
                //cout<<char(i+'a');
                
                search(t->ar[i],v,s+char(i+'a'));
            }
        }
    }
}
int main()
{
    int a;
    trie *head = new trie();
    trie *t=head;
    
    cin>>a;
    string s;
    for(int k=0;k<a;k++){
        cin>>s;
        t=head;
        insert(t, s, 0);
    }
    search(head,head->mx,"");
    return 0;
}



Measured memory_bytes: 208768
import sys

input = sys.stdin.readline
from math import gcd

primes = set([i for i in range(2,10**6+1)])

for i in range(2,1001):
  for j in range(i*2,10**6+1,i):
    if j in primes:
      primes.remove(j)
      
n = int(input())
a = list(map(int,input().split()))

ok = 1
tmp = a[0]

for i in range(1,n):
  tmp = gcd(tmp,a[i])
  
if tmp>1:
  print('not coprime')
else:
  used = set([])
  ok = 1
  
  for num in a:
    if num in primes:
      if num in used:
        ok = 0
      else:
        used.add(num)
    else:
      for i in range(2,int(num**0.5)+1):
        if num % i == 0:
          if i in used:
            ok = 0
          else:
            used.add(i)
          x = num//i
          if x!=i:
          
            if x in used:
              ok = 0
            else:
              used.add(x)
            
    if ok==0:
      break
      
  if ok==1:
    print('pairwise coprime')
  else:
    print('setwise coprime')

Measured memory_bytes: 206548
MOD = 1000_000_007
n = gets.to_i
dp=(0..n).map{{}}
dp[0]['TTT'] = 1
n.times do |i|
  dp[i].each do |k, v|
    'AGCT'.chars do |c|
      s = "#{k}#{c}"
      next if ["AGC", "ACG", "GAC"].include?(s[1..3])
      next if s[0..1] == "AG" && s[3] == "C"
      next if s[0] == "A" && s[2..3] == "GC"
      dp[i+1][s[1..3]] = dp[i+1][s[1..3]].to_i + v
      dp[i+1][s[1..3]] %= MOD
    end
  end
end
p dp[n].values.inject(:+) % MOD

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll i,o,t,j,l,s,z;
    cin>>i>>o>>t>>j>>l>>s>>z;
    ll res = 0;
    res += o;
    if (i==0||j==0||l==0) {
        res += i/2*2 + j/2*2 + l/2*2;
    }
    else if (!(i%2&&j%2&&l%2)&&(i+j+l)%2||
                !(i%2==0&&j%2==0&&l%2==0)&&(i+j+l)%2==0) {
        res += i+j+l-1;
    }
    else {
        res += i+j+l;
    }
    cout <<res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,kai;
	char op;
	while(1)	{
		scanf("%d %c %d",&a,&op,&b);
		if(op=='?')	break;
		if(op=='+')	kai=a+b;
		if(op=='-')	kai=a-b;
		if(op=='*')	kai=a*b;
		if(op=='/')	kai=a/b;
		printf("%d\n",kai);
	}
	return 0;
}


Measured memory_bytes: 2748
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int r, g;
    cin >> r >> g;
    cout << 2 * g - r;
}

Measured memory_bytes: 256
n = int(input())
list_A = list(map(int, input().split()))
a = []
b = []
list_A.sort(reverse=True)
for i in range(n):
    if i % 2 == 0:
        a.append(list_A[i])
    else:
        b.append(list_A[i])
print(sum(a)-sum(b))

Measured memory_bytes: 3060
def YY(x):
    if 1<=x and x<=12:
        return True
    else:
        return False
S=input()
A=int(S[0:2])
B=int(S[2:4])
if YY(A) and YY(B):
    print("AMBIGUOUS")
elif YY(A):
    print("MMYY")
elif YY(B):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 9180