akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,X,M;

int pos[100010];
int num[100010];

signed main(){
	cin>>N>>X>>M;
	set<int> U;
	vector<int> v;
	int a=X;
	int t;
	bool flag=true;
	int sum=0;
	for(int i=0;i<N;i++){
		if(U.find(a)!=U.end()){
			t=i;
			flag=false;
			break;
		}
		pos[a]=i;
		U.insert(a);
		v.push_back(a);
		num[i+1]=num[i]+a;
		a=(a*a)%M;
	}
	if(flag){
		cout<<num[N]-num[0]<<endl;
		return 0;
	}
	int ans=num[pos[a]];
	ans+=(num[t]-num[pos[a]])*((N-pos[a])/(t-pos[a]));
	int l=(N-pos[a])%(t-pos[a])+pos[a];
	ans+=num[l]-num[pos[a]];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class CodeABC138B
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            Console.WriteLine(funcMain(s1,s2));

            Console.ReadKey();
        }

        static public string funcMain(string arg1, string arg2)
        {
            var N = int.Parse(arg1);
            var A = arg2.Split(' ');
            double ret = 0;
            foreach (var d in A.Select(s => double.Parse(s)))
            {
                ret += (1 / d);
            }

            return (1 / ret).ToString();
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B, X;
	cin >> A >> B >> X;

	if (A == X)
	{
		cout << "YES";
	}
	else if(A > X)
	{
		cout << "NO";
	}
	else
	{
		if (B > X - A)
		{
			cout << "YES";
		}
		else
		{
			cout << "NO";
		}
	}

	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <vector>
#include <map>
using namespace std;
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define ll long long 
#define ri register int
#define f(i,a,b) for(ri i=a;i<=b;i++)
#define rf(i,b,a) for(ri i=b;i>=a;i--)
const int N=1e5+10;
int n,cnt,ans;
int a[N],b[N],x[N],y[N];
bool vis[N];
vector<int>Q[N];
map<int,int>d;
inline void read(int &x) {
    x=0;int f=1;char c=getchar();
    while (c>'9'||c<'0') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') {x=x*10+c-'0';c=getchar();}
    x*=f;
}
void dfs(int x)
{
    vis[x]=1;
    for (int i=0;i<Q[x].size();i++) 
    	if (!vis[Q[x][i]]) dfs(Q[x][i]);
}
int main()
{
   	read(n);
    for (int i=1;i<=n;i++) {
        read(a[i]),a[n+1]^=a[i];
        if (!d[a[i]]) d[a[i]]=++cnt;
    }
    if (!d[a[n+1]]) d[a[n+1]]=++cnt;
    for (int i=1;i<=n;i++) {
        read(b[i]),b[n+1]^=b[i];
        if (!d[b[i]]) d[b[i]]=++cnt;
    }
    if (!d[b[n+1]]) d[b[n+1]]=++cnt;
    memcpy(x,a,sizeof x),memcpy(y,b,sizeof y);
    sort(x+1,x+n+2),sort(y+1,y+n+2);
    for (int i=1;i<=n;i++) 
    	if (x[i]!=y[i]) {printf("-1");return 0;}
    for (int i=1;i<=n+1;i++) 
    	a[i]=d[a[i]],b[i]=d[b[i]];
    for (int i=1;i<=n;i++) 
    	if (a[i]!=b[i]) ans++,Q[a[i]].push_back(b[i]);
    if (a[n+1]!=b[n+1]) Q[a[n+1]].push_back(b[n+1]);
    for (int i=1;i<cnt;i++) 
    	if (Q[i].size()&&!vis[i]) dfs(i),ans++;
    if (!vis[cnt]) ans++;
    printf("%d",ans-1);
}

Measured memory_bytes: 15232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
int num[N],nex[N][26],sum[N][26],cnt=1;
ll ans;
string s[N/5+5];
void add1(int x){
    int n=s[x].length();
    int now=1;
    for(int i=n-1;~i;i--){
        if(!nex[now][s[x][i]-'a'])
            nex[now][s[x][i]-'a']=++cnt;
        now=nex[now][s[x][i]-'a'];
    }
}
void add2(int x){
    int n=s[x].length();
    int now=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            if(s[x][i]-'a'==j)sum[i][j]=(i>0?sum[i-1][j]:0)+1;
            else sum[i][j]=(i>0?sum[i-1][j]:0);
        }
    }
    for(int i=n-1;~i;i--){
        for(int j=0;j<26;j++)
            if(sum[i][j]&&nex[now][j])
                num[nex[now][j]]++;
        now=nex[now][s[x][i]-'a'];
    }
}
void finds(int x){
    int n=s[x].length();
    int now=1;
    for(int i=n-1;~i;i--)
        now=nex[now][s[x][i]-'a'];
    ans+=num[now]-1;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        add1(i);
    }
    for(int i=1;i<=n;i++)
        add2(i);
    for(int i=1;i<=n;i++)
        finds(i);
    cout<<ans<<'\n';
    return 0;
}



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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=50001, M=(ll)1e9+1 ;
const int mod = (ll)1e9 +7;
// struct node{
//   ll prefixsum,suffixsum,bettersum,totalsum;
//   void create(ll val){
//     prefixsum=suffixsum=bettersum=val;
//   }
//   void Merge(node& a,node &b){
//     prefixsum=max(a.prefixsum,a.totalsum+b.prefixsum);
//     suffixsum=max(b.suffixsum,a.suffixsum+b.sum);
//     totalsum=a.totalsum+b.totalsum;
    
//   }
// }
//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}


int main(){
 ios_base::sync_with_stdio(0);
  ll i,n;
  cin >> n;
  vl h(n+1),ans(n+1);
  for(i=1;i<=n;i++)
    cin >> h[i];
  ans[1]=0,ans[0]=INT_MAX;
  for(i=2;i<=n;i++){
    ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]),ans[i-2]+abs(h[i]-h[i-2]));
    
  }
    cout << ans[n];
    return 0;
}



Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split(" ");
		long A = Long.parseLong(lines[0]);
		long B = Long.parseLong(lines[1]);

		if((A + B) % 2 == 0) {
			System.out.println((A + B) / 2);
		}
		else {
			System.out.println("IMPOSSIBLE");
		}
	}

}


Measured memory_bytes: 35792
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=1000000007
s='abcdefghijklmnopqrstuvwxyz'
n=ii1()
res=''
for i in range(1,100):
    if n<=26**i:
        n-=1
        for j in range(i):
            res+=chr(97+n%26)
            n//=26
        break
    else:
        n-=26**i
print(res[::-1])


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 10000000007;

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

int main() {
  int h,w;
  cin >> h >> w;
  char Map[h][w];
  for(int i = 0; i < h; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < w; j++) {
      Map[i][j] = s[j];
    }
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(Map[i][j] == '#') continue;
      int sum = 0;
      for(int vx = -1; vx <= 1; vx++) {
        for(int vy = -1; vy <= 1; vy++) {
          if(vx == 0 && vy == 0) continue;
          int ux = vx + j;
          int uy = vy + i;
          if(ux < 0 || uy < 0 || ux >= w || uy >= h) continue;
          if(Map[uy][ux] == '#') sum++;
        }
      }
      Map[i][j] = (char)(sum + '0');
    }
  }
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cout << Map[i][j];
    }
    cout << endl;
  }

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int i, j, n, v, a[100];
	scanf("%d", &n); /*1 <= n <= 100*/
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (j = 0; j < n - 1; j++)
		printf("%d ", a[j]);
	printf("%d\n", a[n-1]);
	for (i = 1; i < n; i++) {
		v = a[i];
		j = i - 1;
		while (j >= 0 && a[j] > v) {
			a[j + 1] = a[j];
			j--;
			a[j + 1] = v;
		}
		for (j = 0; j < n - 1; j++)
			printf("%d ", a[j]);
		printf("%d\n", a[n-1]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
ll A, B;

// if n%2==0で、n xor (n+1) = 1;

// 0始まりなことに注意
ll calc(ll num){
  if (num%4==3){
    return 0ll;
  }
  else if (num%4==0){
    return num;
  }
  else if (num%4==1){
    return 1ll;
  }
  else{
    return num+1ll;
  }
}

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

  cin >> A >> B;

  ll a = calc(A-1);
  ll b = calc(B);

  cout << (a^b) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[]{sc.nextInt(), sc.nextInt(), sc.nextInt()};
        a[0] -= a[2];
        int w = a[1] + a[2];
        System.out.println(a[0] / w);
    }
}


Measured memory_bytes: 23636
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ABC = []
for a in range(X):
    for b in range(Y):
        if (a + 1) * (b + 1) > K: break
        for c in range(Z):
            if (a + 1) * (b + 1) * (c + 1) > K: break
            ABC.append(A[a] + B[b] + C[c])
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])


Measured memory_bytes: 8708
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n, l;
  cin >> n >> l;
  int m = INF, sum = 0;
  for (int i = 0; i < n; i++) {
    int p = l + i;
    m = min(m, abs(p));
    sum += p;
  }
  int ans = 0;
  if (l < 0)
    ans = sum + m;
  else
    ans = sum - m;
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}

// end of Template

int a,b,c,sel;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>a>>b>>c;
    sel = a-b;
    c-=sel; c=max(0,c);
    cout<<c<<newl;
}


Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
typedef long long int ll;
#define SIZE(x) ((int)(x).size())
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
typedef pair<long long, long long> LP;
#define out cout
#define in cin

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; }
// template end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    in >> n;
    ll seet[100000] = {0};
    ll l, r;
    REP(i, n){
        in >> l >> r;
        seet[l-1] += 1;
        seet[r] -= 1;
    }
    ll ans = 0;
    ll num = 0;
    REP(i, 100000){
        num += seet[i];
        ans += num;
    }
    out << ans << endl;

}


Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

auto main() -> i32 {
	i64 x;
	scanf("%ld", &x);
	printf("%ld\n", 10 - (x / 200));
	return 0;
}


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

using namespace std;

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<long long ,long long >
#define ppll pair < pll , pll >
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define INF 1e18
#define eps 0.00001
#define le length
#define debug(n1) cout << n1 << endl
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
const ll N = 2e5 + 5;
const ll M = 1e7 + 5;
const ll mod = 1e18 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
ll BINARY_SEARCH(ll dp[] , ll n , ll key) {
    ll s = 1;
    ll e = n;
    while(s <= e) {
        ll mid = (s + e) / 2;
        if(dp[mid] == key) return mid;
        else if (dp[mid] > key) e = mid - 1;
        else s = mid + 1;
    }
    return -1;
}
string CONVERT_TO_BINARY(ll s) {
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}
bool PALIN(string s) {
    int i = 0;
    int j = s.le() - 1;
    while(i <= j) {
        if(s[i] != s[j]) return false;
        j-- , i++;
    }
    return true;
}
int main() {
    SPEED;
    cout.precision(8);
    cout << fixed;
    ll x , y , z;
    cin >> x >> y >> z;
    int cnt = 1;
    x -= 2 * z;
    x -= y;
    while(x > 0) {
        x -= (y + z);
        if(x >= 0){
            cnt++;
        }
        else break;
    }
    cout << cnt << endl;
    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);
	
	ll n, q;
	while(cin>>n>>q, n!=0){
		vector<pll> d(101, mp(0, 0));
		rep(i, n){
			ll m; cin>>m;
			rep(j, m){
				ll cday; cin>>cday;
				d[cday].fi--;
			}
		}
		rep(i, d.size()) d[i].se = i;
		sort(all(d));
		if (d[0].fi<=-q){
			cout << d[0].se << "\n";
		}else{
			cout << "0\n";
		}
	}
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;


int main() {
    ll n;
    cin >> n;
    ll a = 1;
    ll b = 1;
    ll c = 1;
    for(ll i = 0;i < n;++i){
        a *= 10;
        a %= BIG;
        b *= 9;
        b %= BIG;
        c *= 8;
        c %= BIG;
    }
    ll ans = a - (b * 2 - c);
    ans %= BIG;
    ans = (ans < 0) ? (BIG + ans) : ans;
    cout << ans << endl;
}




Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int n,m,tmp;
double sum=0;
std::vector<int> pt;
void solve(){
    sort(pt.begin(),pt.end());
    reverse(pt.begin(),pt.end());

    if(pt.at(m-1)>=sum/(4*m)) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

int main(){
    cin>>n>>m;
    rep(i,n){
        cin>>tmp;
        sum+=tmp;
        pt.emplace_back(tmp);
    }
    solve();
    return 0;
}


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

using namespace std;

#define int long long

int32_t main()
{
    int n, a, b;

    cin >> n >> a >> b;

    if(a > b || (n < 2 && a != b)) {
        cout << 0;
        return 0;
    }
    else if(a == b && n == 1) {
        cout << 1;
        return 0;
    }

    cout << (n - 2) * (b - a) + 1;


	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))

    sum_a = sum(a_list)

    limit = 1 / (4*m)

    sorted_a = sorted(a_list, reverse=True)
    count = 0
    for ai in sorted_a:
        ratio_ai = ai / sum_a

        if ratio_ai >= limit:
            count += 1
            if count >= m:
                print("Yes")
                exit()
            continue
        else:
            print("No")
            exit()



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 38384
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        //入力を受け取る
        int X = sc.nextInt();
        
        //下2桁を取り出す
        double get_1 = X/10.0/10.0;
        double get_2 = get_1 - Math.floor(get_1);
        int get_3 = (int)(Math.round(get_2*10*10));
        
        //下２桁を作るのに必要な商品の個数
        int count_105 = (int)(get_3/5);
        int countOther = get_3%5;
        if(countOther!=0) {
        	countOther += 100;
        }
        
        if(X>=105*count_105+countOther) {
        	System.out.println(1);
        }else {
        	System.out.println(0);
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long ret = 0;
	int n;
	cin>>n;
	vector<int>arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
	sort(arr.begin(),arr.end());
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			int index = (lower_bound(arr.begin(),arr.end(),arr[i]+arr[j])-arr.begin());
			ret+=index-(j+1);
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3636
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
def lcm(x, y):
    return (x * y) // gcd(x, y)

a, b, c, d = map(int, input().split())
l = lcm(c, d)
bad = (b // c) - ((a-1) // c) + (b // d) - ((a-1) // d) - (b // l) + ((a-1) // l)
ans = b - a + 1 - bad
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stdio.h>
#include <cmath>

using namespace std;

typedef long long ll;
int a[100010];
int ans[100010];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	int maxn = a[n];
	int minn = a[1];
	for (int i = 2; i <= n-1; i++) {
		if (a[i] > 0) {
			ans[i] = minn;
			minn -= a[i];
		}
		else {
			ans[i] = maxn;
			maxn -= a[i];
		}
	}
	cout << maxn - minn << endl;
	for (int i = 2; i <= n - 1; i++) {
		cout << ans[i] << " " << a[i] << endl;
	}
	cout << maxn << " " << minn << endl;

	return 0;
}

Measured memory_bytes: 2688
program j01;
var t:array[0..100086]of longint;
    n,x,k,r,l,i,ans,tmp,c:longint;

procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
  i:=l;j:=r;x:=t[(i+j)div 2];
  repeat
    while t[i]<x do inc(i);
    while x<t[j] do dec(j);
    if i<=j then
    begin
      y:=t[i];t[i]:=t[j];t[j]:=y;
      inc(i);dec(j);
    end;
  until i>j;
  if i<r then qsort(i,r);
  if l<j then qsort(l,j);
end;

begin
  readln(n,c,k);
  for i:=1 to n do readln(t[i]);
  qsort(1,n);l:=1;
  inc(n);t[n]:=maxlongint;
  for i:=2 to n do
  begin
    while t[i]-t[l]>k do
    begin
      inc(ans);tmp:=c;
      while (l<=i-1)and(tmp>0) do
      begin
        inc(l);dec(tmp);
      end;
    end;
  end;
  writeln(ans);
end.

Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>

int main(){
    ll N;
    cin >> N;
    VL a(4,0);
    rep(i,0,N){
        string s;
        cin >> s;
        if(s=="AC")a[0]++;
        else if(s=="WA")a[1]++;
        else if(s=="TLE")a[2]++;
        else if(s=="RE")a[3]++;
    }
    cout << "AC x " << a[0] <<  endl;
    cout << "WA x " << a[1] <<endl;
    cout << "TLE x " << a[2]<<endl;
    cout << "RE x " << a[3] <<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 200010, P = 1000000007;

int n, m;
char s[N];

void add(int& x, int y) {
  if ((x += y) >= P)
    x -= P;
}

void sub(int& x, int y) {
  if ((x -= y) < 0)
    x += P;
}

int norm(int x) {
  return x >= P ? x - P : x;
}

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

  cin >> n >> m >> (s + 1);
  char a = s[1];
  if (count(s + 1, s + m + 1, a) == m) {
    static int dp[N][2][2];
    dp[1][0][0] = dp[1][1][1] = 1;
    for (int i = 2; i <= n; ++i)
      for (int j = 0; j < 2; ++j) {
        add(dp[i][j][0], dp[i - 1][j][0]);
        add(dp[i][j][0], dp[i - 1][j][1]);
        add(dp[i][j][1], dp[i - 1][j][0]);
      }
    int ans = norm(norm(dp[n][0][0] + dp[n][0][1]) + dp[n][1][0]);
    cout << ans << '\n';
    return 0;
  }
  int p = 1;
  while (s[p] == a) ++p;
  int len = p - 1;
  if (len % 2 == 0) ++len;
  int cur = 0;
  for (; p <= m; ++p)
    if (s[p] != a) {
      if (cur & 1)
        len = min(len, cur);
      cur = 0;
    } else
      ++cur;
  static int dp[N], sum[N];
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    sum[i - 1] = dp[i - 1];
    if (i - 3 >= 0)
      add(sum[i - 1], sum[i - 3]);
    dp[i] = sum[i - 2];
    if (i - len - 3 >= 0)
      sub(dp[i], sum[i - len - 3]);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    if ((n - i) <= len && ((n - i) & 1))
      ans = (ans + dp[i] * (n - i + 1LL)) % P;
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string s;
    cin >> s;
    int loop = s.size()/2;
    rep(i,loop){
        if(s.at(i) != s.at(s.size() - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    int loop_2 = ((s.size() - 1) / 2);
    //cout << loop_2 << endl;
    rep(i,loop_2 / 2){
        if(s.at(i) != s.at(loop_2 - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    int loop_3 = ((s.size() + 3) / 2);
    int sa = s.size() - loop_3;
    for(int i = loop_3 - 1;i < (sa / 2) + loop_3;i++){
        if(s.at(i) != s.at(s.size() - 1 - i)){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int N; cin >> N;
  auto A = vector<int>(N);
  for (int i = 0; i < N; ++i) cin >> A[i];
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) ans = max(ans, abs(A[i] - A[j]));
  }
  cout << ans << endl;
  return 0;
}


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

namespace B___ISU
{
    class Program
    {
        static void Main(string[] args)
        {
            var X_Y_Z = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var X = X_Y_Z[0];
            var Y = X_Y_Z[1];
            var Z = X_Y_Z[2];

            Console.WriteLine((X - Z) / (Y + Z));
        }
    }
}


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

int main(){
    int n;
    cin >> n;
    
    double aa,su;
    su=0;
    rep(i,n){
        cin >> aa;
        su+=1.0/aa;
    }


    printf("%.10f",1.0/su);
    
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

bool prm[100006]={};

bool isPrime(int p){
  /*p must be larger than 6*/
  int i=1;
  int n;
  if(p%2==0) return false;
  if(p%3==0) return false;
  if(p%5==0) return false;
  while(p>6*i){
    n=6*i+1;
    if(prm[n]){
      if(p%n==0) return false;
    }
    n=6*i+5;
    if(prm[n]){
      if(p%n==0) return false;
    }
    i++;
  }
  return true;
}
int main() {
  int cnt[100006]={};
  int q,r,l,i,n;
  prm[2]=true;
  prm[3]=true;
  prm[5]=true;
  i=1;
  while(6*i<100000){
    n=6*i+1;
    prm[n]=isPrime(n)
    ;n=6*i+5;
    prm[n]=isPrime(n);
    i++;
  }
  for(int j=3;j<100001;j++){
    cnt[j]=cnt[j-1];
    if((j%2==1)&&prm[j]&&prm[(j+1)/2]){
      cnt[j]++;
    }
  }
  cin>>q;
  for(int j=0;j<q;j++){
    cin>>l>>r;
    cout<<cnt[r]-cnt[l-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void){
        int x,y;
        scanf("%d %d",&x,&y);
        if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
          if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            printf("Yes\n");
          }
          else{
            printf("No\n");
          }
       }
       else if(x==4||x==6||x==9||x==11){
                 if(y==4||y==6||y==9||y==11){
                   printf("Yes\n");
                 }
                 else{
                   printf("No\n");
                 }
       }
       else{
         printf("No\n");
       }
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

#define N 1000000
const int mod = 998244353;

int n;
int A[N+1];
int M[N+1];
int S[N+1];
int inv[N+1];

/*
\sum_{i<j} lcm(Ai,Aj)
\sum_{i<j} Ai Aj / gcd(Ai,Aj)
\sum_{d} 1/d \sum_{i<j: gcd(Ai, Aj) = d} Ai Aj

f(d) = \sum_{i,j: gcd(Ai, Aj) = d} Ai Aj
F(d) = \sum_{i,j: d | gcd(Ai, Aj)} Ai Aj
F(d) = \sum_{i,j: d | Ai, d | Aj)} Ai Aj
F(d) = (\sum_{i: d | Ai} Ai)^2
\sum_{d} 1/d \sum_{n: d|n} m(n/d) F(n)
\sum_{n} F(n) \sum_{d: d|n} 1/d m(n/d)
*/

int main(){
  int i, j, r, s;
  scanf("%d", &n);
  s = 0;
  for(i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    A[x]++;
    s += x;
    if(s >= mod) s -= mod;
  }
  inv[1] = 1;
  for(i=2;i<=N;i++) inv[i] = (long long) (mod - mod/i) * inv[mod%i] % mod;

  for(i=1;i<=N;i++){
    A[i] = (long long) i * A[i] % mod;
    for(j=2*i;j<=N;j+=i){
      A[i] = (A[i] + (long long) j * A[j]) % mod;
    }
  }

  for(i=1;i<=N;i++){
    A[i] = ((long long) A[i] * A[i]) % mod;
  }

  r = mod-s;
  for(i=N;i;i--){
    for(j=2*i;j<=N;j+=i){
      A[i] -= A[j];
      if(A[i] < 0) A[i] += mod;
    }
    r = (r + (long long) inv[i] * A[i]) % mod;
  }

  printf("%d\n", r&1?(r+mod)/2:r/2);

  return 0;
}


Measured memory_bytes: 8320
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> b(m);
    rep(i, m) cin >> b[i];
    ll readA = 0;
    ll readB = 0;
    ll cost = 0;
    // まず全部Aだとして計算
    while (readA < n && a[readA] + cost <= k)
    {

        cost += a[readA];
        ++readA;
    }
    ll best = readA;
    // Bを読めるだけ読み、Aを一冊捨ててもっかい計算
    while (readA >= 0)
    {

        while (readB < m && b[readB] + cost <= k)
        {
            cost += b[readB];
            ++readB;
            best = max(best, readA + readB);
        }
        --readA;
        if (readA >= 0)
        {
            cost -= a[readA];
        }
    }
    cout << best << endl;
}

Measured memory_bytes: 6044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
int main()
{
  int n;
  cin >> n;
  int h[n];
  ll val[n];
  for(int i = 0; i < n; i++) cin >> h[i];
  for(int i = 0; i < n; i++) cin >> val[i];
  ll tree[2*n];
  memset(tree, 0, sizeof(tree));
  for(int i = 0; i < n; i++)
  {
      int r = n + h[i] - 1;
      int l = n;
      ll res = 0;
      while( l<r){
        if(l&1) res = max(res, tree[l++]);
        if(r&1) res = max(res, tree[--r]);
        l >>= 1, r >>= 1;
        //cout << l << r << endl;
      }
      //cout << res << endl;
      r = n+h[i] - 1;
      for(tree[r]=res+val[i]; r > 1; r >>= 1) tree[r >> 1] = max(tree[r], tree[r^1]);

  }
  ll mx = 0;
  for(int i = n; i < 2*n; i++) mx = max(mx, tree[i]);
  cout << mx << endl;

}


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353
using namespace std;
typedef pair<llint, llint> P;
typedef pair<P, llint> E;

llint h, w;
char c[15][15];
bool used[15];
vector<P> vec;
llint center;

bool pal(string &s)
{
	llint n = s.size();
	for(int i = 0; i < n; i++){
		if(s[i] != s[n-1-i]) return false;
	}
	return true;
}

bool check()
{
	multiset<string> S;
	for(int x = 1; x <= w; x++){
		string s;
		for(int j = 0; j < vec.size(); j++) s += c[x][vec[j].first];
		if(center) s += c[x][center];
		for(int j = (int)vec.size()-1; j >= 0; j--) s += c[x][vec[j].second];
		S.insert(s);
	}
	bool flag = false;
	while(S.size()){
		string s = *S.begin();
		reverse(s.begin(), s.end());
		S.erase(S.begin());
		
		auto it = S.lower_bound(s);
		if(it != S.end() && *it == s) S.erase(it);
		else{
			if(flag) return false;
			if(!pal(s)) return false;
			flag = true;
		}
	}
	return true;
}

bool dfs()
{
	int p = 0;
	for(int y = 1; y <= h; y++){
		if(!used[y]){
			p = y;
			break;
		}
	}
	if(p == 0) return check();
	
	for(int y = p+1; y <= h; y++){
		if(used[y]) continue;
		
		used[p] = used[y] = true;
		vec.push_back(P(p, y));
		
		if(dfs()) return true;
		
		used[p] = used[y] = false;
		vec.pop_back();
	}
	return false;
}

int main(void)
{
	cin >> h >> w;
	for(int y = 1; y <= h; y++){
		for(int x = 1; x <= w; x++){
			cin >> c[x][y];
		}
	}
	
	if(h % 2){
		for(int i = 1; i <= h; i++){
			center = i;
			used[i] = true;
			if(dfs()){
				cout << "YES" << endl;
				return 0;
			}
			used[i] = false;
		}
	}
	else if(dfs()){
		cout << "YES" << endl;
		return 0;
	}
	
	cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 384
import sys
import math
def four_number(n,sum1,keta):
    ans=n//4
    amr=n%4
    sum1=sum1+amr*(math.pow(10,keta))
    keta=keta+1
    if(ans==0):
        return sum1
    else:
        return four_number(ans,sum1,keta)
        
    
i=0
sum1=0
keta=0
while i<2000:
    n=int(input())
    if(n==-1):
        break
    after_number=four_number(n,sum1,keta)
    print(round(after_number))



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

t = n
ans = ''
while t > 26:
    if t % 26 != 0:
        ans += chr(t % 26 + 96)
        t = int(t / 26)
    else:
        ans += 'z'
        t = int(t / 26) - 1

ans += chr(t + 96)
print(ans[::-1])

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
    cin>>n;
    ll h[25];
    for(int i=0;i<n;i++)cin>>h[i];
    ll count=1,max_h=h[0];
    for(int i=1;i<n;i++){
        if(h[i]>=max_h){
            count++;
            max_h=h[i];
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll X,Y;
    cin>>X>>Y;
    cout<<(X+Y/2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int res = 0;
		for(int i = 0;i < N;i++) {
			res += 800;
			if((i+1)%15==0) {
				res -= 200;
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
int ans[200][200];
int main()
{
	int H,W,n,i,a,t;
	scanf("%d%d%d",&H,&W,&n);
 	int h=1,w=1; 
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a);
		while(a)
		{
		ans[h][w]=i;
		if(h%2!=0)
		{
			if(w!=W)
				w++;
			else
				h++;
		}
		else
		{
			if(w!=1)
				w--;
			else
				h++;
		}
		a--;
	    }
	}
	for(h=1;h<=H;h++)
	{
		for(w=1;w<=W;w++)
			printf("%d ",ans[h][w]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e6 + 1;
const ll INF = 1e18 + 9;
const int B = 1e9 + 7;

int n;
vi g[N];
int c[N][21];

void dfs(int x, int p = -1) {
    for (auto to : g[x]) {
        if (to == p) continue;
        dfs(to, x);
        forn(i, 0, 20) c[x][i] += c[to][i];
    }
    int y = 21;
    for1(i, 20, 0) {
        if (c[x][i] > 1) break;
        if (!c[x][i]) y = i;
    }
    ++c[x][y];
    for1(i, y - 1, 0) c[x][i] = 0;
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n - 1) {
        int f, t;
        cin >> f >> t;
        g[f].pb(t);
        g[t].pb(f);
    }

    dfs(1);
    int ans = 0;
    forn(i, 0, 20)
        if (c[1][i]) ans = i;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 67584
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

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

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

	int N;
	
	cin >> N;

	int a[N];

	rep(i, N)
	{
		cin >> a[i];
	}

	sort(a, a+N);

	cout << a[N-1] - a[0] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
unsigned long long p;
unsigned long long quick(unsigned long long a,unsigned long long b)
{
	if(b==1)
		return a;
	unsigned long long ret=quick(a,b/2);
	if(b%2==1)
		return ret*ret*a;
	return ret*ret;
}
int main()
{
	int n;
	unsigned long long pp=2,ans=1,tmp;
	scanf("%d%lld",&n,&p);
	if(n==1)
	{
		printf("%lld",p);
		return 0;
	}
	while(p!=1)
	{
		tmp=quick(pp,n);
		if(p<tmp||tmp==0)
			break;
		while(p%tmp==0)
		{
			p/=tmp;
			ans*=pp;
			if(p<tmp)
				break;
		}
		pp++;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll MAX_N=1e18;
int n,m;
struct edge{ll to,cost1,cost2;};
vector<edge> G[100010];
ll d1[100010];
ll d2[100010];

void dijkstra1(int s){
  priority_queue<llP,vector<llP>,greater<llP>> que;
  fill(d1,d1+n,MAX_N);
  d1[s]=0;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();que.pop();
    ll v=p.second;
    if(d1[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d1[e.to]>d1[v]+e.cost1){
        d1[e.to]=d1[v]+e.cost1;
        que.push(P(d1[e.to],e.to));
      }
    }
  }
}

void dijkstra2(int s){
  priority_queue<llP,vector<llP>,greater<llP>> que;
  fill(d2,d2+n,MAX_N);
  d2[s]=0;
  que.push(P(0,s));
  while(!que.empty()){
    P p=que.top();que.pop();
    ll v=p.second;
    if(d2[v]<p.first) continue;
    for(int i=0;i<G[v].size();i++){
      edge e=G[v][i];
      if(d2[e.to]>d2[v]+e.cost2){
        d2[e.to]=d2[v]+e.cost2;
        que.push(P(d2[e.to],e.to));
      }
    }
  }
}

int main() {
  cin>>n>>m;
  int s,t;
  cin>>s>>t;
  for(int i=0;i<m;i++){
    edge e1,e2;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;b--;
    e1.to=b;e1.cost1=c;e1.cost2=d;
    e2.to=a;e2.cost1=c;e2.cost2=d;
    G[a].push_back(e1);
    G[b].push_back(e2);
  }
  dijkstra1(s-1);
  dijkstra2(t-1);
  ll ans=0;
  ll memo[n];
  for(int i=0;i<n;i++){
    ans=max(ans,1000000000000000-(d1[n-1-i]+d2[n-1-i]));
    memo[n-1-i]=ans;
  }
  for(int i=0;i<n;i++){
    cout<<memo[i]<<endl;
  }
  return 0;
}


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

int main(){
	string s;
  	cin >> s;
  	int ans=10000;
  	for(int i=0;i<s.size()-2;i++){
    	ans=min(ans,abs(753-stoi(s.substr(i,3))));
    }
  	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>a(N),b(N);
    int suma = 0,sumb = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        suma += a[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> b[i];
        sumb += b[i];
    }
    if(suma > sumb) {
        cout << "No" << endl;
        return 0;
    }
    int res = 0;
    for(int i = 0; i < N; i++) {
        if(a[i] < b[i]) {
            res -= (b[i]-a[i]+1)/2;
            res += (b[i]-a[i])%2;
        }
        else if(a[i] > b[i]) {
            res += a[i]-b[i];
        }
    }
    if(res <= 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;++i)
#define fos(j,i,n) for(int j=i;j<n;++j)
#define N 100004
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define M 1000000007
#define ll long long
#define abs(x) (x<0?(-x):x)
#define dis(k) cout << k << endl
#define forr(i,n) for(int i= n-1;i>=0;--i)
#define min(x,y) (x<y?x:y)
#define max(x,y) (x>y?x:y)
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
 
int main(){
	fast;
	int t;
	t=1;
	//cin >> t;
	while(t--){
		 ll int h,a,in;
		cin >> h >>a;
		ll int s=0;
		fo(i,a){
			cin >> in;
			s+=in;
		}
		if(s>=h)
		dis("Yes");
		else
		dis("No");
	}
	return 0;
}


Measured memory_bytes: 256
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
  rep(i,3) cout<<str[i];

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();

    int ans = -1;

    for(int i = 0; i <= 1000; i++){
      int tax_a = (i * 8) / 100;
      int tax_b = (i * 10) / 100;

      if(tax_a == a && tax_b == b){
        ans = i;
        break;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,t[210],v[210],r[210],ma[40010],now,sum;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>t[i];
        t[i]*=2;
        r[i+1]=r[i]+t[i];
    }
    fill(ma,ma+r[n]+1,INF);
    ma[0]=ma[r[n]]=0;
    rep(i,n){
        cin>>v[i];
        v[i]*=2;
        for(int j=r[i];j<=r[i+1];j++)ma[j]=min(ma[j],v[i]);
    }
    for(int i=40000;i>=0;i--){
        ma[i]=min(ma[i],ma[i+1]+1);
    }
    for(int i=1;i<=r[n];i++){
        int next=min(now+1,ma[i]);
        sum+=(now+next);
        now=next;
    }
    printf("%.12lf\n",(double)sum/8);
    return 0;
}

Measured memory_bytes: 640