akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  vector<ll> A;
  REP(i,N){
    ll a;
    cin>>a;
    A.PB(a);
  }
  SORT(A);
  
  ll P[1000010];
  bool USE[1000010],CAN[1000010];
  REP(i,1000010){
    USE[i]=false;
    CAN[i]=true;
    P[i]=0;
  }
  
  REP(i,N){
    P[A[i]]++;
  }
  
  REP(i,N){
    if(USE[A[i]]){
      CAN[A[i]]=false;
      continue;
    }
    
    for(ll j=2; j<=1000010/A[i]; ++j){
      CAN[A[i]*j]=false;
    }
    
    USE[A[i]]=true;
  }
  
  RREP(i,1000010){
    if(P[i]==1 && CAN[i]==true) ans++;
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 14796
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) scanf("%d", &a[i]);
    int s = 0;
    REP(i,n) s += a[i] % 2;
    cout << (s % 2 == 0 ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 640
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		string s;
		cin >> s;
		// vector<vector<bool>> dp(n+1,vector<bool>(8,false));
		// vector<vector<int>> pre(n+1,vector<int>(8,-1));
		// REP(j,8) dp[0][j] = true;
		// REP(i,n){
		// 	REP(j,8){
		// 		bool b0 = j&1, b1 = (j>>1)&1, b3 = (j>>2)&1;
		// 		if((s[i] == 'o')^b1){
		// 			if(b0 == b3){
		// 				dp[i+1][j] = false;
		// 				continue;
		// 			}
		// 		}else{
		// 			if(b0 != b3){
		// 				dp[i+1][j] = false;
		// 				continue;
		// 			}
		// 		}
		// 		REP(ps,8) if((ps&3) == (j>>1)){
		// 			if(dp[i][ps]){
		// 				dp[i+1][j] = dp[i+1][j] or dp[i][ps];
		// 			}
		// 		}
		// 	}
		// }

		// REP(i,8) REP(j,8){

		// }
		string ans = "-1";
		REP(bi,4){
			vector<bool> v(n);
			bool b0 = bi&1;
			bool b1 = (bi>>1)&1;
			v[0] = b0;
			v[1] = b1;
			FOR(i,1,n-1){
				if((s[i] == 'o')^v[i]){
					v[i+1] = v[i-1];
				}else{
					v[i+1] = !v[i-1];
				}
			}
			if((s[0] == 'o')^v[0]){
				if(v[n-1] != v[1]){
					continue;
				}
			}else{
				if(v[n-1] == v[1]){
					continue;
				}
			}
			if((s[n-1] == 'o')^v[n-1]){
				if(v[n-2] != v[0]){
					continue;
				}
			}else{
				if(v[n-2] == v[0]){
					continue;
				}
			}
			ans = "";
			REP(i,n){
				if(v[i]){
					ans += 'W';
				}else{
					ans += 'S';
				}
			}
			break;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
int main()
{int n ,i,d;
string s;

    cin>>n;
      cin>>s;
    d=s.size();
 if(n>=d){
    for(i=0;i<s.size();i++){
        cout<<s[i];
    }
 }
    if(n<d){
        for(i=0;i<n;i++){
        cout<<s[i];
    }
      
    cout<<"."<<"."<<".";
    }
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a == b){
      System.out.println("Draw");
    }
    else if(a == 1){
      System.out.println("Alice");
    }
    else if(b == 1){
      System.out.println("Bob");
    }
    else if(a > b){
      System.out.println("Alice");
    }
    else if(a < b){
      System.out.println("Bob");
    }
  }
}


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

int main()
{
    string SA, SB, SC;
    cin >> SA >> SB >> SC;

    string S[3] = {SA, SB, SC};
    string ans[3] = {"A", "B", "C"};
    int idx = 0;
    while (true)
    {
        string current = S[idx];
        if (current.size() == 0)
        {
            cout << ans[idx] << endl;
            return 0;
        }
        S[idx] = current.substr(1);
        idx = current.front() - 'a';
    }
}


Measured memory_bytes: 256
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
per = list(permutations(range(1, n + 1)))
for i in range(len(per)):
    if per[i] == p:
        id_p = i
    if per[i] == q:
        id_q = i

print(abs(id_p - id_q))

Measured memory_bytes: 8052
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, H;
  cin >> N >> H;

  static int a[100010], b[100010];
  memset(a, 0, sizeof(a));
  memset(b, 0, sizeof(b));
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i];
  }

  int ma = 0;
  for (int i = 0; i < N; i++) {
    ma = max(ma, a[i]);
  }

  vector<int> v;
  for (int i = 0; i < N; i++) {
    if (b[i] > ma)
      v.push_back(b[i]);
  }

  sort(v.begin(), v.end(), greater<int>());

  int cont = 0;
  for (auto x : v) {
    H -= x;
    cont++;
    if (H <= 0) {
      cout << cont << endl;
      return 0;
    }
  }

  cont += (H + ma - 1) / ma;

  cout << cont << endl;
  return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, int> mp;
    ll ans = n;
    if(n%k == 0) {
        ans = 0;
    }
    else {
        ans = min(abs(n%k-k), ans);
    }
    
    cout << ans << endl;
    return 0;
}

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

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

   if (a == b) cout << c << endl;
   else if(b == c) cout << a << endl;
   else cout << b << endl;
}

Measured memory_bytes: 256
import numpy as np
from sys import argv
import time


def input_from_file():
    with open(argv[1], "r") as f:
        D = int(f.readline())
        C = np.array(f.readline().split(), dtype=int)
        S = tuple(tuple(map(int, f.readline().split())) for _ in range(D))
    return D, C, S


def input_from_console():
    D = int(input())
    C = np.array(input().split(), dtype=int)
    S = tuple(tuple(map(int, input().split())) for _ in range(D))
    return D, C, S


def greed(D, C, S):
    last = np.ones(26, dtype=int)
    ans = []
    for s in S:
        s = np.array(s)
        tmp = s + C * last
        i = np.argmax(tmp)
        last[i] = 0
        last += 1
        ans.append(i + 1)
    return ans


def calc_score(D, C, S, T):
    res = 0
    last = np.ones(26, dtype=int)
    for d, t in enumerate(T):
        t -= 1
        last[t] = 0
        score = S[d][t]
        score -= (C * last).sum()
        res += score
        last += 1
    return res


def output_to_file(ans):
    with open("output.txt", "w", newline="") as f:
        for a in ans:
            f.write("{}\n".format(a))


def main():
    start = time.time()
    lim = 1.800
    D, C, S = input_from_console()
    #D, C, S = input_from_file()
    #初期解, 貪欲法
    sol = greed(D, C, S)
    score = calc_score(D, C, S, sol)
    while True:
        d = np.random.randint(D//2, D)
        q = np.random.randint(1, 27)
        old = sol[d]
        sol[d] = q
        new_score = calc_score(D, C, S, sol)
        if new_score > score:
            score = new_score
        else:
            sol[d] = old
        if time.time() - start >= lim:
            break
    print(*sol, sep="\n")
    # output_to_file(sol)


if __name__ == "__main__":
    main()

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int h1, m1, h2, m2, k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h2 - h1;
    int b = m2 - m1;
    int c = a * 60;
    cout << b + c - k << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

int g[15][15];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g[i][j] = -1;
    }
  }

  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int a, x;
      cin >> a >> x;
      a--;
      g[i][a] = x;
    }
  }

  int ans = 0;
  for (int i = 0; i < (1<<n); i++) {
    vector<int> d(n);
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        d[j] = 1;
      }
    }

    bool ok = true;
    for (int j = 0; j < n; j++) {
      if (d[j]) {
        for(int k = 0; k < n; k++) {
          if (g[j][k] == -1) {
            continue;
          }

          if (g[j][k] != d[k]) {
            ok = false;
          }
        }
      }
    }

    if (ok) {
      ans = max(ans, __builtin_popcount(i));
    }
  }

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

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b-a<=k and c-a<=k and d-a<=k and e-a<=k and c-b<=k and d-b<=k and e-b<=k and d-c<=k and e-c<=k and e-d<=k:
  print('Yay!')
else:
  print(':(')


        


Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main(void){
    int a, b, c;
    std::cin >> a >> b >> c;
    if(a == 5 && b == 5 && c == 7) std::cout << "YES" << std::endl;
    else if(a == 5 && b == 7 && c == 5) std::cout << "YES" << std::endl;
    else if(a == 7 && b == 5 && c == 5) std::cout << "YES" << std::endl;
    else std::cout << "NO" << std::endl;

    return 0;
}

Measured memory_bytes: 3524
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int A = int.Parse(str[1]);
        int B = int.Parse(str[2]);
        int[,] C = new int[401,401];
        for(int i=0;i<401;i++){
            for(int j=0;j<401;j++){
                C[i,j] = 4000000;
            }
        }
        C[0,0] = 0;
        for(int i=0;i<N;i++){
            str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);
            for(int j=400;j>=a;j--){
                for(int k=400;k>=b;k--){
                    C[j,k] = Math.Min(C[j,k],C[j-a,k-b]+c);
                }
            }
        }
        int count = 4000001;
        {
            int i = 1;
            while(A*i <= 400 && B*i <= 400){
                count = Math.Min(count,C[A*i,B*i]);
                i++;
            }
        }
        if(count > 4000){
            count = -1;
        }
        sb.Append(count+"\n");
    }
}

Measured memory_bytes: 11488
a = int (input())  

if a>81:
  print("No")
else:
  c = 1
  for i in range(9):
    b = a/(9-i)
    
    if b.is_integer()==True and b<10:
      c = 0
    else:
      c = c*1
  if c==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int main(){
	string s;cin>>s;
	bool ans=false;
	for(int i=0;i<s.length()-1;i++){
		if(s.substr(i,2)=="AC"){
			ans=true;
		}
	}
	if(ans){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    vector<int> vec(3);
    REP(i, 3) cin >> vec[i];
    int K;
    cin >> K;
    
    int ans = 0;
    sort(vec.begin(), vec.end());
    ans += vec[2] * pow(2, K);
    ans += vec[0];
    ans += vec[1];
    print(ans);
}

signed main() {
    solve();
}


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

int main(void){
    int d,g; cin >> d >> g;
    vector<vector<int>> pc(d,vector<int>(2,0));
    ll ans = pow(10,9);
    for(int i=0;i<d;i++){
        cin >> pc[i][0] >> pc[i][1];
    }

    for(int i=0;i<(1<<d);i++){
        // cout << (i>0) <<endl;
        ll cnt=0, goal=g;
        for(int j=0;j<d;j++){
            if((i>>j&1)==1){
                cnt+=pc[j][0]; goal -= 100*(j+1)*pc[j][0]+pc[j][1]; 
            }
        }

        // cout << goal << ' ' <<cnt << endl;

        bool flag = false, ok = false;
        if(goal<=0)ok=true;
        for(int j=d-1;0<=j;j--){
            if((i>>j&1)==0){
                flag=true;
                for(int k=0;k<pc[j][0]-1;k++){
                    if (0<goal){
                        goal -= 100*(j+1);
                        cnt++;
                        // cout << goal << ' ';
                    }else{
                        break;
                    }
                    if (goal<=0)ok=true;
                }
                // if(pc[j][0]*100*(j+1)<goal) break;
                // else{
                //     cnt += max(0,int((goal+(100*(j+1))-1)/(100*(j+1))));
                //     // cout << cnt << endl;
                //     if(cnt < ans) ans = cnt;
                // }
            }
            if(flag == true)break;
        }
        // cout << cnt << ' ' << ok << endl;
        if(ok==true && cnt<ans)ans=cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
t=[int(input()) for i in range(n)]
def getStatus(num):
  arr=[]
  for i in range(n)[::-1]:
    arr.append(num//(4**i))
    num%=4**i
  return arr
ans=10**10
for i in range(4**n):
  S=getStatus(i)
  L=[0,0,0]
  chk=0
  if 1 not in S or 2 not in S or 3 not in S:continue
  for j in range(n):
    if S[j]==0:continue
    if L[S[j]-1]!=0:chk+=10
    L[S[j]-1]+=t[j]
  chk+=abs(a-L[0])+abs(b-L[1])+abs(c-L[2])
  if chk<ans:ans=chk
print(ans)

Measured memory_bytes: 44140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	char c; cin >> c;
	printf("%c", c + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const int N = 1e5+10;

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout << c << endl;
	}else if(a==c){
		cout << b << endl;
	}else if(b==c){
		cout << a << endl;
	}
}

Measured memory_bytes: 256
#pragma once
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#define REP(i,e) for(long long i = 0;i < (e);i++)
typedef long long i64;
using namespace std;
int main() {

	i64 N, C;
	cin >> N >> C;
	i64  x[100001];
	i64 v[100001];
	REP(i, N) {
		cin >> x[i];
		cin >> v[i];
	}
	i64 mf[100001];
	mf[0] = 0;

	i64 mb[100001];
	mb[0] = 0;
	i64 vf = 0;
	i64 vb = 0;
	REP(i, N) {
		vf += v[i];
		mf[i + 1] = max(mf[i],vf - x[i]);
		vb += v[N - i - 1] ;
		mb[i + 1] = max(mb[i], vb - (C - x[N - i - 1]));
	}
	i64 res = 0;
	REP(i, N + 1) {
		i64 tm = mf[i] + mb[N - i];
		i64 f = tm - ((i == 0) ? 0 : x[i - 1]);
		i64 f2 = tm - ((i == N) ? 0 : (C - x[i]));
		res = max(res, max(f, f2));
	}
	cout << res << "\n";
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vdbl;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define IREP(i, v) for (auto i = v.begin(); i != v.end(); i++)
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes()
{
    cout << "ARC" << endl;
}
void no()
{
    cout << "ABC" << endl;
}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s ;
    cin >> s ;
    if(s=="ABC"){
        yes() ;
    }
    else{
        no() ;
    }
    

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int N, K;
int h[111111];
int dp[111111];
int main(){
    cin >> N >> K;
    for(int i=0; i<N; i++)
        cin >> h[i];

    fill_n(dp, 111111, 1<<30);
    dp[0] = 0;
    for(int i=0; i<N; i++){
        for(int j=1; j<=K; j++){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout << dp[N-1] << endl;
    return 0;
}


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

using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//最終奥義 #define int long long
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 (b<a) { a=b; return 1; } return 0; }
//lambda: [](int x, int y){return x<y;}

const int MAX=1000002;
const int MOD=1000000007;
ll finv[MAX],inv[MAX];

void COMinit() {
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll loop_sq(ll n,ll r){
    if(r==0) return 1;
    if(r % 2) return loop_sq(n, r - 1) % MOD * n % MOD;
    else return loop_sq(n * n % MOD, r / 2) % MOD;
}

signed main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    COMinit();
    
    ll ans = loop_sq(2, n) - 1LL;
    ll nCa = 1LL, nCb = 1LL;
    
    rep(i,a) nCa = nCa * (n - i) % MOD;
    nCa = nCa * finv[a] % MOD;
    rep(i,b) nCb = nCb * (n - i) % MOD;
    nCb = nCb * finv[b] % MOD;
    
    ans -= nCa + nCb % MOD;
    while(ans < 0) ans += MOD;

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


Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>

// #define INT_MAX 2147483647
// #define LL_MAX 9223372036854775807

using namespace std;
#define i64  long long

void solve(void)
{
  vector<tuple<int,int> > vec;
  while(true)
  {
    int a,b;
    cin>>a>>b;
    if((a==0) && (b==0)) break;
    vec.emplace_back(a,b);
  }


  for (int i = 0; i < vec.size(); i++)
  {
    int H,W;
    H = get<0>(vec[i]);
    W = get<1>(vec[i]);

    for (int h = 0; h < H; h++)
    {
      for (int w = 0; w < W; w++)
      {
        if((h==0)||(h==H-1)||(w==0)||(w==W-1))
        cout<<"#";
        else
        cout<<".";
      }
      cout<<endl;
    }
      cout<<endl;
    
  }

  return;
}
int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



Measured memory_bytes: 3032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int g[50][50];
int route[50][2];

int main()
{
	int n,m;
	int ans=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		cin>>route[i][0]>>route[i][1];
		route[i][0]--;
		route[i][1]--;
	}
	

	for(int i=0;i<m;i++)
	{
		//辺をひとつ除いたグラフの構成
		fill(g[0],g[50],100000);
		for(int j=0;j<m;j++)
		{
			if(j==i)
				continue;
			g[route[j][0]][route[j][1]]=1;
			g[route[j][1]][route[j][0]]=1;
		}

		//ワーシャルフロイド
		for(int k=0;k<n;k++)
		{
			for(int j=0;j<n;j++)
			{
				for(int l=0;l<n;l++)
				{
					g[j][l]=min(g[j][l],g[j][k]+g[k][l]);
				}
			}
		}

		//つながってない辺のチェック
		bool f=true;
		for(int j=0;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				if(g[j][k]==100000)
				{
					f=false;
					break;
				}
			}
			if(!f)
				break;
		}
		if(!f)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// This code writed by chtholly_micromaker(MicroMaker)
#include <bits/stdc++.h>
#define reg register
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
 string s;
 cin>>s;
 if(s=="Sunny")
 	cout<<"Cloudy"<<endl;
else if(s=="Rainy")
	cout<<"Sunny"<<endl;
else
	cout<<"Rainy"<<endl;
	return 0;
}


Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split(' ')))

s = [list(map(int, input().split(' '))) for _ in range(d)]

t = [int(input()) - 1 for _ in range(d)]
ca = [0] * 26 # 放置された不満の数々
dc = 0 # カレントな満足度
dl = [] # 満足度のログ

for i in range(1, d + 1):
    dc += s[i - 1][t[i - 1]]
    ca[t[i - 1]] = i
    dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(26)])
    dl.append(dc)
print('\n'.join(list(map(str, dl))))

Measured memory_bytes: 9296
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a < b && b < c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}



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

int main() {
    int N, A, B;
    int clrCount = 0, foreignCount = 1;
    string S;
    cin >> N >> A >> B >> S;

    for (auto i = 0; i < S.size(); i++) {
        switch (S[i]) {
            case 'a':
                if (clrCount < A + B) {
                    cout << "Yes" << endl;
                    clrCount++;
                } else {
                    cout << "No" << endl;
                }
                break;

            case 'b':
                if (clrCount < A + B && foreignCount <= B) {
                    cout << "Yes" << endl;
                    clrCount++;
                    foreignCount++;
                } else {
                    cout << "No" << endl;
                }
                break;
            default:
                cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int n,sz;

const int N = 401;
int ct[N];
int R;
vector<int> pos;
vector<vector<int>> ans;
void dfs(int num, int idx){
    if(num == n){
        vector<int> sp(pos);
        sort(all(sp));

        vector<int> tmp;
        rep(i,n-1) tmp.pb(sp[i+1]-sp[i]);
        ans.pb(tmp);
        return;
    }

    while(idx>0 && ct[idx]==0) --idx;
    if(ct[idx]==0) return;


    for(int p:{idx,R-idx}){
        bool find_neg = false;
        for(int i:pos){
            int f = abs(i-p);
            --ct[f];
            if(ct[f]<0) find_neg = true;
        }

        if(!find_neg){
            pos.pb(p);
            dfs(num+1, idx);
            pos.pop_back();
        }

        for(int i:pos){
            int f = abs(i-p);
            ++ct[f];
        }
    }
}

int main(){
    while(cin >>n,n){
        memset(ct,0,sizeof(ct));

        sz = n*(n-1)/2;
        vector<int> d(sz);
        rep(i,sz){
            cin >>d[i];
            ++ct[d[i]];
        }

        pos.clear();
        pos.pb(0);
        pos.pb(d[0]);

        --ct[d[0]];
        R = d[0];

        ans.clear();
        dfs(2,d[0]);
        sort(all(ans));
        ans.erase(unique(all(ans)), ans.end());

        for(const vector<int> &v:ans){
            rep(i,n-1) cout << v[i] << " \n"[i==n-2];
        }
        cout << "-----\n";
    }
    return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int cnt = 0;

void insertSort(int n,int a[],int g){
    for(int i=g ; i<n ; i++){
        int v = a[i];
        int j = i-g;
        while(j>=0 and a[j]>v){
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j+g] = v;
    }
}

void shellSort(int n,int a[]){
    int m = 0;
    int s = 1;
    
    while((n/s) > 0){
        s *= 2;
        m++;    //2^(mult-1)?????§?????????????????¨???????¨?
    }
    
    int g[20];
    
    for(int k = 0,t = 1; k < m; k++){
        g[k] = n/t;
        t *= 2;
    }
    
    rep(i,m) insertSort(n,a,g[i]);
    
    cout << m << endl;
    rep(i,m) cout << g[i] << (i != m-1 ? ' ' : '\n');
    cout << cnt << endl;
    rep(i,n) cout << a[i] << endl;
}

int main(){
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    
    shellSort(n,a);

}







Measured memory_bytes: 6968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gcd(a,b)   __gcd(a,b)
#define lcm(a,b)   (a*b)/gcd
#define rep(i,n)   for(int i=0;i<n;i++)
#define Rep(i,n)   for(int i=1;i<=n;i++)
#define REP(i,j,n) for(int i=j;i<=n;i++)
#define fast   ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)


int main()
{ 
	fast;
	int ar[3];
	rep(i,3){
		cin>>ar[i];
	}
	int cnt=0;
	rep(i,3){
		if(ar[i]==5) cnt++;
	}
	if(cnt==2){
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;

}

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

int main(){
  int n, m;
  int s, c;

  cin >> n >> m;

  vector<int> S(n+1, -1);

  for (int i = 0; i < m; i++){
    cin >> s >> c;

    if (S[s] != -1 && S[s] != c){
      cout << "-1" << endl;
      return 0;
    }

    if (S[s] == -1 || S[s] == c){
      S[s] = c;
    }

    if (n > 1 && s == 1 && c == 0){
      cout << "-1" << endl;
      return 0;
    }
  }



  for (int i = 1; i <= n; i++){
    if (S[i] == -1){
      if (i == 1 && n > 1) S[i] = 1;
      else S[i] = 0;
    }
    cout << S[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.math.*;
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        if(n<10){
            System.out.println(r+100*(10-n));
        } else {
            System.out.println(r);
        }
    }
}


Measured memory_bytes: 23380
#include<iostream>
 #include<algorithm>
 using namespace std;
 #define N 100010
 int main(){
 int n,m,h[N],ma[N];
 cin>>n>>m;
 for(int i=1;i<=n;i++){
cin>>h[i];
 ma[i]=0;
 }
 for(int i=0;i<m;i++){
 int a,b;
 cin>>a>>b;
 ma[a]=max(ma[a],h[b]);
 ma[b]=max(ma[b],h[a]);
 }
 int ans=0;
 for(int i=1;i<=n;i++){
 ans+=h[i]>ma[i];
 }
 cout<<ans<<endl;
 }

Measured memory_bytes: 4372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
  
   
   int n;
   cin >> n;
   vector<int> sum(n + 1);
   vector<int> v(n + 1);

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

   for (int i = n -1 ; i>= 0; i--) {
   		if (i == n - 1) {
   			sum[i] = v[i];
   			continue;
   		}
   		sum[i] = sum[i + 1] + v[i];
   		sum[i] %= mod;
   } 

   int ans = 0;
   for (int i = 0; i < n-1; i++) {
   		ans += (v[i] * sum[i + 1]) % mod;
   		ans %= mod;
   }
   cout << ans ;
}
 
int32_t main()
{
    c_p_c();
    return 0;
}

Measured memory_bytes: 6388
h, w = map(int, input().split())

def Divisions(a, b):
    if a % 3 == 0:
        return 0
    else:
        cnt = b
        for i in range(a+1):
            s = min(i * b, (a - i) * (b // 2))
            l = max(i * b, (a - i) * (b - b // 2))
            cnt = min(cnt, l - s)
        return cnt

print(min(Divisions(h, w), Divisions(w, h)))


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)

int main(){
    int m; cin >>m;
    REP(z, m){
        string str; cin >>str;
        set<string> s;
        FOR(i, 1, str.length()){
            string left = str.substr(0, i), right = str.substr(i);
            string rleft = left, rright = right;
            reverse(rleft.begin(), rleft.end());
            reverse(rright.begin(), rright.end());

            s.insert(left + right);
            s.insert(right + left);

            s.insert(rleft + right);
            s.insert(right + rleft);

            s.insert(left + rright);
            s.insert(rright + left);

            s.insert(rleft + rright);
            s.insert(rright + rleft);
        }
        cout <<s.size() <<endl;
    }
    return 0;
}

Measured memory_bytes: 1292
#include<iostream>
#include<algorithm>
using namespace std;
long long xor1_a(long long a)
{
    if(a%4==1) return (long long)1;
		else if(a%4==2) return a+1;
    else if(a%4==3 ||a==0) return (long long)0;
    else return a;
}
int main()
{
    long long n,m;
    cin>>n>>m;
    if(n==0) cout<<(xor1_a(m))<<endl;
    else cout<<((xor1_a(n-1))^(xor1_a(m)))<<endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)1e6 + 10;

struct Q{
  int A, B;
  bool operator< (const Q &F) const {
    return max(-B,-F.B-A) < max(-F.B,-B-F.A);
  }
};

int main(){
  fastIO;
  int n;
  cin >> n;
  string t;
  int cnt, low;
  vector<Q> exc;
  for(int i = 0; i < n; i ++ ){
    cin >> t;
    cnt = 0;
    low = 0;
    for(auto x : t){
      if(x == '(') cnt ++;
      else cnt -- ;
      low = min(low, cnt);
    }
    exc.push_back({cnt, low});
  }
  sort(exc.begin(), exc.end());
  cnt = 0;
  for(auto x : exc){
    if(cnt + x.B < 0){
      cout << "No\n";
      return 0;
    }
    cnt += x.A;
  }

  if(cnt != 0)
    cout << "No\n";
  else
    cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 11580
/*
    ASEEN AAN 
            PINDAN AALE JATT!!!
                                */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli M=1000000007;   
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//unordered_map<pair<ll,lli>,lli> mp;
lli me(lli a,lli b,lli M)
{
    if(b==0)
    return 1;
    else if(b%2==0)
    return me((a*a)%M,b/2,M);
    else
    return (a%M*me((a*a)%M,(b-1)/2,M)%M)%M;
}
lli mI(lli a,lli m)
{
    return me(a,m-2,m);
}
//lli tot=0;
vector<lli> pf(string s) {
    int n = (int)s.length();
    vector<lli> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
//map<ll,lli> dp;
//set<lli> s[100005];
lli dp[105][100005];
lli x[3][105];
int main()
{
    ios_base::sync_with_stdio(0);
    lli w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    {
        cin>>x[0][i]>>x[1][i];
    }
    lli mx=-1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(j>=x[0][i])
            dp[i][j]=max(dp[i-1][j-x[0][i]]+x[1][i],dp[i-1][j]);
            else
            dp[i][j]=dp[i-1][j];
            mx=max(mx,dp[i][j]);
        }
    }
    cout<<mx;
}

Measured memory_bytes: 79360
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

double n;
double a[100],A;
pair<int, double>ans;

int main() {
	cin >> n;
	for (int i = 0; i != n; ++i) {
		cin >> a[i];
		A += a[i];
	}
	A = A / n;
	ans = mkp(0xe869120, 0xe869120);
	for (int i = 0; i != n; ++i) {
		if (ans.second> abs(a[i] - A)) {
			ans = mkp(i, abs(a[i] - A));
		}
	}
	cout << ans.first << endl;
	return 0;
}

Measured memory_bytes: 256
i = [int(s) for s in input().split()]
a = i[0]
b = i[1]

min = (a*10) -1
max = (b*12.5) +1
c1=0
c2=0

while min < max:
  c1 = int(min * 0.08)
  c2 = int(min * 0.1)
  if c1 == a and c2 == b:
    print(min)
    break
  else:
    min += 1
else:
  print(-1)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int array[11][11], i, j, n;
	
	while (1){
		scanf("%d", &n);
		
		if (n == 0){
			break;
		}
		
		for (i = 0; i < 11; i++){
			for (j = 0; j < 11; j++){
				array[i][j] = 0;
			}
		}
		
		for (i = 0; i < n; i++){
			for (j = 0; j < n; j++){
				scanf("%d", &array[i][j]);
			}
		}
		for (j = 0; j < n; j++){
			for (i = 0; i < n; i++){
				array[n][j] += array[i][j];
				array[j][n] += array[j][i];
			}
		}
		for (i = 0; i < n; i++){
			array[n][n] += array[i][n];
		}
		
		for (i = 0; i <= n; i++){
			for (j = 0; j <= n; j++){
				printf("%5d", array[i][j]);
				if (j == n){
					puts("");
				}
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 620
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int n, q;
int p[234567], a1[234567]; vector<int>v[234567];
void f1(int k) {
	for (int i : v[k]) {
		if (i != p[k]) {
			p[i] = k;
			f1(i);
		}
	}
	return;
}
void f2(int k) {
	for (int i : v[k]) {
		if (i != p[k]) {
			a1[i] += a1[k];
			f2(i);
		}
	}
	return;

}
signed main() {
	cin >> n >> q;
	for0(i, n - 1) {
		int a, b; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	f1(1);
	for0(i, q) { int a, b; cin >> a >> b; a1[a] += b; }
	f2(1);
	for1(i, n) {
		if (i != 1)cout << ' '; cout << a1[i];
	}cout << endl;
}

Measured memory_bytes: 23808
#include<stdio.h>
# define BUFSIZE 100

int  main(void){
char hoge[BUFSIZE]=	{0};
int i=0;

scanf(" %s",&hoge);
	for(i=0;i<BUFSIZE;i++){
		if(hoge[i]=='\0'){
			break;
			}
		}
///debug


/*
	printf(" %s",hoge);
	*/
	

int m=0;
	if(i%2==0){
		for(int j=0;j<=(i/2-1);j++){
				if(hoge[j]!=hoge[i-1-j]){
						m++;
					}
		}
	}else{
		for(int j=0;j<(i-1)/2;j++){
				if(hoge[j]!=hoge[i-1-j]){
						m++;
				}
		}
	}

printf(" %d",m);

}
	
	
	


	
	



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

int main() {
  int a,b;
  cin>>a>>b;
  string s=to_string(b);
  int n=s.size();
  int x=a*pow(10,n)+b;
  string ans="No";
  for(int i=1;i<=x;i++){
    if(i*i==x) ans="Yes";
  }
  cout<<ans<<endl;     
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;


public class Main {



	public static void main(String[] args) throws IOException {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String[] buf = br.readLine().split(" ");
		ArrayDeque<Character> str = new ArrayDeque<Character>();
		
        for (char c : buf[0].toCharArray()) {
            str.addLast(c);
        }
		buf = br.readLine().split(" ");
		int q = Integer.parseInt(buf[0]);
		int flip = 0;
		for(int i = 0 ; i < q ; i++) {
			buf = br.readLine().split(" ");
			int t = Integer.parseInt(buf[0]);
			if(t == 1) {
				flip = flip ^ t;
			}else{
				int t2 = Integer.parseInt(buf[1]);
				int index = 0;
				if(t2 == 1) {
					index = 0;
				}else {
					index = 1;
				}

				if(flip == 1) {
					if(index == 0) {
						index = 1;
					}else {
						index = 0;
					}

				}

				char[] c = buf[2].toCharArray();
				if(index == 0) {
					str.addFirst(c[0]);
				}else {
					str.addLast(c[0]);
				}


			}


		}
		PrintWriter out = new PrintWriter(System.out);

        StringBuilder sb = new StringBuilder();
		if(flip == 1){	         
			while(str.size() > 0) {
				sb.append(str.pollLast());
			}
		}else{
			while(str.size() > 0) {
				sb.append(str.pollFirst());
			}
		}
		out.println(sb);
		out.flush();
	}
}

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

int main() {
    int A[3], ans = 0;
    cin >> A[0] >> A[1] >> A[2];
    while (A[0] != A[1] || A[1] != A[2]) {
        sort(A, A + 3);
        if (A[0] + 2 <= A[2]) {
            A[0] += 2;
        } else {
            A[0]++; A[1]++;
        }
        ans++;
    }
    cout << ans << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;
int n,c;
bool ch(ll s){
    string t=to_string(s);
    vector<bool>cv(3,0);
    rep(i,0,t.size()){
        if(t.at(i)=='3')cv.at(0)=true;
        if(t.at(i)=='5')cv.at(1)=true;
        if(t.at(i)=='7')cv.at(2)=true;
    }
    bool cc=true;
    rep(i,0,3){
        if(cv.at(i)==0) cc= false;
    }
    if(cc) return true;
    else return false;
}
void dfs(ll s, int use){
    if(357<=s and s<=n){
        if(use==0b111) c++;
    }
    if(s>=n) return;
    dfs(s*10+7,use|0b001);
    dfs(s*10+5,use|0b010);
    dfs(s*10+3,use|0b100);
}
int main(){
    cin>>n;
    c=0;
    dfs(0,0);
    cout<<c<<endl;
return 0;
}

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

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

int N;
string S;
int num[1000];

int dp[30000+1][4][1000];

void solve(int pos = 0, int k = 0, int sum = 0)
{
    if (k == 3) {
        num[sum] = 1;
        // cout << sum << endl;
        return;
    }

    if (pos == S.size()) {
        return;
    }

    if (~dp[pos][k][sum]) return;

    int digit = S[pos] - '0';

    solve(pos + 1, k, sum);
    solve(pos + 1, k+1, sum*10+digit);

    dp[pos][k][sum] = 1;
}

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

    cin >> N >> S;

    memset(dp, -1, sizeof dp);
    memset(num, 0, sizeof num);
    
    solve();
    
    int ans = 0;
    rep(i, 1000) {
        if (num[i] != 0) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 471424
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a;

int main(){
	cin>>n>>m;
	a=vi(n);
	for(int i=0;i<m;i++){
		int s,t;
		cin>>s>>t;
		s--;t--;
		a[s]++;
		a[t]++;
	}
	for(int i=0;i<n;i++) cout<<a[i]<<endl;
}

Measured memory_bytes: 256