akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const long MOD = 3.037e+09; // sqrt(LONG_MAX)
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unordered_map<string, ll> h2c; // hash => count
    int n;
    cin >> n;
    string str;
    for (int i = 0; i < n; ++i) {
        cin >> str;
        string sstr = str;
        sort(sstr.begin(), sstr.end());
        ++h2c[sstr];
    }

    unsigned long long ans = 0;
    for (auto pa : h2c) {
        ans += (pa.second) * (pa.second - 1) / 2;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 10660
#include "bits/stdc++.h"

using namespace std;

void Main() {
    int K, S;
    cin >> K >> S;

    map<int, int> YpZ;
    for (int Y = 0; Y <= K; ++Y) {
        for (int Z = 0; Z <= K; ++Z) {
            int YZ = Y + Z;
            if (YpZ.count(YZ) == 0) {
                YpZ.insert(make_pair(YZ, 0));
            }
            YpZ[YZ] += 1;
        }
    }
    int ans = 0;
    for (int X = 0; X <= K; ++X) {
        if (S < X) {
            break;
        }
        if (YpZ.count(S - X) == 0) {
            continue;
        }
        ans += YpZ[S - X];
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3828
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
A_array = na()
a_dic = {}

ans = 0
for a in A_array:
    ans += a
    if a in a_dic:
        a_dic[a] += 1
    else:
        a_dic[a] = 1

ans_array = []

Q = ni()
for _ in range(Q):
    b, c = na()
    if b in a_dic:
        if c in a_dic:
            a_dic[c] += a_dic[b]
        else:
            a_dic[c] = a_dic[b]
        ans = ans + (c - b) * a_dic[b]
        a_dic[b] = 0
    ans_array.append(ans)

print("\n".join(map(str, ans_array)))


Measured memory_bytes: 96732
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll x, y;
  cin >> x >> y;
  if (y%2 == 0 && x*2 <= y && x*4 >= y) {
    cout << "Yes" << '\n';
  }
  else {
    cout << "No" << '\n';
  }
}

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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N);
	ll sum = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	bool can = true;
	ll x = N*(N + 1) / 2;
	if (sum % x != 0) { can = false; }

	ll n = sum / x;
	ll cnt = 0;
	for (int i = 0; i < N; ++i) {
		ll diff = a[i] - a[(i - 1 + N) % N] - n;
		if ((diff > 0) || (diff % N != 0)) {
			can = false;
		} else {
			cnt += abs(diff / N);
		}
	}
	if (cnt != n) { can = false; }

	if (can) { cout << "YES" << endl; }
	else { cout << "NO" << endl; }

	return 0;
}


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

int main() {
	char s[100], p[100];
	int i, j, sl, pl;
	bool judge = false;
	cin >> s >> p;
	sl = strlen(s);
	pl = strlen(p);
	for (i = 0; i < sl; i++) {
		for (j = 0; j < pl; j++) {
			if (s[(i + j) % sl] != p[j]) {
				break;
			}
		}
		if (j == pl) {
			judge = true;
			break;
		}
	}
	if (judge == true)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string s;
  cin >> s;
  int l = 0, r = s.size() - 1;
  int x = 0;
  while (l < r)
  {
    if (s[l] == s[r])
      l++, r--;
    else
    {
      if (s[l] == 'x')
        x++, l++;
      else if (s[r] == 'x')
        x++, r--;
      else
      {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << x << endl;
  return 0;
}

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

int main()
{
  int n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    int a;
    cin>>a;
    if(i&1&&a&1)
      ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    static FastScanner sc = new FastScanner();
    public static void main(String[] args) {

        int mod=sc.nextInt();
        
        int val=7%mod;
        for (int i=1;i<1e6;i++){
            if (val==0){
                System.out.println(i);
                return;
            }
            else{
                val=(val*10+7)%mod;
            }

        }
        System.out.println("-1");



    }

        static void sortint(int[] a) {
        ArrayList<Integer> l=new ArrayList<>();
        for (int i:a) l.add(i);
        Collections.sort(l);
        for (int i=0; i<a.length; i++) a[i]=l.get(i);
    }
    static void sort(long[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (long i : a) l.add((int) i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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





Measured memory_bytes: 32844
#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <cstdio>

using namespace std;

int main(void) {

    int N;
    cin >> N;

    int diff = -1e9, begin;
    cin >> begin;
    for (int i = 0, r; i < N - 1; ++i) {
        cin >> r;
        if (r - begin > diff)
            diff = r - begin;
        if (r < begin)
            begin = r;
    }

    printf("%d\n", diff);

    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(int i=a; i<n; i++)
#define loop(i,a,n)	for(int i=a; i>=n; i--)
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int temp=x;
  int temp2=y;
  x=z;
  y=temp;
  z=temp2;
  cout<<x<<" "<<y<<" "<<z;
  return 0;
}

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

int main() {
	int a,b,c;
	scanf("%d %d", &a, &b);
	if (b==1){
		c=0;
	} else {
		c=a-b;
	}
	printf("%d\n",c);
	return 0;
}    

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

int main(){
    while(1){
        string s, t;
        cin >> s;
        if (s == ".") break;
        cin >> t;
        if (s == t) cout << "IDENTICAL" << endl;
        else {
            int k = (int)s.size();
            vector<string> check_s;
            bool flag = false;
            int start = 0;
            for (int i = 0; i < k; i++){
                if (flag){
                    if (s[i]=='"'){
                        flag = false;
                        check_s.push_back(s.substr(start, i - start + 1));
                        start = i + 1;
                    }
                }
                else if (s[i] == '"'){
                    check_s.push_back(s.substr(start, i - start));
                    flag = true;
                    start = i;
                }
            }
            if (start != k) check_s.push_back(s.substr(start));

            int l = (int)t.size();
            vector<string> check_t;
            flag = false;
            start = 0;
            for (int i = 0; i < l; i++){
                if (flag){
                    if (t[i]=='"'){
                        flag = false;
                        check_t.push_back(t.substr(start, i - start + 1));
                        start = i + 1;
                    }
                }
                else if (t[i] == '"'){
                    check_t.push_back(t.substr(start, i - start));
                    flag = true;
                    start = i;
                }
            }
            if (start != l) check_t.push_back(t.substr(start));

            if (check_s.size() != check_t.size()) cout << "DIFFERENT" << endl;
            else{
                int y = (int)check_s.size();
                int ans = 0;
                int cnt = 0;
                for (int i = 0; i < y; i++){
                    if (check_s[i] != check_t[i]) cnt++;
                    if (check_s[i] != check_t[i] && i % 2) ans++;
                }
                if (ans == 0 && cnt == 0) cout << "IDENTICAL" << endl;
                else if (ans == 1 && cnt == 1) cout << "CLOSE" << endl;
                else cout << "DIFFERENT" << endl;
            }
        }
    }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
#define pl pair<ll,ll>
#define p_q priority_queue<pl>
using namespace std;
ll a,b;
ll ans=0;
int main()
{
	p_q q;
	int n,t;
	cin>>n>>t;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		q.push(pl(-a,b));
	}
	while(t>0)
	{
		pl c=q.top();
		q.pop();
		ll f=-c.first,s=c.second;
		if(t<s)
		{
			ans+=f*t;
			break;
		}
		else
		{
			ans+=f*s;
			t-=s;
		}
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 2420
#include<stdio.h>
int main()
{
	char s[10];
	scanf("%s", s);
	int a, b, c, d;
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	if (a + b + c + d == 7) printf("%d+%d+%d+%d=7", a, b, c, d);
	else if (a + b + c - d == 7) printf("%d+%d+%d-%d=7", a, b, c, d);
	else if (a + b - c - d == 7) printf("%d+%d-%d-%d=7", a, b, c, d);
	else if (a+ b - c + d == 7) printf("%d+%d-%d+%d=7", a, b, c, d);
	else if (a-b-c + d == 7) printf("%d-%d-%d+%d=7",a, b, c, d);
	else if (a - b - c -d == 7) printf("%d-%d-%d-%d=7", a, b, c, d);
	else if (a - b + c - d == 7) printf("%d-%d+%d-%d=7", a, b, c, d);
	else if (a - b + c + d == 7) printf("%d-%d+%d+%d=7", a, b, c, d);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<utility>
#include<algorithm>
#include<vector>
#include<queue>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#define INF 2147483647
#define n 300000
#define loop(i, a, b) for(int i=a; i<=b; i++)
#define mem(arr) memset(arr, 0, sizeof(arr));
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
struct edge{
	int to, weight;
};
void solve();
int main()
{
	int times = 1;
//	cin >> times;
	loop(i, 1, times)
	{
		solve();
		cout << '\n';
	}
	return 0;
}
vector<edge> V[n + 50];
int a, b, c, d, e, f;
int arr[n + 50], arr1[n + 50], arr2[n + 50];
string str, str1, str2;

void solve()
{
	cin >> a;
	for(int i=max(a, 2); ;i++)
	{
		int tmp = sqrt(i), yes = true;
		for(int j=2; j<=tmp; j++)
		{
			if(i % j == 0)
			{
//				cout << "try";
				yes = false;
				break;
			}
		}
		if(yes)
		{
			cout << i;
			return;
		}
	}
}

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


int main(){
 	//freopen("in", "r", stdin);
  	//freopen("out", "w", stdout);
	int tc;
	//scanf("%d", &tc);
	tc = 1;
	for(int tt = 1 ; tt <= tc; ++tt){
	   string s;
	   cin >> s;
	   stack<int>st;
	   for(int i = 0; i < (int)s.size(); ++i){
	    	if(s[i] == '0')st.push(0);
	    	else if(s[i]  == '1')st.push(1);
	    	else if(!st.empty())st.pop();
	   }
	   vector<int>ans;
	   while(!st.empty()){
	    	ans.push_back(st.top());
	    	st.pop();
	   }
	   for(int i = ans.size() -1; i >=0; --i)printf("%d", ans[i]);
	//	fprintf(stderr, "caso de teste %d resolvido\n", tt);
	//	fflush(stderr);
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int ABS(int a){return max(a,-a);}
int main(){
	int n,a,b,c,d;
	scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);a--;b--;c--;d--;
	int ret=9999999;
	for(int i=1;i<=n;i++){
		ret=min(ret,ABS(a/i-b/i)+ABS(a%i-b%i)+ABS(c/i-d/i)+ABS(c%i-d%i));
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1028
read s
s=(`echo $s|fold -1`)
read t
t=(`echo $t|fold -1`)
ans=1010
for((i=0;i<=${#s[@]}-${#t[@]};i++));do
	c=0
	for((j=0;j<${#t[@]};j++));do
		if [ ${s[i+j]} != ${t[j]} ];then
			c=$[c+1]
		fi
	done
	if [ $ans -gt $c ];then
		ans=$c
	fi
done
echo $ans


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

int main(){
    long long n,c;
    cin>>n>>c;
    long long x[n],v[n];
    long long ans=0;
    long long sum=0,r[n]={};

    for(int i=0;i<n;i++){
        cin>>x[i]>>v[i];
        sum+=v[i];
        ans=max(ans,sum-x[i]);
        if(i){
            r[i]=max(r[i-1],sum-2*x[i]);
        }
        else r[i]=sum-2*x[i];
    }

    sum=0;
    long long l[n]={};

    for(int i=n-1;i>=0;i--){
        sum+=v[i];
        if(i==n-1){
            l[i]=sum-2*(c-x[i]);
        }
        else{
            l[i]=max(l[i+1],sum-2*(c-x[i]));
        }
        if(i) ans=max(ans,r[i-1]+sum-c+x[i]);
        ans=max(ans,sum-c+x[i]);
        //cerr<<ans<<endl;
    }

    sum=0;

    

    for(int i=0;i<n-1;i++){
        sum+=v[i];
        ans=max(ans,sum-x[i]+l[i+1]);
        cerr<<ans<<endl;
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
using namespace std;

int main() {
	int S, W;
	cin >> S >> W;
	if (S <= W) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(){
  int dist, rad;
  int rad_amount;
  float x, y;
  int a, b;
  float TRANS=3.14159f/180.0f;

  x=0.0; y=0.0; rad_amount=0;
  while(1){
    scanf("%d,%d", &dist, &rad);
    if(dist==0 && rad==0) break;
    x+=(float)dist*sin((double)rad_amount*TRANS);
    y+=(float)dist*cos((double)rad_amount*TRANS);
    rad_amount+=rad;
    if(rad_amount>180) rad_amount-=360;
    if(rad_amount<-180) rad_amount+=360;
  }
  printf("%d\n%d\n", (int)x, (int)y);

  return 0;
}

Measured memory_bytes: 0
fn solve(a: usize, b: usize, c: usize, x: usize, y: usize) -> usize {
    if a + b <= c * 2 {
        a * x + b * y
    } else {
        c * x * 2 + std::cmp::min(b * (y - x), c * 2 * (y - x))
    }
}

fn main() {
    let (a, b, c, x, y) = read_tup5();

    if x > y {
        println!("{}", solve(b, a, c, y, x));
    } else {
        println!("{}", solve(a, b, c, x, y));
    }
}

fn read_tup5<T: std::str::FromStr + Copy>() -> (T, T, T, T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let v = s.trim().split_whitespace()
        .map(|c| c.parse().ok().unwrap())
        .collect::<Vec<T>>();
    (v[0], v[1], v[2], v[3], v[4])
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int q;
  cin >> q;
  int ans = 0;
  while (q--) {
    int x;
    cin >> x;
    bool found = false;
    int lo = 0, hi = n - 1;
    while (lo <= hi) {
      int mid = (lo + hi) >> 1;
      if (a[mid] == x) { 
        found = true;
        break;
      } else if (a[mid] > x) {
        hi = mid - 1;
      } else {
        lo = mid + 1;
      }
    }
    ans += found;
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3348
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
count=0
ans=0
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(n):
  for j in range(m):
    count += a[i][j]*b[j]
  if count+c>0:
    ans += 1
  count = 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string a,b;
int main() {
    cin>>a>>b;
    sort(b.begin(),b.end(),greater<char>());
    sort(a.begin(),a.end());
    if(a<b)cout<<"Yes"<<endl; else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    int N,T;
    cin >> N >> T;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int M = A[A.size()-1];
    map<int,int> ma;
    for(int i=A.size()-1;0<=i;i--){
        ma[M - A[i]]++;
        M = max(M,A[i]);
    }
    auto E = ma.end();
    E--;
    cout << E->second << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rg register
#define llint long long
using namespace std;
const int N=1008611;

struct ios{
	template <typename _tp>
	inline ios operator >> (_tp &x){
		char c = getchar();int f = 1;x = 0; 
		for(;c<'0'||c>'9';c=getchar()) if(c=='-') f = -1;
		for(;c>='0'&&c<='9';c=getchar()) x = (x<<1)+(x<<3)+(c^48);
		x *= f;
		return *this;
	}
	template <typename _tp>
	inline ios operator << (_tp x){
		char s[66];int dgt = 0;
		if(x==0) putchar('0');
		if(x<0) putchar('-'),x = -x;
		while(x)
			++dgt,s[dgt] = x%10+'0',x /= 10;
		while(dgt)
			putchar(s[dgt]),--dgt;
		return *this; 
	}
}io;

char s[N];
int nxt[N],ans[N],n;

int main()
{
	scanf("%s",s+1);
	int las = 1;n = strlen(s+1);
	for(rg int i=1;i<=n;++i){
		if(s[i]=='R') las = i;
		else nxt[i] = las;
	}
	las = n;
	for(rg int i=n;i>=1;--i){
		if(s[i]=='L') las = i;
		else nxt[i] = las;
	}
	for(rg int i=1;i<=n;++i){
		if(s[i]==s[nxt[i]]) ++ans[nxt[i]];
		else if(s[i]=='R'){
			if((nxt[i]-i)&1) ++ans[nxt[i]-1];
			else{
				++ans[nxt[i]];
			}
		}
		else{
			if((i-nxt[i])&1) ++ans[nxt[i]+1];
			else{
				++ans[nxt[i]];
			}
		}
	}
	for(rg int i=1;i<=n;++i){
		io << ans[i],putchar(' '); 
	}
	putchar('\n');
	return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    string s;
    cin >> s;

    if(s == "keyence"){
        cout << "YES" << endl;
        return 0;
    }

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < s.size(); j++){
            string str = "";
            for(int k = 0; k < s.size(); k++){
                if(i < k && k < j) continue;
                else str += s[k];
            }

            if(str == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;


const int SIZE = 101;
int n;
int X[SIZE];

bool input() {
    if ( ! ( cin >> n && n ) ) return false;
    for ( int i = 0; i < n; ++ i ) {
        cin >> X[i];
    }
    return true;
}

string to_string( int n ) {
    OSS oss;
    oss << n;
    return oss.str();
}

int to_int( string s ) {
    ISS iss(s);
    int res;
    iss >> res;
    return res;
}

int get_next( int x ) {
    int res = 0;
    string s = to_string(x);
    int n = s.size();
    for ( int i = 1; i < n; ++ i ) {
        string sl = s.substr( 0, i );
        string sr = s.substr( i );
        int nl = to_int( sl );
        int nr = to_int( sr );
        res = max( res, nl * nr );
    }
    return res;
}

int calc( int x ) {
    int res = 0;
    while ( x >= 10 ) {
        x = get_next(x);
        res ++;
    }
    return res;
}

void solve() {
    for ( int i = 0; i < n; ++ i ) {
        cout << calc(X[i]) << endl;
    }
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1228
function Main(input) {
  input = input.split("\n").map(v => v.split(" "));
  input = parseInt(input[0][0], 10);
  const str = "ACL";
  let res = "";
  
  for (let i = 0; i < input; i++) {
    res += str;
  }
  console.log(res);
}
// 魔法
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29656
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <map>
#include <algorithm>
using Int = long long;
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main()
{
    int N, T; cin >> N >> T;
    vector<int> t(N);
    REP(i, N) cin >> t[i];
    int sum = 0;
    for (int i = 1; i < N; i++) {
        sum += min(t[i] - t[i-1], T);
    }
    sum += T;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
const ll p = 1000000007;
const ll NMAX = 210000;
ll fac[NMAX],finv[NMAX],inv[NMAX];
void combinit(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	
	FORq(i,2,NMAX-1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}
long long comb(ll n,ll r){
	if (n<r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n-r] % p) % p;
}
int main(){
	combinit();
	ll H,W,A,B;
	cin >> H >> W >> A >> B;
	
	ll ans = 0;
	
	for(ll r = B;r<=W-1;r++){ //回数
		ll n1 = ((H-A-1)+r) % p;
		ll n2 = ((A-1) + (W-r-1)) % p;
		
		ll n1cr = comb(n1,r);
		ll n2cr = comb(n2,A-1);
		
		ans = (ans + ((n1cr * n2cr) % p) ) % p;
	}
	
	PRINTLLD(ans);
	return 0;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using product = pair<ll,ll>;
using graph = vector<vector<ll>>;
using vll = vector<ll>;


const int MAX = 3000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    ll X,Y;
    cin>>X>>Y;
    ll res=0;
    ll n=(2*Y-X)/3;
    ll m=(2*X-Y)/3;
    if((X+Y)%3!=0){
        res=0;
    }else if(n < 0 || m < 0){
        res=0;
    }else{
        COMinit();
        res=COM(n+m,n)%MOD;
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 73908
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

// longest increasing subsequence
template <typename T>
int lis(vector<T> &v, T inf) {
    vector<T> a(v.size(), inf);
    for (int i = 0; i < v.size(); ++i) {
        *lower_bound(a.begin(), a.end(), v[i]) = v[i];
    }
    return lower_bound(a.begin(), a.end(), inf) - a.begin();
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<int>> edges(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edges[u].emplace_back(v);
        edges[v].emplace_back(u);
    }
    vector<lint> lis(n, inf);
    vector<int> ret(n);
    lis[0]                       = a[0];
    ret[0]                       = 1;
    function<void(int, int)> dfs = [&](int c, int p) {
        for (auto &v : edges[c]) {
            if (v == p)
                continue;
            int revidx  = lower_bound(lis.begin(), lis.end(), a[v]) - lis.begin();
            lint rev    = lis[revidx];
            lis[revidx] = a[v];
            ret[v]      = lower_bound(lis.begin(), lis.end(), inf) - lis.begin();
            dfs(v, c);
            lis[revidx] = rev;
        }
    };
    dfs(0, -1);
    for (auto &r : ret) {
        cout << r << "\n";
    }
    return 0;
}

Measured memory_bytes: 35240
#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 print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  // abs取るのは、値が見つからなかったときの処理をINFで統一させたいから(-INFあるとめんどい）
  int sRight = *lower_bound(all(s), x);
  int sLeft = *(upper_bound(all(s), x) - 1);
  int tRight = *lower_bound(all(t), x);
  int tLeft = *(upper_bound(all(t), x) - 1);

  int ret = INF;

  // (s, t) -> x -> (t, s)
  chmin(ret, abs(x - min(sLeft, tLeft)));

  // s -> x -> t {
  chmin(ret, min(abs(x - sLeft), abs(x - tRight)) + abs(sLeft - tRight));

  // t -> x -> s {
  chmin(ret, min(abs(x - tLeft), abs(x - sRight)) + abs(tLeft - sRight));

  // x -> (s, t) -> (t, s)
  chmin(ret, abs(max(sRight, tRight) - x));

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると値が見つからなかったときの処理が楽になる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    dbg(ans)
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
from sys import stdin, setrecursionlimit
from collections import deque


def main():
    input = stdin.buffer.readline
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        g[a - 1].append(b - 1)
        g[b - 1].append(a - 1)

    result = []

    d = [[10 ** 12, -1] for _ in range(n)]
    d[0] = [0, 0]

    q = deque()
    q.append(0)

    while q:
        now_i = q.popleft()

        for next_i in g[now_i]:
            if d[next_i][0] > d[now_i][0] + 1:
                d[next_i] = [d[now_i][0] + 1, now_i]
                q.append(next_i)

    for di in d:
        if di[0] == 10 ** 12:
            print('No')
            exit()

    print('Yes')
    for di in d[1:]:
        print(di[1] + 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 105636
import numpy
MOD = 10 ** 9 + 7
 
 
# a ^ b % MOD
def pow_mod(value, exp):
    r = 1
    while exp:
        if exp % 2:
            r *= value
            r %= MOD
        value *= value
        value %= MOD
        exp //= 2
    return r
 
 
fact = [1] * 1000001
for i in range(1, 1000000 + 1):
    fact[i] = fact[i - 1] * i % MOD

x, y = map(int, input().split())

if (x + y) % 3 or x > y * 2 or y > x * 2:
    print("0")
    exit()

a, b = map(int, numpy.linalg.solve([[2, 1], [1, 2]], [x, y]))

ans = fact[a + b] % MOD
# ans /= fact[a] (mod 10^9 + 7)
ans *= pow_mod(fact[a], MOD - 2)
ans %= MOD
# ans /= fact[b] (mod 10^9 + 7)
ans *= pow_mod(fact[b], MOD - 2)
ans %= MOD
print(ans)

Measured memory_bytes: 54312
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if(a == 0 && b == 0) break;
			
			if (a < b) {
				System.out.println(a + " " + b); 
			} else {
				System.out.println(b + " " + a); 
			}
		}
	}
}


Measured memory_bytes: 34684
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int>v[n+1];
    int dp[n+1][3];
    for(int i=1;i<=n;i++){
    int x,y,z;cin>>x>>y>>z;
    v[i]={x,y,z};}
    dp[1][0]=v[1][0],dp[1][1]=v[1][1],dp[1][2]=v[1][2];
  for(int i=2;i<=n;i++){
      dp[i][0]=v[i][0]+max(dp[i-1][2],dp[i-1][1]);
      dp[i][1]=v[i][1]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=v[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=55;
const int N=50;
const int mod=1e9+7;
int n;
ll f[maxn][maxn<<1],fac[maxn],inv_fac[maxn];
int main()
{
	fac[0]=fac[1]=inv_fac[0]=inv_fac[1]=1;
	for(int i=2;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<maxn;i++) inv_fac[i]=(mod-mod/i)*inv_fac[mod%i]%mod;
	for(int i=2;i<maxn;i++) (inv_fac[i]*=inv_fac[i-1])%=mod;
	scanf("%d",&n);
	f[0][N+1]=1;
	for(int i=0;i<n;i++)
	{
		if(i==0)
		{
			int x=1,y=0;
			for(int d=-y;d<=x;d++)
				(f[i+x+y][N+d]+=f[i][N+x-y]*inv_fac[x-d]%mod*inv_fac[y+d])%=mod;
			continue;
		}
		for(int x=0;x<=n-i;x++)
			for(int y=0;y<=n-i-x;y++)
				if(x+y>0)
					for(int d=-y;d<=x;d++)
						(f[i+x+y][N+d]+=f[i][N+x-y]*inv_fac[x-d]%mod*inv_fac[y+d])%=mod;
	}
	printf("%lld\n",(fac[n]*f[n][N]%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 3832
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

l, r = load_list()
mn = 2019
for i in range(l, l+2019):
    if l > r:
        break
    for j in range(i+1, l+2019):
        if j > r:
            break
        mn = min(mn, (i*j) % 2019)

print(mn)
        
    

Measured memory_bytes: 3316
#include"bits/stdc++.h"
#include"math.h"
using namespace std;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
 

using ll = long long int;
using ld = long double;
using pii = pair<int,int>;

#define REP(i,m,n) for(ll i = m; i < (ll)(n);++i)
#define rep(i,n) REP(i,0,n)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
 
using vi=vc<int>;

const ll mod=1e9+7;
const ll INF = 1e18;
  
int main(){
  cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
  
  int n;cin >> n ;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(all(l));
  int ans=0;
  for(int i=n-1;i>0;i--){
    for(int j=1;j<i;j++){
      for(int k=0; k<j;k++){
        
        if(l[i]<l[j]+l[k]){
          ans++;
        }
        
      }
    }
   
  }
  cout << ans << endl;
}
  

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

a = []
b = []

for i in range(n):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])

a_sort = sorted(a)
b_sort = sorted(b)

flags = [False] * n

s = 0

if n % 2 == 1:
    s = b_sort[n//2] - a_sort[n//2] + 1

else:
    p_min = a_sort[(n//2)-1]
    p_max = b_sort[(n//2)-1]
    q_min = a_sort[(n//2)]
    q_max = b_sort[(n//2)]

    s = ((p_max+q_max) - (p_min+q_min) ) + 1
print(s)




Measured memory_bytes: 30160
N,M=map(int,input().split())
mod=10**9+7
S=[int(i) for i in input().split()]
T=[int(i) for i in input().split()]
dp=[[0]*(M+1) for i in range(N+1)]
dp[0][0]=1
Sum=[[0]*(M+1) for i in range(N+1)]
for i in range(N+1):
  Sum[i][0]=1
for j in range(M+1):
  Sum[0][j]=1
for i in range(N):
  for j in range(M):
    if S[i]==T[j]:
      dp[i+1][j+1]=Sum[i][j]
    Sum[i+1][j+1]=(dp[i+1][j+1]+Sum[i][j+1]+Sum[i+1][j]-Sum[i][j])%mod
print(Sum[N][M]) 
#print(dp)
#print(Sum)

Measured memory_bytes: 104796
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = tuple(map(int, input().split()))

    # I = A.count(1)
    # J = A.count(2)
    # K = A.count(3)

    I = 0
    J = 0
    K = 0
    for a in A:
        if a == 1:
            I += 1
        elif a == 2:
            J += 1
        else:
            K += 1

    dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] 

    # def output(lst):
    #     for tmp in lst:
    #         print (tmp)

    for k in range(K + 1):
        for j in range(K + J + 1 - k):
            for i in range(N + 1 - k  - j):
                if i == j == k == 0:
                    continue
                tmp = N
                if i > 0:
                    tmp += i * dp[k][j][i - 1]
                if j > 0:
                    tmp += j * dp[k][j - 1][i + 1]
                if k > 0:
                    tmp += k * dp[k - 1][j + 1][i]
                dp[k][j][i] = tmp / (i + j + k)

    print (dp[K][J][I])

    # output(dp)

if __name__ == '__main__':
    main()

Measured memory_bytes: 508168
#include <bits/stdc++.h>
#define     mod             1000000007
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n" 
#define     ll              long long int 
#define     vi              vector<int> 
#define     vvi             vector<vector<int>>
using namespace std;


void solve(){
	int n,k;
	cin>>n>>k;
	vi v(n);
	for(int i=0;i<n;i++) cin>>v[i];

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

	int sum = 0;
	for(int i=0;i<k;i++)
		sum += v[i];
	cout<<sum;
}
 

int32_t main()
{
    IOS;

    solve();

}

Measured memory_bytes: 3648
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.85 #ループの時間制限
PROB=0.001 #突然変異の確率  
A=26 #アルファベットの数
START=time.time()
C_MIN,C_MAX=1,5
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    K=randint(C_MIN,C_MAX)
    e=randint(1,D)

    U=copy(T)
    X=0
    for d in range(e,min(e+K,D+1)):
        p=T[d]
        q=randint(1,A)
        Y=(d-g(p,d,T))*(f(p,d,T)-d)
        Z=(d-g(q,d,T))*(f(q,d,T)-d)
        X+=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
        
    if X>0 or random()<PROB:
        T[d]=q
    else:
        T=copy(U)

for i in range(1,D+1):
    print(T[i])


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int k;

int main()
{
    _FastIO;
    cin >> k;
    if(k < 1200){
        cout << "ABC" << endl;
        return 0;
    }
    if(k < 2800){
        cout << "ARC" << endl;
        return 0;
    }
    cout << "AGC" << endl;
    return 0;
}


Measured memory_bytes: 3588
import math

def dist2(a, b):
  return (a[0]-b[0])**2 + (a[1]-b[1])**2

def dist(a, b):
  return math.sqrt(dist2(a, b))

N = int(input())
coordinates = []
for _ in range(N):
  x, y = map(int, input().split())
  coordinates.append((x, y))

ans = 0
for i in range(N):
  for j in range(i+1,N):
    ans += dist(coordinates[i], coordinates[j])

print(ans*2/N)

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

namespace ARC068D {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Array.Sort(input);
            int even = 0;
            int odd = 0;
            int nownum = input[0];
            int nowcount = 1;
            for (int i = 1; i < N; i++) {
                if (input[i] == nownum) {
                    nowcount++;
                } else {
                    if (nowcount % 2 == 0) {
                        even++;
                    } else {
                        odd++;
                    }
                    nownum = input[i];
                    nowcount = 1;
                }
            }
            if (nowcount % 2 == 0) {
                even++;
            } else {
                odd++;
            }
            int ans = even + odd;
            if (even % 2 == 1) {
                ans--;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 18144
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n = int(input())
    a = list(map(int, input().split()))
    s = sum(a)
    t = list(itertools.accumulate(a))
    print(min(abs(s-2*t[i]) for i in range(0, n-1)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 24168
import sys
import random
N = int(input())
H = [int(x) for x in input().split()]

if N==1:
    print("Yes")
    sys.exit()

K_left=H[1]-H[0]
if K_left<-1:
    print("No")
    sys.exit()
elif K_left == -1 :
    L_left='-'
elif K_left == 0 :
    L_left='0'
else:
    L_left='+'
maxH=max(H[1],H[0])
for i in range(1,N-1):
    K_right = H[i+1]-H[i]    
    if K_right < -1:
        print("No")
        sys.exit()
    elif K_right == -1 :
        L_right='-'
    elif K_right == 0 :
        L_right='0'
    else:
        L_right='+'

    if L_left =='-' and L_right=='-':
        print("No")
        sys.exit()
    if L_left =='0' and L_right=='-':
        if maxH <= H[i]:
            L_left=L_right
            K_left=K_right
        else:
            print("No")
            sys.exit()
    else:
        L_left=L_right
        K_left=K_right
        maxH=max(H[i+1],maxH)
print("Yes")

Measured memory_bytes: 14780
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <tuple>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#include <random>
#include <cmath>

using namespace std;
using lint = long long int;



int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a - b * 2, 0) << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i <= n/4; i++ {
		for j := 0; j <= n/7; j++ {
			if i*4+j*7 == n {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#include <stdio.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pie 3.141592653

using namespace std;


int main()
{
	IO;

	int tot = 0;
	string s, k;
	cin >> s >> k;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != k[i])
			tot++;
}
	cout << tot;

	return 0;
}


Measured memory_bytes: 3780
fun main(args: Array<String>) {
    val n = readInt()
    val a = readLine()!!.split(" ").map { it.toLong() }

    println(calc(a))
}

fun calc(l: List<Long>): Long {
    if (l.contains(0)) return 0

    val max = 1_000_000_000_000_000_000
    var ans = 1L
    l.forEach {
        if (ans > max / it) return -1
        ans *= it
    }
    return ans
}


fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 63192
#include<stdio.h>
int min(int a, int b){return a>b?b:a;}
int n, i;
int a;
int ans, now;
int main(){
  ans = 16384;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &a);
    now=0;
    while(!(a&1)){a>>=1; now++;}
    ans = min(now, ans);
  }
  printf("%d\n", ans);
}


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

int findSumOfDigits(int x) {
  int sum = 0;
  while(x > 0) {
    sum += x % 10;
    x -= x % 10;
    x /= 10;
  }
  return sum;
}

int main () {
  string ans = "No";
  int N;
  cin >> N;
  int sum = findSumOfDigits(N);
  if(N % sum == 0) {
    ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

    vector<ll> dp(n+1,LINF);

    dp[0] = 0;
    for(int i = 1;i<=n;i++){
        for(int pow6 = 1;pow6 <= i;pow6 *= 6){
            dp[i] = min(dp[i], dp[i - pow6] + 1);
        }
        for(int pow9 = 1;pow9 <= i;pow9 *= 9){
            dp[i] = min(dp[i], dp[i - pow9] + 1);
        }
    }
    cout << dp[n]<<endl;


    return 0;
}



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

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy"<<endl;
    if(s == "Cloudy")
        cout << "Rainy"<<endl;
    if(s == "Rainy")
        cout << "Sunny"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
  int x,y;
  scanf("%d %d", &x,&y);

  if(x==2||y==2){
    printf("No\n");
  }else{
    if(x < 8){
      if(y>=8){
        if(y%2!=x%2){
          printf("Yes\n");
        }else{
          printf("No\n");
        }
      }else{
        if(y%2==x%2){
          printf("Yes\n");
        }else{
          printf("No\n");
        }
      }
    }else {
      if(y%2==x%2){
        printf("Yes\n");
      }else{
        printf("No\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 128