akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
   
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d,n; cin >> d >> n;
   
    ll count = 0;
    ll ans = 0;
    int d1=pow(100,d);
    int d2=pow(100,(d+1));
    for(ll i = 0; i<10000000; i++){
        if(i%d1==0 && i%d2!=0) count++;
        if(count==n) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    score=C
    for j in range(M):
        score+=A[j]*B[j]
    if score>0:
        count+=1
print(count)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> c(9, 0);
  rep(i, n){
    int a;
    cin >> a;
    a /= 400;
    if(a > 8) a = 8;
    c.at(a)++;
    // cerr << a << endl;
  }
  int mn = 0, mx = 0;
  rep(i, 8){
    if(c.at(i) > 0){
      mn++; mx++;
    }
  }
  if(c.at(8) > 0){
    if(mn == 0) mn++;
    mx += c.at(8);
  }
  cout << mn << " " << mx << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;

	scanf("%d", &a); scanf("%d", &b);
	if (a > b) {
		printf("a > b\n");
	}
	else if (a < b) {
		printf("a < b\n");
	}
	else {
		printf("a == b\n");
	}
}




Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
cout << fixed << setprecision(10);
string s;
cin>>s;
ll ca=0;
for(ll i=0; i<3; i++){
if(s.at(i)=='1'){
ca++;}}
cout<<ca<<endl;}

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

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int num = a*100 + b*10 + c;
	if (num % 4 == 0) 
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

Measured memory_bytes: 256
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

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


int main()
{
  int n;
  cin >> n;
  vector<int> v;
  int tmp;
  for (int i = 0; i < n; i++)
  {
    cin >> tmp;
    v.push_back(tmp);
  }
  int res = 0;

  while (true)
  {
    // cout << res << endl;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
      if (v[i] % 2 == 0)
      {
        count++;
      }
    }
    if (count == n)
    {
      for (int i = 0; i < n; i++)
      {
        v[i] /= 2;
        // cout << v[i] << endl;
      }
    }
    if (count != n)
    {
      cout << res << endl;
      return 0;
    }
    res++;
  }
}


Measured memory_bytes: 256
def solve():
    N, X, M = map(int,input().split())
    past_a = {X}
    A = [X]
    ans = prev = X
    for i in range(1, min(M,N)):
        next_a = prev ** 2 % M
        if next_a in past_a:
            loop_start = A.index(next_a)
            loop_end = i
            loop_size = loop_end - loop_start
            loop_elem = A[loop_start:loop_end]

            rest_n = N-i
            ans += rest_n // loop_size * sum(loop_elem)
            ans += sum(loop_elem[:rest_n%loop_size])
            break

        ans += next_a
        past_a.add(next_a)
        A.append(next_a)
        prev = next_a
    
    print(ans)
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 76864
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++)
	{
	    cout<<s[i]<<t[i];
	}
    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;
//using P = pair<int, int>;

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  rep(i,n) p[i] -= x;

  int ans = x;
  int diff = 0;
  while (1) {
    bool fP = true, fM = true;
    rep(i,n) {
      if (p[i] == diff) fP = false;
      if (p[i] == -diff) fM = false;
    }
    if (fM) {
      ans -= diff;
      break;
    }
    else if (fP) {
      ans += diff;
      break;
    } else diff++;
  }
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a;
  for(int i=0;i<N;i++){
    cin >> a;
    if(a%2==0){
      if(a%3!=0 && a%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
long long n;
string s;
string t;
long long ans;
string Ans;
void solve(){
    Ans = "";
    for(int i = 0; i < n; i++){
        Ans = Ans + s.at(i) + t.at(i);
    }
    cout << Ans << endl;
}

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


    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,M;
        cin>>N>>M;
        set<ll> s;
        for(ll i=0;i<M;i++){
            ll a;
            cin>>a;
            s.insert(a);
        }
        ll ans=0;
        for(ll i=0;i<=500;i++){
            if(s.find(i)==s.end()&&abs(ans-N)>abs(i-N)){
                ans=i;
            }
        }
        cout<<ans<<endl;
    }
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int k=a,ans=1;
    if(b==1)cout<<0;
  else if(a>=b) cout<<1;
  
   else{
     while(true){
       k+=(a-1);
       ans++;
       if(k>=b){
         
         cout<<ans;
         return 0;
       }
     }
   }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int r, d, x;
	int i, out;
	cin >> r >> d >> x;
	for (i = 0; i < 10; i++) {
		out = r * x - d;
		cout << out << endl;
		x = out;
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    w, h, n = map(int, input().split())
    a = [0, 0]
    b = [w, h]
    for _ in range(n):
        x, y, t = map(int, input().split())
        if t == 1:
            a[0] = max(a[0], x)
        elif t == 2:
            b[0] = min(b[0], x)
        elif t == 3:
            a[1] = max(a[1], y)
        else:
            b[1] = min(b[1], y)
    print(max(b[0] - a[0], 0) * max(b[1] - a[1], 0))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
static inline int Max(int x,int y){return x>y?x:y;}
static inline int Min(int x,int y){return x<y?x:y;}
const int SUM=0,DIFF=1;
int main(void)
{
  int N=IN(),mn[3][2],mx[3][2];mn[0][SUM]=mn[0][DIFF]=2e9;mx[0][SUM]=mx[0][DIFF]=-2e9;
  while(N--)
  {
    int x=IN(),y=IN();
    mn[0][SUM]=Min(x+y,mn[0][SUM]);if(mn[0][SUM]==x+y){mn[1][SUM]=x,mn[2][SUM]=y;}
    mx[0][SUM]=Max(x+y,mx[0][SUM]);if(mx[0][SUM]==x+y){mx[1][SUM]=x,mx[2][SUM]=y;}
    mn[0][DIFF]=Min(x-y,mn[0][DIFF]);if(mn[0][DIFF]==x-y){mn[1][DIFF]=x,mn[2][DIFF]=y;}
    mx[0][DIFF]=Max(x-y,mx[0][DIFF]);if(mx[0][DIFF]==x-y){mx[1][DIFF]=x,mx[2][DIFF]=y;}
  }
  return OUT(Max(mx[0][SUM]-mn[0][SUM],mx[0][DIFF]-mn[0][DIFF])),0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,h,w;cin>>n>>h>>w;
  int ans=0;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    if(a>=h&&b>=w)ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var n = firstLine[0];
			var m = firstLine[1];

			var lights = new List<List<int>>();

			for(var i = 0; i < m; i++)
			{
				var light = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
				light.RemoveAt(0);
				lights.Add(light);
			}

			var mods = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var answer = 0;

			for(var bit = 0; bit < (1 << n); bit++)
			{
				var isOn = true;
				for(var i = 0; i < m; i++)
				{
					var light = lights[i];
					var count = 0;

					foreach(var s in light)
					{
						if(((bit >> (s - 1)) & 1) == 1)
						{
							count++;
						}
					}

					if(count % 2 != mods[i])
					{
						isOn = false;
						break;
					}
				}

				if(isOn)
				{
					answer++;
				}
			}

			Console.WriteLine(answer);
		}
	}
}


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

int main(){

    long long int k,a,b;
    cin >> k >> a >> b;
    long long int count=1;

    if(b-a<=2 || k-(a-1)<2){
        count+=k;
 //       cout << endl ;
    }
    else{
        if((k-(a-1))%2==1){
            count+=a;
            count+=(k-a)*(b-a)/2;
        }
        else{
            count+=a-1;
            count+=(k-(a-1))*(b-a)/2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define INF 2e9
#define IMAX 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long llong;

int main() // 140-B
{
	int N;
	cin >> N;
	int A[N] = {};
	int B[N] = {};
	int C[N-1] = {};

	int tmp;
	REP(idx, N) {
		cin >> tmp;
		A[idx] = tmp - 1;
	}
	REP(idx, N) {
		cin >> B[idx];
	}
	REP(idx, N-1) {
		cin >> C[idx];
	}

	int satis = 0;
	int prevI = 0;
	REP(idx, N) {
		// B加算
		satis += B[A[idx]];
		if (idx != 0) {
			if (A[idx] == prevI + 1) {
				// C加算
				satis += C[prevI];
			}
		}
		prevI = A[idx];
	}

	cout << satis << endl;

	return 0;
}


Measured memory_bytes: 256
require 'pp'

def gets; ARGF.gets; end

class Solver

  def main
    n, k, q = gets.chomp.split.map(&:to_i)

    ms = Array.new(n, 0)
    q.times do
      a = gets.chomp.to_i
      ms[a-1] += 1
    end

    # Q=10
    # K=8
    # 3回正解で勝ち抜け = 2回以下でアウト

    # Q=10
    # K=10
    # 1回正解で勝ち抜け = 0回以下でアウト
    #
    # Q=10
    # K=11
    # 0回正解でも勝ち抜け

    thresh = q - k
    ms.each do |p|
      if p <= thresh
        puts "No"
      else
        puts "Yes"
      end
    end
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

int main(){
  int H,W; cin >> H>> W;
  vector<vector<int>> a(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<vector<int>> path(H*W, vector<int>(4));
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j)%2 == 1){
        if (j != W-1){
          a.at(i).at(j) --;
          a.at(i).at(j+1) ++;
          path.at(ans) = {i+1, j+1, i+1, j+2};
          ans ++ ;
        } else if( j == W-1){
          if (i != H-1){
          a.at(i).at(j) --;
          a.at(i+1).at(j) ++;
          path.at(ans) = {i+1, j+1, i+2, j+1};
          ans ++;
          }
        }
      }
    }
  }
  cout << ans <<endl;
  for(int i=0; i < ans ; i++){
    for (int j=0; j < 4 ; j++){
    	cout << ( j ? " " : "" ) << path.at(i).at(j); 
    }
    cout << endl;
  }
  
}

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


int main() {
  int N;
  cin >> N;
  vector<int> R(9, 0);
  for (int i=0; i<N; ++i) {
    int rate;
    cin >> rate;
    if (3200 <= rate) {
      ++R[8];
      continue;
    }
    for (int j=0; j<8; ++j) {
      if (j * 400 <= rate && rate < (j + 1) * 400) {
        ++R[j];
        break;
      }
    }
  }
  
  int min_cnt = 0;
  int max_cnt = 0;
  int cnt = 0;
  for (int i=0; i<9; ++i) {
    if (0 < R[i]) {
      if (i == 8) {
        if (cnt == 0) {
          ++min_cnt;
        }
        max_cnt += R[i];
      } else {
        ++min_cnt;
        ++max_cnt;
        ++cnt;
      }
    }
  }
  cout << min_cnt << " " << max_cnt << endl;
}

Measured memory_bytes: 256
<?php

//文字列の入力
fscanf(STDIN,"%d",$n);
$d = explode(' ',fgets(STDIN));


$tako = 0;
for ($i= 0; $i<$n; $i++){
    for($e = $i+1; $e<$n; $e++){
        $tako += $d[$i]*$d[$e];
    }
}

echo $tako;

Measured memory_bytes: 3576
#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[i];
    }

    int count=0;
    for(int i=1;i<n-1;i++){
        if((a[i+1]-a[i])*(a[i]-a[i-1])>0){
            count++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	long long int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K % 2 == 0) {
		cout << A - B << endl;
	}
	else {
		cout << B - A << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (ll i(0), _##i(a); i < _##i; ++i)
#define FOR(i, a, b) for (ll i(a), _##i(b); i <= _##i; ++i)

#ifdef LOCAL
#define _NTH_ARG(_1, _2, _3, _4, _5, _6, N, ...) N
#define _FE_1(_CALL, x) _CALL(x)
#define _FE_2(_CALL, x, ...) _CALL(x) _FE_1(_CALL, __VA_ARGS__)
#define _FE_3(_CALL, x, ...) _CALL(x) _FE_2(_CALL, __VA_ARGS__)
#define _FE_4(_CALL, x, ...) _CALL(x) _FE_3(_CALL, __VA_ARGS__)
#define _FE_5(_CALL, x, ...) _CALL(x) _FE_4(_CALL, __VA_ARGS__)
#define _FE_6(_CALL, x, ...) _CALL(x) _FE_5(_CALL, __VA_ARGS__)
#define FOR_EACH_MACRO(MACRO, ...)                                             \
  _NTH_ARG(__VA_ARGS__, _FE_6, _FE_5, _FE_4, _FE_3, _FE_2, _FE_1)              \
  (MACRO, __VA_ARGS__)
#define watch(x) cerr << "\033[1;32m" #x " = \033[1;34m" << (x) << "\033[0m; ";
#define debug(...)                                                             \
  cerr << "\033[2;31mLine " << __LINE__ << ": \033[0;m";                       \
  FOR_EACH_MACRO(watch, __VA_ARGS__)                                           \
  cerr << endl
#else
#define debug(...)
#endif

using namespace std;

template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << '{' << p.first << ", " << p.second << '}';
}

template <class T, class = decltype(begin(declval<T>())),
          class = enable_if_t<!is_same<T, string>::value>>
ostream &operator<<(ostream &os, const T &c) {
  os << '[';
  for (auto it = begin(c); it != end(c); ++it)
    os << (it == begin(c) ? "" : ", ") << *it;
  return os << ']';
}
using ll = long long;

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int &x : a) cin >> x;
  const int INF = 1 << 30;
  vector<int> ans(n, INF);
  ans[0] = 0;
  for(int i = 1; i < n; ++i){
    if (i - 1 >= 0) ans[i] = min(ans[i], ans[i - 1] + abs(a[i] - a[i - 1]));
    if (i - 2 >= 0) ans[i] = min(ans[i], ans[i - 2] + abs(a[i] - a[i - 2]));
  }
  debug(ans);
  cout << ans[n - 1] << "\n";
}

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

  int T = 1;
  // cin >> T;
  while (T--) {
    solve();
  }
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    if N % 1000 == 0:
        print(0)
    else:
        print(1000 - (N % 1000))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9068
#include <cstdio>
using namespace std;
int N, M;
int main() {
  scanf("%d %d", &N, &M);
  int ans = M;
  for(int i = 1; i*i <= M; ++i) {
    if(M%i != 0) continue;
    if(i >= N) {
      ans = M/i;
      break;
    } else if(M/i >= N) {
      ans = i;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 128
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

class Node(val data:Int) {
  var prev:Node = null
  var next:Node = null
}

class DList {
  var first = new Node(-1)
  var last = new Node(-1)
  first.next = last
  first.next.prev = first

  def insert(data:Int) = {
    var newNode = new Node(data)
    newNode.next = first.next
    if(first.next!=null) first.next.prev = newNode
    first.next = newNode
    newNode.prev = first
  }

  def search(data:Int) = {
    var node = first.next
    while(node != last && node.data != data) {
      node = node.next
    }
    node
  }

  def delete(node:Node):Unit = {
    if(node!=last) {
      node.prev.next = node.next
      node.next.prev = node.prev
    }
  }

  def delete(data:Int):Unit = delete(search(data))
  def deleteFirst() = delete(first.next)
  def deleteLast() = delete(last.prev)

  def print() = {
    val b = new ArrayBuffer[Int]
    var node = first.next
    while(node != last) {
      b += node.data
      node = node.next
    }
    println(b.toArray.mkString(" "))
  }
}

object Main {
  def main(args:Array[String]) = {
    val dlist = new DList()
    val n = readInt
    for(i<-1 to n) {
      val s = readLine.split(" ")
      if(s(0)=="insert") dlist.insert(s(1).toInt)
      else if(s(0)=="delete") dlist.delete(s(1).toInt)
      else if(s(0)=="deleteFirst") dlist.deleteFirst
      else if(s(0)=="deleteLast") dlist.deleteLast
    }
    dlist.print()
  }
}

Measured memory_bytes: 459016
s_arr = gets.chomp.to_s.split('')
arr = ['A', 'C', 'G', 'T']

results = []
counter, max = [0, 0]

s_arr.each do |value|
  if arr.include?(value)
    counter += 1
    max = counter if counter > max
  else
    counter = 0
  end
end

print max


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin >> N;
  vector<long long> v(N);
  for(long long &x: v) cin >> x;
  long long count = 0;
  long long mi = (N + 1);
  for (auto itr=v.begin(); itr != v.end(); ++itr){
    mi = min(mi, *itr);
    count += (mi == *itr);
  }
  cout << count << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
typedef pair<ll, ll> pll;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, z, w;
	cin >>n >>z >>w;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	vector<VI> mem(n+2, VI(2, -1)); 
	
	auto f=[&](auto f, int xs, int ys, int si, int gk)->int{
		if(mem[si][gk] != -1) return mem[si][gk];
		if(si == n) return abs(xs - ys);
		int rtn =0;
		if(gk ==0){
			rtn = 0;
			rep2(i, si, n){
				rtn = max(rtn, f(f, a[i], ys, i+1, 1));
			}
		}else{
			rtn = MD;
			rep2(i, si, n){
				rtn = min(rtn, f(f, xs, a[i], i+1, 0));
			}
		}
		return mem[si][gk] = rtn;
	};

	cout <<f(f,z,w,0,0) <<"\n";
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>

typedef struct {
	int sx,sy,dx,dy;
	char linkto[24];
} button_t;

typedef struct {
	char name[24];
	int button_num;
	button_t buttons[100];
} page_t;

int page_num;
page_t pages[100];

int w,h;

int buffer_num;
int buffer_pos;
int buffer[10000];

int main(void) {
	int i,j,k;
	int sousa_num;
	char command[8];
	int x,y;
	while(1) {
		scanf("%d",&page_num);
		if(page_num==0)break;
		scanf("%d%d",&w,&h);
		for(i=0;i<page_num;i++) {
			scanf("%s%d",pages[i].name,&pages[i].button_num);
			for(j=0;j<pages[i].button_num;j++) {
				scanf("%d%d%d%d%s",
					&pages[i].buttons[j].sx,
					&pages[i].buttons[j].sy,
					&pages[i].buttons[j].dx,
					&pages[i].buttons[j].dy,
					pages[i].buttons[j].linkto);
			}
		}
		buffer_num=1;
		buffer_pos=0;
		buffer[0]=0;
		scanf("%d",&sousa_num);
		for(i=0;i<sousa_num;i++) {
			scanf("%s",command);
			switch(command[0]) {
				case 'c':
					scanf("%d%d",&x,&y);
					for(j=0;j<pages[buffer[buffer_pos]].button_num;j++) {
						if(pages[buffer[buffer_pos]].buttons[j].sx<=x && 
							pages[buffer[buffer_pos]].buttons[j].dx>=x && 
							pages[buffer[buffer_pos]].buttons[j].sy<=y && 
							pages[buffer[buffer_pos]].buttons[j].dy>=y)break;
					}
					if(j<pages[buffer[buffer_pos]].button_num) {
						for(k=0;k<page_num;k++) {
							if(strcmp(pages[buffer[buffer_pos]].buttons[j].linkto,
								pages[k].name)==0)break;
						}
						buffer_pos++;
						buffer_num=buffer_pos+1;
						buffer[buffer_pos]=k;
					}
					break;
				case 'b':
					if(buffer_pos>0)buffer_pos--;
					break;
				case 'f':
					if(buffer_pos+1<buffer_num)buffer_pos++;
					break;
				case 's':
					puts(pages[buffer[buffer_pos]].name);
					break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  // 入力
  ll D;
  cin >> D;
  vll C(26);
  rep(i, 26) cin >> C[i];
  vvll S(D, vll(26));
  rep(i, D) rep(j, 26) cin >> S[i][j];

  vll T(D);  // その日に行うコンテスト
  rep(i, D) {
    T[i] = i % 26 + 1;
  }

  auto calc = [&]() -> ll {
    vll la(26, 0);
    ll res = 0;
    rep(i, D + 1) {
      if (i == 0) continue;
      ll t = T[i - 1];
      res += S[i - 1][t];
      la[t] = i;
      rep(j, 26) {
        res -= C[j] * (i - la[j]);
      }
    }
    return res;
  };

  rep(i, 100) {
    ll original = calc();
    ll index = rand() % D;
    ll before_contest = T[index];
    ll after_contest = rand() % 26 + 1;
    T[index] = after_contest;
    ll after = calc();
    if (original < after) {
      continue;
    } else {
      T[index] = before_contest;
    }
  }

  rep(i, D) {
    COUT(T[i]);
  }

  return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <climits>
#include <array>
using namespace std;
static const int maxv = 100;
static const int maxe = 1000;
struct edge{
  int cap,to,rev;
};

vector<edge> g[maxv];
array<bool,maxv> used;

int dfs(int f,int v,int t){
  if(v == t) return f;
  used[v] = true;
  for(auto &e:g[v]){
    if(e.cap <= 0) continue;
    if(used[e.to]) continue;
    int d = dfs(min(f,e.cap),e.to,t);
    if (d > 0){
      e.cap -= d;
      g[e.to][e.rev].cap += d;
      return d;
    }
  }
  return 0;
}

int max_flow(int s,int d){
  int f = 0;
  const int inf = INT_MAX / 3;
  while(true){
    fill(used.begin(), used.end(), false);
    int df = dfs(inf,s,d);
    if(df == 0) break;
    f += df;
  }
  return f;
}

int main(){
  int v,e;
  cin >> v >> e;
  for(int i = 0;i < e;i++){
    int u,v,c;
    cin >> u >> v >> c;
    
    g[u].push_back({c, v, (int)g[v].size()});
    g[v].push_back({0, u, (int)g[u].size() - 1});
  }
  cout << max_flow(0, v-1) << endl; 
}

Measured memory_bytes: 3184
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
ll mx=a[0];
rep(i,n-1){
  ans+=max(0LL,mx-a[i+1]);
  mx=max(mx,a[i+1]);
}

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

Measured memory_bytes: 4760
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 100008

int parent[N];
int root(int x) {
  if(x == parent[x]) {
    return x;
  }
  return parent[x] = root(parent[x]);
}

bool unite(int x, int y) {
  int px = root(x), py = root(y);
  if(px == py) return false;

  if(px < py) {
    parent[py] = px;
  } else {
    parent[px] = py;
  }
  return true;
}

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

  rep(i, n) parent[i] = i;

  rep(i, q) {
    int com, x, y;
    cin >> com >> x >> y;

    if(com == 0) {
      unite(x, y);
    } else {
      cout << "01"[root(x) == root(y)] << endl;
    }
  }
  return 0;
}


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

int main(){
    unsigned long long int n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) cin >> a[i];

    vector<vector<int>> memo(64, vector<int>(n+1, 0));

    for(int i = 1; i <= n; i++){
        memo[0][i] = a[i];
    }

    for(int i = 1; i < 64; i++){
        for(int j = 1; j <= n; j++){
            memo[i][j] = memo[i-1][memo[i-1][j]];
        }
    }

    int ans = 1;
    for(int i = 0; i < 64; i++){
        if(k & (1LL << i)){
            ans = memo[i][ans];
        }
    }

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

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

int main(){
  string S, result;
  cin >> S;
  
  result = "Good";
  
  for(int i = 0; i < S.size(); i++){
    if(i == S.size()-1)continue;
    if(S[i] == S[i+1])result = "Bad";
  }
  
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] b = new int[n-1];
      int[] a = new int[n];
      int sum = 0;
      for(int i = 0;i < n-1;i++)b[i]=sc.nextInt();
      a[0]=b[0];
      a[n-1]=b[n-2];
      sum += a[0]+a[n-1];
      for(int i = 1;i < n-1;i++){
      	a[i] = Math.min(b[i],b[i-1]);
        sum += a[i];
      }
      System.out.println(sum);
    }
    public static int lcm(int x, int y){
      return x*y/gcd(x,y);
    }
    public static int gcd(int x, int y){
      if(x < y)return gcd(y,x);
      if(y==0)return x;
      return gcd(y,x%y);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

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

    vector<int> point;
    for(int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        point.push_back(temp);
    }
    sort(point.begin(), point.end());

    cout << point[N-1] - point[0] << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
pl, sl = [], []

for i in range(m):
    p, s = map(str, input().split())
    pl.append(int(p))
    sl.append(s)

ac_F = [False] * (n + 1)
acc = 0
pena = [0] * (n+1)

for i in range(m):
    if sl[i] == "AC":
        if not ac_F[pl[i]]:
            acc += 1
            ac_F[pl[i]] = True
    else:
        if not ac_F[pl[i]]:
            pena[pl[i]] += 1

penac = 0
for i in range(n+1):
    if ac_F[i]:
        penac += pena[i]

print(acc, penac)


Measured memory_bytes: 15008
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner sc = new Scanner(System.in);
    int a,b,c,d,e,f;
    double x,y;
    while(sc.hasNext()){
      a = sc.nextInt();
      b = sc.nextInt();
      c = sc.nextInt();
      d = sc.nextInt();
      e = sc.nextInt();
      f = sc.nextInt();
      x = 0;
      y = 0;
      try{
        y = (double) (c * d - a * f) / (b * d - a * e);
        x = (double) (c - b * y) / a;
      }catch(Exception ex){
        System.err.println(ex.getMessage());
      }
      System.out.printf("%.3f %.3f\n", x, y);
    }
  }
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	long long cnt=0;

	for(long long i=0;i<n;i++){
		long long a,b;
		cin>>a>>b;
		if(a==b) cnt++;
		else cnt=0;
		if(cnt==3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3628
#include<cstdio>
using namespace std;
int main(){
  char str[3];
  bool used[26] = {};
  printf("?a\n"); fflush(stdout);
  while(true){
    scanf("%s", str);
    if(str[1] == '\0' || str[0] != 'a' || used[str[1] - 'a']++){
      printf("!OUT\n");
      break;
    }
    printf("?%cjavajavaa\n",str[1]);
    fflush(stdout);
  }
}

Measured memory_bytes: 1256
m,d = map(int, input().split())

dates = [i for i in range(1, d+1) if i>=22 and i%10>1]

count=0
for date in dates:
  d1,d2 = str(date)
  d1 = int(d1)
  d2 = int(d2)
  if d1*d2<=m:
    count+=1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

bool dp[100100]={};
ll a[100100];

int main(void){
    ll n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-a[j]>=0){
                if(!dp[i-a[j]]) dp[i]=true;
            }
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    
    string s,t,u;
    cin >> s >> t;
    auto n = s.length();
    auto m = t.length();
    int ans = 1001;
    int cnt;
    rep(i,n-m+1){
        cnt = 0;
        rep(j,m){
           if(t[j]!=s[j+i]){
               cnt++;
           } 
        }
        ans = min(ans,cnt);
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 3664
import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()
D.append(0)
A = []
cur = D[0]
cnt = 0
for i in range(N+1):
  if cur == D[i]:
    cnt += 1
  else:
    A.append([cur,cnt])
    cur = D[i]
    cnt = 1
M = int(input())
T = list(map(int,input().split()))
T.sort()
T.append(0)
B = []
cur = T[0]
cnt = 0
for i in range(M+1):
  if cur == T[i]:
    cnt += 1
  else:
    B.append([cur,cnt])
    cur = T[i]
    cnt = 1
flag = True
for j in range(len(B)):
  k = bisect.bisect_left(A,B[j])
  if A[k][0] == B[j][0]:
    if A[k][1] >= B[j][1]:
      None
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 125264
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        //リュカ数を求める
        long L[] = new long[N+1];
        for (int i = 0; i <= N; i++) {
            if (i == 0) {
                L[i] = 2;
            } else if (i == 1) {
                L[i] = 1;
            } else {
                L[i] = L[i-1] + L[i-2];
            }
            //System.out.println("L[" + i + "]：" + L[i]);
        }

        //System.out.println(N + "番目のリュカ数：" + L[N]);
        System.out.println(L[N]);
    }

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 0;
const int mod = 0;

int main(){
	int n;
	scanf("%d", &n);
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		if(x == y) cnt++;
		else cnt = 0;
		if(cnt == 3) return !printf("Yes");
	}
	printf("No");


}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
const double eps = 1e-8;
const int MOD = 1000000007;
//int main() {
//    cin.tie(0);
//    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(10);
//
//}
template<typename T>
struct edge {
    int src, to;
    T cost;
    // edge(int src, int to, T cost): src(src), to(to), cost(cost) {}
    // // G[i].push_back({src, to, cost}) requires no constructor
};
template<typename T>
using Graph = vector<vector<edge<T>>>;
struct HopcroftKarp {
    vector<vector<int>> g;
    vector<int> d, mch;
    vector<bool> used, vv;
    HopcroftKarp(int n, int m) : g(n), mch(m, -1), used(n) {}
    void add_edge(int u, int v) {
        g[u].push_back(v);
    }
    void bfs() {
        d.assign(g.size(), -1);
        queue<int> que;
        for (int i = 0; i < g.size(); i++) {
            if (!used[i]) {
                que.emplace(i);
                d[i] = 0;
            }
        }
        while (!que.empty()) {
            int a = que.front();
            que.pop();
            for (auto &b : g[a]) {
                int c = mch[b];
                if (c >= 0 && d[c] == -1) {
                    d[c] = d[a] + 1;
                    que.emplace(c);
                }
            }
        }
    }
    bool dfs(int a) {
        vv[a] = true;
        for (auto &b : g[a]) {
            int c = mch[b];
            if (c < 0 || (!vv[c] && d[c] == d[a] + 1 && dfs(c))) {
                mch[b] = a;
                used[a] = true;
                return (true);
            }
        }
        return (false);
    }
    int bipartite_matching() {
        int ret = 0;
        while (true) {
            bfs();
            vv.assign(g.size(), false);
            int flow = 0;
            for (int i = 0; i < g.size(); i++) {
                if (!used[i] && dfs(i)) ++flow;
            }
            if (flow == 0) return ret;
            ret += flow;
        }
    }
};
int main() {
    int X, Y, E;
    cin >> X >> Y >> E;
    HopcroftKarp bm(X, Y);
    for(int i = 0; i < E; i++) {
        int a, b;
        cin >> a >> b;
        bm.add_edge(a, b);
    }
    cout << bm.bipartite_matching() << endl;
}



Measured memory_bytes: 3232
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        int count=0;
        for(int s=0;s<N-1;s++){
            for(int j=N-1;j>s;j--){
                if(A[j]<A[j-1]){
                    int x = A[j];
                    A[j]=A[j-1];
                    A[j-1]=x;
                    count++;
                }
            }
        }
        for(int k=0;k<N;k++){
            if(k==N-1){
                System.out.printf("%d",A[k]);
            }else{
                System.out.printf("%d ",A[k]);
            }
        }
        System.out.printf("\n");
        System.out.println(count);
        }
    }



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

int main() {
  vector<int> a(5);
  rep(i,5) cin >> a[i];
  int k; cin >> k;
  bool ans = true;
  rep(i,5) rep(j,5) {
    if (abs(a[i] - a[j]) > k) ans = false; 
    break;
  }
  cout << ((ans) ? "Yay!" : ":(") << endl;
}

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

using namespace std;

int n;
char s[maxn];

int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int ans = 0;
	for(int i = 1;i <= n;i++) ans += s[i] != s[i - 1];
	printf("%d", ans - 1);
}

Measured memory_bytes: 3852
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double INF = DBL_MAX / 1000;

int main()
{
    for(int d=1; ; ++d){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<double> x(2*n), y(2*n);
        for(int i=0; i<2*n; ++i)
            cin >> x[i] >> y[i];

        vector<vector<double> > len(1<<n, vector<double>(2*n, INF));
        for(int i=0; i<2*n; ++i){
            bitset<14> bs = 1 << (i / 2);
            len[bs.to_ulong()][i] = 0.0;
        }

        for(int i=0; i<(1<<n); ++i){
            bitset<14> bs = i;
            for(int j=0; j<2*n; ++j){
                if(!bs[j/2])
                    continue;

                for(int k=0; k<2*n; ++k){
                    if(bs[k/2])
                        continue;

                    bs[k/2] = true;
                    len[bs.to_ulong()][k^1] = min(len[bs.to_ulong()][k^1], len[i][j] + sqrt(pow(x[j] - x[k], 2) + pow(y[j] - y[k], 2)));
                    bs[k/2] = false;
                }
            }
        }

        double ret = INF;
        for(int i=0; i<2*n; ++i)
            ret = min(ret, len[(1<<n)-1][i]);

        for(int i=0; i<n; ++i)
            ret += sqrt(pow(x[2*i] - x[2*i+1], 2) + pow(y[2*i] - y[2*i+1], 2));

        printf("Case %d: %.5f\n", d, ret);
    }
}

Measured memory_bytes: 5468
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sum=0;
    int star=0;
    int end=s.size()-1;
    while(star<end)
    {
        if(s[star]==s[end])
        {
            star++;
            end--;
        }
        else
            if(s[star]=='x')
            {
                sum++;
                star++;
            }
            else
                if(s[end]=='x')
                {
                    sum++;
                    end--;
                }
                else
                    break;
                
    }
    if(star>=end)
        printf("%d\n",sum);
    else
        printf("-1\n");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;

bool check(int n, int m, vector<pair<int, int>> v);

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

  vector<pair<int, int>> v(m, {0, 0});
  set<int> s;
  int k = 0;
  for (int i = 1; i <= m; i++) {
    while ((n - k - i) * 2 == n || s.count(abs(n - k - i) % n) != 0 ||
           s.count(abs(k + i) % n) != 0) {
      k++;
    }
    v.at(i - 1).first = i;
    v.at(i - 1).second = n - k;
    s.insert(abs(v.at(i - 1).second - v.at(i - 1).first) % n);
    k++;
  }

  for (auto p : v) {
    cout << p.first << " " << p.second << endl;
  }

  // bool result = check(n, m, v);
  // cout << boolalpha << result << endl;
  return 0;
}

bool check(int n, int m, vector<pair<int, int>> v) {
  bool result = true;
  set<pair<int, int>> p_visited;
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < m; i++) {
      auto& p = v.at(i);
      int d = p.first - p.second;
      cout << p.first-- << "," << p.second-- << "   : " << d << endl;
      if (p.first == 0) {
        p.first = n;
      }
      if (p.second == 0) {
        p.second = n;
      }
      pair<int, int> p_sorted = {min(p.first, p.second),
                                 max(p.first, p.second)};
      if (p_visited.count(p_sorted) == 0) {
        p_visited.insert(p_sorted);
      } else {
        cout << "pair (" << p_sorted.first << ", " << p_sorted.second
             << ") has already matched" << endl;
        result = false;
      }
    }
    cout << endl;
  }
  return result;
}


Measured memory_bytes: 8200