akhauriyash/Code-Regression huggingface dataset:
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let w = scan!();

    let mut m = HashMap::new();
    for c in w.chars() {
        let v = m.entry(c).or_insert(0);
        *v += 1;
    }

    for (_, n) in m {
        if n % 2 == 1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
import sys
from itertools import accumulate
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))

    ans = list(accumulate(A))[-1]

    B = [0 for _ in range(52)]
    for i in reversed(range(51)):
        cnt1 = 0
        for j in range(n):
            if A[j] & (1 << i):
                cnt1 += 1

        cnt0 = n - cnt1
        if cnt0 > cnt1:
            B[i] = (1 << i) * (cnt0 - cnt1)

    pre = 0
    maxV = 0

    for i in reversed(range(51)):
        if k & (1 << i):
            total = 0
            for j in range(i):
                total += B[j]
            total += pre
            maxV = max(maxV, total)
            pre += B[i]

    maxV = max(maxV, pre)
    print(ans + maxV)


if __name__ == '__main__':
    resolve()


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

namespace _0118
{
    public class Program

    {

        public static char[,] map;
        public static bool[,] visited;
        public static int[] di = new int[] { 0, -1, 0, 1 };
        public static int[] dj = new int[] { 1, 0, -1, 0 };

        public static void Main(string[] args)
        {

            while (true)
            {
                int[] HW = RIntAr();
                if (HW.Sum() == 0) break;

                map = new char[HW[0] + 2, HW[1] + 2];
                visited = new bool[HW[0] + 2, HW[1] + 2];

                for (int i = 1 ; i < map.GetLength(0) - 1 ; i++)
                {
                    string line = RSt();
                    for (int j = 1 ; j < map.GetLength(1) - 1 ; j++)
                    {
                        map[i, j] = line[j - 1];
                    }
                }

                int cnt = 0;
                for (int i = 1 ; i < map.GetLength(0) - 1 ; i++)
                {
                    for (int j = 1 ; j < map.GetLength(1) - 1 ; j++)
                    {
                        if (!visited[i, j])
                        {
                            SetGroup(i, j, map[i, j]);
                            cnt++;
                        }
                    }
                }
                Console.WriteLine(cnt);
            }
        }

        private static void SetGroup(int vi, int vj, char type)
        {
            visited[vi, vj] = true;
            for (int i = 0 ; i < di.Count() ; i++)
            {
                if (!visited[vi + di[i], vj + dj[i]] && map[vi + di[i], vj + dj[i]] == type)
                {
                    SetGroup(vi + di[i], vj + dj[i], type);
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16784
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

void solve()
{
   ll n;
   cin>>n;
   double p[n];
   f(i,0,n)cin>>p[i];
   double dp[n+1][n+1];
   dp[0][0] = 1;
   f(i,1,n+1)dp[0][i]=0;
   f(i,1,n+1)
   {
      dp[i][0] = dp[i-1][0]*(1-p[i-1]);
   }
   double ans=0;
   f(i,1,n+1)
   {
      f(j,1,n+1)
      {
         dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
      }
   }
   f(i,1,n+1)
   {
      if(2*i>n)ans+=dp[n][i];
      // cout<<dp[n][i]<<" ";
   }
   // cout<<"\n";
   cout<<fixed<<setprecision(10)<<ans<<"\n";
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

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

int main() {
	int n,m,k;
	cin>>n>>m>>k;
	bool flg=false;
	for(int i=0;i<n+1;++i){
		for(int j=0;j<m+1;++j){
			if(k==(m*i+n*j-2*i*j))flg=true;
		}
	}
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner e = new Scanner(System.in);
		
		int r = e.nextInt();
		int d = e.nextInt();
		int x = e.nextInt();
		
		for(int i = 0; i < 10; i++)
		{
			x = r * x - d;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7') cout<<"Yes";
    else cout<<"No";

return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int a, b, ans;
bool check(int x) {
    string s = to_string(x);
    int i = 0, j = s.length() - 1;
    while (i < j) {
        if (s[i] != s[j]) return false;
        ++i;
        --j;
    }
    return true;
}
int main() {
    cin >> a >> b;
    for (int i = a; i <= b; ++i) {
        if (check(i))
            ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define ll long long
#define mod 1e9+7

using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
    ll n;
    cin>>n;
    if(n==1){
        cout<<0<<"\n";
        return 0;
    }
    ll ans=0;
    for(ll i=2; i<=sqrt(n); ++i){
        if(n%i==0){
            ll cnt=0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            for(ll j=1; j<=10000; ++j){
                if(cnt<j) break;
                else{
                    ans++;
                    cnt-=j;
                }
            }
        }
    }
    if(n>1) ans++;
    cout<<ans<<"\n";
}






Measured memory_bytes: 3704
#include <vector>
#include <iostream>
#include <string>


using namespace std;

const float rate = 380000.0f;
int main () 
{
    int count = 0;
    cin >> count;
    float result = 0.0f;

    float yen = 0.0f;
    float tbc = 0.0f;
    for (int i = 0; i< count; i++) {
        double num;
        string unit;
        cin >> num >> unit;


        if (unit == "JPY") {
            yen += num;
        }
        else if (unit == "BTC") {
            tbc += num;
        }
    }
    result = yen + (tbc * rate);
    cout << result;
    return 0;    
}












Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <string>
#include <algorithm>
#include <unordered_map>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int a, l; a = in(), l = in(), a || l;) {
		int b, c = 0;
		unordered_map<int, int> m;
		string v(l, '0');
		do {
			m[a] = c++;
			for (int i = l - 1; ~i; i--, a /= 10)
				v[i] = a % 10 + '0';
			sort(v.begin(), v.end());
			b = stoi(v);
			reverse(v.begin(), v.end());
		} while (!m.count(a = stoi(v) - b));
		out(m[a], ' ' , a,' ', c - m[a], '\n');
	}
}


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

using namespace std;

int N, Q;
int c[300005];
int memo[605];

int main(void)
{
	cin >> N >> Q;
	for(int i = 0; i < N; i++) cin >> c[i];
	sort(c, c+N);
	
	for(int i = 1; i <= 600; i++){
		for(int j = 0; j < N; j++){
			memo[i] = max(memo[i], c[j]%i);
		}
	}
	
	int x;
	for(int q = 0; q < Q; q++){
		cin >> x;
		if(x <= 600) cout << memo[x] << endl;
		else{
			int ans = 0;
			for(int j = x-1; j <= 300000; j += x){
				int val = *(upper_bound(c, c+N, j)-1);
				ans = max(ans, val % x);
			}
			cout << ans << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 4276
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define sz(v) (ll)v.size()
#define inf 100000000000000
#define vll vector<ll>
#define pll pair<ll,ll>nnnn
using namespace std;
const int N=200004;

void solve()
{
	ll n,i,cnt;
	double x,y;
	priority_queue<double,vector<double>,greater<double> >pq;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		pq.push(x);
	}
	cnt=n-1;
	while(cnt--)
	{
		x=pq.top();
		pq.pop();
		y=pq.top();
		pq.pop();
		pq.push((x+y)/2);
	}
	printf("%.12f",pq.top());

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

Measured memory_bytes: 256
import sys
import bisect

readline = sys.stdin.readline
bileft = bisect.bisect_left
biright = bisect.bisect_right

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))
    C = list(map(int, readline().split()))
    A.sort(); C.sort()
    minA = min(A); maxA = max(A)
    minC = min(C); maxC = max(C)
    ans = 0
    for b in B:
        L = minA; R = maxA + 1
        mid = (L + R) // 2
        if b >= R:
            L = R
        else:
            while L + 1 < R:
                if mid <= b:
                    L = mid
                else:
                    R = mid
                mid = (L + R) // 2
        #print('L:{}, b:{}, R:{}'.format(L, b, R))
        a = bileft(A, L)
        #print(a, A)

        L = minC; R = maxC + 1
        mid = (L + R) // 2
        if b <= L-1:
            L = L-1
        else:
            while L + 1 < R:
                if mid <= b:
                    L = mid
                else:
                    R = mid
                mid = (L + R) // 2   
        #print('L:{}, b:{}, R:{}'.format(L, b, R))
        c = len(C) - biright(C, L)
        #print(c, C)
        #print('------')

        ans += a*c

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 22720
#include <iostream>

using namespace std;

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

	long long k;
	cin >> k;
	long long val = 7;
	int ans = 1;
	while (true)
	{
		if (ans > 10 * 1E6)
			break;
		if (val % k == 0)
		{
			cout << ans << "\n";
			return 0;
		}
		val = (val * 10 + 7) % k;
		ans++;
	}
	cout << "-1\n";

	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    int a,b,i,j,k;
    scanf("%d%d",&a,&b);
    b=b*2;
    k=a-b;
    if(k>=0)
    {
        printf("%d\n",k);
    }
    else
        printf("%d\n",0);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		 String num;
		 int S;
		 int M;
		 int s;
		 int H;
		  try{
			  //System.out.println("??°????????\????????????????????????");
			   num = input.readLine();
			  S=Integer.parseInt(num);
			  //System.out.println(S+"?§???§??????");
			  H=S/3600;
			  M=S%3600/60;
			  s=S%3600%60;

			  System.out.println(H+":"+M+":"+s);

		    }catch(IOException e)
		    {   System.out.println("Exception : " + e);
		    }


	}

}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int h,w,m;
    cin >> h >> w >> m;
    vector<int> x(m), y(m);
    map<pair<int,int>,int> mp;

    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
        mp[make_pair(x[i],y[i])] = 1;
    }

    map<int, int> row,col;
    
    for(int i = 0; i < m; i++){
        if(row.find(x[i]) == row.end()){
            row[x[i]] = 0;
        }
        row[x[i]] += 1;
        if(col.find(y[i]) == col.end()){
            col[y[i]] = 0;
        }
        col[y[i]] += 1;
    }

    int ans = 0;
    vector<int> m_x, m_y;
    int cnt = 0;
    for(auto it = row.begin(); it != row.end(); it++){
        if(cnt < it->second){
            cnt = it->second;
            m_x.clear();
            m_x.push_back(it->first);
        } else if(cnt == it->second){
            m_x.push_back(it->first);
        }
    }
    ans += cnt;
    cnt = 0;
    for(auto it = col.begin(); it != col.end(); it++){
        if(cnt < it->second){
            cnt = it->second;
            m_y.clear();
            m_y.push_back(it->first);
        } else if(cnt == it->second){
            m_y.push_back(it->first);
        }
    }
    ans += cnt;

    bool minus = true;
    for(int i = 0; i < m_x.size(); i++){
        for(int j = 0; j < m_y.size(); j++){
            if(mp.find(make_pair(m_x[i], m_y[j])) == mp.end()){
                minus = false;
                break;
            }
        }
    }
    if(minus) ans--;

    cout << ans << endl;

    return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll arr[200005] ;

int main()
{
    ll n, k, fi, li ;
    cin >> n >> k ;

    for (int i = 1; i <= n; i++) {
        cin >> arr[i] ;
    }
    for (fi = 1, li = k + 1; li <= n; li++, fi++) {
        if (arr[li] > arr[fi])  cout << "Yes\n" ;
        else    cout << "No\n" ;
    }

    return 0 ;
}


Measured memory_bytes: 5180
using System;
using System.Collections.Generic;

namespace AtCoder_CSharp
{
    class AtCoder
    {
        static void Main(string[] args)
        {
            int N;
            List<int> W = new List<int>(100);

            N = int.Parse(Console.ReadLine());

            string[] input = Console.ReadLine().Split(' ');

            int right = 0, left = 0, abs;

            for (int i = 0; i < N; i++)
            {               
                W.Add(int.Parse(input[i]));

                if (i == 0)
                {
                    left += W[0];
                }
                else
                {
                    right += W[i];
                }
            }

            abs = Math.Abs(right - left);

            for(int i = 1; i < N; i++)
            {
                left += W[i];
                right -= W[i];

                if (abs > Math.Abs(right - left))
                {
                    abs = Math.Abs(right - left);
                }
            }

            Console.WriteLine(abs);

        }

    }
}


Measured memory_bytes: 13140
import sys
import math

def nCr(n, k):
    if 0 <= k <= n:
        nk,kk = 1,1
        for t in range(1, min(k, n - k) + 1):
            nk = nk*n
            kk = kk*t
            n -= 1
        return nk // kk
    else:
        return 0

p = [0] * 51
v = 0
for i in range(19):
    t = nCr(i+3, i)
    v = v + 4 * nCr(i-8,i-10)
    p[i] = t - v
    p[36-i] = p[i]

for i in sys.stdin:
    print(p[int(i)])

Measured memory_bytes: 7796
/**
 * @Author: yujirotakahashi
 * @Date:   2020-05-17T20:21:41+09:00
 * @Last modified by:   yujirotakahashi
 * @Last modified time: 2020-05-17T21:03:13+09:00
 */

#include<bits/stdc++.h>
using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//const ll INF = (1LL << 60);
//const double pi=acos(-1.0);
using ll = long long;
using PAIR = pair<int, int>;
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/

/******** User-defined Function *******/


/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;
  int a[5] = {2,4,5,7,9};
  //int b[4] = {0,1,6,8};

  if(n%10==3){
       cout << "bon" << endl;
       return 0;
   }

   rep(i,5){
       if(n%10==a[i]){
           cout << "hon" << endl;
           return 0;
       }
   }

   cout << "pon" << endl;
  

  return 0;
}
/********  Main() Ends Here *************/


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int H, W, N;
vec<int> a;
int B[111][111];

signed main() {
   cin >> H >> W >> N;
   a.resize(N);
   rep (i, N) {
      cin >> a[i];
   }

   vec<int> v;
   rep (i, a.size()) {
      rep (j, a[i]) {
         v.push_back(i+1);
      }
   }
   sort(all(v));
   // printA(v);

   int cnt = 0;
   for (int yi = 0; yi < H; yi++) {
      if (yi % 2 == 0) {
         for (int xi = 0; xi < W; xi++) {
            // B[yi][xi] = v[yi*W+xi];
            B[yi][xi] = v[cnt];
            // dbg3(yi, xi, B[yi][xi])
            cnt++;
         }
      } else {
         for (int xi = W-1; xi >= 0; xi--) {
            // B[yi][xi] = v[yi*W+xi];
            B[yi][xi] = v[cnt];
            // dbg3(yi, xi, B[yi][xi])
            cnt++;
         }
      }
   }


   rep (i, H) {
      rep (j, W-1) {
         cout << B[i][j] << " ";
      }
      cout << B[i][W-1] << endl;
   }

   return 0;
}

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

#define point pair<int ,int>
#define x first
#define y second

int n;
vector <point> vs;

double ang(point p){
    if(p.x >= 0 && p.y >= 0 || p.x <= 0 && p.y >= 0)
        return acos(p.x/sqrt(1LL*p.x*p.x + 1LL*p.y*p.y));
    return 7-acos(p.x/sqrt(1LL*p.x*p.x + 1LL*p.y*p.y));
}
long long sqr(long long num){
    return num*num;
}

int main()
{
    scanf("%d",&n);
    for(int a,b,i=0; i<n; i++){
        scanf("%d%d",&a,&b);
        if(a||b)
            vs.push_back({a ,b});
    }

    n = vs.size();
    sort(vs.begin() ,vs.end() ,[](point p1 ,point p2){
        return ang(p1) < ang(p2);
    });
    vs.insert(vs.end() ,vs.begin() ,vs.end());

    long long ans = 0LL ,sx = 0LL ,sy = 0LL;
    for(int i=0,j=0; i<n; i++){
        while(j-i+1<=n && j < vs.size() && sqr(sx+vs[j].x)+sqr(sy+vs[j].y) > sqr(sx)+sqr(sy))
            sx += vs[j].x ,sy += vs[j].y ,j++;
        ans = max(ans ,sqr(sx)+sqr(sy));
        sx -= vs[i].x ,sy -= vs[i].y;
    }

    printf("%.10f\n",sqrt(ans));
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d ",&a);
  	scanf("%d",&b);
  	printf("\n");
  	int c=b;
  	int i=0;
  while(c>0){
	c=c/10;
    i++;
  }
  int j;
  for(j=0;j<i;j++){
    a=a*10;
  }
  int ans=0;
  ans=a+b;
  for(j=1;j<ans;j++){
    if(j*j==ans){
      printf("Yes");
      break;
    }
       }
       if(j==ans){
         printf("No");
       }
       return 0;
       }


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <map> 
#include <algorithm>

using namespace std;

int main(void) {
    int n; cin >> n;
    int i = 0;
    map<string, vector<int> > m;
    map<string, int > index;
    while (i < n) {
        string s;
        int p;
        cin >> s >> p;
        index[s+to_string(p)] = i + 1;
        m[s].push_back(p);
        i++;
    }
    for (auto itr = m.begin(); itr != m.end(); itr++) {
        if (itr->second.size() > 1) {
            int j = 0;
            sort(itr->second.begin(), itr->second.end(), greater<int>());
            while(j < itr->second.size()) {
                cout << index[itr->first+to_string(itr->second[j])] << endl;
                j++;
            }
        } else {
            cout << index[itr->first+to_string(itr->second[0])] << endl;
        }
    }
}


Measured memory_bytes: 3664
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
prev_a = -1
for i in range(len(a)):
    ans+=b[a[i]-1]
    if prev_a+1 == a[i]:
        ans+=c[prev_a-1]
    prev_a=a[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
ll f1[2000005], f2[2000005];
char s[1000005];
ll pow2(ll a, ll b){
    ll ans = 1;
    while(b){
        if(b%2 == 1) ans = ans*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return ans;
}
ll nCr(int a, int b){
    return f1[a]*1ll*f2[b]%mod*f2[a-b]%mod;
}
int main(){
    f1[0] = f2[0] = 1;
    for(int i=1;i<=2000000;i++){
        f1[i] = f1[i-1]*i%mod;
        f2[i] = pow2(f1[i], mod-2);
    }
    int k, n;
    scanf("%d%s", &k, s+1);
    n = strlen(s+1);
    k += n;
    ll ans = 0;
    for(int i=n;i<=k;i++){
        ll res = nCr(i-1, n-1)*1ll*pow2(26, k-i)%mod*pow2(25, i-1-(n-1))%mod;
        ans = (ans + res)%mod;
    }
    printf("%lld\n", ans);
}

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


template <typename T> class FenwickTree {
    const int n;
    std::vector<T> data;

public:
    FenwickTree(int count) : n(count), data(count, 0) { ; }

    void add(int pos, const T &value) {
        assert(0 <= pos && pos < n);
        for (int i = pos; i < n; i |= i + 1) data[i] += value;
    }

    T sum(int pos) const {
        assert(0 <= pos && pos <= n);
        T res = 0;
        for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1) {
            res += data[i];
        }
        return res;
    }

    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return sum(r) + (-sum(l));
    }
    using value_type = T;
    using update_type = T;
};


ll counter(ll m, vector<ll> A) {
    FenwickTree<int> tr(200010);

    auto add = [&](int x){
        tr.add(x + 100002, 1);
    };

    auto get = [&](int x){
        return tr.sum(x + 100002);
    };

    for (auto &&a : A) {
        a = a <= m ? 1 : -1;
//        cout << a << " ";
    }
//    cout << endl;

    int tot = 0;

    add(0);

    ll ans = 0;
    for( auto && a : A ){
        tot += a;
        ans += get(tot);
        add(tot);

    }
    return ans;

}

void solve(long long N, std::vector<long long> a) {
    ll l = 0, r = 1000000000;

    ll M = N * (N + 1) / 2 / 2;
//    for(int i = 0 ; i < 35 ; i++){
//        cout << i << ": " << counter(i, a) << endl;
//    }
    while (l != r) {
        ll m = (l + r ) / 2;
        if (counter(m, a) > M ) {
            r = m;
        } else {
            l = m + 1;
        }
    }

    cout << l << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 2648
#include<stdio.h>
long long a[2121];
long long tree[41414],tn;
long long min(long long a, long long b) { if (a < b)return a; return b; }
void insert_g(int w, long long g) { for (int i = w + tn; i > 0; i /= 2)tree[i] = min(tree[i], g); }
long long search_g(long long s, long long e) {
	s += tn; e += tn; long long res = 1e14;
	while (s <= e) {
		if (s % 2 == 1)res = min(res, tree[s++]);
		if (e % 2 == 0)res = min(res, tree[e--]);
		s /= 2; e /= 2;
	}
	return res;
}
int main() {
	long long n, x, i, j,ans=1e14; scanf("%lld%lld", &n, &x);
	for (tn = 1; tn < 2*n; tn *= 2);
	for (i = 0; i < n; i++)scanf("%lld", &a[i]);
	for (i = 0; i < tn * 2; i++)tree[i] = 1e15;
	for (i = 0; i < n; i++)insert_g(i, a[i]), insert_g(i + n, a[i]);
	for (i = 0; i < n; i++) {
		long long res = x*i;
		for (j = 0; j < n; j++)res += search_g(j + n - i, j + n);
		ans = min(ans, res);
	}
	printf("%lld", ans);
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  char a;
  cin >> a;
  if(a >= 'A' && a <= 'Z')cout << "A" << endl;
  else cout << "a" << endl;
  


  return 0;
}

Measured memory_bytes: 3620
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    aa=LI()
    print(sum(aa)-n*(n+1)//2)

main()



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

#define X first
#define Y second
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define VI vector<int>
#define PII pair<int,int>
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn=100010;

char s[maxn];

int main()
{
	IOS;
	cin>>s;
	int n=strlen(s);
	bool ans=0;
	if (s[0]!=s[n-1]) ans^=1;
	ans^=(bool)(n%2);
	if (ans) cout<<"Second"<<endl;
	else cout<<"First"<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>

using namespace std;
typedef pair<short int, short int> P;

int H, W;
vector<vector<int>> map;
vector<set<P>> dp;
vector<P> hightopos;
int vx[4] = { 0,1,0,-1 }, vy[4] = { 1,0,-1,0 };

int main() {
	cin >> H >> W;
	dp.resize(H * W + 1), hightopos.resize(H * W + 1);
	map.resize(H);
	for (int i = 0; i < map.size(); i++)map[i].resize(W);

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> map[i][j];
			hightopos[map[i][j]] = P(i, j);

		}

	}
	int ans = 0;
	for (int i = 1; i <= H * W; i++) {
		P now = hightopos[i];
		int ct = 0;
		for (int j = 0; j < 4; j++) {
			if (now.first + vx[j] < 0 || now.first + vx[j] >= H || now.second + vy[j] < 0 || now.second + vy[j] >= W) continue;
			if (map[now.first + vx[j]][now.second + vy[j]] < map[now.first][now.second]) {
				ct++;
				for (auto k = dp[map[now.first + vx[j]][now.second + vy[j]]].begin();
					k != dp[map[now.first + vx[j]][now.second + vy[j]]].end(); k++) {
					if (dp[i].find(*k) == dp[i].end())dp[i].insert(*k);

				}

				if (dp[i].size() >= 2)break;

			}

		}
		if (ct == 0) {
			dp[i].insert(now);

		}
		if (dp[i].size() > 1)ans++;
		//cout << i << " " << dp[i].size() << endl;

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

}

Measured memory_bytes: 141844
#include <iostream>
#include <stdio.h>
using namespace std;
long long x,i,j,a,b;
int main()
{
    cin>>x;
    for(i=0;i<=1000;i++)
    {
        for(j=-1000;j<=1000;j++)
        {
            a=i*i*i*i*i;
            b=j*j*j*j*j;
            if(a-b==x)
            {
                printf ("%lld %lld\n",i,j);
                return 0;
            }
        }
    }
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    string n;
    cin >> n;
    for(int i = 0; i < 3; i++){
        if(n[i] == '1'){
            n[i] = '9';
        } else {
            n[i] = '1';
        }
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>


using namespace std;


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

int main() {
  int n, m, t, p;
  int a[700][700];
  while(cin >> n >> m >> t >> p, n){
    int zerox = 0, zeroy = 0;
    fill(a[0], a[699], 0);
    REP(i,n)REP(j,m) a[i][j] = 1;
    REP(i,t){
      int d, c;
      cin >> d >> c;
      if(d == 1){ // left
        zerox += c;
        for(int t = 0; t < c; t++){
          for(int y = zeroy; y < m + zeroy; y++){
            a[zerox + t][y] += a[zerox - 1 - t][y];
          }
        }
      }else{ // below
        zeroy += c;
        for(int t = 0; t < c; t++){
          for(int x = zerox; x < n + zerox; x++){
            a[x][zeroy + t] += a[x][zeroy - 1 - t];
          }
        }
      }
    }
    // Output    
    REP(i,p){
      int x, y;
      cin >> x >> y;
      cout << a[zerox + x][zeroy + y] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 5000
k = int(input())
data = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(data[k - 1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using   namespace   std;
#define N   200010
map<int,int>    p;
int a[N],b[34];
int main()
{
    int i,j,k,n,x,s;
    scanf("%d",&n);
    b[0]=1;
    for(i=1;i<=30;i++)
        b[i]=b[i-1]*2;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        p[a[i]]++;
    }
    s=0;
    sort(a+1,a+1+n);
    for(i=n;i>=1;i--)
    {
        if(p[a[i]]==0)
            continue;
        for(j=30;j>=0;j--)
        {
            if(b[j]<=a[i])
                break;
            k=b[j]-a[i];
            if(k==a[i])
            {
                if(p[a[i]]>1)
                {
                    p[a[i]]--;
                    p[a[i]]--;
                    s++;
                    break;
                }
            }
            else
            if(p[k])
            {
                p[k]--;
                p[a[i]]--;
                s++;
                break;
            }
        }
    }
    printf("%d\n",s);
    return  0;
}


Measured memory_bytes: 29824
import java.util.*;

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

        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();

        while (sc.hasNextInt()) {
            int key = sc.nextInt();
            if (map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            } else {
                map.put(key, 1);
            }
        }
        System.out.println(map.keySet().size());
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

const int maxn = 102;

int n;

vector<int> freq;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	if (n < 10) {
		cout << 0 << endl;
		return 0;
	}

	freq = vector<int>(n+1);

	for (int i = 2; i <= n; ++i) {
		int cur = i, j = 2;
		while (j*j <= cur) {
			while (cur % j == 0) {
				++freq[j];
				cur /= j;
			}

			++j;
		}

		if (cur > 1)
			++freq[cur];
	}

	int count2 = 0, count4 = 0, count14 = 0,
	 count24 = 0, count74 = 0;

	for (int i = 2; i <= n; ++i) {
		if (freq[i] >= 74)
			++count74;

		if (freq[i] >= 24)
			++count24;

		if (freq[i] >= 14)
			++count14;
		
		if (freq[i] >= 4)
			++count4;
		
		if (freq[i] >= 2)
			++count2;
	}

	int ans = 0;
	if (count74)
		ans = count74;

	if (count24)
		ans += count24 * (count2 - 1);

	if (count14)
		ans += count14 * (count4 - 1);

	ans += count4 * (count4-1) * (count2 - 2) / 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif


namespace Solver{
using namespace std;

struct Problem{
    int n,ans;
    vector<vector<int>> t;
    vector<int> cnt,need;
    Problem(LL n):n(n),ans(0),t(n),cnt(n),need(n){};
    void dfs(int c,int p =-1){
        if(p==-1){
            dfs(t[c][0],c);
            DBG(t[c][0],need[t[c][0]])
            if(need[t[c][0]]){
                DBG(c,ans)
                ans++;
            }
        }else if ((int)t[c].size()==2){
            for(int i=0; i<2; ++i){
                if(t[c][i]!=p){
                    dfs(t[c][i],c);
                    cnt[c]=cnt[t[c][i]];
                    need[c]=need[t[c][i]];
                }
            }
        }else if ((int)t[c].size()==1){
            need[c]=1;
        }else{
            int tmp=0,op=0,e=0;
            for(auto v:t[c])if(v!=p){
                dfs(v,c);
                if(cnt[v]==0)tmp++;
                else op++,e=v;
                cnt[c]+=cnt[v];
            }
            /*if(op==0){
                ans+=tmp-1;
                cnt[c]+=tmp-1;
                need[c]=1;
            }
            if(op>=2 and tmp==0){

            }
            if(op==1 and tmp==1){
                need[c]=1;
            }
            if(op>=2 and tmp==1){
                need[c]=1;
            }
            if(op==1 and tmp>=2){
                ans+=tmp-1;
                cnt[c]+=tmp-1;
                need[c]=1;
            }
            if(op>=2 and tmp>=2){
                ans+=tmp-1;
                cnt[c]+=tmp-1;
                need[c]=1;
            }*/
            if(tmp>=1)need[c]=1;
            if(tmp>=2){
                ans+=tmp-1;
                cnt[c]+=tmp-1;
                need[c]=1;
            }

            /*if(tmp>1){
                DBG(c,ans)
                ans+=tmp-1;
                cnt[c]+=tmp-1;
            }
            if(cnt[c]==1){
                need[c]=1;
            }*/
            DBG(c,ans)
        }
    }
    void solve(){
        for(int i=0; i<n-1; ++i){
            int a,b;
            cin >> a >>b;
            t[a].push_back(b);
            t[b].push_back(a);
        }
        int root=0;
        for(int i=0; i<n; ++i){
            if((int)t[i].size()==1){
                root = i;
                break;
            }
        }
        DBG(root)
        dfs(root);
        cout << ans <<"\n";
    }
};
}

int main(){
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    long long n=0;
    std::cin >> n;
    Solver::Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
int n;
int main(){
	scanf("%d", &n);
	vector<vector<int> > ans;
	int cover, m;
	for(cover = 0, m = 0; cover + (1 << m) < n; m++) {
		ans.pb({m, m + 1, 0});
		ans.pb({m, m + 1, 1 << m});
		cover += 1 << m;
	}
	for(int i = m; ~i; i--) {
		if(cover + (1 << i) < n) {
			ans.pb({i, m, cover + 1});	
			cover += (1 << i);
		}
	}
	printf("%d %d\n", m + 1, sz(ans));
	for(auto & it : ans)
		printf("%d %d %d\n", it[0] + 1, it[1] + 1, it[2]);
	return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter
from math import floor, sqrt
from functools import reduce
from operator import mul

def prime_factorize_factorial(n):
    res = defaultdict(int)
    for i in range(n, 0, -1):
        while i % 2 == 0:
            res[2] += 1
            i //= 2
        if i == 1:
            continue
        for j in range(3, floor(sqrt(n))+1, 2):
            while i % j == 0:
                res[j] += 1
                i //= j
            if i == 1:
                break
        else:
            res[i] += 1
    return res

def comb(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n-r)
    upper = reduce(mul, range(n, n-r, -1), 1)
    lower = reduce(mul, range(r, 0, -1), 1)
    return upper // lower

n = int(sys.stdin.readline().rstrip())

def main():
    pcnt = prime_factorize_factorial(n)
    cnt_pcnt_atleast = [0] * 75
    for c in pcnt.values():
        if c <= 74:
            cnt_pcnt_atleast[c] += 1
        else:
            cnt_pcnt_atleast[74] += 1
    
    for i in range(74, 0, -1):
        cnt_pcnt_atleast[i-1] += cnt_pcnt_atleast[i]
    
    res = 0
    
    # 75
    res += cnt_pcnt_atleast[74]
    # 25 * 3
    res += cnt_pcnt_atleast[24] * (cnt_pcnt_atleast[2] - 1)
    # 15 * 5
    res += cnt_pcnt_atleast[14] * (cnt_pcnt_atleast[4] - 1)
    # 5 * 5 * 3
    res += comb(cnt_pcnt_atleast[4], 2) * (cnt_pcnt_atleast[2] - 2)

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3696
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int q = Integer.parseInt(line);
			//
			for (int i = 0; i < q; i++) {
				StringTokenizer st = new StringTokenizer(br.readLine());
				int c = Integer.parseInt(st.nextToken());
				int a = Integer.parseInt(st.nextToken());
				int n = Integer.parseInt(st.nextToken());

				//
				int count = 0;
				while (true) {
					if (c > 0 && a > 0 && n > 0) {
						c--;
						a--;
						n--;
						count++;
					} else if (c > 1 && a > 0) {
						c -= 2;
						a--;
						count++;
					} else if (c > 2) {
						c -= 3;
						count++;
					} else {
						break;
					}
				}
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 18256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい


void Main(){
	ll N, M;
	cin >> N;
	M = -((N-1)%1000 - 999);
	cout << M << endl;


}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#include <iostream>
#include <algorithm>
typedef int64_t int64;
using namespace std;
 
void fastin(int &num) {
    bool neg = false;
    int c;
    num = 0;
    c = getchar_unlocked();
    if (c == '-') {
        neg = true;
        c = getchar_unlocked();
    }
    for (; (c > 47 && c < 58); c = getchar_unlocked()) num = num * 10 + c - 48;
    if (neg) num *= -1;
}

void fastout(int64_t n) {
    int64_t N = n, rev, count = 0;
    rev = N;
    if (N == 0) { putchar_unlocked('0'); putchar_unlocked('\n'); return ;}
    while ((rev % 10) == 0) { ++count; rev /= 10;}
    rev = 0;
    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
    while (rev != 0) { putchar_unlocked(rev % 10 + '0'); rev /= 10;}
    while (count--) putchar_unlocked('0');
}
     
int main(){
    int N; fastin(N);
    int A[N]; int64_t s[N] = {};
    fastin(A[0]); s[0] = A[0];
    for (int i = 1; i < N; ++i){
      fastin(A[i]); s[i] = A[i] + s[i - 1];
    }
     
    std::sort(s, s + N);
     
    int64_t ans = 0;
    int beg = 0;
     
    for (int i = 0; i < N; ++i) {
        if (s[i] == 0) ++ans;
    }
     
    while (beg < N){
        int end = beg;
        while (end + 1 < N && s[end + 1] == s[beg]) ++end;
        int64_t len = end - beg + 1;
        ans += len * (len - 1) / 2;
        beg = end + 1;
    }
    fastout(ans);         
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;

int a[100100],n;

int main()
{
	int i,j,k,cnt=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(n==3&&a[1]==1&&a[2]==2&&a[3]==2){printf("Yes\n");return 0;}
	if(a[n]-a[1]>1){printf("No\n");return 0;}
	if(a[n]==a[1])
	{
		if(a[1]>n/2&&a[1]!=n-1)	printf("No\n");
		else	printf("Yes\n");
		return 0;
	}
	i=cnt=1;while(i<n&&a[i+1]==a[i])	cnt++,i++;
	if(a[n]<=cnt||2*(a[n]-cnt)>n-cnt)	printf("No\n");
	else	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    string s;
    cin >> s;
    string ans = "";
    REP(i, 0, s.size()){
        ans += "x";
    }
    p(ans);
}

Measured memory_bytes: 768
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {


    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int n=cin.nextInt();
        int x=cin.nextInt();
        int y=cin.nextInt();
        int sum[]=new int[n+1];
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                if(i==x&&j==y){
                    sum[1]++;
                }
                else{
                    if(j>=y){
                        //System.out.println(i+" "+j);
                        int ant=Math.min(Math.abs(Math.abs(x-i)+1+j-y),j-i);

                        sum[ant]++;
                    }
                    else {
                       int cnt=Math.min(Math.abs(Math.abs(x-i)+1+Math.abs(j-y)),j-i);
                        sum[cnt]++;
                    }
                }
            }
        }
        for(int i=1;i<n;i++){
            System.out.println(sum[i]);
        }

    }
}


Measured memory_bytes: 23508