akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

long f(long x) {
    if (x % 2 == 1) {
        return (x + 1)/2 % 2;
    } else {
        return ((x/2)%2) ^ x;
    }
}

int main() {
    long A, B;
    cin >> A >> B;

    long ans;
    if (A == 0) {
        ans = f(B);
    } else {
        ans = f(A-1) ^ f(B);
    }

    cout << ans << endl;

    return 0;
}


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

const int MAXN = 1e5 + 5;
int n, ans;
int Arr[MAXN];
int back[MAXN];
map <int, int> Map;

int main() { 
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &Arr[i]);
		back[i] = Arr[i];
	}
	sort(Arr, Arr + n);
	for (int i = 0; i < n; i++)
		Map[Arr[i]] = i;
	for (int i = 0; i < n; i++)
		if (Map[back[i]] % 2 != i % 2)
			ans++;
	printf("%d\n", ans / 2);
	return 0;
}

Measured memory_bytes: 5760
///*
#include<iostream>
using namespace std;

int main() {

	int a[] = { 1,3,5,7,8,10,12 };
	int b[] = { 4,6,9,11 };
	int c[] = { 2 };
	int x[2], i, j;
	char countx, county;

	for (i = 0; i < 2; i++) {
		cin >> x[i];
	}

	for (i = 0; i < sizeof(a) / 4; i++) {
		for (j = 0; j < 2; j++) {
			if (x[j] == a[i]) {
				if (j == 0)countx = 'a';
				if (j == 1)county = 'a';
			}
		}
	}

	for (i = 0; i < sizeof(b) / 4; i++) {
		for (j = 0; j < 2; j++) {
			if (x[j] == b[i]) {
				if (j == 0)countx = 'b';
				if (j == 1)county = 'b';
			}
		}
	}
	
	for (i = 0; i < sizeof(c) / 4; i++) {
		for (j = 0; j < 2; j++) {
			if (x[j] == c[i]) {
				if (j == 0)countx = 'c';
				if (j == 1)county = 'c';
			}
		}
	}

	countx == county ? cout << "Yes" : cout << "No";

	return 0;
}
//*/

Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        var n = Console.ReadLine();
        var head = int.Parse(n[0].ToString());
        var border = head * 100 + head * 10 + head;
        if (int.Parse(n) > border)
        {
            Console.WriteLine(border + 111);
        }
        else
        {
            Console.WriteLine(border);
        }
    }
}


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

int N, W, d[100], v[100], mem[100][10001];

int dp(int n, int w)
{
  if(n == N)
    return 0;
  if(mem[n][w] != -1)
    return mem[n][w];
  int ans = 0;
  if(w - d[n] >= 0)
    ans = max(ans, dp(n + 1, w - d[n]) + v[n]);
  ans = max(ans, dp(n + 1, w));
  return mem[n][w] = ans;
}

int main()
{
  fill((int*)mem, (int*)mem + sizeof(mem) / sizeof(int), -1);
  cin >> N >> W;
  for(int i = 0; i < N; i++)
    cin >> v[i] >> d[i];
  cout << dp(0, W) << endl;
}

Measured memory_bytes: 5072
# C
N = int(input())
a_list = [0] + list(map(int, input().split())) + [0]

# total
total_trip = 0
for i in range(N+1):
    total_trip += abs(a_list[i+1] - a_list[i])

# res
for i in range(N):
    lag = abs(a_list[i+2] - a_list[i+1]) + abs(a_list[i+1] - a_list[i]) - abs(a_list[i+2] - a_list[i])
    print(total_trip - lag)

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  int A;
  cin >> S >> T;
  A = 0;
  if (S.at(0) == T.at(0)){
    A++;
  }
  if ( S.at(1) == T.at(1)){
    A++;
  } 
  if(S.at(2) == T.at(2)){
    A++;
  }
           cout << A << endl;
           }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define D 365
#define INF 1001001001
typedef long long ll;
ll calcSat(int *tmpt, int s[][26], int *c) {
	int last[26] = {0};
	ll tmpSat = 0;
	for (int i = 0; i < D; i++) {
		tmpSat += s[i][tmpt[i] - 1];
		last[tmpt[i] - 1] = i + 1;
		for (int j = 0; j < 26; j++) {
			tmpSat -= (c[j] * (i + 1 - last[j]));
		}
		/**
		printf("%lld\n", tmpSat);
		/**/
	}
	return tmpSat;
}
int main() {
	clock_t start = clock(), now = clock();
	srand(628);
	scanf("%*d");
	int c[26], s[D][26];
	int t[D] = {0};
	ll bestSat = 0;
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	/**/
	int last[26] = {0};
	for (int i = 0; i < D; i++) {
		ll bestNowSat = -INF;
		int bestType = 0;
		for (int j = 0; j < 26; j++) {
			ll tmpSat = 0;
			tmpSat += s[i][j];
			for (int k = 0; k < 26; k++) {
				if (k != j) {
					tmpSat -= (c[k] * (i + 1 - last[k]));
				}
			}
			if (bestNowSat < tmpSat) {
				bestNowSat = tmpSat;
				bestType = j;
			}
		}
		bestSat += bestNowSat;
		t[i] = bestType + 1;
		last[bestType] = i + 1;
	}

	while ((double)(now - start) / CLOCKS_PER_SEC < 1.95) {
		int pos = rand() % D;
		int oldt = t[pos];
		t[pos] = rand() % 26 + 1;
		ll tmpSat = calcSat(t, s, c);
		if (tmpSat > bestSat) {
			bestSat = tmpSat;
		} else {
			t[pos] = oldt;
		}
		now = clock();
	}
	// printf("%lld\n", bestSat);

	for (int i = 0; i < D; i++) {
		printf("%d\n", t[i]);
	}
	return 0;
}


Measured memory_bytes: 1836
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]){
    int n,a,b;
    string s;
    cin>>n>>a>>b>>s;
    vector<string>v;
    int f=0,t=0;
    for(int i=0;i<s.length();i++){
        if(t>=a+b){
            cout<<"No"<<endl;
        } else {
            if(s[i]=='a'){
                cout<<"Yes"<<endl;
                t++;
            } else if(s[i]=='b'){
                if(f<b){
                    cout<<"Yes"<<endl;
                    t++;
                    f++;
                } else {
                    cout<<"No"<<endl;
                }
            } else {
                cout<<"No"<<endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	printf("%d",max(max(a+b,a-b),a*b));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pow_mod(ll fi,ll se,ll mod){
  if(se==0){
    return 1;
  }
  if(se%2){
    return pow_mod(fi,se-1,mod)*fi%mod;
  }
  ll t=pow_mod(fi,se/2,mod);
  return t*t%mod;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

vector<pair<int,int>> Dir={{-1,0},{1,0},{0,1},{0,-1}};
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

vec(dp,100003);

int main(){
  ll n,m;
  cin>>n>>m;
  vec(a,m);
  rep(i,m){
    cin>>a[i];
    dp[a[i]]=-1;
  }
  dp[0]=1;
  rep(i,n+1){
    if(dp[i]>=0){
    if(dp[i+1]>=0){dp[i+1]+=dp[i];dp[i+1]%=MOD;}
    if(dp[i+2]>=0){dp[i+2]+=dp[i];dp[i+2]%=MOD;}
    }
  }
  op(dp[n]);
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  
  for ( int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  int b = 1;
  
  for (int i = 0; i < N; i++) {
    if ( a.at(b - 1) == 2 ) {
      cout << i + 1 << endl;
      break;
    }
    else if ( i != N -1 ) {
      b = a.at(b - 1);
      
      continue;
    }
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long a,b,c;
    scanf("%ld%ld%ld", &a, &b, &c);

    printf("%ld\n", MIN(c, b/a));



    return 0;
}



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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 998244353
#define curtime chrono::steady_clock::now().time_since_epoch().count
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

int gcd(int a, int b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

void solution() {
  int n, s;
  cin >> n >> s;
  vector<int> dp(s + 1, 0);
  vector<int> last_dp(s + 1, 0);
  last_dp[0] = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    for (int j = s; j >= 0; j--) {
      dp[j] = mod((j - x >= 0 ? last_dp[j - x] : 0LL) + 2 * last_dp[j]);
    }
    for (int j = 0; j <= s; j++) {
      last_dp[j] = dp[j];
      // cout << "dp[" << i << "][" << j << "] = " << dp[j] << endl;
    }
  }
  cout << dp[s] << endl;
}
int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  solution();
}


Measured memory_bytes: 3696
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner scan = new Scanner(System.in);
      
    while (true) {
      int isZero = scan.nextInt();
      
      if (isZero == 0) {
        break;
      } else {
        int cnt = isZero;
        int[] kind = new int[10];
            
        for (int i = 0; i < cnt; i++) {
          int tmp = scan.nextInt();
          kind[tmp]++;
        }
            
        for (int i : kind) {
          if (i > 0) {
            for (int j = 0; j < i; j++) {
              System.out.print("*");
            }
            System.out.println();
          } else {
            System.out.println("-");
          }
        }
      }
    }
  }
}



Measured memory_bytes: 60268
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var A = new long[N];
        var B = new long[N];
        var dic = new SortedDictionary<int,long>();
        for (int i = 0; i < N; i++)
        {
            var inp = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            A[i] = inp[0];
            B[i] = inp[1];
            dic.Add(i, A[i] + B[i]);
        }

        var count = 0;
        long ans = 0;

        
        foreach (var item in dic.OrderByDescending((x) => x.Value))
        {
            if(count%2 == 0)
            {
                ans += A[item.Key];
            }
            else
            {
                ans -= B[item.Key];
            }
            count++;
        }

        Console.WriteLine(ans);
    }



}


Measured memory_bytes: 51700
import java.util.Scanner;

public class Main {

	static int[] par, rank;

	static void init(int N) {
		for(int i=0; i<N; i++) {
			rank[i]=0;
			par[i]=i;
		}
	}

	static int root(int x) {
		if(par[x]==x) {
			return x;
		}
		return par[x]=root(par[x]);
	}

	static boolean same(int x, int y) {
		return (root(x)==root(y));
	}

	static void unite(int x, int y) {
		x = root(x);
		y = root(y);

		if(x == y)return;

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


	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int n=sc.nextInt();
			int m=sc.nextInt();
			rank=new int[n+1];
			par=new int[n+1];
			init(n);
			for(int i=0; i<m; i++) {
				int a=sc.nextInt();
				int b=sc.nextInt();
				unite(a, b);
			}
			int q=sc.nextInt();
			for(int i=0; i<q; i++) {
				int a=sc.nextInt();
				int b=sc.nextInt();
				if(same(a, b)) {
					System.out.println("yes");
				}
				else {
					System.out.println("no");
				}
			}

		}
	}
}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    rep(i,n) cin >> A[i];
    bool ans = true;
    for(int i = 0;i < n;i++){
        if(A[i] % 2 == 0){
            if((A[i] % 3 != 0) && (A[i] % 5 != 0)){
            ans = false;
            break;
            }
        }
    }
    if(ans) cout << "APPROVED";
    else cout << "DENIED";
    return 0;
}

Measured memory_bytes: 256
<?php
	while (!feof(STDIN))
	{
		$stdin[] = trim(fgets(STDIN));
	}
	$a = (int)$stdin[0];
	$b = (int)$stdin[1];
	$c = (int)$stdin[2];
	$x = (int)$stdin[3];

	$answer = 0;
	if (!is_ok1($a) || !is_ok1($b) || !is_ok1($c))
	{
		echo $answer;
	}

	if (!is_ok2($a+$b+$c))
	{
		echo $answer;
	}

	if (!is_ok3($x))
	{
		echo $answer;
	}

	for ($i=0; $i<=$a; $i++)
	{
		for ($j=0; $j<=$b; $j++)
		{
			for ($k=0; $k<=$c; $k++)
			{
				$total = (500*$i)+(100*$j)+(50*$k);
				if (is_ok4($x, $total))
				{
					$answer++;
				}
			}
		}
	}
	echo $answer;

	function is_ok1($num)
	{
		if ((!is_int($num)) || ($num < 0 || 50 < $num))
		{
			return false;
		}
		return true;
	}

	function is_ok2($total)
	{
		if(($total) < 0)
		{
			return false;
		}
		return true;
	}

	function is_ok3($stdin_total)
	{
		if(($stdin_total < 50) || (20000 < $stdin_total) || ($stdin_total % 50 != 0))
		{
			return false;
		}
		return true;
	}

	function is_ok4($stdin_total, $total)
	{
		if ($total != $stdin_total)
		{
			return false;
		}
		return true;
	}
?>

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

int main()
{


        long long n,m,a,b,c,d,e,f,g,h,p,q,r,fr,sc,tr,sz,tz,i,j,k,mx=LLONG_MIN,mn=LLONG_MAX;
        long long x=1,y=0,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,char>mp,nq,qr; string str,ttr,ntr;

        char ch;

        for(ch='a',i=1;ch<='y',i<=25;ch++,i++)
        {
            mp[i]=ch;
        }

        mp[0]='z';
        sc=1;

        scanf("%lld",&n);





            while(1)
            {
                fr=n%26;  str.push_back(mp[fr]);   if(fr==0)n--;  n=n/26;

                if(n<=0)break;


            }

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






        return 0;

}





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

int main(){
  int n, i, j, k, si, temp1, temp2, sum1, sum2;
  string str;
  stack<int> temp;
  
  while(1){
    cin>>n;

    if(n == 0) break;

    for(i = 0; i <= n; i++){
      
      if(i != n){
	cin>>str;
	si = str.size()-1;
	if(i==0)temp1 = si;
	temp2 = si;
      } else {
	temp2 = 0;
      }
      
      
      sum1 = 1; sum2 = 0;
      
      if(temp2 < temp1){
	j = 0;
	while(1){
	  if(temp.top() < 0){
	    if(temp.top() == -1){
	      temp.pop();
	      temp.push(sum1);
	      } else{
	      temp.pop();
	      temp.push(sum2);
	    }
	    sum1 = 1; sum2 = 0;
	    j++;
	  }
	  if(temp1-temp2 <= j) break;
	  
	  sum1 *= temp.top();
	  sum2 +=temp.top();
	  temp.pop();
	  }
      }
      
      if(i != n && str[si] == '*'){
	temp.push(-1);
	} else if(i != n && str[si] == '+'){
	temp.push(-2);
      } else if(i != n){
	temp.push(str[si] - '0');
      }	
      temp1 =  temp2;
    }
    cout<<temp.top()<<endl;
    temp.pop();
  }
  
  return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
int main() 
{
    int h, w, cnt=0;
    cin >> h >> w;

    char A[h+10][w+10];
    char B[h+10][w+10];

    rep(i,h+1){
        rep(j,w+1){
            A[i][j]=0;
            B[i][j]=0;
        }
    }

    REP(i,h){
        REP(j,w){
            cin >> A[i][j];
        }
    }

    REP(i,h){
        REP(j,w){
            if(A[i][j] == '#'){
                B[i][j] = '#';
            }
            else
            {
                for(int k=i-1;k<=i+1;k++){
                    for(int l=j-1;l<=j+1;l++){
                        if(A[k][l]=='#')
                        	cnt++;
                    }
                }
                B[i][j]= 48+cnt;
                cnt=0;
            }
            

        }
    }
    REP(i,h){
        REP(j,w){
            cout << B[i][j];
        }
      cout << endl;
    }
  	cout << endl;
  


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int n, Q;
ll D;
ll d[1<<19];
ll m[1 << 19];
ll loc[1 << 19];
int main() {
	cin >> n >> D;
	rep(i, n) {
		cin >> d[i];
	}
	m[n] = 1;
	per(i, n) {
		if (d[i] <= 2 * m[i+1] - 1) {
			m[i] = m[i + 1] + d[i];
		}
		else m[i] = m[i + 1];
	}
	loc[0] = D;
	rep(i, n) {
		loc[i + 1] = min({ loc[i],abs(loc[i] - d[i]) });
	}
	cin >> Q;
	rep(i, Q) {
		int q; cin >> q; q--;
		if (loc[q] >= m[q + 1])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	//stop
	return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <algorithm>

using namespace std;
long long mon[200007];
int main()
{
    long long n,k,att=0;
    cin>>n>>k;
    for (int i=0;i<n;i++){
        cin>>mon[i];
        att+=mon[i];
    }
    sort(mon,mon+n);
    for (int i=n-1;i>-1;i--){
        if (k!=0){
            att-=mon[i];
            mon[i]=0;
            k--;
        }
        else break;
    }
    cout<<att;
    

    return 0;
}

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

int main(void){
	int length;
	int up = 0, down = 0;
	int step;
	int steps[100];
	int now;
	int next;
	int dif;
	int i, n;

	scanf("%d", &length);
	for(i=0; i<length; i++){
		scanf("%d", &step);
		for(n=0; n<step; n++){
			scanf("%d", &steps[n]);
		}
		for(n=1; n<step; n++){
			next = steps[n];
			now = steps[n-1];
			dif = next - now;
			if(dif > 0){
				if(up < dif){
					up = dif;
				}
			}else{
				if(down > dif){
					down = dif;
				}
			}
		}
		printf("%d %d\n", up, abs(down));
		dif = 0;
		up = 0;
		down = 0;
	}
	return 0;
}

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

int main(){
  ll N,N_cp;cin>>N;N_cp=N;
  vector<ll> ans;
  while(N!=0){
    ll i=0,left=0,right=0;
    if(N>0){
      while(right<N){
        if(i%2==0) right += pow(-2,i);
        ++i;
      }
    }
    if(N<0){
      while(left>N){
        if(i%2!=0) left += pow(-2,i);
        ++i;
      }
    }
    N -= pow(-2,i-1);
    ans.push_back(i-1);
  }

  if(N_cp==0)cout << 0 << endl;
  else{
    for(int i=ans[0];i>=0;i--){
      if(find(ans.begin(),ans.end(),i)!=ans.end())cout<<1;
      else cout<<0;
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    S=str(input())
    w=int(input())
    ls=len(S)
    L=[S[i*w] for i in range(-(-ls//w))]
    print(''.join(L))


    
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef vector <int> VI;
typedef vector <char> VC;

string toNums( string s ) {
    string R = "*/+";
    for ( int i = 0; i < 3; ++ i ) {
        replace( s.begin(), s.end(), R[i], ' ' );
    }
    return s;
}

string toOps( string s ) {
    string R = "0123456789-";
    for ( int i = 0; i < 11; ++ i ) {
        replace( s.begin(), s.end(), R[i], ' ' );
    }
    return s;
}

int eval( string expr ) {
    stack <int> S;
    for ( int i = 0; i < (int)expr.size(); ++ i ) {
        if ( expr[i] == '(' ) {
            S.push( i );
        } else if ( expr[i] == ')' ) {
            int left = S.top();
            int right = i;
            string L = expr.substr( 0, left );
            string M = expr.substr( left, right - left + 1 );
            string R = expr.substr( right + 1 );
            ostringstream os;
            os << eval( M.substr( 1, M.size()-2 ) );
            expr = L + os.str() + R;
            i = -1;
            S = stack <int>();
            continue;
        }
    }
    string nums = toNums( expr );
    string ops = toOps( expr );
    VI N;
    int num;
    istringstream is1( nums );
    while ( is1 >> num ) {
        N.push_back( num );
    }
    VC O;
    char op;
    istringstream is2( ops );
    while ( is2 >> op ) {
        O.push_back( op );
    }
    for ( int i = 0; i + 1 < (int)N.size(); ++ i ) {
        int a = N[i], b = N[i+1];
        char c = O[i];
        if ( c == '*' ) {
            N.erase( N.begin() + i );
            char cc = O[i+1];
            O.erase( O.begin() + i );
            N[i] = a * b;
            O[i] = cc;
            i --;
        } else if ( c == '/' ) {
            N.erase( N.begin() + i );
            char cc = O[i+1];
            O.erase( O.begin() + i );
            N[i] = a / b;
            O[i] = cc;
            i --;
        }
    }
    int answer = accumulate( N.begin(), N.end(), 0 );
    return answer;
}

bool isOp( char c ) {
    string O = "+-*/";
    for ( int i = 0; i < 4; ++ i ) {
        if ( c == O[i] ) return true;
    }
    return false;
}

string convert( string s ) {
    for ( int i = 0; i < (int)s.size(); ++ i ) {
        if ( s[i] != '-' ) continue;
        string L = s.substr( 0, i );
        string R = s.substr( i );
        s = L + ( (i>0 && isOp( s[i-1] )) || i == 0 ? " " : "+" ) + R;
        i ++;
    }
    return s;
}

int main() {
    int n;
    while ( cin >> n ) {
        if ( n == 0 ) break;
        for ( int i = 0; i < n; ++ i ) {
            string line;
            cin >> line;
            line = convert( line );
            cout << eval( line.substr( 0, line.size() - 1 ) ) << endl;
        }
    }
    return 0;
}

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

int main(){
  int N;
  int d[101];
  int count = 0;
  int max = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
  sort(d,d+N);
  for(int i=0;i<N;i++){
    if(max < d[i]){
      max = d[i];
      count++;
    }
  }
  cout << count << endl;
}

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

ans=0

for i in range(A,B+1):
    for j in range(len(str(i))):
        zen = j
        kou = len(str(i))-1-j
        if zen >= kou:
            ans+=1
            break
        if str(i)[zen] != str(i)[kou]:
            break
    
print(ans)

Measured memory_bytes: 9128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();

		List<String> cake = new ArrayList<>();
		for (int i = 0; i < h; i++) {
			cake.add(sc.next());
		}

		List<String> cut = new ArrayList<>();
		int count = 0;

		for (String row : cake) {

			String cutRow = "";

			if (row.contains("#")) {
				count++;

				boolean berry = false;

				for (int i = 0; i < row.length(); i++) {

					if (row.charAt(i) == '#') {
						if (berry) {
							count++;
						}
						berry = true;
					}
					cutRow += count + " ";
				}
			}

			cut.add(cutRow.trim());
		}

		String tmp = "";
		for (int i = 0; i < cut.size(); i++) {
			String row = cut.get(i);
			if(row.equals("") == false) {
				tmp = row;
			} else {
				cut.set(i, tmp);
			}
		}

		tmp = "";
		for (int i = cut.size() - 1; i >= 0; i--) {
			String row = cut.get(i);
			if(row.equals("") == false) {
				tmp = row;
			} else {
				cut.set(i, tmp);
			}
		}

		for (String row : cut) {
			System.out.println(row);
		}

		sc.close();
	}

}


Measured memory_bytes: 207692
#include <bits/stdc++.h>
using namespace std;
#define int long long

int memo[100005];

int f(int a[],int n)
{
    if(memo[n]!=-1)
       return memo[n];
       
    if(n==2)
        return abs(a[n-2]-a[n-1]);
    if(n==3)
        return min(abs(a[n-1]-a[n-3]),(abs(a[n-1]-a[n-2]) + abs(a[n-2]-a[n-3])));
    else
    {
        int res=min((f(a,n-1) + abs(a[n-1]-a[n-2])) , (f(a,n-2) + abs(a[n-1]-a[n-3])));
        memo[n]=res;
        return res;
    }
}
#undef int
int main()
{
 #define int long long
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)
       cin >> a[i];

    memset(memo,-1,sizeof(memo));
    cout << f(a,n) << endl;   
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }


main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}


Measured memory_bytes: 3692
N = int(input())
S = input()
c1 = S.count("#")
c2 = S.count(".")
r1 = [0] * N
r2 = [0] * (N + 1)
r1[0] = 1 * (S[0] == '#')
for i in range(1, N):
    if S[i] == "#":
        r1[i] = r1[i - 1] + 1
    else:
        r1[i] = r1[i - 1]
r2[N - 1] = 1 * (S[N - 1] == ".")
r2[N] = r2[N - 1]
for i in range(N - 2, -1, -1):
    if S[i] == ".":
        r2[i] = r2[i + 1] + 1
    else:
        r2[i] = r2[i + 1]
res = N
for i in range(N):
    res = min(res, r1[i] + r2[i + 1])
print(min(res, c1, c2))

Measured memory_bytes: 12784
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    vll a(n);
    for(i = 0; i < n; i++)
        cin >> a[i];
    bool p = true;
    for(i = 1; i <= n; i++)
        if(a[i - 1] != i)
            p = false;
    if(p)
    {
        cout << "YES\n";
        return 0;
    }
    for(i = 0; i < n; i++)
    {
        for(ll j = i + 1; j < n; j++)
        {
            swap(a[i], a[j]);
            bool poss = true;
            for(ll k = 1; k <= n; k++)
                if(a[k - 1] != k)
                    poss = false;
            if(poss)
            {
                cout << "YES\n";
                return 0;
            }
            swap(a[i], a[j]);
        }
    }
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }

typedef long long ll;
using namespace std;

const ll p = 1000000007;

int main() {
    
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n, 0), b(m, 0);
    REP (i, n) cin >> a[i];
    REP (i, m) cin >> b[i];

    sort(ALL_OF(a));
    sort(ALL_OF(b));

    REP(i, n-1) {
        if (a[i+1] == a[i]) {
            cout << 0 << endl;
            return 0;
        }
    }
    REP(i, m-1) {
        if (b[i+1] == b[i]) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll u = n-1, v = m-1;
    ll ans = 1;
    for (ll k = m * n + 1; --k;) {

        while (u >= 0) {
            if (a[u] < k) break;
            u--;
        }
        while (v >= 0) {
            if (b[v] < k) break;
            v--;
        }
        u++; v++;

        if (u >= n || v >= m || a[u] < k || b[v] < k) {
            cout << 0 << endl;
            return 0;
        }
        ll pr = 0;
        if (a[u] == k && b[v] == k) {
            // cerr << "pattern 0, ";
            pr = 1;
        } else if (a[u] == k) {
            // cerr << "pattern 1, ";
            pr = (m - v) % p;
        } else if (b[v] == k) {
            // cerr << "pattern 2, ";
            pr = (n - u) % p;
        } else {
            // cerr << "pattern 3, ";
            pr = 1ll * ((n - u) % p * (m - v) % p + p - (m * n - k) % p) % p;
        }
        // cerr << "[" << k << "]: ";
        // cerr << "(" << u << ", " << v << ") ";
        // cerr << pr << " toori (total " << ans << "toori)" << endl;
        ans *= pr;
        ans %= p;
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

typedef long long LL;

const int N = 200010;

int r[N];
LL a[N][2];
LL sum;

int main()
{
    int n;
    scanf("%d", &n);
    
    LL sum = 0;
    for(int i = 1; i <= n; i ++)  scanf("%d", &r[i]),  r[i + n] = r[i],  sum += r[i];
    
    for(int i = 1; i <= n * 2; i ++)
    {
        a[i][0] = a[i - 1][0];
        a[i][1] = a[i - 1][1];
        a[i][i & 1] += r[i];
        //printf("%d: %d %d\n", i, a[i][0], a[i][1]);
    }
    
    for(int i = 0; i < n; i ++)
        printf("%lld ", sum - 2 * (a[i + n - 1][i & 1] - a[i][i & 1]));
    
    return 0;
}

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

using namespace std;

using ll = long  long;

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

    ll n;

    cin >> n;

    vector<ll> a(n);

    for(ll i=0; i<n-1; i++){
        ll a_i;
        cin >> a_i;
        a[a_i-1]++;
    }
    for(ll i=0; i<n; i++){
        cout << a[i] << endl;
    }

    return 0;
}

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

struct abcd
{
    int a;
    int b;
    int c;
    int d;
};

bool match(const std::vector<int>& A, const abcd& d)
{
    return (A[d.b] - A[d.a] == d.c);
}

void setA(std::vector<int>& A, int n, int N, int M, int& result, const std::vector<abcd>& d)
{
    // A[n]を設定
    for (int j = A[n - 1]; j <= M; ++j)
    {
        A[n] = j;

        // 終端判定
        if (n == N)
        {
            // for (int i = 1; i <= n; ++i)
            // {
            //     std::cerr << A[i] << " ";
            // }
            // std::cerr << std::endl;
            // 評価
            int sum = 0;
            for (const auto& cond : d)
            {
                if (match(A, cond))
                {
                    sum += cond.d;
                }
            }

            result = std::max(result, sum);
        }
        else
        {
            setA(A, n + 1, N, M, result, d);
        }
    }
}

int main()
{
    int N, M, Q;
    std::cin >> N >> M >> Q;

    std::vector<abcd> d(Q);
    for (int q = 0; q < Q; ++q)
    {
        std::cin >> d[q].a >> d[q].b >> d[q].c >> d[q].d;
    }

    int result = 0;

    std::vector<int> A(N + 1);
    A[0] = 1;

    setA(A, 1, N, M, result, d);

    std::cout << result << std::endl;
}


Measured memory_bytes: 3632
a, b, c, x, y = gets.chomp.split.map(&:to_i)
result = 0
if (a - c) + (b - c) > 0
  result += [x, y].min * c * 2
  if x > y
    result += a / 2 > c ? c * (x - y) * 2 : a * (x - y)
  elsif x < y
    result += b / 2 > c ? c * (y - x) * 2 : b * (y - x)
  end
else
  result += x * a + y * b
end
puts result


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  vector<vector<int>> to(N);
  rep(i, N) rep(j, N) {
    char c;
    cin >> c;
    if (c == '1')
      to[i].push_back(j);
  }
  int ans = 0;
  rep(i, N) {
    queue<int> que;
    vector<int> memo(N, -1);
    memo[i] = 1;
    que.push(i);
    while (!que.empty()) {
      int now = que.front();
      que.pop();
      rep(j, to[now].size()) {
        int next = to[now][j];
        if (memo[next] == -1) {
          memo[next] = memo[now]+1;
          que.push(next);
        } else {
          if (memo[next] == memo[now]) {
            cout << -1 << endl;
            return 0;
          }
        }
      }
    }
    rep(i, N)
      chmax(ans, memo[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,a,b,c,dp[394],ch[393],A[393];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c;
        a--,b--;
        for(int i=a;i<=b;i++){
            ch[i]=max(ch[i],c);
        }
    }
    for(int i=0;i<393;i++){
        for(int j=393;j>=0;j--){
            for(int k=1;k<=393;k++){
                if(j==0||dp[j]>0){
                    if(j+k*(i+1)<=393){
                        dp[j+k*(i+1)]=max(dp[j+k*(i+1)],dp[j]+ch[i]*k);
                    }
                    else break;
                }
            }
        }
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>a;
        if(dp[a]==0){
            cout<<-1<<endl;
            return 0;
        }
        A[i]=dp[a];
    }
    for(int i=0;i<m;i++){
        cout<<A[i]<<endl;
    }
    //for(int i=0;i<15;i++)cout<<dp[i]<<endl;
}



Measured memory_bytes: 3108
n=int(input())
a=list(map(int,input().split()))
flag=1
ans=0
while flag:
  flag=0
  for i in reversed(range(1,n)):
    if a[i]<a[i-1]:
      a[i],a[i-1]=a[i-1],a[i]
      flag=1
      ans+=1
print(*a)
print(ans)


Measured memory_bytes: 5608
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n)cin>>a[i];
    map<int,int> map_;
    REP(i,n)map_[a[i]]++;

    int j=0;
    for(auto m:map_)if(m.second>=2)j+=m.second-1;

    int minus = (j+1)/2;
    int ans=n-minus*2;

    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 5376
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a[51];
int main()
{
	int n;
	scanf("%d", &n);
	int ma = -1234567890;
	int mi = 1234567890;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		ma = max(ma, a[i]);
		mi = min(mi, a[i]);
	}
	printf("%d\n", 2 * n - 1);
	if (abs(ma) > abs(mi))
	{
		int ch = 0;
		for (int i = 0; i < n; i++)
		{
			if (ma == a[i])
				ch = i;
		}
		for (int i = 0; i < n; i++)
		{
			printf("%d %d\n", ch + 1, i + 1);
		}
		for (int i = 0; i < n-1; i++)
		{
			printf("%d %d\n", i+1, i + 2);
		}
	}
	else
	{
		int ch =0;
		for (int i = 0; i < n; i++)
		{
			if (mi == a[i])
				ch = i;
		}
		for (int i = 0; i < n; i++)
		{
			printf("%d %d\n", ch + 1, i + 1);
		}
		for (int i=n - 1; i >= 1; i--)
		{
			printf("%d %d\n", i+1, i);
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int p = -1;
    int r = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if (a == p) {
            r++;
            p = -1;
        } else {
            p = a;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, K, Q int
	fmt.Scan(&N, &K, &Q)
	A := make(map[int]int)
	var a int
	for i := 0; i < Q; i++ {
		fmt.Scan(&a)
		A[a-1]++
	}

	for i := 0; i < N; i++ {
		v := K - Q + A[i]
		ans := "No"
		if v > 0 {
			ans = "Yes"
		}
		fmt.Println(ans)
	}
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    vector<int> a(m), b(m), c(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--;
    }

    int q;
    cin >> q;
    vector<int> s(q), t(q);
    for (int i = 0; i < q; ++i) {
        cin >> s[i] >> t[i];
        s[i]--; t[i]--;
    }

    ll d[310][310];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            d[i][j] = LINF;
        }
    }
    for (int i = 0; i < m; ++i) {
        d[a[i]][b[i]] = c[i];
        d[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                chmin(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int res[310][310];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (d[i][j] <= l) res[i][j] = 1;
            else res[i][j] = INF;
        }
    }
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                chmin(res[i][j], res[i][k] + res[k][j]);
            }
        }
    }

    for (int i = 0; i < q; ++i) {
        cout << (res[s[i]][t[i]] == INF ? -1 : res[s[i]][t[i]] - 1) << endl;
    }
}

Measured memory_bytes: 5572
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 3009
using namespace std;

int n,m,a[N],f[N][N];
int main(){
	scanf("%d%d",&n,&m);
	int i,j,x,y,tmp;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (i=1; i<=n; i++)
		for (j=1; j<=n; j++) f[i][j]=(a[i]<a[j]);
	int t=1;
	while (m--){
		t=t*2%mod;
		scanf("%d%d",&x,&y);
		for (i=1; i<=n; i++) if (i!=x && i!=y){
			tmp=(f[x][i]+f[y][i])%mod; tmp=(tmp&1)?(tmp+mod>>1):tmp>>1;
			f[x][i]=f[y][i]=tmp%mod;
			tmp=(f[i][x]+f[i][y])%mod; tmp=(tmp&1)?(tmp+mod>>1):tmp>>1;
			f[i][x]=f[i][y]=tmp%mod;
		}
		tmp=(f[x][y]+f[y][x])%mod; tmp=(tmp&1)?(tmp+mod>>1):tmp>>1;
		f[x][y]=f[y][x]=tmp%mod;
	}
	int ans=0;
	for (i=1; i<=n; i++)
		for (j=1; j<i; j++) ans=(ans+f[i][j])%mod;
	printf("%lld\n",(ll)ans*t%mod);
	return 0;
}


Measured memory_bytes: 35584
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >>= print . sum . zipWith f "CODEFESTIVAL2016"

f a b = which 0 1 $ a == b


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long



int32_t main() {

    string s; cin >> s;
    int n = s.length();
    
    vector<char> c = {'A', 'C', 'G', 'T'};

    int ans = 0, cur = 0;
    for(int i = 0; i < n; ++i) {
        if(find(c.begin(), c.end(), s[i]) != c.end()) {
            ++cur;
        } else {
            cur = 0;
        }
        ans = max(ans, cur);
    }

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


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

int main() {
   long long n, a, b, ans;
   cin >> n >> a >> b;
   if(n%(a+b)<=a) ans=a*(n/(a+b))+n%(a+b);
   else ans=a*(n/(a+b))+a;
   cout << ans;
    
}

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

using namespace std;

int main(void){
  int n,k;
  cin>>n>>k;
  int num=1;
  for(int i=0;i<n;i++){
    num=min(num*2,num+k);
  }
  cout<<num<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
ll n,ans=0,r=1;
ll cur=0;
ll a[200005];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;++i) cin>>a[i];
    for (int l=1;l<=n;++l){
    	while(r<=n&&!(cur&a[r])) cur|=a[r++];
    	ans+=r-l;
    	cur-=cur&a[l];
	}
	cout<<ans;
    return 0; 
}

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

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

	long long int whole = 0; //バームクーヘンの大きさ
	int* A = new int[N];
	for (int i = 0; i < N; i++){
		cin >> A[i];
		whole += (long long int)A[i];
	}

	long long int one_third = whole / 3;

	int i = 0;
	long long int piece1 = 0;
	while (piece1 + (long long int)A[i] <= one_third){
		piece1 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
	}
	
	int piece2_i = i;
	long long int piece2 = 0;
	while (1){
		piece2 += (long long int)A[i];
		i++;
		if (i == N) i -= N; //周期的境界条件
		if (piece2 >= piece1) break;
	}
	
	int piece3_i = i;
	long long int piece3 = whole - piece1 - piece2;
	long long int ans = min(piece1, piece3);

	for (int i = 1; i < N; i++){
		if (piece1 == 0){
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
		}
		else piece1 -= (long long int)A[i-1];

		while (piece1 + (long long int)A[piece2_i] <= one_third){
			piece1 += (long long int)A[piece2_i];
			piece2 -= (long long int)A[piece2_i];
			piece2_i++;
			if (piece2_i == N) piece2_i -= N; //周期的境界条件
		}

		while (piece2 < piece1){
			piece2 += (long long int)A[piece3_i];
			piece3_i++;
			if (piece3_i == N) piece3_i -= N; //周期的境界条件
		}

		piece3 = whole - piece1 - piece2;
		ans = max(ans, min(piece1, piece3));
	}

	cout << ans << endl;

	delete[] A;
	return 0;
}

Measured memory_bytes: 1536
// finish date: 2018/04/09

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int A, B, K;
    cin >> A >> B >> K;
    map<int, int> mp;
    rep(i, K) {
        if (A + i <= B) cout << A + i << endl;
        mp[A + i] = 1;
    }
    for (int i = K - 1; i >= 0; i--) {
        if (A <= B - i && mp[B - i] == 0) cout << B - i << endl;
    }

    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::min;

int
main()
{
  long N, A, B;
  cin >> N >> A >> B;
  cout << (A * (N / (A + B)) + min(A, N % (A + B))) << endl;
  return 0;
}


Measured memory_bytes: 256