akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;

int n;
ull a[10004];
ull b[10004];
ull cnt1,cnt2;

int main()
{
    cin >> n;
    for(int i=0;i<n;++i) cin >> a[i];
    for(int i=0;i<n;++i) cin >> b[i];

    for(int i=0;i<n;++i)
    {
        if(a[i]<b[i])
        {
            ull d = b[i]-a[i];
            if(d%2==0) cnt1+=d/2;
            else cnt1+=(d/2) + 1,++cnt2;
        }
        else if(a[i]>b[i]) cnt2 += a[i] - b[i];
    }

    if(cnt1 >= cnt2) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 384
n, m = list(map(int, input().split()))
maze = []
for i in range(n):
  l = input()
  dl = []
  for j in range(m):
    if l[j] == '.':
      dl.append(0)
    else:
      dl.append(1)
  maze.append(dl)
ans = 0
for i in range(n):
  for j in range(m):
    if maze[i][j] == 0:
      a = [list(l) for l in maze]
      a[i][j] = 1
      q = [(i, j)]
      d = 0
      while len(q) > 0:
        nq = []
        for x, y in q:
          if x > 0 and a[x - 1][y] == 0:
            a[x - 1][y] = 1
            nq.append((x - 1, y))
          if y > 0 and a[x][y - 1] == 0:
            a[x][y - 1] = 1
            nq.append((x, y - 1))
          if x < n - 1 and a[x + 1][y] == 0:
            a[x + 1][y] = 1
            nq.append((x + 1, y))
          if y < m - 1 and a[x][y + 1] == 0:
            a[x][y + 1] = 1
            nq.append((x, y + 1))
        if len(nq) > 0:
          d += 1
        q = nq
      ans = max(ans, d)
print(ans)


Measured memory_bytes: 50416
import java.util.Scanner;

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

    	/*Scanner = テキスト入力を扱うためのクラス
		 *キーボードからの入力を受けつける場合は
		 *System.inを使って下記のように記述
		 */
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();
		int x;
		int i;

		//for文を設置。初期値として3を用意。
		for(i=3; i<= n; i++){
			x = i;
			if(x%3==0){
				System.out.print(" " + i);
				continue ; //こちらで割り切れたものはwhile文に飛ばす必要はないのでスキップさせる。
			}
			while(x!=0){
				if(x%10==3){
					System.out.print(" " + i);
					break ; //while文を抜けるため
				}
				x = x/10; //これをしないとxがいつまでたっても割られないはず。xの値変更。
			}
		}
		System.out.println();
    }
}

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

class analysis
{
	public:
	int curly;
	int round;
	int square;
	int indent;
	analysis()
	{
	}
	analysis(int c,int r,int s,int i)
	{
		curly=c;
		round=r;
		square=s;
		indent=i;
	}
};
bool allpattern[21][21][21]; //R,C,Sの順
string sample[10];
analysis sample_a[10];
string target[10];
analysis target_a[10];
vector<int> v;
int main()
{
	int p,q;
	while(1)
	{
		cin>>p>>q;
		if(p==0)
			break;
		for(int i=0;i<p;i++)
			cin>>sample[i];
		sample_a[0]=analysis(0,0,0,0);
		int c,r,s,ind;
		c=0;r=0;s=0;ind=0;
		//解析する
		for(int i=1;i<p;i++)
		{
			ind=0;
			while(sample[i][ind]=='.')
				ind++;
			for(int j=0;j<sample[i-1].size();j++)
			{
				switch(sample[i-1][j])
				{
					case '(':
						r++;
						break;
					case ')':
						r--;
						break;
					case '{':
						c++;
						break;
					case '}':
						c--;
						break;
					case '[':
						s++;
						break;
					case ']':
						s--;
						break;
					default:
						break;
				}
			}
			sample_a[i]=analysis(c,r,s,ind);
		}
		//すべてのパターンについて調べる
		fill(allpattern[0][0],allpattern[21][0],false);
		for(int i=1;i<21;i++)
		{
			for(int j=1;j<21;j++)
			{
				for(int k=1;k<21;k++)
				{
					bool f=true;
					for(int l=0;l<p;l++)
					{
						if(sample_a[l].round*i+sample_a[l].curly*j+sample_a[l].square*k!=sample_a[l].indent)
						{
							f=false;
							break;
						}
					}
					if(f)
						allpattern[i][j][k]=true;
				}
			}
		}
		//入力パターン
		for(int i=0;i<q;i++)
			cin>>target[i];
		target_a[0]=analysis(0,0,0,0);
		c=0;r=0;s=0;
		for(int i=1;i<q;i++)
		{
			for(int j=0;j<target[i-1].size();j++)
			{
				switch(target[i-1][j])
				{
					case '(':
						r++;
						break;
					case ')':
						r--;
						break;
					case '{':
						c++;
						break;
					case '}':
						c--;
						break;
					case '[':
						s++;
						break;
					case ']':
						s--;
						break;
					default:
					break;
				}
			}
			target_a[i]=analysis(c,r,s,-1);
		}
		//2行以降すべてのパターンについて調べる、矛盾がなければOK
		for(int i=1;i<q;i++)
		{
			if(target_a[i].curly==0 && target_a[i].square==0 && target_a[i].round==0)
			{
				target_a[i].indent=0;
				continue;
			}
			v.clear();
			//R,C,Sの順
			for(int x=1;x<21;x++)
			{
				for(int y=1;y<21;y++)
				{
					for(int z=1;z<21;z++)
					{
						if(allpattern[x][y][z])
							v.push_back(x*target_a[i].round+y*target_a[i].curly+z*target_a[i].square);
					}
				}
			}
			if(v.size()==0)
			{
				target_a[i].indent=-1;
			}else{
				int tmp=v[0];
				for(int i=1;i<v.size();i++)
				{
					if(tmp!=v[i])
						tmp=-1;	
				}
				target_a[i].indent=tmp;
			}
		}
		//output
		for(int i=0;i<q;i++)
		{
			cout<<target_a[i].indent;
			if(i<q-1)
				cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  const int MAX = 100010;
  vector< pair<int, int> > codd(MAX), ceven(MAX);
  for (int i = 0; i < MAX; i++) {
    codd[i].second = i;
    ceven[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (i & 1) {
      codd[x].first++;
    } else {
      ceven[x].first++;
    }
  }
  nth_element(codd.begin(), codd.begin() + 1, codd.end(), greater< pair<int, int> >());
  nth_element(ceven.begin(), ceven.begin() + 1, ceven.end(), greater< pair<int, int> >());
  int ans = -1;
  if (codd[0].second == ceven[0].second) {
    ans = n - max(codd[0].first + ceven[1].first, codd[1].first + ceven[0].first);
  } else {
    ans = n - codd[0].first - ceven[0].first;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:2
*Problem:Mancala
*Date:2019-7-3
*Algorithm:Monkey King's Formula
*Stats:Unknown*/

bool debug=false;

int table[]={0,0,10,218,4224,86824,1952672,48334090,313331137,979800274,828540260,695210844,345903227,725536399,533377947,126870238,417392240,582344565,570144113,387531847,95472904,736367570,100824653,53789760,861980712,126607859,241069168,159577844,127999019,739565197,588572026,
			 472004108,198573042,281307947,286342614,686185824,48747915,30658266,198584024,760183454,258844241,646193002,972078799,897190473,283365309,488780441,951115850,28681383,942905856,688391542,525884844,41980196,386470834,476933350,752854574,920579153,963866760,52440366,648227423,224231848,133288127,
			 149349410,239142404,803678704,197142159,350958507,502820237,752727832,871386865,338082736,566806799,174435924,823030120,175675710,613983717,27947594,438064939,461569938,546560028,895202927,431746632,443078512,972753815,617930628,367826740,539142587,514039930,351945083,68959273,870822947,125889175,
			 452006881,101355703,195535277,755580870,603125858,943472898,483436448,536722284,883521289,900100930
			 };

int n,k;

ll dp[105][105];

const ll mod=1e9+7;

ll qp(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll ans=qp(a,b/2);
	if(b%2){
		return ans*ans%mod*a%mod;
	}else{
		return ans*ans%mod;
	}
}

ll S(int n,int k){
	if(n==k){
		return table[n];
	}
	
	if(dp[n][k]!=-1){
		return dp[n][k];
	}
	
	ll ans=0;
	for(int i=0;i<=k;i++){
		ans+=(S(n-1,k)+qp(k+1,n-1)*i%mod)%mod;
		ans%=mod;
	}
	
	return dp[n][k]=ans;
}
int main(int argc,char* argv[]){
	memset(dp,-1,sizeof(dp));
	
	cin>>n>>k;
	cout<<S(n,k)<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

struct Info_max{
	Info_max(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_max &arg) const{
			return point < arg.point;
	};
	int point,id;
};

struct Info_min{
	Info_min(int arg_point,int arg_id){
		point = arg_point;
		id = arg_id;
	}
	bool operator<(const struct Info_min &arg) const{
			return point > arg.point;
	};
	int point,id;
};

 int main(){

	 int N,M,max_points[10001],point,num,tmp,forced_points[10001],maximum,minimum;

	 while(true){
		 scanf("%d %d",&N,&M);
		 if(N == 0 && M == 0)break;

		 for(int i = 1; i <= N; i++){
			 max_points[i] = 0;
			 forced_points[i] = 0;
		 }

		 for(int loop = 0; loop < M; loop++){
			 scanf("%d %d",&point,&num);
			 if(num == 1){
				 scanf("%d",&tmp);
				 forced_points[tmp] += point;
				 max_points[tmp] += point;
			 }else{ //num > 1
				 for(int i = 0; i < num; i++){
					 scanf("%d",&tmp);
					 max_points[tmp] += point;
				 }
			 }
		 }

		 priority_queue<Info_max> MAX;
		 priority_queue<Info_min> MIN;

		 for(int i = 1; i <= N; i++){
			 MAX.push(Info_max(max_points[i],i));
			 MIN.push(Info_min(forced_points[i],i));
		 }

		 if(MAX.top().id != MIN.top().id){
			 printf("%d\n",MAX.top().point-MIN.top().point+1);
		 }else{
			 maximum = MAX.top().point;
			 MAX.pop();
			 minimum = MIN.top().point;
			 MIN.pop();
			 printf("%d\n",max(maximum-MIN.top().point,MAX.top().point-minimum)+1);
		 }
	 }

	 return 0;
}

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

public class Main {
	// AtCoder Beginner Contest 086
	// https://atcoder.jp/contests/abc086/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if ((a*b) % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main(){int n,k,i,t,c,l,num=1,l1=0,r;
cin>>n>>k;
int a[n+1];
vector<int>v;
int vis[n+1]={0};
for(i=1;i<=n;i++){cin>>a[i];}

v.push_back(1);
vis[1]=1;
c=1;
while(1){
   t=a[c];
   if(vis[t]){num=t;break;}
   v.push_back(t);
   vis[t]=1;
   c=t;
}
l=v.size();
for(i=0;i<l;i++){
    if(v[i]==num){l1=i;break;}
}
if(l1>=k){cout<<v[k];return 0;}
k-=l1;
r=l-l1;
r=k%r;
cout<<v[r+l1];
    return 0;}

Measured memory_bytes: 8492
n = int(input())
a = list(map(int, input().split()))
dp = [[[float(0)]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
I,J,K = 0,0,0
for i in a:
  if i == 1:
    I += 1
  elif i == 2:
    J += 1
  else:
    K += 1
for k in range(n+1):
  for j in range(n+1):
    for i in range(n+1):
      if (i+j+k) <= n:
        if (i+j+k) != 0:
          dp[i][j][k] = float(n)/float(i+j+k)
        if i > 0:
          dp[i][j][k] += dp[i-1][j][k]*float(i) / float(i+j+k)
        if j > 0:
          dp[i][j][k] += dp[i+1][j-1][k]*float(j) / float(i+j+k)
        if k > 0:
          dp[i][j][k] += dp[i][j+1][k-1]*float(k) / float(i+j+k)
print(dp[I][J][K])

Measured memory_bytes: 254856
import java.util.Scanner;

public class Main {
    Scanner   sc   = new Scanner(System.in);
    final int MOD   = 1000000007;

    void run() {
        int N = sc.nextInt();
        int[] T = new int[N];
        int[] A = new int[N];
        for (int i = 0; i < N; i++) T[i] = sc.nextInt();
        for (int i = 0; i < N; i++) A[i] = sc.nextInt();

        if (T[N - 1] != A[0]) {
            System.out.println(0);
            return;
        }

        boolean[] f = new boolean[N];
        f[0] = f[N - 1] = true;
        for (int i = 0; i < N - 1; i++) {
            if (T[i] != T[i + 1]) {
                f[i + 1] = true;
                if (T[i + 1] > A[i + 1]) {
                    System.out.println(0);
                    return;
                }
            }
        }
        for (int i = N - 1; i >= 1; i--) {
            if (A[i - 1] != A[i]) {
                f[i - 1] = true;
                if (A[i - 1] > T[i - 1]) {
                    System.out.println(A);
                    return;
                }
            }
        }

        long cnt = 1;
        for (int i = 0; i < N; i++) {
            if (!f[i]) {
                cnt *= Math.min(A[i], T[i]);
                cnt %= MOD;
            }
        }
        System.out.println(cnt);
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 48556
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 300010;

int sum[2][maxn];
char S[maxn];
int n = 0;

int main() {
    scanf("%d", &n);
    scanf("%s", S+1);
    for (int i = 1; i <= n; i++ ){
        sum[0][i] = sum[0][i-1] + (S[i]=='E');
        sum[1][i] = sum[1][i-1] + (S[i]=='W');
    }
    int ans = n+1;
    for (int i = 1; i <= n; i++) {
        int tans = sum[1][i-1]+sum[0][n]-sum[0][i];
        if (tans < ans) ans = tans;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 2944
import sys


class Node():
    def __init__(self,  key=None, prev=None, next=None):
        self.key = key
        self.prev = prev
        self.next = next


class DoublyLinkedList():
    def __init__(self):
        self.head = Node()
        self.head.next = self.head
        self.head.prev = self.head

    def insert(self, x):
        node = Node(key=x, prev=self.head, next=self.head.next)
        self.head.next.prev = node
        self.head.next = node

    def search(self, x):
        node = self.head.next
        while node is not self.head and node.key != x:
            node = node.next
        return node

    def delete_key(self, x):
        node = self.search(x)
        self._delete(node)

    def _delete(self, node):
        if node is self.head:
            return None
        node.prev.next = node.next
        node.next.prev = node.prev

    def deleteFirst(self):
        self._delete(self.head.next)

    def deleteLast(self):
        self._delete(self.head.prev)

    def getKeys(self):
        node = self.head.next
        keys = []
        while node is not self.head:
            keys.append(node.key)
            node = node.next
        return " ".join(keys)


L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
    if 'insert' in i:
        x = i[7:-1]
        L.insert(x)
    elif 'deleteFirst' in i:
        L.deleteFirst()
    elif 'deleteLast' in i:
        L.deleteLast()
    elif 'delete' in i:
        x = i[7:-1]
        L.delete_key(x)
    else:
        pass
print(L.getKeys())



Measured memory_bytes: 227796
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 2005;
int f[MAXN][MAXN],n,a[MAXN],x;
inline int realpos(int x,int a)
{
	x+=a;
	if(x<0)x+=n;
	if(x>=n)x-=n;
	return x;
}
int main()
{
	scanf("%d%d",&n,&x);
	for(int i=0;i<n;++i)
		scanf("%d",a+i);
	for(int i=0;i<n;++i)
		f[i][0]=a[i];
	for(int j=1;j<n;++j)
		for(int i=0;i<n;++i)
			f[i][j]=min(f[i][j-1],a[realpos(i,-j)]);
	long long ans=0x3f3f3f3f3f3f3f3f;
	for(int i=0;i<n;++i){
		long long sum=0;
		for(int j=0;j<n;++j)
			sum+=f[j][i];
		ans=min(ans,sum+(long long)x*i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 15872
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int m = scanner.nextInt();
    int sum = 0;
    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextInt();
      sum += a[i];
    }

    final int finalSum = sum;
    if(Arrays.stream(a).filter( e -> 4 * e * m>= finalSum).count() >= m ) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 30164
N,M=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort()

if N>=M:print(0)
else:
	B=[0]*(M-1)
	for i in range(M-1):
		B[i]=A[i+1]-A[i]
	B.sort()
	
	print(sum(B[:M-N]))



Measured memory_bytes: 13840
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
#define ULL unsigned long long
using namespace std;
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 300
#define INF 1000000000000000ll
LL f[MAXN+5][MAXN+5],g[MAXN+5][MAXN+5];
int main(){
	int n=read(),m=read();
	LL L=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			f[i][j]=g[i][j]=INF;
	for(int i=1;i<=n;i++)
		f[i][i]=g[i][i]=0;
	for(int i=1;i<=m;i++){
		int u=read(),v=read();LL w=read();
		f[u][v]=min(f[u][v],w);
		f[v][u]=min(f[v][u],w);
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j&&f[i][j]<=L)
				g[i][j]=1;
	
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	int q=read();
	for(int i=1;i<=q;i++){
		int s=read(),t=read();
		if(g[s][t]==INF)
			puts("-1");
		else printf("%lld\n",g[s][t]-1);
	}
	return 0;
}


Measured memory_bytes: 1920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {

	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	//n, _ := strconv.Atoi(s.Text())
	s.Scan()

	m := make(map[int]bool)
	a := strings.Split(s.Text(), " ")
	c := 0
	for _, v := range a {
		i, _ := strconv.Atoi(v)
		if i > 3199 {
			c++
		} else {
			m[i/400] = true
		}
	}
	r := c + len(m)

	if len(m) == 0 {
		fmt.Printf("%v %v\n", 1, r)
		return
	}
	fmt.Printf("%v %v\n", len(m), r)
}


Measured memory_bytes: 640
n, W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(n)]
inf = 10 ** 10
dp = [[inf] * (1000 * n + 1) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(1000 * n + 1):
        if dp[i][j] == inf:continue
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

        w, v = wv[i]
        if dp[i][j] + w <= W:
            dp[i + 1][j + v] = min(dp[i + 1][j + v], dp[i][j] + w)

for i in range(1000 * n + 1):
    if dp[-1][-(i + 1)] != inf:
        print(1000 * n - i)
        exit()

Measured memory_bytes: 119772
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int mod_pow(Int x, Int a, Int m = MOD){
  if(a == 0)return 1;
  Int res = mod_pow(x, a / 2, m);
  res = res * res % m;
  if(a % 2)res *= x;
  return res % m;
}

Int rev(Int x){
  return mod_pow(x, MOD-2);
}
Int fact[1080000];
void init(){
  fact[0] = 1;
  for(Int i = 1;i < 1080000;i++){
    fact[i] = fact[i-1] * i % MOD;
  }
}

Int nCk(Int n, Int k){
  if(n < k)return 0;
  return fact[n] * rev(fact[n-k]) %MOD  * rev(fact[k]) % MOD;
}

Int cnt[1080000];

int main(){
  init();
  Int n, res = 0;
  cin >> n;
  if(n == 2){
    cout << 1 << endl;
    return 0;
  }
  n--;
  for(Int i = 2;i <= n;i++){
    cnt[i] =  fact[i] * fact[n-i] % MOD;
    cnt[i] *= nCk(i-1, n-i);
    cnt[i] %= MOD;
  }
  for(Int i = n;i >= 2;i--){
    cnt[i] -= cnt[i-1];cnt[i] %= MOD;
    res += cnt[i] * i % MOD;
    res %= MOD;
  }
  if(res < 0)res += MOD;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 17152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
ll C(ll n,ll k)
{
	ll x=1,y=1;
	for(ll i=1;i<=k;i++)
	{
		x=x*(n-i+1)%mod;
		y=y*i%mod;
	}
	return x*power(y,mod-2)%mod;
}

int main(){
    ll x,y;
    cin>>x>>y;
    if((x+y)%3!=0){
        printf("0");
        exit(0);
    }
    //cout<<(x+y)/3<<" "<<(2*x-y)/3<<" "<<(2*y-x)/3<<endl;
    if(2*x-y>=0){
        printf("%lld\n",C((x+y)/3,(2*x-y)/3));
    }else if(2*y-x>=0){
        printf("%lld\n",C((x+y)/3,(2*y-x)/3));
    }
}


Measured memory_bytes: 3756
#include<iostream>
using namespace std;
#define INF 9999999

int main()
{
	int kona,i;
	int money[51];
	money[0] = 0;
	int size[6] = {2,3,5,10,12,15};
	int cost[6] = {380,550,850,1520,1870,2244};
		
	for(i=1;i<51;i++) money[i] = INF;
	
	for(i=0;i<50;i++)
	{
		if( money[i] != INF)
		{
			for(int j=0;j<6;j++)
			{
				if( (i + size[j]) < 51)
				{
					if( money[i]+cost[j] < money[ i+size[j] ] )
					{
						money[ i+size[j] ] = money[i] + cost[j];
					}
				}
			}
		}
	}


while(cin>>kona,kona != 0)
{
cout<< money[kona/100] << endl;
}
	
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l,a,b,c;
    long long arr1[200];
    long long arr[200];
    cin>>n;
    for(i=0;i<(n-1);i++)
    {
        cin>>arr1[i];
    }
    arr[0]=arr1[0];
    for(i=0;i<(n-1);i++)
    {
        k=max(arr[i],arr1[i]);
        if(k<=arr1[i])
        {
            arr[i+1]=k;
        }
        else
        {
            arr[i]=arr1[i];
            arr[i+1]=arr1[i];
        }
    }
    l=0;
    for(i=0;i<n;i++)
    {
        l+=arr[i];
    }
    cout<<l<<endl;
    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll int, null_type,less<ll int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	string s,y;
    	cin>>s;
    	n=s.size();
    	n=n/2;
    	for(i=0;i<n;i++)
    		y+="hi";
    	if(y==s)
    		cout<<"Yes";
    	else
    		cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MOD=1000000007;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int h,w;
	char c;
	cin >> h >> w;
	vector<vector<int>> v(h+1,vector<int>(w+1));
	v[1][1]++;
	for (int i=1; i<=h; ++i){
		for (int j=1; j<=w; ++j){
			cin >> c;
			if (c == '.') v[i][j] += (v[i][j-1]+v[i-1][j])%MOD;
			v[i][j] %= MOD;
		}
	}
	cout << v[h][w]%MOD;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, k;
	cin >> n >> k;
	
	double ans = 0.0;
	for(int i = 1; i <= n; ++i) {
		double tmp = 1.0 / (double)n;
		int x = i;
		
		while( x < k ) {
			x *= 2;
			tmp /= 2.0;
		}
		
		ans += tmp;
	}
	
	printf("%.12f\n", ans);

	return 0;
}


Measured memory_bytes: 256
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.ml
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, a, b) for (int i = (a); i <= (b); i++) 
#define Rep(i, a, b) for (int i = (a); i >= (b); i--) 
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)

#define int long long
const int maxn = 202;
const int inf = 0x3f3f3f3f3f3f3f3f;
int n;
int a[maxn];
int Solve(int l, int r, int x, int y) {
	if (l == r) return a[l] * x;
	if (l + 1 == r) return a[l] * x + a[l + 1] * y;
	int ans = inf;
	For (i, l + 1, r - 1) {
		ans = min(ans, Solve(l, i, x, x + y) + Solve(i, r, x + y, y) - (x + y) * a[i]);
	}
	return ans;
}
signed main() {
	read(n);
	For (i, 1, n) read(a[i]);
	printf("%lld\n", Solve(1, n, 1, 1));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 1, f = k;
  while(f <= n) {
    ans++;
    f *= k;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace  std;
using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<int, int> pairs;
typedef complex<ll> G;
const int N = 1e5+5;

void solve(){

    int x, n;
    cin >> x >> n;
    set<int>res;
    for(int i=0;i < n;i++) {
        int a;cin >> a;
        res.insert(a);
    }
    int best=INT_MAX, z= INT_MAX, q = INT_MAX;
    for(int i=x;i < 102;i++) {
        if(res.find(i)==res.end()) {
            if(abs(i-x) < z) {
                z = abs(i-x);
                best = i;
            }
        }
    }
    for(int i=x;i >= 0;i--) {
        if(res.find(i)==res.end()) {
            if(abs(i-x) <= z) {
                z = abs(i-x);
                q = i;
            }
        }
    }
    cout << min(q, best);





}
int main() {
    fast;
    solve();


}


Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-6;
const double PI = 3.14159265;
const ll MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 100005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int arr[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    printf("%d", (n + m - 1) / m);
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include <cmath>
#include <ctype.h>
#include<vector>
using namespace std;
string a, b;
int main() {
    cin >> a >> b;
    int n=a.size(), m=b.size();
    if(n>m) {
        cout << "GREATER" << endl;
    }else if(n<m){
        cout << "LESS" << endl;
    }else if(n==m){
        for(int i=0; i<m; ++i){
            if(a[i]>b[i]) {
                cout << "GREATER" << endl;
                break;
            }else if(a[i]<b[i]){
                cout << "LESS" << endl;
                break;
            }
            if(i==m-1) cout << "EQUAL" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
a, b, c, d, e, f = map(int, input().split())
sug, dif2 = 0, 100
s = {}
wat1, wat2 = 100*a, 100*b
cap1, cap2 = a*e, b*e
for i in range(1,f//wat1+1):
    for j in range(f//wat2+1):
        if (wat1+cap1)*i+(wat2+cap2)*j<=f:
            s[cap1*i+cap2*j] = wat1*i+wat2*j
if s == {}:
    dif1 = f-wat1
    for i in range(10):
        for j in range(10):
            if 0<=(f-wat1)-(c*i+d*j)<dif1:
                dif1 = (f-wat1)-(c*i+d*j)
                sug3 = c*i+d*j
    print(wat1+sug3, sug3)
    exit(0)
for i in s.keys():
    for j in range(i//c+1):
        for k in range(i//d+1):
            if 0<=i-(c*j+d*k)<dif2:
                dif2 = i-(c*j+d*k)
                wat,sug1,sug2 = s[i],j,k
print(c*sug1+d*sug2+wat, c*sug1+d*sug2)


Measured memory_bytes: 3064
/// sultanov

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
     
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
using namespace __gnu_pbds;

template<typename T> 
using ordered_set = tree<T, null_type,   
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;

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

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n & 1)
        cout << "No", exit(0);
    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2))
        cout << "Yes";
    else
        cout << "No";
    return 0;    
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  
  if (S == T.erase(T.size()-1)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
void LCS(string s,string t){
    int n=s.size(),m=t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1,0));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    //cout<<dp[n][m]<<endl;
    vector<char> res;
    int i=n,j=m;
    while(i>0 and j>0){
        if(s[i-1]==t[j-1]){
            res.push_back(s[i-1]);
            i--,j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    string p="";
    if(res.size()==0)
        cout<<p<<endl;
    else{
    for(int i=res.size()-1;i>=0;i--)
        cout<<res[i];
    cout<<endl;
    }
    
}
int main() {
	// your code goes here
	string s,t;
	cin>>s>>t;
	
	LCS(s,t);
	return 0;
}


Measured memory_bytes: 35584
l=int(input())
for i in range(1,21):
    if 2**i>l:
        n=i
        break
m=2*(n-1)
data=[]
for i in range(1,n):
    data.append([i,i+1,0])
    data.append([i,i+1,2**(n-i-1)])
add=2**(n-1)
for i in range(1,n):
    if (l>>n-1-i)&1==1:
        data.append([1,i+1,add])
        add+=2**(n-1-i)
        m+=1
print(str(n)+" "+str(m))
for u in data:
    print(*u)

Measured memory_bytes: 38512
//xotwod
#include<bits/stdc++.h>
using namespace std; 
#define gol(n) for(ll u=0;u<n;u++)
typedef long long ll;
int main(){
	int k,a,b,f=0;cin>>k>>a>>b;
	for(int u=a;u<=b;u++){
		if(u%k==0) f=1;}
	cout<<(f? "OK":"NG");
}


Measured memory_bytes: 3612
X = int(input())
temp = []
N = 200
for i in range(-N, N):
    temp.append(i**5)

ok = []
flag = False

# print(temp)
for i in range(2 * N):
    if flag:
        break
    for j in range(2 * N):
        if flag:
            break
        if temp[i] + temp[j] == X:
            ok = [temp[i], temp[j]]
            flag = True

# print(ok)
ans = [0, 0]
mai = 1
if ok[0] == 0:
    ans[0] = 0
else:
    if ok[0] < 0:
        mai = -1
        ok[0] *= -1
    ans[0] = int(ok[0]**0.2)
    ans[0] = ans[0] * mai * -1

mai = 1
if ok[1] == 0:
    ans[1] = 0
else:
    if ok[1] < 0:
        mai = -1
        ok[1] *= -1
    ans[1] = int(ok[1]**0.2)
    ans[1] *= mai

print(str(ans[1]) + " " + str(ans[0]))

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

ostream &operator<<(ostream &os, __int128_t value) {
  if (ostream::sentry(os)) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[64];
    char *d = end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = end(buffer) - d;
    if (os.rdbuf()->sputn(d, len) != len) {
      os.setstate(ios_base::badbit);
    }
  }
  return os;
}
 
istream &operator>>(istream &is, __int128_t &value) {
  string in;
  is >> in;
  value = 0;
  for (const char &c : in) {
    if ('0' <= c && c <= '9') value = 10 * value + (c - '0');
  }
  if (in[0] == '-') value *= -1;
  return is;
}
 
__int128_t a[15];
 
int main(){
    for(int i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a, a+10);
    cout<<a[9]<<endl
        <<a[8]<<endl
        <<a[7]<<endl;
}

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if((a+b)>(c+d)){
        cout << "Left" << endl;
    }
    else if((a+b)<(c+d)){
        cout << "Right" << endl;
    }
    else
        cout << "Balanced" << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np

s = input()[:-1]

cnts = []

tmp = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        tmp += 1
    else:
        if s[i] == '>':
            tmp *= -1
        cnts.append(tmp)
        tmp = 1

if s[-1] == '>':
    tmp *= -1
cnts.append(tmp)

idx = 0
a = [0] * (len(s)+1)

for i in range(len(cnts)):
    if i != 0 and cnts[i-1] > 0 and cnts[i] < 0 and a[idx-1] >=  abs(cnts[i]):
        a[idx] = a[idx-1] + 1

    for j in range(abs(cnts[i])):
        if a[idx] != 0:
            idx += 1
            continue
        if cnts[i] > 0:
            a[idx] = j
        else:
            a[idx] = abs(cnts[i]) - j
        idx += 1
if s[-1] == '<':
    a[-1] = a[-2] + 1

# print(*cnts)
# print(*a)
print(sum(a))
# for i in range(len(s)):
#     print(a[i],s[i],end='')
# print(a[-1])


Measured memory_bytes: 32552
#include <stdio.h>
#include <string.h>
int main()
{
	char a[101];
	scanf("%s",a);
	int i,j;
	int n;
	int m;
	if(a[0]=='C'&&a[1]=='F')
	{
	printf("Yes\n");
	return 0;
}
	for(i=0;i<strlen(a);i++)
	{
		a[0]=a[i];
		if(a[i]=='C')
		{
			m=i;
			break;
		}
	}
	for(j=i+n;j<strlen(a);j++)
	{
		a[1]=a[j];
		if(a[j]=='F')
		break;
	}
	if(a[0]=='C'&&a[1]=='F')
	printf("Yes\n");
	else 
	printf("No\n");
}

Measured memory_bytes: 256
while True:
	H, W = map(int, raw_input().split())
	if H == 0 and W == 0:
		break
	else:
		x = '.'
		y = '#'
		for k in range(0, H):
			x,y = y,x
			if W%2 == 0:
				print (x+y) * (W/2)
			elif W%2 != 0:
				print (x+y) * (W/2) + x
		print ''

Measured memory_bytes: 4640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

const int MAX_N = 1 << 17;

int n, q, data_sum[2 * MAX_N - 1];

void init(int _n) {
    n = 1;
    while(n < _n) n *= 2;
    for(int i = 0; i < 2 * n - 1; ++i) data_sum[i] = 0;
}

void update(int k, int a) {
    k += n - 1;
    data_sum[k] += a;
    while(k > 0) {
	k = (k - 1) / 2;
	data_sum[k] += a;
    }
}

int query(int a, int b, int k, int l, int r) {
    int mid = (l + r) / 2;
    if(a <= l && r <= b) {
	return data_sum[k];
    } else if(b <= mid) {
	return query(a, b, k * 2 + 1, l, (l + r) / 2);
    } else if(a > mid) {
	return query(a, b, k * 2 + 2, (l + r) / 2 + 1, r);
    } else {
	int lv, rv;
	lv = query(a, b, k * 2 + 1, l, (l + r) / 2);
	rv = query(a, b, k * 2 + 2, (l + r) / 2 + 1, r);
	return lv + rv;
    }
}

int main() {
    int N, Q;
    scanf("%d%d",&N, &Q);
    init(N);
    for(int i = 0; i < Q; ++i) {
	int c, a, b;
	scanf("%d%d%d",&c, &a, &b);
	if(c == 0) {
	    --a;
	    update(a, b);
	} else {
	    --a; --b;
	    printf("%d\n", query(a, b, 0, 0, n - 1));
	}
    }
    return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(x) ll t; cin >> t; x.push_back(t);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<string> vvs;

const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    string s;
    cin >> s;

    ll top = 0;
    ll tail = s.length() - 1;

    ll ans = 0;
    while (true) {
        if (s.at(top) != s.at(tail)) ans++;
        top++;
        tail--;
        if (top >= tail) break;
    }

    MSG(ans)
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

string s;

void fuck( ) {
        string t = s;
        do {
            if( s == t ) continue;
            for( int i = 0; i < t.size(); i++ ) {
                    cout << t[i];
                    if( s[i] != t[i] ) return;
            }
        } while( next_permutation(all(t)));
}
int main( ) {
        IO;
        #ifdef LOCAL
            freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        fuck();
        cin >> s;
        if( s == "zyxwvutsrqponmlkjihgfedcba" ) return cout << -1 << endl,0;
        if( s.size() < 26 ) {
                for( char i = 'a'; i <= 'z'; i++ ) {
                        bool have = false;
                        for( int j = 0; j < s.size(); j++ ) {
                                if( s[j] == i ) have = true;
                        }
                        if( !have ) return cout << s << i << endl,0;
                }
        }
        fuck( );
        return 0;
}











Measured memory_bytes: 256
// O(n)

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdint>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;

int main(){
    //?????°?????£?¨?
    int R[200000];
    int n;
    int ans = -2000000000;
    int min_price;

    //?????????????????????
    scanf("%d", &n);
    for (int i=0; i<n; i++) scanf("%d", &R[i]);

    //?????????
    min_price = R[0];

    
    //??¢?????´?????????
    for(int i=1; i<n; i++){
        ans = max(ans, R[i] - min_price);
        min_price = min(min_price, R[i]);
    }

    //??????
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1952
#include <bits/stdc++.h>
#define FOR(i, b, n) for (long i = b; i < n; ++i)

using namespace std;

void solve(long N) {
  FOR(X, N / 1.08, (N + 1) / 1.08)
    if (long(X * 1.08) == N) {
      cout << X << endl;
      return;
    }
  cout << ":(" << endl;
}

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

  long N;
  cin >> N;

  solve(N);

  return 0;
}


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

int main() {
	ll N,M,K,r,c=0;
	cin >> N >> M >> K;
	r = M;

	vector<ll> A(N+1,0),B(M+1,0);
	rep(i,N) {
		cin >> A.at(i+1);
		A.at(i+1) += A.at(i);
	}
	rep(i,M) {
		cin >> B.at(i+1);
		B.at(i+1) += B.at(i);
	}

	rep(i,N+1) {
		if(A.at(i) > K)
			break;
		for(int j=r; j>=0; --j)
			if(B.at(j) <= K-A.at(i)) {
				r = j;
				break;
			}
		c = max(c, i+r);
	}
	
	cout << c << endl;
}

Measured memory_bytes: 6432
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 1; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
H,W=list(map(int,input().split()))
A=[list(map(lambda x: int(x)%2,input().split())) for _ in range(H)]
visit=[[0]*W for _ in range(H)]

pt=[0,0]
disp=False
ans=[]
while True:
    y,x=pt
    visit[y][x]=1
    if A[y][x]==1:
        disp=not disp
    flag=True
    for dy,dx in [[1,0],[0,1],[-1,0],[0,-1]]:
        ny=y+dy
        nx=x+dx
        if 0<=ny<H and 0<=nx<W and visit[ny][nx]==0:
            npt=[ny,nx]
            flag=False
    if flag:
        break

    if disp:
        ans.append('{} {} {} {}'.format(y+1,x+1,npt[0]+1,npt[1]+1))
    
    pt=npt

print(len(ans))
for s in ans:
    print(s)

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    map<char, bool> dic;
    int N;
    cin >> N;
    REP(i, N) {
        char ch;
        cin >> ch;
        dic[ch] = true;
    }
    if(dic.size() == 3) {
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
    return 0;
}



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

int main(void)
{
    int N;

    cin >> N;

    int ans = N%1000;
    if(ans == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        ans = 1000 - ans;
    }
    

    cout << ans << endl;

    

    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int N, K;
    cin >> N >> K;
    cout << N - (K-1) << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			String[] s = sc.nextLine().split(" ");
			int x = Integer.parseInt(s[0]);
			int y = Integer.parseInt(s[1]);

			if (x == 0 && y == 0) {
				break;
			}
			if (x > y) {
				System.out.println(y + " " + x);
			} else {
				System.out.println(x + " " + y);
			}
		}
	}
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

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

    int N;
    cin >> N;
    N = N%10;
    if(N == 2 || N==4 || N==7 || N==5 || N==9){
        cout << "hon" << endl;
    }else if(N == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }

    return 0;
}


Measured memory_bytes: 3632