akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

typedef pair<int, int> pii;

#define fst first
#define scd second
#define rep(i,x) for(int i=0;i<(x);++i)

template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

const int inf = 1e9;

int k[150];
vector<pii> stone[150];
int N, M;

int memo[150][150][10];

int rec(int n, int m, int i)
{
	if (n >= N - 1) return 0;

	if (~memo[n][m][i]) return memo[n][m][i];

	int res = inf;

	rep(j, k[n + 1]) {
		int dist = (stone[n][i].scd + stone[n + 1][j].scd) * abs(stone[n][i].fst - stone[n + 1][j].fst);
		chmin(res, dist + rec(n + 1, m, j));
	}

	if (m < M) {
		if (n + 2 >= N) return 0;
		rep(j, k[n + 2]) {
			int dist = (stone[n][i].scd + stone[n + 2][j].scd) * abs(stone[n][i].fst - stone[n + 2][j].fst);
			chmin(res, dist + rec(n + 2, m + 1, j));
		}
	}

	return memo[n][m][i] = res;
}

signed main()
{
	while (scanf("%d %d", &N, &M), N || M) {
		rep(i, N) {
			scanf("%d", &k[i]);

			stone[i].resize(k[i]);

			rep(j, k[i]) {
				int x, d; scanf("%d %d", &x, &d);
				stone[i][j].fst = x, stone[i][j].scd = d;
			}
		}

		int ans = inf;

		memset(memo, -1, sizeof(memo));

		rep(i, k[0]) chmin(ans, rec(0, 0, i));

		if (M > 0) rep(i, k[1]) chmin(ans, rec(1, 1, i));

		printf("%d\n", ans);
	}
}

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

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


Measured memory_bytes: 3080
#include<stdio.h>
int main(void){
  char w[10];
  scanf("%s",&w);
  switch(w[0]){
    case 'S':
      printf("Cloudy");
      break;
    case 'C':
      printf("Rainy");
      break;
    case 'R':
      printf("Sunny");
      break;
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

ll calc_Aq(ll q){
  ll tot = 0, i = 0;
  while (i*(i+1)/2<=q){
    i++;
  }
  return i-1;
}
void func(ll N, map<ll,ll> &p){
  if (N<=1) return;

  ll i=2;
  ll N0 = N;
  ll pw = 1;
  bool isprime = true;
  while (i<=sqrt(1.0*N)){
    if (N0%i==0){
      isprime = false;
      while (N0%i==0){
        N0/=i;
        p[i]++;
        pw *= i;
      }
      break;
    }
    else i++;
  }
  if (isprime) {
    p[N]++;
    return;
  }  
  N /= pw;
  func(N,p);
  return;
}



int main(){
  ll N; cin >> N;

  ll i = 2;
  map<ll,ll> p;
  func(N,p);

  ll cnt = 0;
  for (auto pl:p){
    cnt += calc_Aq(pl.second);
  }

  cout << cnt << endl;
  // for (auto pl:p) cout << pl.first<< " " << pl.second << " " << calc_Aq(pl.second) << endl;
  // for (int q=1;q<10;q++) cout << q << " " << calc_Aq(q) << endl;


  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//freopen ( "input.txt", "r", stdin );
	map< string, int > mp;
	mp["AC"] = 0;
	mp["WA"] = 0;
	mp["TLE"] = 0;
	mp["RE"] = 0;
	string s;

	int t;
	cin >> t;
	while ( t-- )
	{
		cin >> s;
		mp[s]++;
	}

	for ( auto it = mp.begin(); it != mp.end(); it++ )
	{
		if ( it->first == "AC" ) {
			cout << it->first << " x " << it->second << endl;
		}

	}
	for ( auto it = mp.begin(); it != mp.end(); it++ )
	{
		if ( it->first == "WA" ) {
			cout << it->first << " x " << it->second << endl;
		}

	}
	for ( auto it = mp.begin(); it != mp.end(); it++ )
	{
		if ( it->first == "TLE" ) {
			cout << it->first << " x " << it->second << endl;
		}

	}
	for ( auto it = mp.begin(); it != mp.end(); it++ )
	{
		if ( it->first == "RE" ) {
			cout << it->first << " x " << it->second << endl;
		}

	}



}

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

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


Measured memory_bytes: 256
#include    <iostream>

using namespace std;

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

    for(int i = a; i <= b; i++)
        sum += (c % i == 0) ? 1 : 0;
    
    cout << sum << endl;

    return 0;
}


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

int main(){
    int n,k; cin>>n>>k;
    int d[k]; for(int i=0;i<k;i++) cin>>d[i];
    n--;

    while(true){
        n++; bool flag=true;

            for(int i=0;i<k;i++){
                if(n%10000%1000%100%10==d[i]) flag=false;
            }
            if(!flag) continue;

        if(n>9){
            for(int i=0;i<k;i++){
                if(n%10000%1000%100/10==d[i]) flag=false;
            }
            if(!flag) continue;
        }

        if(n>99){
            for(int i=0;i<k;i++){
                if(n%10000%1000/100==d[i]) flag=false;
            }
            if(!flag) continue;
        }

        if(n>999){
            for(int i=0;i<k;i++){
                if(n%10000/1000==d[i]) flag=false;
            }
            if(!flag) continue;
        }

        if(n>9999){
            for(int i=0;i<k;i++){
                if(n/10000==d[i]) flag=false;
            }
            if(!flag) continue;
        }
        
        break;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
past_a = [1]
first = 0
for i in range(n):
    past_a.append(a_list[past_a[-1] - 1])
    
def check(past_a):
  if len(past_a) == len(set(past_a)):
    return True
  else:
    return False
  
left = 0
right = len(past_a)

while right - left > 1:
  middle = (right + left)//2
  if check(past_a[:middle]) == True:
    left = middle
  else:
    right = middle
roop_2 = left 
roop_1 = past_a.index(past_a[roop_2])
unit = roop_2 - roop_1
p_unit = past_a[roop_1:roop_2]
if k <= left:
  print(past_a[k])
else:
  k = (k - left) % unit
  print(p_unit[k])
    
  

Measured memory_bytes: 36976
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			// 整数の入力
			int a,b;
			int result,k0;
			a = sc.nextInt();
			b = sc.nextInt();
			result=0;
			if ((a+b)%2==0) {
				k0=(a+b)/2;
				System.out.print(k0);
				}
			else
				System.out.print("IMPOSSIBLE");

			
 
			// 出力
 
	}
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "cycle"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5, MAXV = 2003;

int dp[2 * MAXV][2 * MAXV];

int a[MAXN], b[MAXN];

ll f[4 * MAXV], _f[4 * MAXV];

int cnt[2 * MAXV][2 * MAXV];

ll pow_mod(ll a, ll st){
	ll ans = 1ll;
	for(; st; st >>= 1){
		if (st & 1){
			ans = (ans * a) % MOD;
		}
		a = (a * a) % MOD;
	}
	return ans;
}

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n){
		scanf("%d%d", &a[i], &b[i]);
	}
	
	f[0] = 1;
	REP(i, 1, 4 * MAXV){
		f[i] = (f[i - 1] * i) % MOD;
	}
	
	_f[4 * MAXV - 1] = pow_mod(f[4 * MAXV - 1], MOD - 2);
	for(int i = 4 * MAXV - 2; i >= 0; i--){
		_f[i] = (_f[i + 1] * (i + 1)) % MOD;
	}
	
	int offset = 2000;
	REP(i, 0, n){
		cnt[offset - a[i]][offset - b[i]]++;
	}
	ll ans = 0ll;
	REP(i, 0, 2 * MAXV){
		REP(j, 0, 2 * MAXV){
			if (i){
				dp[i][j] = dp[i - 1][j];
			}
			if (j){
				dp[i][j] += dp[i][j - 1];
			}
			dp[i][j] += cnt[i][j];
			if (dp[i][j] >= MOD){
				dp[i][j] -= MOD;
				if (dp[i][j] >= MOD){
					dp[i][j] -= MOD;
				}
			}
			if (i >= offset && j >= offset){
				if (2 * offset - i >= 0 && 2 * offset - j >= 0){
					ans = (ans + (ll)cnt[2 * offset - i][2 * offset - j] * (ll)dp[i][j]) % MOD;
				}
			}
		}
	}
	
	REP(i, 0, n){
		ll c = (f[a[i] + a[i] + b[i] + b[i]] * _f[a[i] + a[i]]) % MOD;
		c = (c * _f[b[i] + b[i]]) % MOD;
		//cout << a[i] + a[i] + b[i] + b[i] << " " << a[i] + a[i] << " " << c << endl;
		ans = (ans + MOD - c) % MOD;
	}
	ll tmp = (MOD + 1) / 2;
	ans = (ans * tmp) % MOD;
	cout << ans << endl;
}	

int main(){

	//freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();	
	}
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N;
  scanf("%lld", &N);

  for (ll i = 0; i < 100; i++) {
    ll m = 1000 * i;
    if (m >= N) {
      cout << (m - N) << endl;
      break;
    }
  }
}


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

public class Main {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            for(int i=0;i<n;i++){
                ans += in.nextInt()-1;
            }
            System.out.println(ans);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21972
import java.util.*;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int answer = solve(a, b, c);
        System.out.println(answer);
    }

    private static int solve(int a, int b, int c) {
        Integer[] array = new Integer[3];
        array[0] = a;
        array[1] = b;
        array[2] = c;
        Arrays.sort(array, Collections.reverseOrder());
        int count = 0;
        int deg = array[0] - array[1];
        count += deg;
        int deg2 = array[0] - (array[2] + deg);
        count += deg2 / 2;
        if (deg2 % 2 == 1) {
            count += 2;
        }
        return count;
    }


}


Measured memory_bytes: 22740
import java.util.*;


class Main{
  

  
  
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
      
      int n = sc.nextInt();
      int l = sc.nextInt();
      String[] s = new String[n];
      
      for(int i=0;i<n;i++){
      	s[i] = sc.next();
      }
      
    Arrays.sort(s);
      
      for(int j=0;j<n;j++){
      	System.out.print(s[j]);
      }
      
      
	}
}

Measured memory_bytes: 37132
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second

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

int k, n;
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s >> k;
	n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] != 'a') {
			int t = int('z' - s[i]) + 1;
			if (t <= k) {
				k -= t;
				s[i] = 'a';
			}
		}
	}
	if (k > 0) {
		k %= 26;
		while (k--) {
			if (s[n - 1] == 'z')
				s[n - 1] = 'a';
			else
				s[n - 1]++;
		}
	}
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 592
N=int(input())
S=input()
S,T=S[:N],S[N:][::-1]
A=dict()
B=dict()
X1,Y1,X2,Y2,Z=0,0,0,0,0
for i in range(1<<N):
  X1,Y1,X2,Y2,Z='','','','',1
  for j in range(N):
    if i&Z:
      X1+=S[j]
      X2+=T[j]
    else:
      Y1+=S[j]
      Y2+=T[j]
    Z<<=1
  A[(X1,Y1)]=A.get((X1,Y1),0)+1
  B[(X2,Y2)]=B.get((X2,Y2),0)+1
P=0
Z=list(A.keys())
for i in range(len(Z)):
  P+=A[Z[i]]*B.get(Z[i],0)
print(P)

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  ll su = 0;
  vector<pair<int, int>> p(m);
  for(int i=0;i<m;++i) {
    cin >> p[i].second >> p[i].first;
    su += p[i].second;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());

  /* for(int i=0;i<m;++i) {
    cout << p[i].first << ":" << p[i].second << endl;
  } */

  int pos = 0;
  for(int i=0;i<n;++i) {
    if(p[pos].first > a[i]) {
      a[i] = p[pos].first;
      p[pos].second--;
    } else if(p[pos].first < a[i]) {
      break;
    }
    if(p[pos].second == 0) {
      pos++;
    }
    if(pos == m) break;
  }

  // printv(a);

  ll ans = 0;
  for(int i=0;i<n;++i) {
    ans += a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include<cmath>
#include<stdio.h>
#define PI 3.14159265358979
using namespace std;


int main(){

	double a, b, c, C, L,S,H,rad;
	cin >> a >> b >> C;

	rad = C*PI / 180;

	S = sin(rad)*a*b / 2;
	
	c = sqrt((b*b) + (a*a) - 2 * a*b*cos(rad));

	L = a + b + c;

	H = b*sin(rad);

	printf("%.5lf", S);
	cout << " ";
	printf("%.5lf", L);
	cout << " ";
	printf("%.5lf", H);






	return 0;
}

Measured memory_bytes: 1252
K = int(input())

if K == 1:
    print(1)
elif K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    if K % 7 == 0:
        L = 9 * K // 7
    else:
        L = 9 * K
    
    b = 10 % L
    for i in range(1, 1000000):
        if b == 1:
            print(i)
            break
        else:
            b = (10 * b) % L

Measured memory_bytes: 9172
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    N = int(readline())
    if N == 0:
        return False
    A = [0]*N; B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, readline().split())
    dp = [[0]*(1 << (3*N)) for i in range(2*N+1)]
    for i in range(1, 10):
        c = 0
        if A[0] <= i <= B[0]:
            c |= 1
        if A[0]//10 <= i < B[0]//10 or A[0]//10 == B[0]//10 == i:
            c |= 2
        if A[0]//10 < i <= B[0]//10:
            c |= 4
        dp[1][c] += 1
    N0 = 1 << (3*N)
    for i in range(1, N*2):
        dp0 = dp[i]
        dp1 = dp[i+1]
        for j in range(1, N0):
            v = dp0[j]
            if v == 0:
                continue
            for k in range(10):
                c = 0
                for l in range(N):
                    a0 = A[l]; b0 = B[l]
                    s = 1 << (3*l)
                    if j & s and l < N-1 and k > 0:
                        a1 = A[l+1]; b1 = B[l+1]
                        if a1 <= k <= b1:
                            c |= (s << 3)
                        if a1//10 <= k < b1//10 or a1//10 == b1//10 == k:
                            c |= (s << 4)
                        if a1//10 < k <= b1//10:
                            c |= (s << 5)
                    if j & (s << 1):
                        if j & (s << 2):
                            c |= s
                        elif a0//10 == b0//10:
                            if a0%10 <= k <= b0%10:
                                c |= s
                        elif a0%10 <= k:
                            c |= s
                    if j & (s << 2):
                        if k <= b0%10:
                            c |= s
                if c:
                    dp1[c] += v
    ans = 0
    for i in range(2*N+1):
        dpi = dp[i]
        ans += sum(dpi[j] for j in range(N0) if j & (1 << (3*N-3)))
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 32400
S = input()
con = 10**9 + 7

T = [s if s != "?" else "0" for s in S]
T = int(''.join(T))
SS = T % 13

def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c
c = get_mod(S)

def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in v.keys():
        for _r, _v in pdp.items():
            tdp[(_r + r) % 13] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp

pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in c.items():
    pdp = get_tdp(pdp)

ans = pdp[5]
print(ans)

Measured memory_bytes: 137376
# -*- coding: utf-8 -*-
a,b,m = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = min(a) + min(b)
for i in range(m):
    x, y, c = map(int,input().split())
    tmp = a[x-1] + b[y-1] - c
    if tmp < ans:
        ans = tmp
print(ans)


Measured memory_bytes: 18500
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;        

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 110000
int A[Max];
int N;
map<int, int> counter;

int main(int argc, const char * argv[]) {
    N = inputValue();
    inputArray(A, N);
    sort(A, A+N);
    counter[A[0]] = 1;
    repd(i, 1, N) {
        if (A[i] != A[i-1]) {
            counter[A[i]] = 1;
        } else {
            counter[A[i]] += 1;
        }
    }

    int count_all = 0;

    for(auto i = counter.begin(); i != counter.end() ; ++i) {
        if (i->second >= 3) {
            counter[i->first] = (i->second+1) % 2 + 1;
        }
        count_all += 1;
    }

    int count2 = 0;
    for(auto i = counter.begin(); i != counter.end() ; ++i) {
        if (i->second == 2) {
            count2 += 1;
        }
    }

    int rest = count2 % 2;
    int ans = count_all - rest;
    output(ans);
    
    // for(auto i = counter.begin(); i != counter.end() ; ++i) {
    //     std::cout << i->first << " " << i->second << "\n";
    // }

    return 0;
}


Measured memory_bytes: 5376
t=int(input())
if t>=400 and t<600:
    print("8")
if t>=600 and t<800:
    print("7")
if t>=800 and t<1000:
    print("6")
if t>=1000 and t<1200:
    print("5")
if t>=1200 and t<1400:
    print("4")
if t>=1400 and t<1600:
    print("3")
if t>=1600 and t<1800:
    print("2")
if t>=1800 and t<2000:
    print("1")




Measured memory_bytes: 9184
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();
    if ((a==1 || a==2) && (b==1 || b==2)) {
      System.out.println("3");
    }
    else if ((a==1 || a==3) && (b==1 || b==3)) {
      System.out.println("2");
    }
    else{
      System.out.println("1");
    }

  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){

    int n,m,x;
    int a[101];
    int i,j,k;
    int count_l=0, count_r=0;

    scanf("%d %d %d", &n,&m,&x);

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

    for(i=0;i<m;i++){
        if(a[i]<x){
            count_l++;
        }else{
            count_r++;
        }
    }

    if(count_l<=count_r){
        printf("%d\n",count_l);
    }else{
        printf("%d\n",count_r);
    }

    return 0;
}

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

int main()
{
    int n; cin>>n;
    int x=(n*100/108);
    vector<int> xv(201);
    for(int i=0;i<=200;i++){
        xv[i]=(x+i-100);
    }
    for(int i=0;i<=200;i++){
        if(xv[i]<=0) continue;
        int tmp=xv[i]*108/100;
        if(tmp==n){
            cout<<xv[i]<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
const int N = 3e5 + 10;

int main() {
    fast;
    int a; cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}



Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = GetNumbers();
            var a = nums[0];
            var b = nums[1];

            System.Console.WriteLine("{0} {1} {2:F8}", a / b, a % b, a / (double)b);
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static List<int> GetNumbers()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
        }

        static List<string> GetStrings()
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
    }
}

Measured memory_bytes: 10088
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>

int main()
{
    int  n,k;
    int  a[10005];
    k=0;
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&a[i]);
    for (int i=0;i<n;i++)
        while(a[i]%2==0)
    {
        k++;
        a[i]=a[i]/2;
    }
    printf("%d\n",k);
    return 0;
}


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

int a,b,c;
int matrix[4][4];

int main()
{
	cin>>a>>b>>c;
	matrix[1][1]=a;
	matrix[1][2]=b;
	matrix[2][2]=c;
	matrix[1][3]=c*3-a-b;
	matrix[3][2]=c*2-b;
	matrix[3][1]=c*2-matrix[1][3];
	matrix[2][1]=c*3-a-matrix[3][1];
	matrix[2][3]=c*2-matrix[2][1];
	matrix[3][3]=c*2-a;
	
	for (int i=1;i<=3;i++)
	{
		for (int j=1;j<=3;j++)  cout<<matrix[i][j]<<' ';
		cout<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 384
n = int(input())
s = input()
ecnt = [0]*n
wcnt = [0]*n
for i in range(1,n):
    if s[i-1] == 'W':
        wcnt[i] = wcnt[i-1]+1
    else:
        wcnt[i] = wcnt[i-1]
for i in range(n-2,-1,-1):
    if s[i+1] == 'E':
        ecnt[i] = ecnt[i+1] +1
    else:
        ecnt[i] = ecnt[i+1]
ans = 10**10
for i in range(n):
    res = ecnt[i]+wcnt[i]
    ans = min(ans,res)
print(ans)

    

Measured memory_bytes: 47320
import math
import collections
from operator import mul
from functools import reduce



n,q=map(int,input().split())
s=input()
y=[0]*(n+1)
flag=0
for i in range(n):
    if flag==0:
        if s[i]=="A":flag=1
    else:
        if s[i]=="C":
            y[i+1]+=1
            flag=0
        elif s[i]!="A":
            flag=0

    y[i+1]+=y[i]

for i in range(q):
    l,r=map(int,input().split())
    print(y[r]-y[l])



Measured memory_bytes: 51584
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int N, K, Q;
    scanf("%d%d%d", &N, &K, &Q);

    int *s = malloc(sizeof(int) * N);
    for(int n=0; n<N; n++){
        s[n] = K - Q;
    }

    for(int q=0; q<Q; q++){
        int A;
        scanf("%d", &A);
        s[A-1] += 1;
    }

    for(int n=0; n<N; n++){
        if(s[n] <= 0){
            printf("No\n");
        } else {
            printf("Yes\n");
        }
    }

    return 0;
}


Measured memory_bytes: 896
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n, m = map(int, input().strip().split())
	city = [[] for _ in range(m)]
	for i in range(m):
		p, y = map(int, input().strip().split())
		city[i] = [i, p, y]
	city.sort(key=itemgetter(2))
	city.sort(key=itemgetter(1))
	id = 0
	for i in range(m):
		if i != 0 and city[i][1] != city[i-1][1]:
			id = 1
		else:
			id += 1
		city[i].append(id)
	city.sort(key=itemgetter(0))
	for i in range(m):
		print("{:06}{:06}".format(city[i][1], city[i][3]))
if __name__ == '__main__':
	main()


Measured memory_bytes: 78512
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define N 200005

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T &y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T &y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int tot;
long long n;
deque<int> que;

void dfs(long long x) {
	if (x == 1) return void();
	if (x & 1) dfs(x - 1), que.push_front(++tot);
	else dfs(x / 2), que.push_back(++tot);
}

int main() {
	n = ll(read) + 1ll;
	dfs(n);

	printf("%d\n", tot * 2);
	while (!que.empty()) printf("%d ", que.front()), que.pop_front();
	for (int i = 1; i < tot; ++i) printf("%d ", i);
	printf("%d\n", tot);
	return 0;
}


Measured memory_bytes: 256
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <iomanip>
#include <queue>

using namespace std;
using namespace std::chrono;

#define ld long double

int r(ld x)
{
	int z = (int)x;
	x -= z;
	if (x < 0.5)
	{
		return z;
	}
	return z + 1;
}

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int l = 0, r = 1e9;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		int cnt = 0;
		for (int i = 0; i < n; ++i)
		{
			cnt += (a[i] - 1) / m;
		}
		if (cnt <= k)
		{
			r = m;
		}
		else
		{
			l = m;
		}
	}
	cout << r << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3996
#include<cstdio>
typedef struct{
    int high;
    int sum;
}box;

int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    int H[N];
    for(int i=0;i<N;i++) scanf("%d", &H[i]);
    box pair[N];
    for(int i=0;i<N;i++){
        pair[i].high = 0;
        pair[i].sum = 0;
    }
    for(int i=0;i<M;i++){
        int A,B;
        scanf("%d %d", &A, &B);
        A--;
        B--;
        pair[A].sum++;
        pair[B].sum++;
        if(H[A] > H[B]) pair[A].high++;
        if(H[A] < H[B]) pair[B].high++;        
    }
    int ans = 0;
    for(int i=0;i<N;i++){
        if(pair[i].high == pair[i].sum) ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 2892
h,w,a,b = map(int, input().split())
import math
ans = 0
mod = 10**9+7
l =[i for i in range(1,h+w+2)]
for i in range(1,len(l)-1):
    l[i+1] = l[i+1]*l[i]%mod
l = [1]+ l
gyakugen = [pow(l[i], mod-2, mod) for i in range(1, len(l))]
gyakugen = [1] + gyakugen
for p in range(1, w-b+1):
    ans += l[(h-a-1+b+p-1)]*l[w-(b+p)+a-1]*\
    gyakugen[h-a-1]*gyakugen[b+p-1] * gyakugen[a-1]*gyakugen[w-(b+p)]
print(int(ans)%mod)

Measured memory_bytes: 20540
import bisect

def find_gt(a, x):
    'Find leftmost value greater than x'
    i = bisect.bisect_right(a, x)
    if i != len(a):
        return a[i]
    raise ValueError

def find_lt(a, x):
    #'Find rightmost value less than x'
    i = bisect.bisect_left(a, x)
    if i:
        return a[i-1]
    raise ValueError

s=input().strip()
n=len(s)

l_ind=[]
r_ind=[]
for i in range(n):
    if s[i]=="L":
        l_ind.append(i)
    else:
        r_ind.append(i)

ans=[0]*n
for i in range(n):
    if s[i]=="R":
        nextL=find_gt(l_ind,i)
        ans[nextL-(nextL-i)%2]+=1
    else:
        nextR=find_lt(r_ind,i)
        ans[nextR+(i-nextR)%2]+=1

for i in range(n):
    print(ans[i],end=" ")

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b)
    cout << c << endl;
  if(b == c)
    cout << a << endl;
  if(c == a)
    cout << b << endl;
  
  //cout << (  ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
using ll = long long;
#define int ll
int INF = -LONG_MAX/100;
signed main(){
    using pii = pair<int,int>;
    using piii  = pair<pii,int>;
    vector<piii>edge;
    int n,m; cin>>n>>m;
    rep(i,m){
        piii hoge; cin>>hoge.first.first>>hoge.first.second>>hoge.second;
        edge.push_back(hoge);
    }
    vector<int>d(n,INF);
    d[0]=0;
    for(int v=0; v<n*3;v++){
        bool update=false;
        rep(i,edge.size()){
            int from=edge[i].first.first-1;
            int to=edge[i].first.second-1;
            int cost=edge[i].second;
            if(d[from]==INF)continue;
            if(d[to]<d[from]+cost){
                d[to]=d[from]+cost;
                if(to==n-1)update=true;
            }
        }
        if(update&&v>2*n)return puts("inf")*0;
    }
    cout<<d[--n]<<endl;
}

Measured memory_bytes: 384
i = input().split(" ")

N = int(i[0])
M = int(i[1])

m = []

for _ in range(M):
	i = list(map(int, input().split(" ")))
	m.append(i[1:])

p = list(map(int, input().split(" ")))

from itertools import product

co = 0

s = list(product([True, False], repeat=N))

for comb in s:
	#print(comb)
	allon = True
	for l, b in enumerate(m):
		look = [comb[i - 1] for i in b]
		#print(l, look)
		if look.count(True) % 2 != p[l]:
			allon = False
			break
	if allon:
		co += 1

print(co)

Measured memory_bytes: 3188
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int W, D;
    int[] Hw, Hd;
    bool input() {
        scanf("%d %d\n", &W, &D);
        if (W == 0 && D == 0) return false;
        Hw = readln.chomp.split(" ").map!(to!int).array;
        Hd = readln.chomp.split(" ").map!(to!int).array;
        return true;
    }
    void solve() {
        auto Uw = new bool[W];
        auto Ud = new bool[D];
        int Ans = 0;
        foreach (i; 0 .. W) {
            foreach (j; 0 .. D) {
                if (Uw[i] || Ud[j]) continue;
                if (Hw[i] == Hd[j]) {
                    Uw[i] = Ud[j] = true;
                    Ans += Hw[i];
                }
            }
        }
        foreach (i; 0 .. W) {
            if (!Uw[i]) Ans += Hw[i];
        }
        foreach (i; 0 .. D) {
            if (!Ud[i]) Ans += Hd[i];
        }
        writeln(Ans);
    }
    while (input) solve;
}

Measured memory_bytes: 1136
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	sort(ALL(a));
	ll now = a[0];
	int c=1;
	for(int i =1;i<n;i++)
	{
		if(now*2>=a[i])
		{
			now+=(1LL)*a[i];
			c++;
		}
		else
		{
			now+=(1LL)*a[i];
			c=1;
		}
		//cout<<now<<endl;
		
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
n, p = map(int, input().split())
s = input()

if p == 2:
    ret = 0
    for i in range(len(s)):
        if int(s[i]) % 2 == 0:
            ret = ret + i + 1
    print(ret)
elif p == 5:
    ret = 0
    for i in range(len(s)):
        if int(s[i]) % 5 == 0:
            ret = ret + i + 1
    print(ret)
else:
    c_list = [0] * n
    power = 1
    for i in range(len(s)):
        c_list[i] = (c_list[i-1] + (int(s[-i-1]) * power)) % p
        power *= 10
        power = power % p
    c_list.append(0)
    counter = [0] * p
    for i in c_list:
        counter[i] += 1
    ret = 0
    for item in counter:
        if item >= 2:
            ret = ret + (item * (item - 1) // 2)
    print(ret)


Measured memory_bytes: 44364
import math
a,b,h,m = map(int,input().split())
hour_angle = 0.5 * (h * 60 + m)  
minute_angle = 6 * m

angle = abs(hour_angle - minute_angle)
angle = min(360.0 - angle, angle)
ans= (a*a) + (b*b) - (2.0*a*b*math.cos(angle * math.pi /180))
ans = math.sqrt(ans)
print(ans)

Measured memory_bytes: 9516
/*
Date: 2020/1/10.
Name: AtCoder ABC150 C "Count Order".
Category: next_permutation().
*/
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
using namespace std;
typedef vector<int> vi;

int main(){
	int n;
	cin>>n;
	
	vi p(n),q(n);
	REP(i,n) cin>>p[i];
	REP(i,n) cin>>q[i];
	
	vi v(n);
	REP(i,n) v[i]=i+1;
	
	int num=1;
	int pn,qn;
	do{
		if(p==v) pn=num;
		if(q==v) qn=num;
		num++;
	}while(next_permutation(ALL(v)));

	cout<<abs(pn-qn)<<endl;
}


Measured memory_bytes: 256
from math import factorial
from collections import Counter

N = int(input())
mod = 10 ** 9 + 7


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


x = factorial(N)
p = prime_decomposition(x)

ans = 1
for v in Counter(p).values():
    ans *= v + 1
print(ans % mod)


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

bool IsW(string s,int W) {
	bool flg = true;
	for (int i = 0; i < W; i++)
	{
		if (s[i] == '#')
			flg = false;
	}
	return flg;
}

bool IsH(string s[], int H, int k) {
	bool flg = true;
	for (int i = 0; i < H; i++)
	{
		if (s[i][k] == '#')
			flg = false;
	}
	return flg;
}

int main() {
	string S[110];
	int H, W;

	cin >> H >> W;

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

	//cout << endl;

	for (int i = 0; i < H; i++)
	{
		if (IsW(S[i], W)) {
			string tmp = S[i];
			int j = i;
			for (; j < H; j++)
			{
				S[j] = S[j + 1];
			}
			S[j] = tmp;
			H--;
			i--;
		}
	}
	
	for (int i = 0; i < W; i++)
	{
		//cout << IsH(S, H, i) << endl;
		if (IsH(S, H,i)) {
			for (int j = 0; j < H; j++)
			{
				int k = i;
				char tmp = S[j][k];
				for (; k < W; k++)
				{
					S[j][k] = S[j][k+1];
				}
				S[j][k] = tmp;
			}
			i--;
			W--;
		}
	}
	
	//結果
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cout << S[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()

    val g = Graph(N, 0, 1e8.toInt()) {a, b -> a + b}

    for (i in 1 until N) {
        val (a, b) = readLine()!!.split(" ").map{it.toInt() - 1}

        g.edges[a].add(Edge(a, b, 1))
        g.edges[b].add(Edge(b, a, 1))
    }

    val c = readLine()!!.split(" ").map{it.toLong()}.sorted()

    val d = Array(N) { g.edges[it].size }
    val used = Array(N) { false }
    val ans = Array(N) { -1L }

    for (t in c.indices) {
        var idx = -1
        var mx = 1e18.toInt()

        for (i in d.indices) {
            if (used[i]) continue

            if (mx > d[i]) {
                mx = d[i]
                idx = i
            }
        }

        for (e in g.edges[idx]) {
            d[e.to]--
        }
        used[idx] = true
        ans[idx] = c[t]
    }

    var res = 0L
    for (i in g.edges.indices) for (e in g.edges[i]) {
        if (e.from > e.to) continue

        res += Math.min(ans[e.from], ans[e.to])
    }

    println(res)
    println(ans.joinToString(" "))
}

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

inline fun <reified T: Comparable<T>>dijkstra(g: Graph<T>, s: Int): Pair<Array<T>, Array<Int>> {
    val N = g.n
    val dist = Array(N) { g.inf }
    val prev = Array(N) {-1}

    val Q = PriorityQueue<Edge<T>>()

    dist[s] = g.zero
    Q.add(Edge(-2, s, g.zero))

    while(Q.isNotEmpty()) {
        val e = Q.peek()
        val v = e.to
        Q.poll()

        if (prev[v] != -1) continue
        prev[v] = e.from
        for (i in g.edges[v]) {
            val d = g.plus(dist[v], i.weight)
            if (dist[i.to] > d) {
                dist[i.to] = d
                Q.add(Edge(i.from, i.to, d))
            }
        }
    }

    return Pair(dist, prev)
}


Measured memory_bytes: 50600
// アルファベット総当りでやってみる
// アルファベットつーかSに登場する文字
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	SS := make([]string, len(S))
	target := make(map[string]bool)
	for i, c := range []rune(S) {
		SS[i] = string(c)
		target[string(c)] = true
	}
	keys := []string{}
	for k, _ := range target {
		keys = append(keys, k)
	}
	ans := int(1e8)
	for _, k := range keys {
		tmp_s := append([]string{}, SS...)
		tmp_ans := 0
		for {
			// なんかforで更新しながらのチェックができないのでここで一回やる
			flag := true
			for _, c := range tmp_s {
				if c != k {
					flag = false
				}
			}
			if flag {
				break
			}
			nex_s := []string{}
			for i := 0; i < len(tmp_s)-1; i++ {
				if tmp_s[i] == k || tmp_s[i+1] == k {
					nex_s = append(nex_s, k)
				} else {
					nex_s = append(nex_s, tmp_s[i])
				}
			}
			tmp_ans++
			tmp_s = append([]string{}, nex_s...)
		}
		ans = min(ans, tmp_ans)
	}
	fmt.Println(ans)
}

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


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h, w, n;
    cin >> h >> w >> n;
    ll grid[h * w];
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll sum = 0;
    for (ll i = 0; i < n;i++) {
        for (ll j = 0; j < a[i];j++){
            grid[sum] = i + 1;
            sum++;
        }
    }
    for (ll i = 0; i < h;i++){
        for (ll j = 0; j < w;j++){
            if(i%2==0){
                cout << grid[i * w + j] << " ";
            }
            else{
                cout << grid[(i+1) * w - j-1] << " ";
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)


def main():
    INF = float('INF')

    from collections import defaultdict, deque
    t = int(readline())

    for _ in range(t):
        n, a, b, c, d = map(int, readline().split())
        memo = defaultdict(lambda: INF)
        memo[n] = 0
        que = deque()
        que.append((n, 0))
        ans = n * d

        while que:
            cur, score = que.popleft()
            ans = min(ans, score + cur*d)

            if cur == 0:
                continue

            if cur % 2 == 0:
                if score + a < memo[cur // 2] and a < cur // 2 * d:
                    memo[cur // 2] = score + a
                    que.append((cur // 2, score + a))
            else:
                diff1 = cur % 2
                diff2 = 2 - diff1
                nx1 = (cur - diff1) // 2
                nx2 = (cur + diff2) // 2
                cost1 = a + diff1 * d
                cost2 = a + diff2 * d
                if score + cost1 < memo[nx1]:
                    memo[nx1] = score + cost1
                    que.append((nx1, score + cost1))
                if score + cost2 < memo[nx2]:
                    memo[nx2] = score + cost2
                    que.append((nx2, score + cost2))

            if cur % 3 == 0:
                if score + b < memo[cur // 3] and b < 2 * cur // 3 * d:
                    memo[cur // 3] = score + b
                    que.append((cur // 3, score + b))
            else:
                diff1 = cur % 3
                diff2 = 3 - diff1
                nx1 = (cur - diff1) // 3
                nx2 = (cur + diff2) // 3
                cost1 = b + diff1 * d
                cost2 = b + diff2 * d
                if score + cost1 < memo[nx1]:
                    memo[nx1] = score + cost1
                    que.append((nx1, score + cost1))
                if score + cost2 < memo[nx2]:
                    memo[nx2] = score + cost2
                    que.append((nx2, score + cost2))

            if cur % 5 == 0:
                if score + c < memo[cur // 5] and c < 4 * cur // 5 * d:
                    memo[cur // 5] = score + c
                    que.append((cur // 5, score + c))
            else:
                diff1 = cur % 5
                diff2 = 5 - diff1
                nx1 = (cur - diff1) // 5
                nx2 = (cur + diff2) // 5
                cost1 = c + diff1 * d
                cost2 = c + diff2 * d
                if score + cost1 < memo[nx1]:
                    memo[nx1] = score + cost1
                    que.append((nx1, score + cost1))
                if score + cost2 < memo[nx2]:
                    memo[nx2] = score + cost2
                    que.append((nx2, score + cost2))

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 113844
#include <iostream>
#include <stack>
#include <vector>
#include <map>

using namespace std;


int pwr(int n){
    if(n<=0) return 1;
    return 10 * pwr(n-1);
}





int main(){
    for (; ;) {
        int times=0;
        map<int,int> mem;
        int a,l;
        cin >> a >> l;
        int aa =a;
        if(a==0 and l ==0) break;
        while(true){
        int p=0;
        vector<int> A(10,0),B(10,0);
        while (a >0) {
            p++;
            A[a%10]++;
            B[a%10]++;
            a /= 10;
        }
            A[0]+=l-p;
            B[0]+=l-p;
        int ma=0,mi=0;
        int q=l, r=l;
        for (int i=9; i>=0; i--) {
            while (A[i]>0) {
                ma += i*pwr(q-1);
                q--;
                A[i]--;
                //cout << A[i]<<endl;
            }
        }
           /* for (int i=0; i<10; i++) {
                cout << B[i]<<" ";
            }
            cout <<endl;*/
            r-=B[0];
        for (int i=1; i<10; i++) {
            while (B[i]>0) {
                mi += i*pwr(r-1);
                r--;
                B[i]--;
            }
        }
            a = ma-mi;
            //cout <<"|"<<a<<","<<ma<<","<<mi<<"|";
            times++;
            if(mem[a]==0 and a != aa){
                mem[a]= times;
                continue;
            }else{
                if (a == aa) {
                    cout << 0 <<" "<< a <<" "<< times<<endl;
                    break;
                }
                cout << mem[a] <<" "<<a <<" "<< times - mem[a]<<endl;
                break;
            }
            
            
    }
    }
}

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

using namespace std;

int main(){
	string s;
	cin>>s;
	int n=s.length();
	int f=0,l=s.length()-1;
	while(f<l){
		if(s[f]!=s[l]){
			break;
		}
		f++;l--;
	}
	if(f>=l){
		f=0;l=(n-3)/2;
		while(f<l){
			if(s[f]!=s[l]){
				break;
			}
			f++;l--;
		}
		if(f>=l){
			f=(n+1)/2;
			l=n-1;
			while(f<l){
			if(s[f]!=s[l]){
				break;
			}
			f++;l--;
			}
			if(f>=l){
				cout<<"Yes"<<endl;
			}
			else{
				cout<<"No"<<endl;
			}
		}else{
			cout<<"No"<<endl;
		}
	}
	else{
		cout<<"No"<<endl;
	}
}



Measured memory_bytes: 3612
from collections import Counter
def check():
  N = int(input())
  D = list(map(int, input().split()))
  M = int(input())
  T = list(map(int, input().split()))
  d = Counter(D)
  t = Counter(T)
  for k,v in t.items():
    if d[k]<v:
      return 'NO'
  return 'YES'
print(check())

Measured memory_bytes: 57136