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

using namespace std;
const int N = 2e5 + 10;
const int inf = 1e9;
struct E{
    int to , nex , cap;
}e[N * 8];int head[N] , ecnt;

void init(){ecnt = 1;}
void putin(int fr,int to,int cap) { e[++ecnt]=(E){to,head[fr],cap}; head[fr] = ecnt; }
void adde (int fr,int to,int cap) { putin(fr,to,cap);putin(to,fr,0); }


int dep[N];
queue <int> q;
void bfs(int s,int t)
{
    memset(dep,-1,sizeof dep);
    dep[s] = 0;q.push(s);
    
    while (!q.empty())
    {
        int cur = q.front();q.pop();
        for (int j=head[cur];j;j=e[j].nex)
        if ( e[j].cap && dep[ e[j].to ] == -1)
        {
            dep[ e[j].to ] = dep[ cur ] + 1;
            q.push( e[j].to );
        }
        
    }
}
int iter[N];
int dfs(int o,int t,int lim)
{
    if (o == t || !lim) return lim;
    
    int flow = 0;
	for (int &j = iter[o];j;j = e[j].nex)
    if ( e[j].cap && dep[e[j].to] == dep[o] + 1)
    {
        int d = dfs( e[j].to , t , min(lim , e[j].cap ) ) ;
        flow += d;
        lim -= d;
        e[j].cap -= d;
        e[j^1].cap += d;
    }
    
    return flow;
}

int dinic(int s,int t,int n)
{
    int ans = 0 , f;
    for (;;)
    {
        bfs(s,t);
//		printf("%d\n",dep[t]);
        if (dep[t] == -1 ) return ans;
        memcpy(iter,head,sizeof (int) * (n+1) ) ;
        ans += dfs(s,t,inf);
    }
    return ans;
}

vector <int> G[N];

int apo[N] , sem[N] , bel[N] , n;

int main(){
	init();
	scanf("%d",&n);
	
	for (int i = 1;i < n;i++){
		int v;scanf("%d",&v);
		
		while (v--){
			int u;scanf("%d",&u);
			G[u].push_back(i);
			adde(u , i + n , 1);	
		}
		adde(i + n , 2 * n + 1 , 1);	
	}
	
	for (int i = 2;i <= n;i++){
		adde(2 * n , i , 1);
	}
	
	if (dinic(2 * n , 2 * n + 1 , 2 * n + 1) != n - 1) return puts("-1") , 0;
	
	for (int i = 1;i < n;i++){
		for (int j = head[i + n]; j; j = e[j].nex){
			if (e[j].cap && e[j].to != 2 * n + 1 ){
				apo[i] = e[j].to;
				bel[e[j].to] = i;
			}
		}
	}
	for (int i = 1;i < n;i++){
		if (!apo[i]) return puts("-1") , 0;
	}
	
	q.push(1);
	while (!q.empty()){
		int cur = q.front();q.pop();
		for (int u : G[cur]){
			if (!sem[u]){
				sem[u] = cur;
				q.push(apo[u]);
			}
		}
	}
	
	for (int i = 1;i < n;i++){
		if (!sem[i]) return puts("_-1") , 0;
	}
	for (int i = 1;i < n;i++){
		printf("%d %d\n",apo[i],sem[i]);
	}
	return 0;
}

Measured memory_bytes: 29056
#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int x;
    x=N%10;
    if(x==2 || x==4 || x==5 || x==7 || x==9 )
    {
        cout << "hon";
    }
    else if(x==0 || x==1 || x==6 || x==8)
    {
        cout << "pon";
    }
    else
    {
        cout << "bon";
    }
    
    return 0;
}

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

int main(){
  int n;  cin >> n;
  int a[n];

  map<int, int> m;
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> a[i];
    m[a[i]-1]++;
    m[a[i]]++;
    m[a[i]+1]++;

    ans=max(ans, max(m[a[i]-1], max(m[a[i]], m[a[i]+1])));
  }

  /*
  int ans=0;
  for(auto itr=m.begin(); itr!=m.end(); itr++){
    ans = max(itr->second, ans);
  }
  */

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()

int main() {
   int n,T;
   cin >> n >> T;
   int ans=1100;
   rep(i,n){
      int c,t; 
      cin >> c >> t;
      if(t<=T)
      ans=min(c,ans);
   }
   if(ans==1100)
   cout << "TLE" << endl;
   else
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll M = 1000000007;

int main(){
    string S; cin >> S;
    ll n = S.size();
    ll K; cin >> K;
    vll a(n);
    for(int i=0; i<n; i++){
        a[i] = 'z' - S[i] + 1;
    }
    for(int p=0; p<n; p++){
        if(S[p] == 'a'){
            continue;
        }else if(K >= a[p]){
            S[p] = 'a';
            K -= a[p];
        }else{
            continue;
        }
    }
    if(K > 0){
        ll h = (K%26);
        if('z' - (S[n-1] + h) >= 0){
            S[n-1] = (S[n-1] + h);
        }else{
            S[n-1] = ('a' + ((S[n-1] + h - 'z' - 1)));
        }
    }
    cout << S;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
        a[i] -= i+1;
    }
    sort(a.begin(), a.end());

    ll mid = a[n/2];
    ll ans = 0;
    for(ll i=0;i<n;++i){
        ans += abs(mid - a[i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
i = list(map(int, input().split()))

H = int(i[0])
W = int(i[1])

if H % 2 ==0:
    h = H/2    
else:
    h = H//2 + 1
        
if W % 2 == 0:
    w = W/2
else:
    w = W//2 +1
    
if H == 1 or W ==1:
    print(1)
elif H%2 ==0:
    print(int(W*h))
else:
    print(int((W*(h-1)+w)))

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <vector>
#define pb push_back
std::vector<int> son[100005];
int arr[100005], ans, n, k;
inline int dfs(int u)
{
	int res = 1;
	for (int v : son[u])
		res = std::max(res, dfs(v) + 1);
	if (res == k && arr[u])
	{
		ans++;
		return 0;
	}
	return res;
}
int main()
{
	// freopen("AGC004-D.in", "r", stdin);
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", arr + i);
		if (!i)
		{
			ans += arr[i] != 1;
			arr[i] = 0;
		}
		else
			son[--arr[i]].pb(i);
	}
	dfs(0);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 9216
N,K = map(int, input().split())
has = [False for i in range(N)]
for i in range(K):
    input()
    args = list(map(int, input().split()))
    for i in args:
        has[i-1] = True

res = 0
for i in has: 
    if i == False: 
        res += 1
print(res)

Measured memory_bytes: 67848
n = gets.to_i

array = (1..n-1).to_a
array_r = (1..n-1).to_a.reverse

#p array
#p array_r

ctn = 0
for i in 0..array.length-1
  #puts array[i]
  #puts array_r[i]
  if array[i] != array_r[i]
    ctn += 1
   # puts "a"
  end
end

puts ctn / 2

Measured memory_bytes: 27260
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	private class UnionField {
		private class Node {
			public int parent = 0;
			public long size = 1;
			
			public Node(int parent) {
				this.parent = parent;
				this.size = 1;
			}
		}
		
		private Node nodes[] = null;
		
		public UnionField(int size) {
			this.nodes = new Node[size];
			for (int i=0; i<this.nodes.length; i++) {
				this.nodes[i] = new Node(i);
			}
		}
		
		public int getRoot(int node) {
			int parent = this.nodes[node].parent;
			if (parent == node) {
				return node;
			} else {
				int root = getRoot(parent);
				this.nodes[node].parent = root;
				return root;
			}
		}
		
		public long getSize(int node) {
			node = getRoot(node);
			return this.nodes[node].size;
		}
		
		public void union(int a, int b) {
			a = getRoot(a);
			b = getRoot(b);
			if (a != b) {
				this.nodes[a].parent = b;
				this.nodes[b].size += this.nodes[a].size;
			}
		}
		
		public boolean isSame(int a, int b) {
			a = getRoot(a);
			b = getRoot(b);
			return (a == b);
		}
	}

	private class Way {
		public int a;
		public int b;
		
		public Way(int a, int b) {
			this.a = a;
			this.b = b;
		}
	}
	
	public void solve() {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int M = in.nextInt();
		
		UnionField unionField = new UnionField(N);
		LinkedList<Way> ways = new LinkedList<Way>();
		
		for (int i=0; i<M; i++) {
			int a = in.nextInt();
			int b = in.nextInt();

			ways.addFirst(new Way(a, b));
		}
		in.close();

		LinkedList<Long> results = new LinkedList<Long>();
		long nowResult = (long)N * (long)(N-1) / 2;
		results.addFirst(nowResult);
		
		for (Way way : ways) {
			int a = way.a-1;
			int b = way.b-1;
			
			if (unionField.isSame(a, b) == false) {
				long aSize = unionField.getSize(a);
				long bSize = unionField.getSize(b);
				nowResult -= aSize * bSize;
				unionField.union(a, b);	
			}
			
			
			results.addFirst(nowResult);
		}
		
		results.removeFirst();
		for (Long result : results) {
			System.out.println(result);
		}
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
}


Measured memory_bytes: 110024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
    fastio;
    
    int n,k;
    cin>>n>>k;
    if((n+1)/2>=k)

        {cout<<"YES";
}
else
cout<<"NO";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
  ll n ;
  cin >> n ;
  vector<ll> v(n),dp(n) ;
  for(ll i=0;i<n;i++) cin >> v[i] ;
  for(ll i=1;i<n;i++)
  {
    if(i==1) dp[i] = abs(v[i]-v[0]) ;
    else dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2] + abs(v[i]-v[i-2])) ;
  }
  cout << dp[n-1] << endl;

}

Measured memory_bytes: 4752
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	int m=n,k=n;
	long long ans=1,cnt=1,tle=1;
	while(n--)
	{
		ans*=(long long)10;
		ans%=(long long)1000000007;
	}
	while(m--)
	{
		cnt*=(long long)9;
		cnt%=(long long)1000000007;
	}
	while(k--)
	{
		tle*=(long long)8;
		tle%=(long long)1000000007;
	}
	cout<<(2000000014+ans-2*cnt+tle)%1000000007;
	return 0;
}

Measured memory_bytes: 3632
IDENTIFICATION DIVISION.
PROGRAM-ID. A-BEGINNER.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 K        PIC 9(3).
01 SHO      PIC 9(2).
01 AMARI    PIC 9(1).
01 O-PAIR   PIC ZZZ9.
 
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT K.

  DIVIDE K BY 2 GIVING SHO REMAINDER AMARI.
  COMPUTE O-PAIR = SHO * (SHO + AMARI).

  DISPLAY O-PAIR.

MAIN-EXIT.
  STOP RUN.

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

using namespace std;

#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define mem(a) memset(a, 0, sizeof(a))
#define sqr(x) ((x) * (x))

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

const int mn = 2e5 + 5;
const int mod = 1e9 + 7;
#define P mod

int n;
int a[mn];
ll b[mn],c[mn],d[mn],e[mn],f[mn];

int main() {
#ifdef LOCAL
    freopen("../1.txt", "r", stdin);
#endif
    scanf("%d", &n);
    int l = 0, r = n;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]), b[i] = a[i] + b[i - 1];
    }

    for(int i=1;i<=n;i++){
        int u=0;
        if (a[i]%2==1) u=1;
        if (a[i]==0) u=2;
        c[i]=min(b[i],c[i-1]+u);
    }

    for(int i=1;i<=n;i++){
        int u=(a[i]%2==0);
        d[i]=min(c[i],d[i-1]+u);
    }

    for(int i=1;i<=n;i++){
        int u=0;
        if (a[i]%2==1) u=1;
        if (a[i]==0) u=2;
        e[i]=min(d[i],e[i-1]+u);
    }

    for(int i=1;i<=n;i++){
        f[i]=min(e[i],f[i-1]+a[i]);
    }

    printf("%lld\n", f[n]);
    return 0;
}


Measured memory_bytes: 8960
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define mod 1000000009
typedef long long ll;
using namespace std;

const int MAX = 100005;
int dp[MAX];
int h[MAX];
int n;

int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i+1];
  }

  dp[1] = 0;
  dp[2] = abs(h[2] - h[1]);
  for(int i=3;i<=n;i++) dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));

  cout << dp[n] << endl;
  return 0;
}

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

int a, b, c;

int solve(string s){
  int tmp;
  if(s == "north") tmp = b, b = a, a = 7-tmp;
  if(s == "east") tmp = a, a = c, c = 7-tmp;
  if(s == "west") tmp = c, c = a, a = 7-tmp;
  if(s == "south") tmp = a, a = b, b = 7-tmp;
  
  return a;
}

int main(){
  int n, ans;
  string op;
  while(cin >> n, n){
    a = 1, b = 2, c = 3;
    for(int i = 0 ; i < n ; i++){
      cin >> op;
      ans = solve(op);
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

int h, n;
int a[10100], b[10100];
int dp[10100];

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

    memset(dp, 255, sizeof(dp));
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= h; j++) {
            int id = max(0, j - a[i]);
            if (dp[id] != -1 && dp[j] != -1) dp[j] = min(dp[id] + b[i], dp[j]);
            else {
                if (dp[id] != -1) {
                    dp[j] = dp[id] + b[i];
                }
                else continue;
            }
        }
    }
    cout << dp[h] << '\n';
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] l = new int[n];
        for(int i = 0; i<n; i++) {
            l[i] = sc.nextInt();
        }
        long now = 0;
        long count = 1;
        for(int i = 0; i<n; i++) {
            now = now + l[i];
            if(now<=x)count++;
        }

            System.out.println(count);
    }
}

Measured memory_bytes: 21844
using System;

namespace AtCoder_Biggner168
{
    class Program
    {
        static void Main(string[] args)
        {
            // int num = int.Parse(Console.ReadLine());

            //var num = Console.ReadLine().ToCharArray();

            //if (num[num.Length - 1].Equals( '2') ||
            //    num[num.Length - 1].Equals('4') ||
            //    num[num.Length - 1].Equals('5') ||
            //    num[num.Length - 1].Equals('7') ||
            //    num[num.Length - 1].Equals('9')) Console.WriteLine("hon");
            //else if (num[num.Length - 1].Equals('0') ||
            //    num[num.Length - 1].Equals('1') ||
            //    num[num.Length - 1].Equals('6') ||
            //    num[num.Length - 1].Equals('8')) Console.WriteLine("pon");
            //else Console.WriteLine("bon");

            var num = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();

            if (str.Length > num)
            {
                var ary = str.ToCharArray();

                for(int i = 0; i < num; i++) 
                {
                    Console.Write(ary[i].ToString());
                
                }
                Console.Write("...");
                Console.Write("\n");
            }
            else Console.WriteLine(str);

        }
    }
}


Measured memory_bytes: 17700
//
//  main.cpp
//  ABC166
//
//  Creatn 2020/05/03.
//  Copyright © 2020 エロやん. All rights reserved.
//

#include <iostream>
#include<string>
using namespace std;
int main(){
    string str;
    cin>>str;
    if(str[1]=='R')
        cout<<"ABC"<<endl;
    else
     cout<<"ARC"<<endl;
    
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#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 irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    cout<<n*(n+1)/2<<endl;
}


Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_089_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(200).
    01 maxlen PIC 9(3).
    01 cur    PIC 9(3)  VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(3).

    01 S      PIC X(1).

    01 N      PIC 9(3).

    01 cnt    PIC 9(3).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    ACCEPT INP.

    MOVE 0 TO cnt.

    MOVE N TO maxlen.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO S

        IF S = 'Y' THEN
            MOVE 1 TO cnt
            EXIT PERFORM
        END-IF

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    IF 0 < cnt THEN
        DISPLAY "Four"
    ELSE
        DISPLAY "Three"
    END-IF.

    STOP RUN.


Measured memory_bytes: 764
N=int(input())
a=list(map(int,input().split()))
p,q,r=0,0,0
for i in range(N):
  if a[i]%2==0:
    if a[i]%4==0:
      r+=1
    else:
      q+=1
  else:
    p+=1
if p-1<r:
  print('Yes')
elif p-1==r:
  if q==0:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 20036
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	int a, b, c;
	char gomi;
	int x = 0, y = 0;
	while (cin >> a >> gomi >> b >> gomi >> c) {
		x += a * a + b * b == c * c;
		y += a == b;
	}
	cout << x << endl << y << endl;
}

Measured memory_bytes: 3088
n= int(input())
a = [int(i) for i in input().split()]
ans = 0
a.sort()
# ~ print(a)
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if a[i]+a[j]>a[k] and len(set([a[i],a[j],a[k]]))==3:
				# ~ print(a[i],a[j],a[k])
				ans+=1
print(ans)


Measured memory_bytes: 9196
import fractions
n, m = map(int,input().split())
s = input()
t = input()
q = fractions.gcd(n, m)
l = n * m // q #lcm(n, m)
for i in range(0, q):
  if s[i * n//q] != t[i * m//q]:
    print('-1')
    exit()
print(l)

Measured memory_bytes: 5560
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
int n,m,k;
char s[805][805];
int dist[805][805];
int si,sj;
void bfs(){
	memset(dist,-1,sizeof(dist));
	queue<pair<int,int> >q;
	dist[si][sj]=0;
	q.push(make_pair(si,sj));
	while(!q.empty()){
		int x=q.front().first,y=q.front().second;q.pop();
		for(int i=0;i<4;i++){
			int nx=x+dx[i];
			int ny=y+dy[i];
			if(nx<1||nx>n||ny<1||ny>m||s[nx][ny]=='#')continue;
			if(dist[nx][ny]!=-1)continue;
			dist[nx][ny]=dist[x][y]+1;
			q.push(make_pair(nx,ny));
		}
	}
}
int main(){
	n=in();m=in();k=in();
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;j++){
			if(s[i][j]=='S'){
				si=i;sj=j;
				s[i][j]='.';
			}
		}
	}
	bfs();
	int MIN=INF;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(dist[i][j]!=-1&&dist[i][j]<=k){
				if(min(min(i-1,j-1),min(n-i,m-j))<MIN){
					MIN=min(min(i-1,j-1),min(n-i,m-j));
				}
			}
		}
	}
	printf("%d\n",(MIN+k-1)/k+1);
	return 0;
}

Measured memory_bytes: 3456
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
    int n;
    cin>>n;
    int arr[n];
  int xo=0;
    for(int  i=0;i<n;i++)
    {
   cin>>arr[i];
      xo=xo^arr[i];
    }
  for(int i=0;i<n;i++)
    cout<<(xo^arr[i])<<" ";
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 4376
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>


int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	if(a+b==15)printf("+\n");
	else if(a*b==15)printf("*\n");
	else printf("x\n");
	
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  ll K;
  cin>>s>>K;
  int N=s.size();
  char memo;
  for(int i=0;i<N&&i<K;i++){
    memo=s[i];
    if(memo!='1')break;
  }
  cout<<memo<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10005
#define INF 99999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

int fun(int end,int p[])
{
  int x=end,sum=1;
  while(p[x]!=-1)
    sum++,x=p[x];
  return sum;
}

int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n,arr[100005];
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>arr[i];
 int cur=1,cnt=0;
  while(cnt<=1000000)
  {
    if(cur==2)
      break;
    cnt++;
    cur=arr[cur];

  }
  if(cnt<1000000)
  cout<<cnt<<endl;
else
  cout<<-1<<endl;

 return 0;
}

Measured memory_bytes: 640
def main():
    N = int(input())
    nums = list(map(int, input().split()))

    count = 0
    flag = True

    while(flag):
        for num in nums:
            if num % 2 == 0:
                continue
            else:
                flag = False
                break
        nums = [n/2 for n in nums]
        count += 1

    print(count-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39408
#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"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	vector<vector<long long int>>dp(N, vector<long long int>(N,MOD*MOD));
	for (int i = 0; i < N - 1; i++)dp[i][i + 1] = v[i] + v[i + 1];
	for (int i = 1; i < N; i++)v[i] += v[i - 1];
	for (int i = 0; i < N; i++)dp[i][i] = 0;
	for (int i = 2; i < N; i++) {
		for (int j = 0; j + i < N; j++) {
			for (int k = 0; k < i; k++) {
				if(j)dp[j][i + j] = min(dp[j][j + i], dp[j][j + k] + dp[j + k + 1][j + i] + v[j + i] - v[j - 1]);
				else dp[j][i + j] = min(dp[j][j + i], dp[j][j + k] + dp[j + k + 1][j + i] + v[j + i] );
			}
		}
	}
	cout << dp.front().back() << endl;
	return 0;
} 

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int cnt=0;  
    for(int i=0;i<a.size();i++){
        if(a[i]=='C'){
            cnt=1;
        }
        if(a[i]=='F'&&cnt==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

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

int main() {
  int n, l;
  cin>>n>>l;
  long long a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  bool ok = false;
  int s = 0;
  for (int i=1; i<n; i++) {
    if (a[i-1] + a[i] >= l) {
      ok = true;
      cout<<"Possible"<<endl;
      s = i;
      break;
    }
  }
  if (!ok) {
    cout<<"Impossible"<<endl;
    return 0;
  }
  vector<int> ans;
  ans.push_back(s);
  for (int i=s-1; i>0; i--) {
    ans.push_back(i);
  }
  for (int i=s+1; i<n; i++) {
    ans.push_back(i);
  }
  reverse(ans.begin(), ans.end());
  for (int i=0; i<n-1; i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 2168
#include<iostream>

using namespace std;

int main(){
 int n,m,x;
  cin >> n >> m >>x;
  
  int a;
  int left=0,right=0;
  
  for(int i=0;i<m;i++){
    cin >> a;
    if(a<x) left++;
    else right++;
  }

  if(left<right) cout << left << endl;
  else cout << right << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int a[100005];
int main(void)
{
	int n;
	long long int x;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &x);
		a[i] = x;
	}
	for (int i = n - 1; i > 0; i--)
	{
		if (a[i] < a[i - 1])
		{
			a[i - 1]--;
		}
	}
	for (int i = 0; i < n - 1; i++)
	{
		if (a[i] > a[i + 1])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef pair<int,int> P_ii;
typedef pair<double,double> P_dd;
typedef long long int ll;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

int main()
{
    int N; cin >> N;
    auto dp = make_vec<ll>(N+1,5,5,5);

    dp[0][0][0][0]=1;
    for(int n=0;n<N;n++){
        for(int i=0;i<5;i++){
            for(int j=0;j<5;j++){
                for(int k=0;k<5;k++){
                    for(int l=1;l<5;l++){
                        if(i==1 && j==2 && l==3) continue;
                        if(i==1 && k==2 && l==3) continue;
                        if(j==2 && k==1 && l==3) continue;
                        if(j==1 && k==3 && l==2) continue;
                        if(j==1 && k==2 && l==3) continue;
                        addM(dp[n+1][j][k][l],dp[n][i][j][k]);
                   }
                }
            }
        }
    }

    ll ans = 0;
    for(int i=1;i<5;i++){
        for(int j=1;j<5;j++){
            for(int k=1;k<5;k++){
                addM(ans,dp[N][i][j][k]);
            }
        }
    }
    pl(ans)
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;

const int maxn=100111;
int n,pa[maxn],sz[maxn];
LL d[maxn];
pair<LL,int> vs[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",d+i);
		vs[i]=mp(d[i],i);
		sz[i]=1;
	}
	sort(vs+1,vs+n+1);for(int i=1;i<=n;i++)d[i]=vs[i].ff;
	for(int i=n;i>=2;i--)
	{
		int dlt=(n-sz[i])-sz[i],id=lower_bound(d+1,d+n+1,d[i]-dlt)-d;
		if(id>=i||d[id]!=d[i]-dlt)
		{
			puts("-1");
			return 0;
		}
		pa[i]=id;
		sz[id]+=sz[i];
	}
	LL sum=0;
	for(int i=1;i<=n;i++)sum+=sz[i]-1;
	if(sum!=d[1])
	{
		puts("-1");
		return 0;
	}
	for(int i=2;i<=n;i++)printf("%d %d\n",vs[pa[i]].ss,vs[i].ss);
	return 0;
}

Measured memory_bytes: 4608
#include <iostream>
#include <algorithm>
#include <cstring>

typedef long long ll;

ll dp[12][102][1001];

int s, n;

int main(){
	dp[0][0][0] = 1;

	for (int i = 0; i <= 9; ++i){
		for (int j = 0; j <= 100; ++j){
			for (int k = 0; k <= 1000; ++k){
				if (dp[i][j][k] == 0)continue;
				for (int l = j; l <= 100; ++l){
					if (k + l < 1001)dp[i + 1][l + 1][k + l] += dp[i][j][k];
				}
			}
		}
	}

	while (true){
		std::cin >> n >> s;
		if (s == 0 && n == 0)break;
		ll sum = 0;
		for (int i = 0; i <= 101; ++i)sum += dp[n][i][s];
		std::cout << sum << std::endl;
	}
	return 0;
}

Measured memory_bytes: 8480
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;

vector<pair<int,int> > adj[MAX];

void dijkstra(){
  priority_queue<pair<int,int> > PQ;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=GRAY;

  while(!PQ.empty()){
    pair<int,int>f=PQ.top();PQ.pop();
    int u=f.second;
    color[u]=BLACK;
    if(d[u]<f.first*(-1))continue;
    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==BLACK)continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=GRAY;
      }
    }
  }

  for(int i=0;i<n;i++){
    cout << i << " " << (d[i]==INFTY?-1:d[i]) << endl;

  }
}
int main(){
  int k,u,v,c;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int j=0;j<k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
	}
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 7988
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a;
  int ans = 0; 
  int j = 1; 
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a == j) {
      ++j;
    } else {
      ++ans;
    }
  }
  if (ans == n) {
    puts("-1");
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	s := sc.Text()
	n, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = nextInt(sc)
	}
	sort(n, as)
}

func printArray(as []int) {
	fmt.Println(strings.Trim(fmt.Sprint(as), "[]"))
}

func sort(n int, as []int) {
	count := 0
	flag := true
	for flag {
		flag = false
		for j := n - 1; j > 0; j-- {
			if as[j] < as[j-1] {
				a := as[j]
				as[j] = as[j-1]
				as[j-1] = a
				flag = true
				count = count + 1
			}
		}
	}
	printArray(as)
	fmt.Println(count)
}



Measured memory_bytes: 1144
using System;
using System.Linq;

public class TorT{
    public static void Main(string[] argc){
        string[] input = Console.ReadLine().Split(' ');
        int[] arr = input.Select(x => int.Parse(x) ).ToArray();

        int charge = GetCharge(arr[0], arr[1], arr[2]);
        Console.WriteLine(charge);
    }

    public static int GetCharge(int num, int trainPerOne, int taxi){
        int train = num * trainPerOne;
        return train > taxi ? taxi : train;
    }

}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

//level n ,layer x

ll fun(ll n, ll x)
{
	if (x == 0)
		return 0;
	if (n == 0)
		return 1;
	if (x <= lay[n - 1] + 1)
		return fun(n - 1, x - 1);
	if (x < lay[n])
		return p[n - 1] + 1 + fun(n - 1, x - 1 - (lay[n - 1] + 1));
	return p[n];
}

int main()
{
	cin >> n >> k;
	lay.push_back(1),p.push_back(1);
	for (int i = 1; i <= n; i++)
	{
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}


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

int main()
{
    string S;
    cin >> S;
    if(S.size() < 4) { cout << "No" << endl; return 0; }
    if(S.substr(0,4) != "YAKI") { cout << "No" << endl;}
    else {cout << "Yes" << endl;}
    return 0;
}

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

using ll = long long;
using namespace std;

void solve() {
   int n;
   cin >> n;
   vector <ll> a(n), b(n);
   for(int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
   }

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


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   }
 
   return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  ll ans=700;
  for(auto x:S) {
if(x=='o') {
ans+=100;
}
  }
cout<<ans<<endl;
}

Measured memory_bytes: 3600
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	a := nextLine()

	b := strings.Split(a, "")
	length := len(a)
	
	s := []int{}
	for i := 0; i < length; i++ {
		v, e := strconv.Atoi(b[i])
		if e != nil {
			panic(e)
		}

		s = append(s, v)
	}

	var ans string

	for bit := 0; bit < 8; bit++ {
		sum := s[0]
		ops := b[0]

		for i := 0; i < 3; i++ {
			op := (bit & (1<<uint8(i)))

			// When the operator is '+'
			if op > 0 {
				sum += s[i+1]
				ops += "+" + b[i+1]
			// When the operator is '-'
			} else {
				sum -= s[i+1]
				ops += "-" + b[i+1]
			}
	
		}
		if sum == 7 {
			ans = ops + "=7"
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
using namespace std;
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define N 100005
int main()
{
	lld n,cnt=0;
	string s,final="";
	cin>>n>>s;
	stack<char> ss;
	rep(i,0,n) {
		if(s[i]=='(') ss.push(s[i]),final+=s[i];
		else {
			if(ss.empty()) final='('+final;
			else ss.pop();
			final+=s[i];
		}
	}
	while(!ss.empty()) final=final+')',ss.pop();
	cout<<final;
	return 0;
}

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

int main() {
  ll n;cin>>n;
  vector<ll>a(n);
  for(int i=0;i<n;i++){
    cin >>a.at(i);
    if(a.at(i)==0){
      cout <<0<<endl;
      return 0;
    }
  }
  ll seki=1;
  for(int i=0;i<n;i++){
    if(1000000000000000000/seki<a.at(i)){
      cout <<-1<<endl;
      return 0;
    }
    seki*=a.at(i);
  }
  cout <<seki<<endl;
}

Measured memory_bytes: 4052
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		String S = sc.next();
		int length = S.length();
		String S1 = "";
		String S2 = "";
		if (length % 2 == 0) {
			S1 = S.substring(0, length / 2);
			S2 = S.substring(length / 2);
		} else {
			S1 = S.substring(0, length / 2);
			S2 = S.substring(length / 2 + 1);
		}
		int cnt = 0;
		char[] c1 = S1.toCharArray();
		char[] c2 = S2.toCharArray();
		for (int i = 0; i < c1.length; i++) {
			if (c1[i] != c2[c2.length - i - 1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};


ll c[100001];
ll N;

int main(){

	cin >> N;

	for (int i = 0; i < N; i++){
		int t;
		cin >> t;
		if (t>100000) c[0]++;
		else c[t]++;
	}

	int r = c[0];
	for (int i = 1; i <= 100000; i++){
		if (c[i] >= i) r += c[i] - i;
		else r += c[i];
	}

	cout << r << endl;

	return 0;
}

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

using namespace std;

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

    if(n % 2)
    {
        cout << 0;
        return 0;
    }

    long long ans = 0;

    for(long long i = 10; i <= n; i *= 5)
    {
        ans += (n / i);
    }
    cout << ans << endl;
}

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

int main() {
	long long x, n, h;
	cin >> x;
	n = x / 500;
	n *= 1000;
	h=(x % 500) / 5;
	n += (h * 5);
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(C)]
c = [list(map(int,input().split())) for _ in range(N)]

colordata = [[0]*C for i in range(3)]
for i in range(N):
    for j in range(N):
        colordata[(i+j)%3][c[i][j]-1] += 1

#print(colordata)

ans = 10**30

for color1 in range(C):
    for color2 in range(C):
        if color2 == color1:continue
        for color3 in range(C):
            if color1 == color3 or color2 == color3:continue
            now = 0
            for i in range(C):
                now += data[i][color1]*colordata[0][i]
            for i in range(C):
                now += data[i][color2]*colordata[1][i]
            for i in range(C):
                now += data[i][color3]*colordata[2][i]
            ans = min(ans,now)

print(ans)

Measured memory_bytes: 47068
#include<iostream>
#include<vector>
using namespace std;
int n,m,a,b,c,t;
struct ary{
  int x[50][50]; 
  ary(){}
  ary(const ary &p){
    for(int i=0;i<50;i++){
      for(int j=0;j<50;j++){
	x[i][j]=p.x[i][j];
      }
    }
  }
};

ary mp,st;
ary multi(ary bmp1,ary bmp2){
  ary nmp;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      nmp.x[i][j]=0;
      for(int k=0;k<n;k++){
	nmp.x[i][j]+=(bmp1.x[i][k]*bmp2.x[k][j])%m;
      }
      nmp.x[i][j]%=m;
    }
  }
  return nmp;
}

ary rec(ary bmp,int ti){
  ary nmp(bmp);
  ti--;
  while(ti>0){
    if(ti&1) nmp=multi(nmp,bmp);
    bmp=multi(bmp,bmp);
    ti>>=1;
  }
  return nmp;
}
int main(){
  while(cin>>n>>m>>a>>b>>c>>t,n||m||a||b||c||t){
    int s[50]={},o[50]={};
    int i,j,k,p,q;
    for(i=0;i<n;i++){
      cin >> s[i]; 
    }
    fill(mp.x[0],mp.x[50],0);
    fill(st.x[0],st.x[50],0);
    mp.x[0][0]=b; mp.x[0][1]=c;
    for(i=1;i<n-1;i++){
      mp.x[i][i-1]=a;
      mp.x[i][i]=b;
      mp.x[i][i+1]=c;
    }
    mp.x[n-1][n-2]=a; mp.x[n-1][n-1]=b;
    mp=rec(mp,t);
    if(t==0){
      for(i=0;i<n;i++)
	cout << s[i] << (i==n-1?"\n":" ");
    }else{
      for(i=0;i<n;i++){
	o[i]=0;
	for(k=0;k<n;k++){
	  o[i]+=(mp.x[i][k]*s[k])%m;
	}
	o[i]%=m;
	cout << o[i] << (i==n-1?"\n":" ");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<map>
#include<vector>
using namespace std;
vector<int> v;
map<int,int> mp;
int ans=0;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(!mp[x]){
			v.push_back(x);
		}
		mp[x]++;
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		ans=max(ans,mp[v[i]-1]+mp[v[i]]+mp[v[i]+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4988
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << max(A * B, C * D) << endl;
    return 0;
}

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

const int32_t MAX_N = 2999;

double p[MAX_N + 5], dp[MAX_N + 5][MAX_N + 5];

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int32_t n;
	std::cin >> n;

	for(int32_t i = 1; i <= n; i++) {
		std::cin >> p[i];
	}

	dp[0][0] = 1.0;
	for(int32_t i = 1; i <= n; i++) {
		for(int32_t j = 0; j <= i; j++) {
			dp[i][j] = 0.0;

			if(j != 0) {
				dp[i][j] += dp[i - 1][j - 1] * p[i];
			}
			if(j != i) {
				dp[i][j] += dp[i - 1][j] * (1.0 - p[i]);
			}
		}
	}

	double ans = 0.0;
	for(int32_t i = n / 2 + 1; i <= n; i++) {
		ans += dp[n][i];
	}

	std::cout << std::fixed << std::setprecision(9);
	std::cout << ans << '\n';
}



Measured memory_bytes: 68992
N = int(input())
H = list(map(int, input().split()))
flag = 0
m_flag = 0

for i in range(N-1):
    if H[i+1] - H[i] >= 1:
        m_flag = 0
        continue
    
    elif H[i+1] - H[i] == 0:
        continue
    
    elif H[i+1] - H[i] == -1 and m_flag == 0:
        H[i] -= 1
        m_flag = 1

    
    else:
        print("No")
        flag = 1
        break

if flag == 0:
    print("Yes")

Measured memory_bytes: 14252
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int sum=0;
        for(int i=2;i*i<=n;i++){
            if(n%i==0)sum+=i+n/i;
            if(i*i==n)sum-=i;
        }
        if(n!=1)sum++;
        if(sum<n)cout<<"deficient number"<<endl;
        else if(sum>n)cout<<"abundant number"<<endl;
        else cout<<"perfect number"<<endl;
    }
}

Measured memory_bytes: 1152