akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; ++i)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define PB push_back
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> Point;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cerr << #x << " = " << (x) << "\n"
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int n, m, a[ 100 ], b[ 100 ][ 100 ];

void input() {
  scanf( "%d %d", &n, &m );
  for ( int i = 0; i < m; i++ ) {
    scanf( "%d", &a[ i ] );
  }
  for ( int i = 0; i < m; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      scanf( "%d", &b[ i ][ j ] );
    }
  }
}

void solve() {
  int ans[ 100 ] = {};
  for ( int i = 0; i < m; i++ ) {
    int x = 0;
    for ( int j = 0; j < n; j++ ) {
      ans[ j ] += a[ i ] == b[ i ][ j ];
      x += a[ i ] != b[ i ][ j ];
    }
    ans[ a[ i ] - 1 ] += x;
  }
  for ( int i = 0; i < n; i++ ) {
    printf( "%d\n", ans[ i ] );
  }
}

int main() {
  input();
#ifdef WIN32
  clock_t stime = clock();
#endif
  solve();
#ifdef WIN32
  clock_t etime = clock();
  fprintf(stderr,"TIME : %f\n", ( double ) ( etime - stime ) / CLOCKS_PER_SEC);
#endif
  return 0;
}

Measured memory_bytes: 1228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main  implements Runnable {

    public static void main(String[] args) {

        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

    }

    public void run() {
    	FastScanner sc = new FastScanner(System.in);
		//long n = Long.parseLong(sc.next());
    	//int[] ar = new int[3];
    	//ar[0]=Integer.parseInt(sc.next());
    	//ar[1]=Integer.parseInt(sc.next());
    	//ar[2]=Integer.parseInt(sc.next());
    	//Arrays.parallelSort(ar);
		int n = Integer.parseInt(sc.next());
		//int k = Integer.parseInt(sc.next());
		//int l = Integer.parseInt(sc.next());
		//long a = Long.parseLong(sc.next());
		//String s = sc.next();
		//int k = Integer.parseInt(sc.next());
		//int m = Integer.parseInt(sc.next());
		//int x2000 = Integer.parseInt(sc.next());
		//int t = Integer.parseInt(sc.next());
		//int k = 0;
		//int k = Integer.parseInt(sc.next());
		//String str = sc.next();
		//char c[] = str.toCharArray();
		//char a[][] = new char[n];
		//int atmp[] = new int[h];
		//int max= 0;
		//int blackar[][] = new int[h*w][2];
		//int p=0;
		//ArrayList<Integer> lists = new ArrayList<Integer>();
		//lists = new ArrayList;
		PrintWriter out = new PrintWriter(System.out);
		int[] a = new int[n];
		int ans = 0;
		for(int i = 0; i< n; i++)
		{
			a[i] = Integer.parseInt(sc.next());
		}
		Arrays.parallelSort(a);
		out.println(a[n/2]-a[n/2-1]);


		out.flush();
	}

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;
        public FastScanner(String in) {
        	StringReader sr = new StringReader(in);
            reader = new BufferedReader(new BufferedReader(sr));
            tokenizer = null;
        }
        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long nextInt() {
            return Integer.parseInt(next());
        }

    }


}

Measured memory_bytes: 34708
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,ans;
  ans=400000001;
  cin>>n>>k;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i+k-1<n;i++){
    if(x[i]<0&&x[i+k-1]>0){ans=min(ans,min(abs(x[i])+2*x[i+k-1],2*abs(x[i])+x[i+k-1]));}
    else if(x[i]<0){ans=min(ans,abs(x[i]));}
    else{ans=min(ans,x[i+k-1]);}
  }
  cout<<ans;
}


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

#define F first
#define S second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define in(x) insert(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) (int)(s.size())
#define all(x) x.begin(), x.end()
#define did_you_calis_enough ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define int long long

using namespace std;

const int INF =  4294967295;
const int  N = 2e6 + 667;
const int mod = 1e9 + 7;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double PI = acos(-1.0);


main() {
	did_you_calis_enough
	int a, b;
	cin >> a >> b;
	cout << a * b;
}

//Coded by LoliThief

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  llt x;
  cin>>x;
  rep(i, 1, 100000)
  {
    llt z = (i*(i+1)) / 2;
    if(z >= x){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


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

using ll = long long;

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int k;
	string s;
	cin>>k>>s;

	if(int(s.size())<=k)
	{
		cout << s << endl;
		return 0;
	}

	for(int i=0; i<k; i++) cout << s[i];
	cout << "..." << endl;
}

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

int main() {
  int N, K, h;

  cin >> N >> K;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> h;
    if (h >= K) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {

  int A;
  int B;
  int X;

  std::cin >> A >> B >> X;

  //if (B >= X && A <=  X) {
  if (A <=  X) {
    
    if(B>=X-A){
      std::cout << "YES" << std::endl;
    }else{
      std::cout << "NO" << std::endl;
    }
    
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
# print(NM)
if N == 1 and M == 1:
    print(1)
elif N == 1 and M > 1:
    print(M-2)
elif M == 1 and N > 1:
    print(N-2)
elif N >= 2 or M >= 2:
    print((N-2)*(M-2))


Measured memory_bytes: 2940
N=int(input())
S=[]
T=[]
total=0
for i in range(N):
    s,t=map(str,input().split())
    t=int(t)
    total+=t
    S.append(s)
    T.append(t)
X=input()
flag=True
a=0
j=0
while flag:
    a+=T[j]
    if S[j]==X:
        flag=False
    j+=1
print(total-a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bitset <4050> a,b,c; int n,m,ans,h[4050],p,fl,mo=998244353;
int main(){
	cin>>n; cin>>a;
	for (int i=1;i<=n;++i)
		for (cin>>c;c.any();swap(b,c)){
			for (p=4000;;--p) if (c[p]) break;
			for (int j=4000;j>=p;--j) if (b[j]) b^=c<<j-p;
		}
	for (p=4000;;--p) if (b[p]) break;
	c=a; h[0]=fl=1;
	for (int i=1;i<=4000;++i) h[i]=h[i-1]*2%mo;
	for (int i=p;i<4001;++i)
	if (a[i]) (ans+=h[i-p])%=mo;
	for (int i=4000;i>=p;--i) if (a[i]) a^=b<<i-p;
	for (int i=p;~i;--i)
	if (a[i]) {fl=c[i]; break;}
	printf("%d\n",(ans+fl)%mo);
	return 0;
}

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

void solve(long long N, std::vector<std::string> S)
{
    long long cnt_ac = 0, cnt_wa = 0, cnt_tle = 0, cnt_re = 0;
    for (long long i = 0; i < N; i++)
    {
        if (S[i] == "AC")
            cnt_ac++;
        else if (S[i] == "WA")
            cnt_wa++;
        else if (S[i] == "TLE")
            cnt_tle++;
        else if (S[i] == "RE")
            cnt_re++;
    }

    cout << "AC x " << cnt_ac << endl;
    cout << "WA x " << cnt_wa << endl;
    cout << "TLE x " << cnt_tle << endl;
    cout << "RE x " << cnt_re << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 6444
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("../input.txt", "r", stdin);

    string s;
    cin >> s;

    int global_cnt = 0;
    int cur_cnt = 0;

    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == 'R'){
            cur_cnt++;
            global_cnt = max(global_cnt,cur_cnt);
        }else{
            global_cnt = max(global_cnt,cur_cnt);
            cur_cnt = 0;
        }
    }

    cout << global_cnt;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// abc129c
int main(){
    int n, m;
    cin >> n >> m;
    int a[m+1];
    rep(i, m) cin >> a[i];
    ll dp[n+2];
    rep(i, n+2) dp[i] = -1;
    rep(i, m){
        int tmp = a[i];
        dp[a[i]] = 0;
    }
    dp[0] = 1;
    if (dp[1]!=0) dp[1] = 1;
    for(int i=2; i<=n+1; i++){
        if (dp[i]==0) continue;
        dp[i] = dp[i-1] + dp[i-2];
        dp[i] %= mod;
    }
    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int change(int a,int b,int c){
  return a*3600+b*60+c;
}
void printtime(int x){
  cout<<x/3600<<' '<<x/60%60<<' '<<x%60<<endl;
}
int main(){
  int a,b,c,x,y,z;
  for(int i=0;i<3;i++){
    cin>>a>>b>>c>>x>>y>>z;
    printtime( change(x,y,z)-change(a,b,c) );
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <cmath>
#define int long long
using namespace std;

signed main() {
	int n;
	string s;
	
	cin >> n;
	for (int i = 0; n != 0; i++) {
		if (abs(n) % 2) {
			s += '1';
			if (i % 2 == 0) n--;
			else  n++;
		}
		else {
			s += '0';
		}
		n /= 2;
	}
	if (s.length() == 0) s += '0';
	
	for (int i = s.length() - 1; i >= 0; i--) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

int main(){
  int n,k,x,y;
  int sum =0;
  cin >> n >> k >> x >> y;
  int i=0;
  for(i=1;i<=n;i++){
    if(i<=k){
      sum +=x;
    }else if(k<i){
      sum += y;
    }
  }

  cout << sum <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場


//main
int main() {
	input();
	i64 n;
	cin >> n;
	map<i64, i64> ball;
	vector<i64> no(n);
	ff(i, 1, n+1) {
		ball[i] = 0;
	}
	ff(i, 0, n) {
		cin >> no[i];
		ball[no[i]]++;
	}
	i64 ans = 0;
	ff(i, 0, n + 1) {
		//cout << ball[i] << endl;
		if (ball[i] > 1) {
			ans += (ball[i] * (ball[i] - 1)) / 2;
		}
	}
	ff(i, 0, n) {
		cout << ans - ball[no[i]] + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 16640
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
vector<vector<int>> v;


int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w];
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++){
            cin >> a[i][j];
        }
    }
    queue<pair<int,int>> q;
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            if (i%2){
                q.push(make_pair(i,j));
            }
            else {
                q.push(make_pair(i,w+1-j));
            }
        }
    }
    int flg=0;
    int x_wait=0,y_wait=0;
    for (int i=0; i<h*w; i++){
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        if (a[x-1][y-1]%2==1 && flg==0){
            flg=1;
            x_wait=x;
            y_wait=y;
        }
        else if(a[x-1][y-1]%2==0 &&flg==1){
            v.push_back({x_wait,y_wait,x,y});
            x_wait=x,y_wait=y;
        }
        
        else if (a[x-1][y-1]%2==1 && flg==1){
            v.push_back({x_wait,y_wait,x,y});
            flg=0;
        }
    }
    cout << v.size()<<endl;
    for (int i=0; i<v.size(); i++){
        cout << v[i][0] << " " << v[i][1] << " " << v[i][2] << " " << v[i][3] <<endl;
    }
  
  
}





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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vi r,g,b;
    rep(i,0,sz(s)-1){
        if(s[i]=='R') r.pb(i);
        else if(s[i]=='G') g.pb(i);
        else b.pb(i);
    }
    ll ans=(sz(r)*sz(b)*sz(g));
    rep(i,0,sz(r)-1){
        rep(j,1,n){
            if((r[i]-j)>=0 && (r[i]+j)<n){
                if(binary_search(all(g),r[i]-j) && binary_search(all(b),r[i]+j)) ans--;
                if(binary_search(all(g),r[i]+j) && binary_search(all(b),r[i]-j)) ans--;
            }
        }
    }
    rep(i,0,sz(g)-1){
        rep(j,1,n){
            if((g[i]-j)>=0 && (g[i]+j)<n){
                if(binary_search(all(r),g[i]-j) && binary_search(all(b),g[i]+j)) ans--;
                if(binary_search(all(r),g[i]+j) && binary_search(all(b),g[i]-j)) ans--;
            }
        }
    }
    rep(i,0,sz(b)-1){
        rep(j,1,n){
            if((b[i]-j)>=0 && (b[i]+j)<n){
                if(binary_search(all(g),b[i]-j) && binary_search(all(r),b[i]+j)) ans--;
                if(binary_search(all(g),b[i]+j) && binary_search(all(r),b[i]-j)) ans--;
            }
        }
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 3720
local function comp(a, b)
  return a < b
end

local function lower_bound(ary, x)
  local num = #ary
  if num == 0 then return 1 end
  if not comp(ary[1], x) then return 1 end
  if comp(ary[num], x) then return num + 1 end
  local min, max = 1, num
  while 1 < max - min do
    local mid = (min + max) // 2
    if comp(ary[mid], x) then
      min = mid
    else
      max = mid
    end
  end
  return max
end

local a, b, q = io.read("*n", "*n", "*n")
local s, t = {}, {}
for i = 1, a do
  s[i] = io.read("*n")
end
for i = 1, b do
  t[i] = io.read("*n")
end
local mab, mmi = math.abs, math.min
for iq = 1, q do
  local x = io.read("*n")
  ap = lower_bound(s, x)
  bp = lower_bound(t, x)
  local al = 1 < ap and s[ap - 1] or false
  local bl = 1 < bp and t[bp - 1] or false
  local ar = ap <= a and s[ap] or false
  local br = bp <= b and t[bp] or false
  local ret = 1000000007 * 100
  if al and bl then
    ret = mmi(ret, mab(x - al) + mab(al - bl), mab(x - bl) + mab(bl - al))
  end
  if al and br then
    ret = mmi(ret, mab(x - al) + mab(al - br), mab(x - br) + mab(br - al))
  end
  if ar and bl then
    ret = mmi(ret, mab(x - ar) + mab(ar - bl), mab(x - bl) + mab(bl - ar))
  end
  if ar and br then
    ret = mmi(ret, mab(x - ar) + mab(ar - br), mab(x - br) + mab(br - ar))
  end
  print(ret)
end


Measured memory_bytes: 11968
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    a = int(input().rstrip())
    b = int(input().rstrip())
    c = int(input().rstrip())
    x = int(input().rstrip())

    ans = 0
    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                if (i*500+j*100+k*50) == x:
                    ans += 1
    print(ans)




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 65016
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

const int MOD = 100000;

int w,h;
int memo[102][102][2][2];

// 位置,どっちから来たか,曲がれるか
int dfs(int x,int y,int dir, bool turn) {
    // printf("[debug] %d,%d,%d,%d\n", x,y,dir,turn);
    if(x==w && y==h) {
        return 1;
    }
    else if(x>w || y>h) {
        return 0;
    }

    if(memo[x][y][dir][turn] != -1) {
        return memo[x][y][dir][turn];
    }
    int res = 0;

    if(dir == 0) {
        // 下から
        if(turn) {
            // 曲がれる
            res += dfs(x+1,y,1,false) % MOD;
        }
        res += dfs(x,y+1,0,true) % MOD;

    }
    else {
        // 右
        if(turn) {
            res += dfs(x,y+1,0,false) % MOD;
        }
        res += dfs(x+1,y,1,true) % MOD;
    }

    return memo[x][y][dir][turn] = res;

}

void solve() {
    rep(i,102) rep(j,102) rep(k,2) memo[i][j][k][0] = memo[i][j][k][1] = -1;
    int ans;
    ans = dfs(1,1,0,false) % MOD;
    ans += dfs(1,1,1,false);
    ans %= MOD;
    cout<<ans<<endl;

}

int main() {
    while(cin>>w>>h) {
        if(w+h==0) break;
        solve();

    }
    return 0;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
const int MAX = 2222;

int B[MAX][MAX];
int W[MAX][MAX];

int fracB(int c,int d,int a,int b){
    if(c<a||d<b) return 0;
    return B[c][d]-B[c][b-1]-B[a-1][d]+B[a-1][b-1];
}
int fracW(int c,int d,int a,int b){
    if(c<a||d<b) return 0;
    return W[c][d]-W[c][b-1]-W[a-1][d]+W[a-1][b-1];
}

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,k; cin >> n >> k;
    rep(i,n){
        int x,y; cin >> x >> y;
        char c; cin >> c;
        x%=(2*k); y%=(2*k);
        if(c=='B') B[x+1][y+1]++;
        else W[x+1][y+1]++;
    }

    for(int i=1;i<=2*k;i++){
        for(int j=1;j<=2*k;j++){
            B[i][j]+=B[i-1][j]+B[i][j-1]-B[i-1][j-1];
            W[i][j]+=W[i-1][j]+W[i][j-1]-W[i-1][j-1];
        }
    }
    int ans=0;
    for(int i=1;i+k-1<=2*k;i++){
        for(int j=1;j+k-1<=2*k;j++){
            int res1=fracB(i+k-1,j+k-1,i,j)+fracB(2*k,2*k,i+k,j+k)+fracB(i-1,j-1,1,1)+fracB(2*k,j-1,i+k,1)+fracB(i-1,2*k,1,j+k)
            +fracW(i-1,j+k-1,1,j)+fracW(i+k-1,j-1,i,1)+fracW(2*k,j+k-1,i+k,j)+fracW(i+k-1,2*k,i,j+k);
            
            int res2=fracW(i+k-1,j+k-1,i,j)+fracW(2*k,2*k,i+k,j+k)+fracW(i-1,j-1,1,1)+fracW(2*k,j-1,i+k,1)+fracW(i-1,2*k,1,j+k)
            +fracB(i-1,j+k-1,1,j)+fracB(i+k-1,j-1,i,1)+fracB(2*k,j+k-1,i+k,j)+fracB(i+k-1,2*k,i,j+k);
            if(res1==5) cout << i << " " << j;
            chmax(ans,res1);
            chmax(ans,res2);
            
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 38360
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
ll n,ans,a,b,cnt,cn;
vector<P>v,v2;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(auto x:v){
        v2.push_back({x.first+x.second,-cnt});
        cnt++;
    }
    sort(v2.begin(),v2.end());
    reverse(v2.begin(),v2.end());
    for(auto x:v2){
        if(cn%2==0){
            ans+=v[-x.second].first;
        }
        else ans-=v[-x.second].second;
        cn++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4848
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = sc.next()
    println(problem110c(s, t))
}

fun problem110c(s: String, t: String): String {
    var ok = true
    val ma = mutableMapOf<Char, Char>()
    val ima = mutableMapOf<Char, Char>()
    for (i in 0 until s.length) {
        val si = s[i]
        val ti = t[i]
        if (ma.containsKey(si) && ma[si] != ti) ok = false
        if (ima.containsKey(ti) && ima[ti] != si) ok = false
        ma[si] = ti
        ima[ti] = si
    }
    return if (ok) "Yes" else "No"
}

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

int main(){
    int m,f,r;
    
   while(1){
       
       cin >> m >> f >> r;
       if(m+f+r == -3) break;
       
       if(m == -1 || f == -1){
           cout << "F" << endl;
       }
       else if(m+f >= 80){
           cout << "A" << endl;
       }
       else if(m+f >= 65){
           cout << "B" << endl;
       }
       else if(m+f >= 50){
           cout << "C" << endl;
       }
       else if(m+f < 30){
           cout << "F" << endl;
       }
       else{
           if(r >= 50){
               cout << "C" << endl;
           }
           else{
               cout << "D" << endl;
           }
       }
   }
    return 0;
}


Measured memory_bytes: 3108
function tabtostr(t, n)
  local s=""
  for i=1, n do
    s=string.format("%s%s", s, t[i])
  end
  return s
end

n=io.read("*n")
s={}
m={}
c=0

for i=1, n do
  si={}
  for j=1, 11 do
    table.insert(si, io.read(1))
  end
  table.sort(si, function(a, b) return a:upper() < b:upper() end)
  str=tabtostr(si, 11)
  if s[str]==nil then
    s[str]=0
    c=c+1
    table.insert(m, str)
  end
  s[str]=s[str]+1
end

ans=0
for i=1, c do
  n=s[m[i]]
  ans=ans+(n*(n-1)/2)
end

print(ans)

Measured memory_bytes: 16284
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	char c;
	cin >> c;
	if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')cout << "vowel";
	else cout << "consonant";
	cout << endl;
	return 0;
}


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

int main() {
    int n;
    while (cin >> n, n) {
        vector<pair<int, int>> target(n);
        vector<bool> flag(n);
        rep(i, n) cin >> target[i].first >> target[i].second;

        int x = 10, y = 10;
        set<pair<int, int>> st;
        st.insert({x, y});

        int m;
        cin >> m;
        rep(i, m) {
            char c;
            int d;
            cin >> c >> d;
            rep(j, d) {
                if (c == 'N')
                    y++;
                else if (c == 'S')
                    y--;
                else if (c == 'E')
                    x++;
                else
                    x--;
                st.insert({x, y});
            }
        }

        string ans = "Yes";
        rep(i, n) {
            if (st.find(target[i]) == st.end()) {
                ans = "No";
                break;
            }
        }

        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3108
import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
arr=[i for i in range(1,n+1)]
res_p=0
for i in range(n-1):
  res_p+=math.factorial(n-i-1)*(arr.index(p[i]))
  arr.remove(p[i])
arr=[i for i in range(1,n+1)]
res_q=0
for i in range(n-1):
  res_q+=math.factorial(n-i-1)*(arr.index(q[i]))
  arr.remove(q[i])
print(abs(res_p-res_q))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;


int main() {
    //read,write;
    string s;
    getline(cin,s);
    int sz = s.size();
    for(int i=0;i<sz;i++){
        if(s[i]>='a' && s[i]<='z') s[i]-=32;
        else if(s[i]>='A' && s[i]<='Z') s[i]+=32;
    }
    cout << s << endl;
   
 

    return 0;
}



Measured memory_bytes: 3140
/* In the name of Allah */
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n, L, a[N];

void readInput() {
	cin >> n >> L;
	for (int i = 0; i < n; i++)
		cin >> a[i];
}

void solve() {
	for (int i = 0; i < n - 1; i++)
		if (a[i] + a[i + 1] >= L) {
			cout << "Possible\n";
			for (int j = 0; j < i; j++)
				cout << j + 1 << endl;
			for (int j = n - 2; j != i; j--)
				cout << j + 1 << endl;
			cout << i + 1 << endl;
			return;
		}
	cout << "Impossible\n";
}

int main() {
	ios_base :: sync_with_stdio(false), cin.tie(0), cout.tie(0);
	readInput(), solve();
	return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin>>n)
    {
        if(n%2==0)
            cout<<n/2-1<<endl;
        else
            cout<<(n+1)/2-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * B - FizzBuzz Sum
 * FizzBuzz列 a1,a2,... を次のように定めます。
 * i が 3 でも 5 でも割り切れるなら、ai=FizzBuzz
 * そうではなく i が 3 で割り切れるなら、ai=Fizz
 * そうではなく i が 5 で割り切れるなら、ai=Buzz
 * そうではないなら、ai=i
 * FizzBuzz列の N 項目までに含まれる数の和を求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力された整数
        long n = sc.nextLong();

        // 入力値までの整数で3でも5でも割り切れない数の総和を求める
        long sum = 0;
        for( int i = 1; i <= n; i++ ) {
            if( i % 3 != 0 && i % 5 != 0 ) {
                sum += i;
            }
        }

        System.out.println( sum );

        sc.close();
    }
}


Measured memory_bytes: 35748
#include<iostream>
#include<cstdio>
#include<cmath>
#define _MATH_DEFINES_DEFINED
using namespace std;
double a,b,c,h;
int main()
{
	
	cin>>a>>b>>c;
	if(a*a*b>=2*c){
		h = c/(a*a*b)*2*a;
		printf("%.10lf", (double)atan(b/h)*180/M_PI);
	}
	else{
		h = (1-c/(a*a*b))*2*b;
		printf("%.10lf", (double)atan(h/a)*180/M_PI);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++11 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 9:15-
const int MAX_N=2e5+1;
int N;
LL A[MAX_N];
int L1[22],L2[22];

string n2bin(long long n) {
  assert(n>=0);
  string res="";
  while(n>0) res+=(n%2LL?'1':'0'),n/=2LL;
  return string(res.rbegin(), res.rend());
}

LL solve() {
  /*
  REP(i,N) {
    string x=n2bin(A[i]);
    dump2(i,x);
  }*/
  
  LL res=0;
  MINUS(L1),MINUS(L2);
  REP(i,N) {
    int x=N;
    REP(j,22) {
      int a=(A[i]&(1<<j))?L1[j]:L2[j];
//      dump4(i,L1[j],L2[j],a);
      SMIN(x,i-a);
      if(A[i]&(1<<j)) {
        L2[j]=L1[j];
        L1[j]=i;
      }
    }
//    dump2(i,x);
    res+=x;
/*
    int xx=1;
    REPE(j,i) {
      int ex=0,sum=0;
      FORE(k,j,i) ex^=A[k],sum+=A[k];
      if(ex==sum) {
        xx=i-j+1;
        break;
      }
    }
    if(xx!=x) {
      dumpAR(L2);
      dumpAR(L1);
      dump3(i,xx,x);
    }
    assert(xx==x);*/
  }
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  cout<<solve()<<endl;
  return 0;
}


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

using namespace std;

int main(){

    string s;

    cin>>s;

    if(s.size()<4){
        cout<<"No";
        return 0;
    }
    if(s[0]=='Y' && s[1]=='A' &&s[2]=='K' &&s[3]=='I'){
        cout<<"Yes";
    }else{
        cout<<"No";
    }

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin>>n;
	bool yes=false;
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			if (i*j==n){
				yes = true;
				break;
			}
		}
	}
	if (yes){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define max(a,b)((a)>(b)?(a):(b))
const int N=1e5+3;
struct edge{int v,nxt;}g[N];
int n,m,f[N],head[N],k,ans;
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
int Dfs(int u){
	if(f[u])return f[u];
	for(int i=head[u];i;i=g[i].nxt)
	  f[u]=max(f[u],Dfs(g[i].v)+1);
	return f[u];
}
signed main(){
	int u,v;
	scanf("%d%d",&n,&m);
	for(;m--;)scanf("%d%d",&u,&v),Insert(u,v);
	for(u=1;u<=n;u++)Dfs(u),ans=max(ans,f[u]);
	printf("%d",ans);
	return 0;
}

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

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int N;
    string S, T;
    cin >> N >> S >> T;

    string ans="";
    REP(i, N){
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

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

Measured memory_bytes: 256
q = int(input())
quest = [tuple(map(int, input().split())) for _ in range(q)]
for a, b in quest:
    m = a*b
    l = int((m - 1) ** (1/2))
    # check float
    if l * l >= m:
        l -= 1
    elif (l+1) * (l+1) < m:
        l += 1
    if a == b:
        print((a-1) * 2)
    elif (l+1) * l < m:
        print(l*2 - 1)
    else:
        print(l*2 - 2)


Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
	int n,a,card[52],i;
	char mark;
	for(i=0;i<52;i++) card[i]=0;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf(" %c%d", &mark, &a);
		a-=1;
		if(mark=='S') card[a]=1;
		else if(mark=='H') card[a+13]=1;
		else if(mark=='C') card[a+26]=1;
		else if(mark=='D') card[a+39]=1;
	}
 	for(i=0;i<52;i++){
		if(card[i]==0){
			if((i/13)==0) printf("S %d\n", i+1);
			else if((i/13)==1) printf("H %d\n", i%13+1);
			else if((i/13)==2) printf("C %d\n", i%13+1);
			else if((i/13)==3) printf("D %d\n", i%13+1);
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(void){
	int card[14] , buf[5] = {0} , i , flag , check_3 , cnt;
	while(scanf("%d,%d,%d,%d,%d" , &buf[0] , &buf[1] , &buf[2] , &buf[3] , &buf[4])!=EOF){
		for(i=1;i<14;i++){
			card[i] = 0;
		}
		for(i=0;i<5;i++){
			card[buf[i]]++;
		}
		flag = 0;
		check_3 = 0;
		cnt = 0;

		for(i=1;i<=13;i++){
			if(card[i] == 4){
				printf("four card\n");
				flag = 1;
			}
			if(card[i] == 3){
				check_3 = 1;
			}
		}
		if(flag) continue;

		if(check_3){
			for(i=1;i<=13;i++){
				if(card[i] == 2){
					printf("full house\n");
					flag = 1;
				}
			}
		}
		if(flag) continue;

		for(i=1;i<=9;i++){
			if(card[i]==1&&card[i+1]==1&&card[i+2]==1&&card[i+3]==1&&card[i+4]==1){
				printf("straight\n");
				flag = 1;
			}
		}
		if(flag) continue;
		if(card[10]==1&&card[11]==1&&card[12]==1&&card[13]==1&&card[1]==1){
			printf("straight\n");
			continue;
		}

		if(check_3){
			printf("three card\n");
			continue;
		}

		for(i=1;i<=13;i++){
			if(card[i] == 2) cnt++;
		}
		if(cnt == 2){
			printf("two pair\n");
			continue;
		}

		if(cnt == 1){
			printf("one pair\n");
			continue;
		}

		printf("null\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <cmath>
#include <cstdio>
#include <limits>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <string>
#include <array>
#include <iomanip>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = n-1; i >= 0; --i)
#define REP(i, s, n) for (int i = s; i< (int)(n); ++i)
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;

template<class Len = int>
class Dijkstra {
 private:
  int n;
  std::vector<std::vector<std::pair<int, Len> > > edges;
 public:
  explicit Dijkstra(int n) : n(n), edges(n) {}

  void add_edge(int from, int to, Len cost) {
    edges[from].push_back(std::pair<int, Len>(to, cost));
  }

  std::vector<Len> solve(int source) {
    const Len inf = 1e16;
    typedef std::pair<Len, int> pi;
    std::vector<Len> d(n, inf);
    std::priority_queue<pi, std::vector<pi>, std::greater<pi> > que;
    que.push(pi(0, source));
    while (!que.empty()) {
      pi p = que.top();
      que.pop();
      int idx = p.second;
      if (d[idx] <= p.first) {
        continue;
      }
      d[idx] = p.first;
      for (int j = 0; j < edges[idx].size(); ++j) {
        que.push(pi(p.first + edges[idx][j].second, edges[idx][j].first));
      }
    }
    return d;
  }
};

void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, m, rr;
  ccin >> n >> m >> rr;
  vector<ll> r(rr);
  rep(i, rr) ccin >> r[i];

  Dijkstra<ll> dij1(n);
  rep(i, m) {
    ll a, b, c;
    ccin >> a >> b >> c;
    --a;
    --b;
    dij1.add_edge(a, b, c);
    dij1.add_edge(b, a, c);
  }
  ll2d vr(rr, ll1d(rr, 0));

  Dijkstra<ll> dij2(rr);
  rep(i, rr) {
    ll rrr = r[i];
    --rrr;
    ll1d v = dij1.solve(rrr);
    rep(j, rr) {
      vr[i][j] = v[r[j] - 1];
    }
  }

  ll ans = ll(1e18);
  vector<ll> nxt(rr);
  iota(all(nxt), 0);
  do {
    ll cnt = 0;
    rep(i, rr - 1) {
      cnt += vr[nxt[i]][nxt[i + 1]];
    }
    ans = min(ans, cnt);
  } while (next_permutation(all(nxt)));

  ccout << ans << endl;

}

int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

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

int main() {
        string s;
        ll k;
        cin >> s >> k;
        char ans = '1';
        for (ll i = 0; i < k; i++) {
                if (s[i] != '1') {
                        ans = s[i];
                        break;
                }
        }
        cout << ans << endl;
}


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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
// cout << fixed << setprecision(10) << PI << endl;
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

ll sum(vll &v){
    ll n = v.size(), ans = 0;
    REP(i,n) ans += v[i];
    return ans;
}

int main(){
    ll n, s, tmp;
    cin >> n;
    vll a(n), b(n,0), c(n,0);
    cin >> a;
    REP(i,n) a[i]--;
    REP(i,n) b[a[i]]++;
    REP(i,n) c[i]=b[i]*(b[i]-1)/2;
    s=sum(c);
    REP(i,n){
        tmp = c[a[i]]*2/b[a[i]];
        cout << s-tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 7296
import math
import itertools
import numpy as np

def cf(x1, x2):
    hoge = []
    for i in range(1,min(x1, x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            hoge.append(i)
    return hoge

def solve():
    a, b, k = map(int, input().split())
    print(cf(a, b)[-k])
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 12500
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll w,h,n; cin >> w >> h >> n;
    ll xl = 0, xr = w;
    ll yd = 0, yu = h;
    ll x,y,a;
    rep(i,n){
        cin >> x >> y >> a;
        if(a == 1) xl = max(xl,x);
        else if(a == 2) xr = min(xr,x);
        else if(a == 3) yd = max(yd,y);
        else yu = min(yu,y);
    }
    cout << max(0LL,xr-xl) * max(0LL,yu-yd) << endl;
}

Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
int a[10],b[111];
int main()
{
    int s=0;
    for(int i=1;i<=3;i++)
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=0;i<=111;i++)
    {
        if(b[i]>0)
        {
            s++;
        }
    }
    cout<<s;
}

Measured memory_bytes: 256