akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, ans, Group[50];
bool Graph[50][50];

int Solve(int A, int B){
  for (int i = 0; i < N; i++) Group[i] = i;
  Graph[A][B] = false; Graph[B][A] = false;

  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (!Graph[i][j]) continue;
      int Gi = Group[i], Gj = Group[j];
      while (Gi != Group[Gi]) Gi = Group[Gi];
      while (Gj != Group[Gj]) Gj = Group[Gj];
      Group[i] = min(Gi, Gj);
      Group[j] = min(Gi, Gj);
      Group[max(Gi, Gj)] = min(Gi, Gj);
    }
  }
  
  int GA = Group[A], GB = Group[B];
  while (GA != Group[GA] || GB != Group[GB]){
    GA = Group[GA]; GB = Group[GB];
  }
  if (GA != GB) ans++;

  Graph[A][B] = true; Graph[B][A] = true;
  return 0;
}


int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++){
    int A, B; scanf("%d%d", &A, &B);
    Graph[A - 1][B - 1] = true;
    Graph[B - 1][A - 1] = true;
  }
  
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (Graph[i][j]) Solve(i, j);
    }
  }
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, A[111111];

int main() {
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &A[i]);
    ll mn = 2, mx = 2;
    if(A[n] != 1 && A[n] != 2) {
        puts("-1");
        return 0;
    }
    for(int i = n - 1; i >= 1; i--) {
        mn = (mn - 1) / A[i] * A[i] + A[i];
        mx = (mx + A[i + 1] - 1) / A[i] * A[i];
    }
    if(mx < mn) {
        puts("-1");
        return 0;
    }
    printf("%lld %lld\n", mn, mx + A[1] - 1);
    return 0;
}

Measured memory_bytes: 896
def allbits(n,mask):
    tmp_n = format(n,"032b")
    tmp_mask = format(mask,"032b")
    ans = 0
    for i in range(32):
        if tmp_mask[i] == "1" and tmp_n[i] == "1":
            ans += 1
    if ans == tmp_mask.count("1"):
        print(1)
    else:
        print(0)

def anybits(n,mask):
    tmp_n = format(n,"032b")
    tmp_mask = format(mask,"032b")
    flag = False
    for i in range(32):
        if tmp_mask[i] == "1" and tmp_n[i] == "1":
            flag = True
            break
    if flag:
        print(1)
    else:
        print(0)

def nonebits(n,mask):
    tmp_n = format(n,"032b")
    tmp_mask = format(mask,"032b")
    flag = False
    for i in range(32):
        if tmp_mask[i] == "1" and tmp_n[i] == "1":
            flag = True
            break
    if flag:
        print(0)
    else:
        print(1)

def countbits(n,mask):
    tmp_n = format(n,"032b")
    tmp_mask = format(mask,"032b")
    cnt = 0
    for i in range(32):
        if tmp_mask[i] == "1" and tmp_n[i] == "1":
            cnt += 1
    print(cnt)

def bit_reverse(n,mask):
    tmp_n = list(format(n,"032b"))
    tmp_mask = list(format(mask,"032b"))
    for i in range(32):
        if tmp_mask[i] == "1":
            tmp_n[i] = "0" if tmp_n[i] == "1" else "0"
    s = ""
    for i in tmp_n:
        s += i
    return int(s,2)


mask = []
for i in range(int(input())):
    tmp = list(map(int,input().split()))
    s = 0
    for j in tmp[1:]:
        s += 2**j
    mask.append(s)


b = 0
for i in range(int(input())):
    q,m = map(int,input().split())

    if q == 0:##test
        print((b>>m)&1)
    elif q == 1:##set
        b = b|mask[m]
    elif q == 2:##clear
        ##b = bit_reverse(b,mask[m])
        b = b & ~mask[m]
    elif q == 3:##flip
        b = b^mask[m]
    elif q == 4:##all
        ##allbits(b,mask[m])
        print(1 if b&mask[m]==mask[m] else 0)
    elif q == 5:##any
        print(1 if b&mask[m] else 0)
    elif q == 6:##none
        print(1 if not b&mask[m] else 0)
    elif q == 7:##count
        print((format(b&mask[m],"032b")).count("1"))
    elif q == 8:##val
        print(b&mask[m])



Measured memory_bytes: 5644
#include <iostream>

using namespace std;

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

    if  ((( a != b ) && ( b != c ) && ( a != c )) && ( a , b , c  <= 100 ))
        cout << "3";

    else if  ((( a == b ) && ( b != c) && ( a != c )) && (a , b , c <= 100 ))
        cout << "2" ;

    else if ((( a == c ) && ( a != b ) && ( b != c)) && (a , b , c <= 100))
        cout << "2" ;

    else if ((( b == c) && ( b != a ) && ( a != c )) && (a , b , c  <= 100 ))
        cout << "2" ;

        else if ((( a == b) && (b == c )&& ( a = c )) && ( a,b ,c <=100 ))
       cout << "1" ;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long count = 1;
		while(H > 0) {
			H = H / 2;
			count *= 2;
		}
		System.out.println(count - 1);
	}
}

Measured memory_bytes: 35756
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};



int main()
{
	int n,m;
	cin >> n >> m;
	vi k[15];
	for(int i = 0; i < m; i++){
		int kk; cin >> kk;
		for(int j = 0; j < kk; j++){
			int s; cin >> s;
			k[s-1].emplace_back(i);
		}
	}
	vi p(m);
	rep(i,m) cin >> p[i];

	int ans = 0;
	for(int i = 0; i < (1<<n); i++){
		int tmp = i,j = 0;
		vi flash(n,0);
		while(tmp){
			if(tmp&1){
				for(auto x: k[j]){
					flash[x]++;
				}
			}
			tmp >>= 1;
			j++;
		}
		int cnt = 0;
		for(int j = 0; j < m; j++){
			if(flash[j]%2 == p[j]) cnt++;
		}
		if(cnt == m) ans++;
	}
	cout << ans << endl;

	return 0;
}


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

namespace ABC160
{
    class B
    {
        static void Main(string[] args)
        {
            var X = long.Parse(Console.ReadLine());
            Console.WriteLine((X / 500 * 1000) + ((X % 500) / 5) * 5);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
void input_int(int*);
void output_int(int);

int main(int argc, const char * argv[]) {
    int a,b;
    input_int(&a);
    input_int(&b);
    int x=a+b,y=a-b,z=a*b;
    int mx=x;
    if (mx<y) {
        mx=y;
    }
    if (mx<z) {
        mx=z;
    }
    output_int(mx);
    return 0;
}

void input_int(int *x){
    int k,negative=0;
    *x=0;
    while (1) {
        k = getchar_unlocked();
        if (k=='-'){
            negative=1;
            break;
        }
        if ('0'<=k && k<='9') {
            *x = k-'0';
            break;
        }
    }
    
    while (1) {
        k = getchar_unlocked();
        if (k<'0'||k>'9'){
            break;
        }
        *x=(*x)*10+k-'0';
    }
    if (negative){
        *x=-(*x);
    }
}

void output_int(int x){
    char k[10];
    int negative=0,k_index=0;
    if (x<0){
        negative=1;
        x=-x;
    }
    while (x) {
        k[k_index++]=x%10;
        x/=10;
    }
    if (k_index==0){
        k[k_index++]=0;
    }
    if (negative){
        putchar_unlocked('-');
    }
    while (k_index--) {
        putchar_unlocked(k[k_index]+'0');
    }
    putchar_unlocked('\n');
}
  

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s,t;
  cin >> s >> t;
  int ret = 0;
  for(int i = 0;i < 3;i++){
    if(s[i] == t[i])ret++;
  }
  cout << ret << endl;
}


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

int main()
{
    string s;
    while(cin >> s)
    {
        int n = s.size();
        if(n < 3)
        {
            if(s[0] == s[1])
                printf("1 2\n");
            else
                printf("-1 -1\n");
            continue;
        }
        int L = -1, R = -1;
        for(int i = 0; i < n-2; i++)
        {
            if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2])
            {
                L = i + 1, R = i + 3;
                break;
            }
        }
        printf("%d %d\n", L, R);
    }
    return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

class Main {

	private static List<Integer>[] G;

	private static List<Integer> bfs(int v) {
		int n = G.length;
		int[] prev = new int[n];
		int[] dist = new int[n];
		Arrays.fill(prev, -1);
		Arrays.fill(dist, Integer.MAX_VALUE);
		dist[v] = 0;

		Queue<Integer> q = new LinkedList<>();
		q.add(v);
		while (!q.isEmpty()) {
			int x = q.poll();
			for (int nx : G[x]) {
				if (dist[nx] != Integer.MAX_VALUE) continue;
				prev[nx] = x;
				dist[nx] = dist[x] + 1;
				q.offer(nx);
			}
		}

		int id = -1, d = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			if (i == v) continue;
			for (int nx : G[i]) {
				if (nx == v && dist[i] < d) {
					d = dist[i];
					id = i;
				}
			}
		}

		List<Integer> a = new ArrayList<>();

		if (d == Integer.MAX_VALUE) return a;
		for (int i = id; i != -1; i = prev[i]) {
			a.add(i);
		}

		return a;
	}

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		G = new ArrayList[N];
		for (int i = 0; i < N; i++) {
			G[i] = new ArrayList<>();
		}

		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			G[a].add(b);
		}

		List<Integer> answer = new ArrayList<>();
		for (int v = 0; v < N; v++) {
			List<Integer> x = bfs(v);
			if (!x.isEmpty()) {
				if (answer.isEmpty()) answer = x;
				else if (x.size() < answer.size()) answer = x;
			}
		}

		if (answer.isEmpty()) {
			System.out.println(-1);
			return;
		}

		StringBuilder sb = new StringBuilder();
		sb.append(answer.size()).append("\n");
		for (Integer a : answer) sb.append(a + 1).append("\n");
		System.out.print(sb.toString());
	}
}


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

int main()
{
	long long int n,k,count=0;
	cin>>n>>k;
	n=n%k;
	while(n>k/2) {
		n=abs(n-k);
		count++;
	}
	cout<<n<<endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    vector<int> num(3);
    cin >> n >> num[0] >> num[1] >> num[2];
    string s_tmp;
    vector<pair<int, int>> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s_tmp;
        if(s_tmp == "AB")
        {
            s[i].first = 0;
            s[i].second = 1;
        }
        else if (s_tmp == "AC")
        {
            s[i].first = 0;
            s[i].second = 2;
        }
        else
        {
            s[i].first = 1;
            s[i].second = 2;
        }
        
        
    }

    vector<int> ans(n);
    if (num[0]+num[1]+num[2] == 0)
    {
        cout << "No" << endl;
        return 0;
    }
    else if (num[0]+num[1]+num[2] == 1)
    {
        for (int i = 0; i < n; i++)
        {
            if(num[s[i].first] + num[s[i].second] == 0){
                cout << "No" << endl;
                return 0;
            }
            else
            {
                if (num[s[i].first] == 0)
                {
                    num[s[i].first]++;
                    num[s[i].second]--;
                    ans[i] = s[i].first;
                }
                else{
                    num[s[i].first]--;
                    num[s[i].second]++;
                    ans[i] = s[i].second;
                }
            }
        }
        
    }
    else
    {
        if(num[s[0].first] + num[s[0].second] == 0)
        {
            cout << "No" << endl;
            return 0;
        }
        else{
            // Yes
            for (int i = 0; i < n; i++)
            {
                int s1, s2;
                s1 = s[i].first;
                s2 = s[i].second;
                if(num[s1] == 0)
                {
                    num[s1]++;
                    num[s2]--;
                    ans[i] = s1;
                }
                else if (num[s2] == 0)
                {
                    num[s1]--;
                    num[s2]++;
                    ans[i] = s2;
                }
                else
                {
                    if(i < n-1){
                        if(s1 == s[i+1].first || s1 == s[i+1].second){
                            num[s1]++;
                            num[s2]--;
                            ans[i] = s1;
                        }
                        else{
                            num[s1]--;
                            num[s2]++;
                            ans[i] = s2;
                        }
                    }else{
                        num[s1]--;
                        num[s2]++;
                        ans[i] = s2;
                    }
                }
            }
            
        }
    }
    
    cout << "Yes" << endl;
    for (int i = 0; i < n; i++)
    {
        cout << (char)('A' + ans[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 4560
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll K,X; cin>>K>>X;
    cout<< ( K*500>=X ? "Yes" : "No" )<<"\n";
}

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


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

int dp[3010][3010];

int main()
{
    string s, t;
    cin >> s >> t;
    s = ' ' + s;
    t = ' ' + t;

    int m = s.size();
    int n = t.size();

    rep(i, m) dp[i][0] = 0;
    rep(i, n) dp[0][i] = 0;

    for(int i = 1; i < m; ++i){
        for(int j = 1; j < n; ++j){
            if(s[i] == t[j]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    string ans = "";
    int x = m-1;
    int y = n-1;
    while(x > 0 && y > 0){
        if(dp[x][y] == dp[x][y-1]){
            --y;
        } else if (dp[x][y] == dp[x-1][y]){
            --x;
        } else {
            ans.push_back(s[x]);
            --x;
            --y;
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
#define PI 3.1415926535897932384626433832795
using namespace std;

int main()
{
	int64 aa;
	string ss;
	cin >> aa >> ss;
	if(aa >= 3200)
	{
		cout << ss << endl;
	}
	else
	{
		cout << "red" << endl;
	}
	return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && b==c) cout << '1';
  else if(a==b) cout << '2';
  else if(c==b) cout << '2';
  else if(a==c) cout << '2';
  else cout << '3';
  return 0;
}

Measured memory_bytes: 3528
n, m = map(int, input().split())
xyz=[list(map(int, input().split())) for i in range(n)]
x=[x[0]for x in xyz]
y=[x[1]for x in xyz]
z=[x[2]for x in xyz]
ans=[]
answer=-1
for p in range(2):
    for q in range(2):
        for r in range(2):
            tmp=[]
            for i in range(n):
                tmp.append((-1)**p*x[i]+(-1)**q*y[i]+(-1)**r*z[i])
            ans.append(tmp)
for a in ans:
    a.sort(reverse=True)
    answer=max(answer, sum(a[:m]))
    
print(answer)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define IOS   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mp    make_pair
#define pb    push_back
#define F     first
#define pi 	  3.14159265358979323846
#define S     second
#define ll    long long
#define ld    long double
#define sz(s) (ll)s.size() 
#define vl    vector < ll >
#define pll   pair < ll, ll >
#define ml    map < ll, ll >
#define mod   1000000007
#define qe	  998244353
#define MAXN  100005
#define mx    10000005
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define inv(i,a,b)  for(i=a;i>=b;i--)
#define all(a)  (a).begin(),(a).end()
using namespace std;
int main(){
//	#ifndef ONLINE_JUDGE
//    if (fopen("input.txt", "r"))
//    {
//        freopen("input.txt", "r", stdin);
//        freopen("output.txt", "w", stdout);
//    }
//	#endif
	IOS;
	ll t,n,l,l1;
	ll i,j,m,mn,q,d,x,y,sum=0,r,p,k,c;
	string s,s1;
	cin>>n;
	ll a[n];
	rep(i,0,n)cin>>a[i];
	ll dp[n][n][2];
	rep(i,0,n)dp[i][i][0]=a[i],dp[i][i][1]=-a[i];
	rep(j,1,n){
		rep(i,0,n-j){
			dp[i][i+j][0]=max(dp[i][i+j-1][1]+a[i+j],dp[i+1][i+j][1]+a[i]);
			dp[i][i+j][1]=min(dp[i][i+j-1][0]-a[i+j],dp[i+1][i+j][0]-a[i]);
//			cout<<"("<<dp[i][i+j][0]<<", "<<dp[i][i+j][1]<<") ";
		}
//		cout<<endl;
	}
	cout<<dp[0][n-1][0];
}

Measured memory_bytes: 85584
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define pf printf
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node

using namespace std;
///check n=1;
///check corner case;

int main()
{
    ll n;
    cin>>n;
    cout<<n*n<<endl;
return 0;
}


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

int main() {
    int N;
    cin >> N;
    string s, t;
    cin >> s >> t;

    for (int l = N; l >= 0; l--) {
        if (s.substr(N - l) == t.substr(0, l)) {
            cout << 2 * N - l << endl;
            return 0;
        }
    }
    return 0;
}

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

		if(n == 1)
		System.out.println(0);
		else if(n == 0)
		System.out.println(1);
	}
}

Measured memory_bytes: 35608
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
int t,ans;
void DFS(int sum, unsigned char ch){
    if(sum > t)
        return;
    if(ch == 07)
        ans++;
    if(sum<99999999){
        DFS(sum*10+3, ch|1);
        DFS(sum*10+5, ch|2);
        DFS(sum*10+7, ch|4);
    }
}
start{
    /**
    ll x=read;
    if(x==7||x==5||x==3)
        printf("YES\n");
    else
        printf("NO\n");
    string s;
    cin>>s;
    int len=s.size();
    int ans=999;
    for(int i=0;i<=len-3;++i)
    {
        int num=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        ans=min(abs(num-753),ans);
    }
    cout<<ans;**/
    t=read;
    DFS(0,0);
    cout<<ans;
	end;
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, x):
    self.x=x
    self.root=[-1]*(N+1)
    self.rnk=[0]*(N+1)
  
  def Find_root(self, x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.Find_root(self.root[x])
      return self.root[x]
    
  def Unite(self, x, y):
    x = self.Find_root(x)
    y = self.Find_root(y)
    if x==y:
      return
    elif self.rnk[x]>self.rnk[y]:
      self.root[x] += self.root[y]
      self.root[y] = x
    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      if self.rnk[x]==self.rnk[y]:
        self.rnk[y]+=1
  
  def isSameGroup(self, x, y):
    return self.Find_root(x)==self.Find_root(y)
  
  def Count(self, x):
    return -self.root[self.Find_root(x)]

N,M = map(int,input().split())
p = list(map(lambda x : int(x)-1,input().split()))
count = 0
uf = UnionFind(N)
for _ in range(M):
    i,j = map(lambda x : int(x)-1,input().split())
    uf.Unite(i,j)
for i in range(N):
    if uf.isSameGroup(p[i],i):
        count += 1
print(count)

Measured memory_bytes: 13812
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> v(n + 1);
    v[0] = 0;
    rep(i, 0, n)
    {
        int temp;
        cin >> temp;
        v[i + 1] = v[i] + temp;
    }
    // rep(i, 0, n + 1) cout << v[i] << " ";
    cout << distance(v.begin(), upper_bound(all(v), x)) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i < (int)(n+1); i++)
#define pi 3.141592653589793

int main() {
  int A, B;
  int H, M;
  double theta_A, theta_B, theta;
  double res = 0.0;

  cin >> A >> B >> H >> M;

  theta_A = pi/6.0*(H + M/60.0);
  theta_B = pi*M/30.0;

  theta = abs(theta_A - theta_B);
  
  res = sqrt(A*A + B*B - 2*A*B*cos(theta));

  cout << fixed << setprecision(20) << res << endl;

  return 0;
}

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

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pci pair<char,int>
 
using namespace std; 



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int r,d,x;
    cin>>r>>d>>x;
    for(int i = 0 ; i < 10 ; i++)
    {
        int ans = x*r-d;
        cout<<ans<<endl;
        x = ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll leng; cin >> leng;
    string s; cin >> s;
    ll ret = 0;
    dump(s)
    REP(i, leng-2){
        if ((s[i]=='A') && (s[i+1]=='B') && (s[i+2] == 'C')){
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID
/*#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define print(o) for(auto it=(o).begin();it!=(o).end();it++) cout<<*it<<" ";
#define vll vector<ll>
#define pb push_back
#define FOR(n) for(ll i=0;i<=n;i++)
#define FORd(n) for(ll i=n;i>=0;i--)
#define FORrd(a,b) for(ll i=a;i>=b;i--)
#define FORr(a,b) for(ll i=a;i<=b;i++)
#define all(x) (x).begin(),(x).end()
#define FIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define ff first
#define ss second
#define w(t) ll t;cin>>t;while(t--)

int main()
{
    FIO;
    ll n;
    cin>>n;
    unordered_set<ll> s;
    FOR(n-1)
    {
      ll k;
      cin>>k;
      s.insert(k);
    }
   if(s.size()==n)
   {
     cout<<"YES\n";
   }
  else{
    cout<<"NO\n";
  }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 8520
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    string s;
    cin >> s;
    replace(s.begin(), s.end(), ',', ' ');
    cout << s << '\n';
}


Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections.Generic;
 
public class PaizaTest{
    public static void Main(){
        var line = Console.ReadLine().Trim().Split(' ').Select(s => int.Parse(s)).ToArray();
        var num = line[1]%line[0] == 0? line[1]+line[0] : line[1]-line[0];
      	Console.WriteLine(num);
    }
}

Measured memory_bytes: 13268
N,M = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = [0]*M
for j in range(M):
	B[j] = list(map(int,input().split(" ")))

tmp = sorted(B,key=lambda x:x[1],reverse=True)
A.sort()

r = 0
for i in tmp:
	for k in range(r,N,1):
		if i[1] > A[k] and i[0] > 0:
			A[k] = i[1]
			i[0] -= 1
			r = k+1
		elif A[k] > i[1] or i[0] == 0:
			break

print(sum(A))

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

const int MAX_V = 10;
const int INF = 1 << 29;
const int MAX_N = 45;

int d[MAX_V + 1][MAX_V + 1];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(1){
		int n;
		cin >> n;
		if(n == 0) break;
		
		for(int i = 0; i != MAX_V; ++i){
			for(int j = 0; j != MAX_V; ++j){
				d[i][j] = INF;
				if(i == j)
					d[i][j] = 0;
			}
		}
		
		int v = 0;
		for(int i = 0; i != n; ++i){
			int a, b, c;
			cin >> a >> b >> c;
			v = max({a + 1, b + 1, v});
			d[a][b] = c;
			d[b][a] = c;
		}
		//cout << v << endl;
		//cout << INF*2 << endl;
		
		for(int k = 0; k != v; ++k){
			for(int i = 0; i != v; ++i){
				for(int j = 0; j != v; ++j){
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
					//cout << d[i][j] << endl;
				}
			}
		}
		
		int m = INF;
		int now = -1;
		for(int i = 0; i != v; ++i){
			int sum = 0;
			for(int j = 0; j != v; ++j){
				sum += d[i][j];
			}
			if(m > sum){
				m = sum;
				now = i;
			}
			//cout << sum << endl;
		}
		
		cout << now << " " << m << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	ll n,ans=0;
	cin>>n;
	if(n%2==1){
		puts("0");
		return 0;
	}
	n /= 2;
	while(n){
		ans += n/5;
		n /= 5;
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  ll x,a,b;cin>>x>>a>>b;

  if(a>=b)out("delicious")
  else if(b-a<=x)out("safe")
  else out("dangerous")

  return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> xs(n, 0);
    vector<int> plus, minus;
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
        if(xs[i] >= 0)
        {
            plus.push_back(xs[i]);
        }else{
            minus.push_back(abs(xs[i]));
        }
    }
    reverse(minus.begin(), minus.end());
    vector<long long int> dpminus(minus.size(), 0);
    vector<long long int> dpplus(plus.size(), 0);
    for (int i = 0; i < plus.size(); ++i) {
        dpplus[i] = plus[i];
    }
    for (int i = 0; i < minus.size(); ++i) {
        dpminus[i] = minus[i];
    }
    long long int result = (100000000 + 1) * n;
    ///マイナスの方から
    for (int i = 0; (i < dpminus.size()) && (i < k); ++i) {
        long long int temp;
        if(i == k - 1)
        {
            temp = dpminus[i];
        }else{
            if(k - (i + 2) >= dpplus.size()) continue;
            temp = dpminus[i] * 2 + dpplus[k - (i + 2)];
        }
        result = min(result, temp);
        //cout << result << endl;
    }
    ///プラスの方から
    for (int i = 0; (i < dpplus.size()) && (i < k); ++i) {
        long long int temp;
        if(i == k - 1)
        {
            temp = dpplus[i];
        }else{
            if(k - (i + 2) >= dpminus.size()) continue;
            temp = dpplus[i] * 2 + dpminus[k - (i + 2)];
        }
        result = min(result, temp);
        //cout << result << endl;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const Int INF = (1<<20);
int main(){
    int H,A;cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a, b, c = ril()
if a == b == c:
    if a * b * c % 2 == 1:
        print(0)
    else:
        print(-1)
    exit()

count = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
    count += 1
print(count)

Measured memory_bytes: 3064
c = [[int(i) for i in input().split()] for i in range(3)] 

ans = False

for a_1 in range(101):
	b_1 = c[0][0] - a_1
	b_2 = c[0][1] - a_1
	b_3 = c[0][2] - a_1
	a_2 = c[1][0] - b_1
	a_3 = c[2][0] - b_1
	if 	a_2+b_2==c[1][1] and a_2+b_3==c[1][2] and a_3+b_2==c[2][1] and a_3+b_3==c[2][2]:
		ans = True
		break

if ans:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int k;
  cin >> k;
  queue<ll> que;
  rep(i, 1, 10) que.push(i);
  ll ans = 0;
  rep(i, 0, k) {
    ans = que.front();
    ll mod10 = ans % 10;
    que.pop();
    if (mod10 != 0) que.push(10 * ans + mod10 - 1);
    que.push(10 * ans + mod10);
    if (mod10 != 9) que.push(10 * ans + mod10 + 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
N, D = map(int, input().split())

import numpy as np
X = np.zeros((N, D))
for i in range(N):
    x = list(map(int, input().split()))
    X[i] = x

def isSq(n):
    a = np.sqrt(n)
    return n == int(a) * int(a)

p = 0
for i in range(N-1):
    for j in range(i+1, N):
        a = X[i] - X[j]
        s = a.dot(a)
        if isSq(s):
            p += 1

print(p)

Measured memory_bytes: 21648
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf= 1e14;
ll mod = 1e9+7;
ll powm(ll a, ll b) { ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
vector<ll> g[N];
ll score[N];
void dfs(ll v,ll p){
     score[v]+=score[p];
     for(auto u:g[v]){
          if(u==p)continue;
          dfs(u,v);
     }
}
 int main() {   
     ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
     // #endif
     ll t = 1;
     // cin>>t;
     while(t--){
          string s;cin>>s;
          ll ans = 0;
          for(int i = 0;i<s.size();i++){
               if(s[i]!=s[s.size()-1-i]){
                    ans++;
               }
          }
          ans = ans/2;
          cout<<ans;
     }
}            


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

int n, x;
vector<int> a;
long long ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> x;
	for(int i=0; i<n; ++i){
		int t;
		cin >> t;
		a.push_back(t);
	}
	a[0] -= ans += max(0, a[0] - x);
	for(int i=1; i<n; ++i){
		ans += max(0, a[i] + a[i-1] - x);
		a[i] -= max(0, a[i] + a[i-1] - x);
	}
	cout << ans << "\n";
}

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

int main() {
    int N,ans=0;
    cin >> N;
    vector<string>S(N);
    vector<int>T(N);
    for(int i=0 ; i<N ; i++)
        cin >> S.at(i) >> T.at(i);
    string X;
    cin >> X;
    for (int i=0 ; i<N ; i++){
        if(S.at(i)!=X)
            continue;
    while (i<N-1){
        ans+=T.at(i+1);
        i++;
    }
    break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
# define pi 3.141592
int main()
{
    ll n, m;
    cin >> n >> m;
    ll arr[m];
    for(ll i = 0; i < m; i++) cin >> arr[i];
    ll k = 0;
    for(ll i = 0; i < m; i++) k+= arr[i];
    if(k > n) cout << -1 << endl;
    else cout << n - k << endl;
}


Measured memory_bytes: 3712
h,w = map(int, input().split())
grid = []
for i in range(h):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x=1
y=1
anslis = []
n = 0
while x*y < h*w:
  if grid[y-1][x-1]%2 == 1:
    if x != w:
      grid[y-1][x-1] += -1
      grid[y-1][x] += 1
      anslis.append(y)
      anslis.append(x)
      anslis.append(y)
      anslis.append(x+1)
      n += 1
    else:
      grid[y-1][x-1] += -1
      grid[y][x-1] += 1
      anslis.append(y)
      anslis.append(x)
      anslis.append(y+1)
      anslis.append(x)
      n += 1
  if x < w:
    x += 1
  else:
    x = 1
    y += 1
print(n)
i = 0
while i < n:
  print(anslis[4*i],anslis[4*i+1],anslis[4*i+2],anslis[4*i+3])
  i += 1

Measured memory_bytes: 15732
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr ll MOD=1000000007;
constexpr ll INF=1LL<<60;
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;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int M,N;
    while((cin>>M>>N,M|N)){
        bool ok[7707707];rep(i,7707707)ok[i]=0;
        int ct=0,id=M;
        while(ct!=N){
            if(ok[id]){id++;continue;}
            ct++;if(ct>N)break;
            for(int i=id;i<7707707;i+=id)ok[i]=1;
            id++;
        }
        while(ok[id])id++;
        cout<<id<<endl;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 10688
#include <stdio.h>

int main(void)
{
   int n,a,s=0;

   scanf("%d",&n);

   a = n;
   while(a){
      s+=a%10;
      a=a/10;
   }

   if(n%s==0) printf("Yes\n");
   else       printf("No\n");

   return 0;
}


Measured memory_bytes: 128
# python3
# -*- coding: utf-8 -*-
import sys
import math
#from math import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint

INF = float('inf')

ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
sys.setrecursionlimit(1000000000)


def lcm(a, b):
    return (a * b) // gcd(a, b)


# main
N = ii()
slist = {}
maxvalue = 0

for _ in range(N):
    S = input()
    try:
        slist[S] += 1
    except KeyError:
        slist[S] = 1

    if maxvalue < slist[S]:
        maxvalue = slist[S]

maxs = []
for s in slist:
    if slist[s] == maxvalue:
        maxs.append(s)


for s in sorted(maxs):
    print(s)



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for (int i=0;i<M;i++) {
        cin >> A.at(i);
    }

    int play_day=0;
    int study_day=0;
    for(int i=0;i<M;i++) {
        study_day+=A.at(i);
    }
    play_day=N-study_day;
    if (study_day > N) cout << -1 << endl;
    else cout << play_day << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;
ll pref[200500], suf[200500], a[200500];

void solve(){
    ll n;
    cin >> n;
    
    for(ll i = 0; i < n; i++) cin >> a[i];
    
    pref[0] = a[0];
    for(ll i = 1; i < n; i++){
       pref[i] = pref[i - 1] + a[i];
    }
    suf[n - 1] = a[n - 1];

    for(ll i = n - 2; i >= 0; i--) suf[i] = suf[i + 1] + a[i];

    ll ans = 4e9 + 100000;
    for(ll i = 0; i < n - 1; i++){
        ans = min(abs(pref[i] - suf[i + 1]), ans);
    }
    cout << ans;
}


int main(){
    int q = 1;
    //cin >> q;
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


Measured memory_bytes: 4992
#include <bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define __TRUE "Yes"
#define __FALSE "No"
#define cout(x) cout << (x) << endl
#define MAX 100001
using namespace std;

int main() {
  int c[3][3];
  for(int h=0;h<3;h++) {
    for(int w=0;w<3;w++) {
      cin >> c[h][w];
    }
  }
  int a,b[3];
  for(int a=0;a<=c[0][0];a++) {
    bool flag=true;
    b[0]=c[0][0]-a;
    b[1]=c[0][1]-a;
    b[2]=c[0][2]-a;

    if( !( (c[1][0]-b[0]==c[1][1]-b[1])&&(c[1][1]-b[1]==c[1][2]-b[2]) ) ) flag=false;
    if( !( (c[2][0]-b[0]==c[2][1]-b[1])&&(c[2][1]-b[1]==c[2][2]-b[2]) ) ) flag=false;

    if(flag) {
      cout << __TRUE << endl;
      return 0;
    }
  }
  cout << __FALSE << endl;
}

Measured memory_bytes: 256
/*
 * parasol 
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <time.h>
using namespace std;
#define ll long long
const ll maxn = 2e5+5;
const ll mod = 1e9+7;
const double eps = 1e-9;
const double pi = acos(-1.0);
const ll inf = 0x3f3f3f3f;

ll a[maxn];
ll n;
ll sum[maxn];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n;
    for(ll i = 1; i <= n; i++){
        scanf("%lld", &a[i]);
        sum[i] = sum[i-1]+a[i];
    }
    ll ans = (1ll)<<60;
    for(ll i = 2; i < n; i++){
        ll j = upper_bound(sum+1, sum+i+1, sum[i]/2)-sum;
        ll k = upper_bound(sum+i+1, sum+1+n, sum[i]+(sum[n]-sum[i])/2)-sum;
        
        //printf("---i = %lld  k = %lld  %lld ",i, k, (sum[n]-sum[i])/2);
        ll x = max(max(sum[j], sum[i]-sum[j]), max(sum[k]-sum[i], sum[n]-sum[k]))-min(min(sum[j], sum[i]-sum[j]), min(sum[k]-sum[i], sum[n]-sum[k]));
        ans = min(ans, x);
        //printf("111++++%lld %lld %lld \n", ans, j, k);        
        
        x = max(max(sum[j], sum[i]-sum[j]), max(sum[k-1]-sum[i], sum[n]-sum[k-1]))-min(min(sum[j], sum[i]-sum[j]), min(sum[k-1]-sum[i], sum[n]-sum[k-1]));
        ans = min(ans, x);
        //printf("222++++%lld %lld %lld \n", ans, j, k);        
        
        x = max(max(sum[j-1], sum[i]-sum[j-1]), max(sum[k]-sum[i], sum[n]-sum[k]))-min(min(sum[j-1], sum[i]-sum[j-1]), min(sum[k]-sum[i], sum[n]-sum[k]));
        ans = min(ans, x);
        //printf("333++++%lld %lld %lld \n", ans, j, k);        
        
        x = max(max(sum[j-1], sum[i]-sum[j-1]), max(sum[k-1]-sum[i], sum[n]-sum[k-1]))-min(min(sum[j-1], sum[i]-sum[j-1]), min(sum[k-1]-sum[i], sum[n]-sum[k-1]));
        ans = min(ans, x);
        
        //printf("444++++%lld %lld %lld \n\n", ans, j, k);        
    }
    
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 3328
n=int(input())
L=list(map(int,input().split()))
M=[]
ans=0
for i in range(1,n-1):
    M=[L[i-1],L[i],L[i+1]]
    M.sort()
    if M[1]==L[i]:
        ans+=1
    M=[]
print(ans)

Measured memory_bytes: 3060
import std.stdio, std.conv, std.algorithm, std.range, std.array, std.string, std.uni;

void main() {
  auto inp = readln.split.to!(int[]);
  if (inp[1] * 2 == inp[0] + inp[2]) {
    writeln("YES");
  } else {
    writeln("NO");
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(void){
  int row, col, i, j;
  std::string str;
  std::cin >> row >> col;
  char board_c[row][col];
  int board_i[row][col];
  for(i = 0; i < row; i++){
    for(j = 0; j < col; j++){
      board_i[i][j] = 0;
      std::cin >> board_c[i][j];
    }
  }
  for(i = 0; i < row; i++){
    for(j = 0; j < col; j++){
      if(board_c[i][j] == '#'){
        if(i != 0){
          if(j != 0) board_i[i-1][j-1]++;
          board_i[i-1][j]++;
          if(j != col-1) board_i[i-1][j+1]++;
        }
        if(i != row-1){
          if(j != 0) board_i[i+1][j-1]++;
          board_i[i+1][j]++;
          if(j != col-1) board_i[i+1][j+1]++;
        }
        if(j != 0) board_i[i][j-1]++;
        if(j != col-1) board_i[i][j+1]++;
      }
    }
  }
  for(i = 0; i < row; i++){
    for(j = 0; j < col; j++){
      if(board_c[i][j] == '#') std::cout << '#';
      else std::cout << board_i[i][j];
    }
    std::cout << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3592
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val xy = (0 until n).map { sc.next().toDouble() to sc.next().toDouble() }
    var str = ""
    for (i in 0 until n) {
        str += i.toString()
    }
    val p = permutation(str,"")
    //println(p)
    //println(xy)
    //println(p)
    
    var distsum = 0.0
    p.forEach {
        for (j in 1 until n) {
            val j1 = it[j].toString().toInt()
            val j2 = it[j-1].toString().toInt()
            val dx = Math.pow(xy[j1].first - xy[j2].first,2.0)
            val dy = Math.pow(xy[j1].second - xy[j2].second,2.0)
            distsum += Math.sqrt(dx + dy)
        }
    }
    println(distsum / p.size)
 }

fun permutation(q:String,ans:String) : MutableList<String>{
    // Base Case
    val ret :MutableList<String> = mutableListOf()
    if (q.length <= 1) {
        ret.add(ans + q)
    }
    // General Case
    else {
        for (i in 0 until q.length) {
            ret.addAll( permutation(q.substring(0, i) + q.substring(i + 1),ans + q[i]) )
        }
    }
    return ret
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll solve(ll a, ll b) {
	if (b % a == 0) {
		return 2 * b - a;
	}

	return 2 * floor(b / a) * a + solve(b % a, a);
}

int main() {
	ll n, x;

	cin >> n >> x;

	ll ans = n + solve(x, n - x);

	cout << ans << endl;
}

Measured memory_bytes: 256
n,T = map(int, input().split())

# t以下のもののcをリストにする、最小値を返す
l = []

for i in range(n):
    c, t =  map(int, input().split())
    if t <= T:
        l.append(c)

if l == []:
    print("TLE")
else:
    print(min(l))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
const int MOD = 1e9 + 7;
 
int main() {
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  ll mi = min(min(min(min(A, B), C), D), E);
  ll group = (N + mi - 1) / mi;
  cout << group - 1 + 5 << endl;
}

Measured memory_bytes: 256