akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}

lli check(vector<lli>& vec, lli n,lli cmp, lli num) {
	if (num > 26)return -1;
	if (vec[n] == cmp)return 1;
	else return check(vec, vec[n], cmp, num + 1);
}

int main() {
	lli n,temp,ans=0;
	cin >> n;
	rep1(i, n) {
		if (i % 2 == 0)continue;
		temp = 0;
		rep1(j, i) {
			if (i % j==0)temp++;
		}
		if (temp == 8) {
			ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
//----ak_lm10----
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

//TYPEDEFS
typedef long long int ll;
typedef unsigned long long int uli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpll;
typedef set<int> si;
typedef set<ll> sll;
//DEFINES
#define PI 3.1415926535897932384
#define fastIO  std::ios::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define mod1 1000000009
#define mod2 998244353
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REP(i, k, n) for (ll (i) = (k); (i) < (n); (i)++)
#define repr(i, k, n) for (ll (i) = (k); (i) >= (n); (i)--)
#define pb push_back
#define popb pop_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(x) x.be,x.en
#define rall(x) x.rbegin(),x.rend()
#define sortinc(x) sort(all(x))
#define sortdec(x) sort(rall(x))
#define tr(it, a) for(auto (it) = a.begin(); (it) != a.end(); (it)++)
#define p0(a) cout << (a) << " "
#define p1(a) cout << (a) << endl
#define p2(a, b) cout << (a) << " " << (b) << endl
#define p3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define p4(a, b, c, d) cout << (a) << " " << (b) << " " << (c) << " " << (d) << endl
#define cend cout<<endl
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define inpi in<int>()
#define inpll in<ll>()
#define inps in<string>()
#define r0 return 0
#define e0 exit(0)
#define F first
#define S second
#define setBits(x) _builtin_popcount(x)
#define setBitsll(x) _builtin_popcountll(x)
#define parity(x) _builtin_parity(x)
#define leadZero(x) __builtin_clz(x)
#define leadZeroll(x) __builtin_clzll(x)
#define trailZero(x) __builtin_ctz(x)
#define w(t) int t; cin>>t; while(t--)
#define CASE(t) int t; cin>>t; rep(i,t){cout<<"Case #"<<i+1<<":\n";}
#define debug(x) cout << #x << " is " << x << endl;
//TEMPLATES
template <typename T>
T in(){
    T x;
    cin >> x;
    return x;
}
template <typename T>
void print(vector<T> v){
    for (auto i : v){
        cout << i << " ";
    }
    cout << endl;
}
template <typename T>
void printArr(T *arr, int s, int n){
    for(int i=s;i<=n;i++){
        cout<<arr[i]<<" ";
    }
    cout<<endl;
}
template <typename T>
void cmp(pair<T, T> &a, pair<T, T> &b ){
    return a.S>b.S;
}
int main(){
    fastIO;
    
    int t=1;
    // cin>>t;
    while(t--){
        ll x=inpll,k=inpll,d=inpll;
        x=abs(x);
        ll t=x/d;
        if(t>k){
            cout<<abs(x-d*k);
        }
        else{
            ll tem=k-t;
            x=x%d; 
            if(tem%2==0){
                cout<<abs(x);
            }
            else{
                cout<<abs(d-x);
            }
        }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define out(n) cout << (n) << endl;

// __attribute__((constructor))
// void initial() {
//   cin.tie(0);
//   ios::sync_with_stdio(false);
// }

int main() {
  int n, m, d[100001] = {0};
  scanf("%d%d", &n, &m);

  int a, b;
  rep(i, 0, m) {
    scanf("%d%d", &a, &b);
    d[a]++, d[b]++;
  }

  rep(i, 0, n + 1) {
    if(d[i] & 1) {
      printf("%s", "NO");
      return 0;
    }
  }

  printf("%s", "YES");
}


Measured memory_bytes: 640
n=int(input())

L=list(map(int,input().split()))
a=0
b=0

for i in range(n):
	if L[i]%4==0:
		b+=1
	if L[i]%2==1:
		a+=1

if a+b==n and a-b==1:
	print('Yes')
	exit()
if b>=a:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 20028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,B,K;
  cin >> A >> B >> K;
  if(A>K){
      A = A-K;
  }
  else{
      if(B>K-A){
          B=B-K+A;
      }
      else{
          B=0;
      }
      A=0;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
    string s;
    cin>>s;
    if(s.find('W')==-1||s.find('B')==-1){
        cout<<"0"<<endl;
    }
else{
    int cnt=0;
        for(int i=0; i<s.size()-1; i++){
            if(s[i]!=s[i+1])
                cnt++;
        }
        cout<<cnt<<endl;
}
return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int f(int n) {
	if (n % 2 == 0)return n / 2;
	else return n * 3 + 1;
}
int main() {
	int s, ans;
	cin >> s;
	set<int> a;
	a.insert(s);
	vector<int> v;
	v.PB(s);
	for (int i = 1; true; i++) {
		int p = f(v[i - 1]);
		v.PB(p);
		a.insert(p);
		if (SZ(a) != i + 1) {
			ans = i + 1;
			break;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K;
    cin >> K;

    queue<ll> que;
    rep2(i, 1, 10) {
        que.push(i);
    }
    ll cnt = 1;

    while (!que.empty()) {
        ll q = que.front();
        que.pop();
        if (K == cnt) {
            cout << q << '\n';
            return;
        }
        cnt++;
        ll d = q % 10;
        if (d == 0) {
            que.push(q * 10 + d);
            que.push(q * 10 + d + 1);
        } else if (d == 9) {
            que.push(q * 10 + d - 1);
            que.push(q * 10 + d);
        } else {
            que.push(q * 10 + d - 1);
            que.push(q * 10 + d);
            que.push(q * 10 + d + 1);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
int main(){
    int n;cin>>n;
    vector<int>v(n);rep(i,n)cin>>v[i];
    vector<int>ans;
    bool A=true;
    for(int i=n-1;i>=0;i--){
        int count=-1;
        for(int j=i;j>=0;j--){
            if(v[j]==j+1){
                count=j;ans.push_back(j+1);break;
            }
        }
        if(count==-1){A=false;cout<<-1;break;}
        else{
            for(int j=count;j<i;j++)v[j]=v[j+1];
        }
    }
    if(A){
        rep(i,n)cout<<ans[n-i-1]<<endl;
    }
}

Measured memory_bytes: 256
import bisect
import heapq

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()
r.sort()
m = A - X
n = B - Y
l = bisect.bisect_right(r, min(p[m], q[n]))
print(sum(list(heapq.merge(p[m:], q[n:], r[l:]))[-(X + Y):]))


Measured memory_bytes: 23360
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
typedef long long int ll;
const int MAX=1e5+10;
int F[30];
ll dist;
ll f(ll x)
{
    return x*(x-1)/2;
}
int main (){
    string S;cin >> S;
    int sz = S.size();
    for(int i=0;i<sz;i++){
        F[S[i]-'a']++;
    }
    for(int i=0;i<26;i++){
        if(F[i])dist+=f(F[i]);
    }
    --dist;
    cout<<f(sz)-dist<<endl;
    return 0;
}

Measured memory_bytes: 640
from math import sqrt
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        t = 0
        for k in range(d):
            t += (x[i][k] - x[j][k]) ** 2
        if float.is_integer(sqrt(t)):
            ans += 1
print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,k;
  cin >>a >> b >> k;
 
      if(a>=k){
        a=a-k;
        cout << a << " "<< b << endl;
      }
      else if(a+b>k){
        b=a+b-k;
        cout << 0 << " "<< b << endl;
      }
  		else{
        cout << 0 << " "<< 0 << endl;
        }
}

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

using namespace std;

int main() {
    int N,X; cin>>N>>X;
    vector<int> L;

    for (int i=0;i<N;i++){
        int l; cin>>l;
        L.push_back(l);
    }
    //sort(L.begin(), L.end());

    int cnt=1;
    int d=0;
    for (int i=0;i<N;i++){
        
        d = d + L[i];
        if (d <= X) cnt++;
        //cout << "d=" << d << endl;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;
    int res = 0;  
  
    for(int len = 2; len < S.size(); len += 2) {
      string subS = S.substr(0, len);
      string L = subS.substr(0, len/2);
      string R = subS.substr(len/2);
      if (L == R) res = max(res, len);
    }
  
    cout << res << endl;
}


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

using namespace std;

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

const int TAN = 1, FUKU = 2;

int main() {
	int n, y;
	while(cin >> n && n)
	{
		cin >> y;
		int b, t;
		double r;
		double maxben = 0, ben  = 0;
		int maxb = 0;
		REP(n)
		{
			cin >> b >> r >> t;
			if(t == TAN) ben = 1 + y * r /100;
			else
			{
				ben = 1;
				rep(j,y) ben *= (1 + r/100);
			}
			
			if(ben > maxben) { maxb = b; maxben = ben;}
		}
		cout << maxb << endl;
		

	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

const int INF = 1050000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int N_MAX = 2010;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main() //input->compute->output
{

        int N = 0;

        cin >> N;

        cout << N*N*N;

        return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e6+5;
int ans,sum;
char s[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
signed main()
{
	cin>>s+1;
	int n=strlen(s+1);
	s[0]=s[n+1]='D';
	for(int i=n;i;i--)
	{
		if(s[i]=='A')ans+=sum;
		else if(s[i]=='B')
		{
			if(s[i+1]=='C')sum++;
			else sum=0;
		}
		else if(s[i]=='C')
		{
			if(s[i-1]=='B')sum=sum;
			else sum=0;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	set<int>s;
	for(int i = 0;i<n; i++)
	{
		int j;
		cin>>j;
		s.insert(j);
	}
	if(s.size()&1) cout<<s.size()<<endl;
	else cout<<s.size()-1<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n,l,i,sum=0,flag=0,mi=200,ma=0;
    scanf("%d %d",&n,&l);
    sum=(l+l+n-1)*n/2;
    //printf("%d\n",sum);
    if(l<=0&&l+n>0)
        printf("%d\n",sum);
    else
    {
        if(l+n-1<0)
        {
            printf("%d\n",sum-l-n+1);
        }
        else
            printf("%d\n",sum-l);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N ;
  cin >> N ;
  if(N % 1111 == 0 || N % 1110 < 10 || N % 1000 % 111 == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define E 2.71828182845905
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define debug(x) cout<<#x<<" is "<<x<<endl;
#define PI 3.14159265
#define mem(x) memset(x,0,sizeof(x));
using namespace std;
  
void sol() {
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	int dp[n+1][m+1];
	mem(dp);
	rep(i,1,n+1){
		rep(j,1,m+1){
			if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n,j=m;
	string ans="";
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]) {
			ans=s[i-1]+ans;
			i--;j--;
		}
		else {
			if(dp[i-1][j]>dp[i][j-1])
				i--;
			else
				j--;
		}
	}
	cout<<ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
 	//cin>>t;
 	while(t--){	
	sol();
 	}
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
string t;
int main() {
  cin >> t;
  for(int i = 0;i<t.size();i++){
    if(t.at(i) == '?'){
      t.at(i) = 'D';
    }
  }
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3724
N = int(input())
words = [input() for _ in range(N)]
exsited_words = [words[0]]

ok = True
for i in range(1, len(words)):
    w = words[i]
    if words[i-1][-1] != w[0] or w in exsited_words:
        ok = False
        break
    exsited_words.append(w)

if ok:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
# C. One-stroke Path
# https://atcoder.jp/contests/abc054/tasks/abc054_c

from collections import deque

def dfs(i, visited):
    stack = deque()
    total = 0
    stack.append((i, visited))
    while stack:
        idx, vis = stack.pop()
        if all(vis):
            total += 1
        for j in graph[idx]:
            if not vis[j]:
                v = vis[:]
                v[j] = True
                stack.append((j, v))
    return total

N, M = map(int, input().split())
graph = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)

visited = [False] * N
visited[0] = True
print(dfs(0, visited))



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
#define abs llabs 
#define INF 10000000000000000LL
using namespace std;
signed main(){
  int n,h[100000],dp[100000];
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>h[i];
    dp[i]=INF;
  }
  dp[0]=0;
  for(int i=0;i<n-2;++i){
    dp[i+1]=min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    dp[i+2]=min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
  }
  dp[n-1]=min(dp[n-1],dp[n-2]+abs(h[n-2]-h[n-1]));
  cout<<dp[n-1]<<"\n";
}

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

const int MAXN = 200010;

char s[MAXN];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s);
    int cntb = 0, cntw = 0;
    for (int i = 0; i < n; ++i) {
        cntw += s[i] == '.';
    }
    int ans = cntw;
    for (int i = 0; i < n; ++i) {
        cntb += s[i] == '#';
        cntw -= s[i] == '.';
        ans = std::min(ans, cntb + cntw);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>

int n, k;

int main() {
	scanf("%d %d", &n, &k);
	if (k == 1 || k == 2 * n - 1) {
		puts("No");
	} else {
		puts("Yes");
		int t = 1;
		for (int i = 1; i <= n - 2; i++) {
			if (t >= k - 1 && t <= k + 1) t = k + 2;
			printf("%d\n", t), t++;
		}
		printf("%d\n%d\n%d\n", k - 1, k, k + 1);
		for (int i = 1; i <= n - 2; i++) {
			if (t >= k - 1 && t <= k + 1) t = k + 2;
			printf("%d\n", t), t++;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

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

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;

  ui N{}, K{}; cin >> N >> K;
  string S{}; std::cin >> S;

  --K;
  S[K] = std::tolower(S[K]);

  using std::cout;
  cout << S << '\n';
  
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n,t,a;
  cin >> n;
  cin >> t >> a;
  int h[n]; 
  for(int i=0;i<n ;i++ ){
    cin >> h[i];
  }
  
  float min = 99999,tmp;
  int i = 0,count=0;
   while(i<n){
     tmp = abs(a - (t - h[i]*0.006));
     if(tmp < min) {
     min = tmp;
     count = i+1;}
     i += 1;
   }
  cout << count;
}

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

lint n, p;
string s;

lint modpow(lint base, lint exp) {
    if(exp == 0) return 1;
    base %= p;
    return modpow(base*base, exp/2) * (exp&1 ? base : 1) % p;
}

vector<lint> cumsum(vector<char>& data) {
    lint n = data.size();
    vector<lint> before(n+1, 0);
    for(lint i=0; i<n; i++) {
        before[i+1] = (before[i]*10 + data[i] - '0') % p;
    }
    return before;
}

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

    vector<char> cs(s.begin(), s.end());
    auto r = cumsum(cs);

    if(p == 2 || p == 5) {
        lint ans = 0;
        for(lint i=0; i<n+1; i++) {
            if(r[i] == 0)  ans += i;
        }
        cout << ans << endl;
        return 0;
    }

    lint inv = modpow(10, p-2);
    for(lint i=0; i<n+1; i++) {
        r[i] = r[i] * modpow(inv, i) % p;
    }

    map<lint, lint> mp;
    for(auto& e : r)  mp[e]++;
    lint ans = 0;
    for(auto& e : mp)  ans += (e.second) * (e.second-1) / 2;

    cout << ans << endl;
}

Measured memory_bytes: 2820
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    ri = 0
    cur_sum = 0
    for le in range(N):
        while ri < N and cur_sum + A[ri] == cur_sum ^ A[ri]:
            cur_sum += A[ri]
            ri += 1
        ans += ri - le
        if le == ri:
            ri += 1
        else:
            cur_sum -= A[le]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 77772
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::fmt;
use std::io;

fn insertion_sort(a: &mut Vec<i32>, step: usize) -> i32 {
    let n = a.len();
    let mut cnt = 0;
    for i in step..n {
        let v = a[i];
        let mut j = i;
        while j >= step && a[j-step] > v {
            a[j] = a[j-step];
            j -= step;
            cnt += 1;
        }
        a[j] = v;
    }
    cnt
}

fn shell_sort(a: &mut Vec<i32>) -> (i32, usize, Vec<usize>) {
    let mut cnt = 0;
    let mut m = 1;
    let mut g_vec = vec![];
    loop {
        g_vec.push(m);
        m = 3*m+1;
        if m > a.len() {
            break;
        }
    }
    let m = g_vec.len();
    g_vec.reverse();
    for g in &g_vec {
        cnt += insertion_sort(a, *g);
    } 
    (cnt, m, g_vec)
}

fn print_vec<T: std::fmt::Display>(a: &Vec<T>){
    let s = a.iter()
        .map(|v| v.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", s);
}


fn main() {
    // let mut a = vec![5, 1, 4, 3, 2];
    // print_vec(&a);  

    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let n = buf.trim().parse::<usize>().unwrap();
    let mut a: Vec<i32> = vec![0; n];
    for i in 0..n {
        let mut buf = String::new();
        sin.read_line(&mut buf).ok();
        a[i] = buf.trim().parse::<i32>().unwrap();
    }

    let (cnt, m, g) = shell_sort(&mut a);
    // let cnt = insertion_sort(&mut a,2);
    println!("{}", m);
    print_vec(&g);
    println!("{}", cnt);
    //print_vec(&a);
    for v in &a {
        println!("{}", v);
    }
}



Measured memory_bytes: 9116
package main

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

func main() {
	fmt.Printf("%d\n", resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (a, b int) {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	a = scanInt(sc)
	b = scanInt(sc)
	return
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}

func resolve(a, b int) int {
	maxPrice := max(originMax8(a), originMax10(b))
	for i := 1; i <= maxPrice; i++ {
		if a == (i*2)/25 && b == (i/10) {
			return i
		}
	}
	return -1
}

func originMax8(tax int) int {
	return ((tax + 1) * 100 / 8)
}
func originMax10(tax int) int {
	return ((tax + 1) * 10)
}

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


Measured memory_bytes: 640
N = int(input())
s = list(int(input()) for i in range(N))
ans = 0
sum_s = sum(s)
if sum_s%10 != 0:
    ans = sum_s
for i in s:
    if (sum_s - i)%10 != 0:
        ans = max(ans,sum_s - i)
print(ans)

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


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


const int MOD = 1000000007;

long long N, K;
vector<int> A;

long long solve() {
    long long self = 0, oth = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            if (A[i] > A[j]) ++self;
        }
    }
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (A[i] > A[j]) ++oth;
        }
    }
    //COUT(self); COUT(oth);
    return (self * K % MOD + oth * ((K * (K-1) / 2) % MOD) % MOD) % MOD;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    cout << solve() << endl;
}


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

struct Candidates{
    string name;
    int num;
};

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<Candidates> c;
    
    rep(i,n) cin >> s[i];

    sort(s.begin(), s.end());

    int serial = 1;
    int max_serial = 0;
    rep(i,n){
        if(i == n-1 || s[i] != s[i+1]){
            max_serial = max(max_serial, serial);
            Candidates x;
            x.name = s[i];
            x.num = serial;
            c.push_back(x);
            serial = 1;
        }else{
            serial++;
        }
    }

    for(Candidates x : c){
        if(x.num == max_serial) cout << x.name << endl;
    }
    
    return 0;
}

Measured memory_bytes: 17780
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}



Measured memory_bytes: 3084
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,h] <- getIntList
    [as,bs] <- transpose <$> replicateM n getIntList
    let amax = maximum as
        bls = takeWhile (>= amax) $ sortOn Down bs
        ans | sum bls >= h = length . takeWhile (< h) $ scanl (+) 0 bls
            | otherwise = (h - s - 1) `div` amax + 1 + length bls
            where s = sum bls
    print ans

Measured memory_bytes: 62844
#abc133 c
L,R=map(int,input().split())
x=R-L
ans=0
R=min(R,L+2019*2)
ans=2018
for i in range(L,R+1):
    for j in range(i+1,R+1):
        amari=(i*j)%2019
        ans=min(ans,amari)
        if ans==0:
            break
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll f[n][10];
	for(ll i = 0; i < n; ++i)for(ll j = 0; j < 10; ++j) cin >> f[i][j];
	ll ans = -1145148931919810;
	ll p[n][10 + 1];
	for(ll i = 0; i < n; ++i)for(ll j = 0; j < 11; ++j) cin >> p[i][j];
	for(ll i = 1; i < (1 << 10); ++i){
		ll po[n] = {};
		ll yo = i;
		ll pi = 0;
		ll pu = 0;
		while(yo){
			if(yo % 2){
				for(ll j = 0; j < n; ++j){
					if(f[j][pi]) ++po[j];
				}
			}
			yo /= 2;
			++pi;
		}
		for(ll j = 0; j < n; ++j) pu += p[j][po[j]];
		ans = max(ans, pu);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int memo[21][11][156];
int dfs(int n, int k, int s){
  if(s == 0 && k == 0) return 1;
  if(s <= 0 || n < 0 || k == 0) return 0;
  if(memo[n][k][s] >= 0) return memo[n][k][s];
  return (memo[n][k][s] = dfs(n-1, k, s) + dfs(n-1, k-1, s-n));
}

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

  fill((int*)memo, (int*)memo+21*11*156, -1);
  while(true){
	int n, k, s; cin >> n >> k >> s;
	if(n == 0) break;
	cout << dfs(n,k,s) << endl;
  }
  
  return 0;
}

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

int n;
long long money, stock;

void buyStock(int value){
    stock += money/value;
    money %= value;
    return;
}
void sellStock(int value){
    money += stock*value;
    stock = 0;
    return;
}

int main(void){
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    money = 1000;
    stock = 0;
    for(int i = 0; i < n; i++){
        if(i == n-1){
            sellStock(a[i]);
        }else{
            if(a[i] < a[i+1]) buyStock(a[i]);
            else if(a[i] > a[i+1]) sellStock(a[i]);
        }
    }
    cout << money << endl;
    return 0;
}


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

int main(){
    string s;
    int a, b;
    cin >> s;
    bool flag1, flag2;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == 'A'){
            a = i;
            flag1 = true;
            break;
        }
    }
    for(int i = s.size()-1; i >= 0; i--){
        if(s.at(i) == 'Z'){
            b = i;
            flag2 = true;
            break;
        }
    }
    if(flag1 && flag2){
        cout << b-a+1 << endl;
    }

}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<n<<endl;
    }else{
        cout<<n*2<<endl;
    }
}

Measured memory_bytes: 256
K, T = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)

if T == 1:
	print(K - 1)
else:
	if 2 * a[-1] - K - 1 >= 0:
		print(2 * a[-1] - K - 1)
	else:
		print(0)

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
const int mod=1e9+7;
//###################################################################
int n,m;
char a[1009][1009];
bool valid(int x,int y){
    return (x>=0&&y>=0&&x<n&&a[x][y]=='.');
}
int mem[1009][1009];
int solve(int x,int y){
    if(!valid(x,y))return 0;
    if(x==(n-1)&&y==(m-1))return 1;
    if(mem[x][y]!=-1)return mem[x][y];
    return mem[x][y]=solve(x+1,y)%mod+solve(x,y+1)%mod;
}

int main(){
    n=D(),m=D();
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];

    memset(mem,-1,sizeof mem);
    cout<<solve(0,0)%mod;

}


Measured memory_bytes: 8756
n = int(input())
A = list(map(int,input().split()))

x = []
f = 0
for a in A:
    if a//400 < 8:
        x.append(a//400)
    else:
        f += 1
x = set(x)
l = len(x)
print(max(l,1),l+f)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
#define f first
#define s second
#define ll long long
#define read(x) scanf("%d", &x)
#define all(v) v.begin(), v.end()
using namespace std;
int n, K;
vector<int> v;
int dp[100005];
int solve(int k){
    if(k > K)
        return 0;
    if(k == K)
        return 1;
    if(dp[k] != -1)
        return dp[k];
    for(int &a : v){
        if(solve(k + a))
            return dp[k] = 0;
    }
    return dp[k] = 1;
}
int main(){
    //freopen("test.txt", "r", stdin);
    cin >> n >> K;
    v.resize(n);
    for(int &a : v)
        cin >> a;
    memset(dp, -1, sizeof(dp));
    cout << (solve(0) ? "Second" : "First");
}

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

int main(void){
  int A[100][100],b[100],c[100],n,m;
  cin>>n>>m;
  
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)cin>>A[i][j];
  for(int i=0;i<m;i++)cin>>b[i];

  for(int i=0;i<n;i++){
    c[i]=0;
    for(int j=0;j<m;j++){
      c[i]+=A[i][j]*b[j];
    }
  }

  for(int i=0;i<n;i++)cout<<c[i]<<endl;

}


Measured memory_bytes: 3120
#include<stdio.h>

int main(void)
{
  int N,i;
  long long K=0;
  long long M=1000;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)
  {
    scanf("%d",&A[i]);
  }
  
  for(i=0;i<N-1;i++)
  {
    if(A[i]<A[i+1])
    {
      K=K+M/A[i];
      M=M%A[i];
    }
    if(A[i]>A[i+1])
    {
      M=M+K*A[i];
      K=0;
    }
  }
  printf("%ld",M+K*A[N-1]);
  return 0;
}

Measured memory_bytes: 1700
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int dp[21][2001];//0:未計算 1:ok 2:no
       

bool isok(int ii,int rest,vector<int> *ni,int n){

  if(dp[ii][rest] == 1){
    return true;
  }
  else if(dp[ii][rest] == 2){
      return false;
  }

     
  if(rest == 0){
    dp[ii][0] = 1;
    //return true;
  }
  else if(ii >= n){
    dp[ii][rest] = 2;
  }
  else if(isok(ii+1,rest,ni,n)){
    dp[ii][rest] = 1;
  }
  else if(isok(ii+1,rest - ni->at(ii),ni,n)){
    dp[ii][rest] = 1;
  }
  else{
    dp[ii][rest] = 2;
  }
  
  if(dp[ii][rest] == 1){
    return true;
  }
  else {
      return false;
  }
    
}

int main(){
  long ii,jj,kk;
  vector<int> a;

  int n,m;

  vector<int> ni,qi;

  cin >> n;
  ni.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> ni[ii];
  }

  cin >> m;
  qi.resize(m);

  memset(dp,0,sizeof(dp));
  
  for(ii=0;ii<m;ii++){

    cin >> qi[ii];
    if(isok(0,qi[ii],&ni,n)){
      cout << "yes" << endl;
    }
    else{
      cout << "no" << endl;
    }
  }
  
  return 0;
}



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


int main(){
    int a, b;
    cin >> a >> b;
    vector<int> aa(b), bb(a);
    rep(i, b){
        aa.at(i)=a;
    }
    rep(i, a){
        bb.at(i)=b;
    }
    if(a<=b){
        rep(i, b){
            cout << aa.at(i);
        }
        cout << endl;
    }
    else{
        rep(i, a){
            cout << bb.at(i);
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n,m;cin>>n>>m;
    long long sum=0;
    for(int i=0;i<m;i++){
        int no;cin>>no;
        sum+=no;
    }
    if(sum>n) cout<<"-1";
    else cout<<(n-sum);
}

Measured memory_bytes: 3644
//hi
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long int LL;
struct E{
	int tp;
	int c;
	bool operator<(const E x){
		return c<x.c;
	}
}e[300000];
int main(void){
    int w,h;
    scanf("%d%d",&w,&h);
    int i;
    for(i=0;i<w;i++){
		scanf("%d",&e[i].c);
		e[i].tp=0;
	}
	for(i=0;i<h;i++){
		scanf("%d",&e[i+w].c);
		e[i+w].tp=1;
	}
	sort(e,e+(w+h));
	int nw=0,nh=0;
	LL tot=0;
	for(i=0;i<w+h;i++){
		if(e[i].tp==0){
			tot+=(LL)e[i].c*(h+1-nh);
			nw++;
		}else{
			tot+=(LL)e[i].c*(w+1-nw);
			nh++;
		}
	}
	printf("%lld\n",tot);
    return 0;
}


Measured memory_bytes: 1792
n, m, q = gets.strip.split.map(&:to_i)
lr = m.times.map { gets.strip.split.map(&:to_i)}
pq = q.times.map { gets.strip.split.map(&:to_i)}

cum_table = Array.new(n+1) { [0]*(n+1) }

lr.each do |l, r|
  cum_table[l][r] += 1
end

(1..n).each do |i|
  (1...n).each do |j|
    cum_table[i][j+1] = cum_table[i][j] + cum_table[i][j+1]
  end
end

(1..n).each do |j|
  (1...n).each do |i|
    cum_table[i+1][j] = cum_table[i][j] + cum_table[i+1][j]
  end
end

pq.each do |p, q|
  p cum_table[q][q] - cum_table[q][p-1] - cum_table[p-1][q] + cum_table[p-1][p-1]
end



Measured memory_bytes: 48052
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;

int get_where_organ(vector<int> v, int organ) {
	for (int i = 0; i < v.size(); i++) {
		if (v[i] == organ)return i;
	}
}
int main() {
	vector<int> group, correct,priorities,organ_nums; int g, c,organ_num;
	while(true){//??´???????????¨??£?§£??°????????????????????£??\
		scanf("%d,%d", &g, &c);
		if (g == 0 && c == 0)break;
		group.push_back(g); correct.push_back(c);
	}
	for (int i = 0;i<correct.size()-1 ; i++) {//group??¨correct???????????????????????????????????????????????????
		for (int j = correct.size() - 1; i < j; j--) {
			if (correct[j] > correct[j - 1]) {
				int num_org = correct[j]; int num_gro = group[j];
				correct[j] = correct[j - 1]; group[j] = group[j - 1];
				correct[j - 1] = num_org; group[j - 1] = num_gro;
			}
		}
	}
	 //??£?§£??°?????????????????????????????????
	int priority = 1; priorities.push_back(priority);
	for (int i = 1; i < group.size(); i++) {
		if (correct[i] == correct[i - 1]){priorities.push_back(priority);
	}
		else {
			priority++; priorities.push_back(priority);
		}
	}
	while(cin>>organ_num){//??????????¬?????????´???????????????????????????
		organ_nums.push_back(organ_num);
	}
	for (int i = 0; i < organ_nums.size(); i++) {
		cout << priorities[get_where_organ(group,organ_nums[i])] << endl;
	}
	return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans = 0;
    int mode = -1;
    for(int i=0;i<n;i++){
        if(i==n-1) {ans++; break;}
        if(mode == -1){
        if(a[i+1]==a[i]) continue;
        if(a[i+1]>a[i]) mode = 1;
        else mode = 0;
        }
        if(mode==1&& a[i+1]<a[i]){
            ans++; mode = -1; continue;
        }
        if(mode == 0&& a[i+1]>a[i]){
            ans++; mode = -1; continue;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
a.sort()

for i in range(n):
    if a[i]>=a[-1]//2:
        break
if abs(a[-1]/2-a[i-1])<=abs(a[-1]/2-a[i]):
    print(a[-1],a[i-1])
else:
    print(a[-1],a[i])


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

void print_array(int n, int a[])
{
    for(int i=0;i<n;i++)
    {
        cout << a[i];
        if(i!=n-1) cout << " ";
    }
    cout << endl;
}

int main()
{
    int n, count=0;
    cin >> n;
    //n=5;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    //a[0]=5;
    //a[1]=3;
    //a[2]=2;
    //a[3]=4;
    //a[4]=1;

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


Measured memory_bytes: 3088
from collections import deque

H,W = map(int,input().split())
_input = []
for i in range(H):
    row = list(map(str,input().split()))
    _input.append(list(row[0]))

sy,sx = 0,0
gy,gx = H-1,W-1

queue = deque([(sy,sx)])

dyx=((1,0),(-1,0),(0,1),(0,-1))

counted_map = [[-1]*W for _ in range(H)]
counted_map[sy][sx] = 0

reach = False

while queue:
    y,x = queue.popleft()

    if (y,x) == (gy,gx):
        reach = True
        break

    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue

        # 空きマスかつ未訪問
        if _input[ny][nx] == '.' and counted_map[ny][nx] == -1:
            counted_map[ny][nx] = counted_map[y][x] + 1
            queue.append((ny,nx))

if not reach:
    print(-1)
    exit()
'''
y,x = gy,gx
move_num = counted_map[gy][gx]
while move_num != 0:
    _input[y][x] = 'o'
    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue
        
        if _input[ny][nx] == '.':
            tmp_dist = counted_map[ny][nx]
            if tmp_dist < move_num:
                move_num = tmp_dist
                next_y,next_x = ny,nx
    
    y,x = next_y,next_x

_input[sy][sx] = 'o'
'''

res = 0

for raw in _input:
    for i in raw:
        if i == '.':
            res += 1

print(res-counted_map[gy][gx]-1)

Measured memory_bytes: 3316
#include <stdio.h>

void dividing_student(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100 || ((pm + pe) / 2 >= 90) || ((pm + pe + pj) / 3 >= 80)) {
        printf("A\n");
    }
    else if (((pm + pe + pj) / 3 >= 70) || (((pm + pe + pj) / 3 >= 50) && (pm >=80 || pe >= 80))) {
        printf("B\n");
    }
    else {
        printf("C\n");
    }
}

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            scanf("%d %d %d", &pm, &pe, &pj);
            dividing_student(pm, pe, pj);
        }    
        scanf("%d", &n);
    }
    return 0;
}

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

int main(void){
  int n, res;
  double buf;
  while(cin >> n){
    res = 0;
    for(int i=0;i<=600-n;i+=n){
      res += pow(i,2) * n;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3076
package main

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

func main() {
	sc := newScanner()
	N := sc.nextInt()
	M := sc.nextInt()
	K := sc.nextInt()
	ans := false
	for i := 0; i < N+1; i++ {
		for j := 0; j < M+1; j++ {
			black := 0
			black += i * M
			if j > 0 {
				black += j*N - i*j*2
			}
			if K == black {
				ans = true
			}
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

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

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}
	return result
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = 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; }
const long long INF = 1LL << 60;

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

    map<string,int> mp;

    rep(i,n){
        string s;
        cin >> s;

        mp[s]++;
    }

    int mx = 0;
    for(auto p: mp) mx = max(mx, p.second);
    for(auto p: mp){
        if(p.second != mx) continue;
        cout << p.first << endl;
    } 
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N; 
    cin >> N;
    vector<long long> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int Count = 0;
    for(int i = 0; i < N; i++){
        while(a[i] % 2 == 0){
            Count++;
            a[i] /= 2;
        }
    }
    cout << Count << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
int main() {
    auto primes = vector<int>();
    for (int n = 2; n <= 55555; n++) {
        if (n % 5 != 1) continue;
        auto prime = true;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                prime = false;
                break;
            }
        }
        if (prime) {
            primes.PB(n);
        }
    }
    int n;
    cin >> n;
    rep(i, n) {
        cout << primes[i] << ((i < n - 1) ? ' ' : '\n');
    }
}


Measured memory_bytes: 256