akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = input[0];　// 仲間の数
            int k = input[1];　// ジェットコースターに乗るために必要な身長

            int[] height = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int count = 0;
            for(int i = 0; i < height.Length; i++)
            {
                if (k <= height[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

int main(){
    long long n;
    cin >> n;
    string ans;
    
    while (n > 0){
        n--;
        ans += (n % 26) + 'a';
        n /= 26;
    }

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int ant[5] = {0};
    int k;
    rep(i, 5) {
        cin >> ant[i];
    }
    cin >> k;
    bool result = true;
    rep(i, 5) {
        rep(j, 5) {
            if (abs(ant[i] - ant[j]) > k) result = false;
        }
    }
    cout << (result ? "Yay!" : ":(" ) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

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

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

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

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

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    String t = sc.next();
    System.out.println(t + s);
  }
}

Measured memory_bytes: 20820
N = int(input())
l = []
for i in range(N):
    s = input()
    S = [s[x] for x in range(10)]
    S = sorted(S)
    s = ""
    for j in range(10):
        s += S[j]
    l.append(s)


from collections import Counter

l = Counter(l)
c = l.values()
ans = 0
for i in c:
    ans += i * (i - 1) // 2

print(ans)

Measured memory_bytes: 24084
#include<bits/stdc++.h>
using namespace std;
#define f(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define d(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ri register int
#define ll long long
#define il inline
#define _ 100005
const ll qwq=10;
int max(int x, int y) {return x>y?x:y;} int min(int x, int y) {return x<y?x:y;}
queue<ll> Q; ll num[_];
void bfs() {
  int sum = 0;
  f(i,1,9) Q.push(i);
  while(sum <= 100000) {
    ll x = Q.front(); int y; Q.pop(); y=x%qwq; num[++sum] = x;
    if(y!=0 && y!=9) Q.push(x*qwq+y-1), Q.push(x*qwq+y), Q.push(x*qwq+y+1);
    else if(y == 0) Q.push(x*qwq+y), Q.push(x*qwq+y+1);
    else if(y == 9) Q.push(x*qwq+y-1), Q.push(x*qwq+y);
  }
}
signed main(){
  bfs();
  int k; cin>>k; cout<<num[k]<<endl;
  return 0;
}
// sto wyxkk orz


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>

using namespace std;

#define mod 1000000007

int n, m;
int f[1100][1100];
char s[1100][1100];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++ i)
		for (int j = 1; j <= m; ++ j)
			scanf(" %c", &s[i][j]);
	for (int i = 1; i <= n && s[i][1] == '.'; ++ i)
		f[i][1] = 1;
	for (int i = 1; i <= m && s[1][i] == '.'; ++ i)
		f[1][i] = 1;
	for (int i = 2; i <= n; ++ i)
		for (int j = 2; j <= m; ++ j)
			f[i][j] = (s[i][j] == '#' ? 0 : (f[i - 1][j] + f[i][j - 1]) % mod);
	printf("%d", f[n][m]);
	return 0;
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}

ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,ma,mb;
  cin>>n>>ma>>mb;
  vll a(n),b(n),c(n);
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  map<pll,ll> x,y;
  for(int bit=0;bit<(1<<(n/2));bit++){
    pll p=pll(0,0);
    ll cost=0;
    rep(i,n/2){
      if(bit&(1LL<<i)){
        p.F+=a[i];
        p.S+=b[i];
        cost+=c[i];
      }
    }
    if(x.count(p)){
      chmin(x[p],cost);
    }
    else x[p]=cost;
  }
  for(int bit=0;bit<(1<<(n-n/2));bit++){
    pll p=pll(0,0);
    ll cost=0;
    rep(i,n-n/2){
      if(bit&(1LL<<i)){
        p.F+=a[i+n/2];
        p.S+=b[i+n/2];
        cost+=c[i+n/2];
      }
    }
    if(y.count(p)){
      chmin(y[p],cost);
    }
    else y[p]=cost;
  }
  ll ans=INF;
  for(auto p:x){
    pll now=p.F;
    for(int i=1;i<=40;i++){
      ll mma=ma*i;
      ll mmb=mb*i;
      if(y.count(pll(mma-now.F,mmb-now.S))){
        chmin(ans,p.S+y[pll(mma-now.F,mmb-now.S)]);
      }
    }
  }
  if(ans==INF) COUT(-1);
  else COUT(ans);
}
      

Measured memory_bytes: 4200
#include <stdio.h>

int main() {
	int i, j, k, n, v;
	int a[100];

	scanf("%d", &n);

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

	for (i = 0; i < n; i++) {
		v = a[i];
		j = i - 1;

		while (j >= 0 && a[j] > v) {
			a[j+1] = a[j];
			a[j] = v;
			j--;
		}

		for (k = 0; k < n - 1; k++) {
			printf("%d ", a[k]);
		}

		printf("%d\n", a[n - 1]);
	}

	return 0;
}

Measured memory_bytes: 2756
#include <cstdio>
#include <algorithm>
#include <vector>

const int Inf = 0x3f3f3f3f;
const int MN = 200005;

int N, a[MN];
std::vector<int> G[MN];

int par[MN], len[MN], gl[MN], b[MN];
void DFS0(int u, int p) {
	par[u] = p, b[u] = a[u];
	for (int v : G[u]) if (v != p) {
		DFS0(v, u);
		len[u] = std::max(len[u], len[v] + 1);
		b[u] += b[v];
	}
}
void DFS1(int u, int p) {
	static int seq[MN], pre[MN], suf[MN];
	int t = 0;
	for (int v : G[u]) if (v != p) seq[++t] = v;
	pre[0] = suf[t + 1] = gl[u] + 1;
	for (int i = 1; i <= t; ++i) pre[i] = suf[i] = len[seq[i]] + 1;
	for (int i = 1; i <= t; ++i) pre[i] = std::max(pre[i], pre[i - 1]);
	for (int i = t; i >= 1; --i) suf[i] = std::max(suf[i], suf[i + 1]);
	for (int i = 1; i <= t; ++i) gl[seq[i]] = std::max(pre[i - 1], suf[i + 1]);
	for (int v : G[u]) if (v != p) DFS1(v, u);
}

int lower[MN], upper[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1, x, y; i < N; ++i) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for (int i = 1; i <= N; ++i) scanf("%1d", &a[i]);
	DFS0(1, 0), gl[1] = -1, DFS1(1, 0);
	for (int i = 1; i <= N; ++i) {
		int x = gl[i], y = -1, z = b[1] - b[i] ? gl[i] : Inf;
		for (int v : G[i]) if (v != par[i]) {
			if (len[v] > y) y = len[v];
			if (y > x) std::swap(x, y);
			z = std::min(z, b[v] ? len[v] : Inf);
		}
		upper[i] = std::min(x, y + 2);
		if (!a[i]) lower[i] = z + 1;
	}
	long long Ans = 1;
	for (int i = 1; i <= N; ++i) Ans += std::max(upper[i] - lower[i] + 1, 0);
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 31032
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define int long long
using namespace std;
signed main(){
	int n,x;
	cin>>n>>x;
	vector<int> a;
	for(int i=0;i<n;i++){
		int tx;cin>>tx;a.pb(tx);
	}
	a.pb(0);
	int ans = 0;
	for(int i=0;i<n;i++){
		if(a[i] + a[i+1] > x){
			if(a[i]>x){
				ans += a[i] -x;
				ans += a[i+1];
				a[i] = x;
				a[i+1] = 0;
			}
			else{
				ans += a[i+1] - ( x - a[i] );
				a[i+1] = x - a[i];
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int MOD = 1000000007;
main(){
    int N;
    string s,t;
    cin >> N >> s >> t;
    for(int i = 0;i < N;i++){
        if(!t.find(s.substr(i,N-i))){
            cout << N+i << endl;
            return 0;
        }
    }
    cout << N*2 << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

vector<int> topological_sort(vector<vector<int>> &graph, vector<int> &indegree, int V) {
	vector<int> ans;
	queue<int> Q;
	Rep(i, V) {
		if (indegree[i] == 0) {
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		Rep(i, graph[v].size()) {
			int u = graph[v][i];
			indegree[u]--;
			if (indegree[u] == 0) Q.push(u);
		}
		ans.push_back(v);
	}
	return ans;
}

int main() {
	int V, E;
	cin >> V >> E;
	vector<vector<int>> graph(V);
	vector<int> indegree(V);
	Rep(i, E) {
		int a, b;
		cin >> a >> b;
		graph[a].push_back(b);
		indegree[b]++;
	}
	vector<int> ans = topological_sort(graph, indegree, V);
	Rep(i, V) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3712
#include <algorithm>
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
inline char gc() {
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void rd(T &x) {
	x=0; int f=1,ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=gc();}
	x*=f;
}
template<class T> inline bool Cmax(T &x,T y) {return x<y?x=y,1:0;}
typedef long long ll;
const int maxn=1e5+50;
int N,M,V,P,A[maxn];
bool check(int x) {
	static int B[maxn]; int k=0;
	for(int i=1;i<=N;++i) if(A[i]>x) B[++k]=A[i]-x;
	if(k<=P) return 1; k-=P;
	int mx=0; ll sum=0;
	for(int i=1;i<=k;++i) {
		Cmax(mx,B[i]),sum+=B[i];
	}
	return max((ll)mx,(sum+V-1)/V)<=M;
}
int main() {
	rd(N),rd(M),rd(V),rd(P),V=N-V,--P;
	for(int i=1;i<=N;++i) rd(A[i]);
	sort(A+1,A+N+1);
	int l=0,r=1e9,re=-1;
	while(l<=r) {
		int mid=(l+r)>>1;
		if(check(mid)) r=mid-1,re=mid;
		else l=mid+1;
	}
	int an=0;
	for(int i=1;i<=N;++i) if(A[i]>=re) ++an;
	printf("%d\n",an);
	return 0;
}

Measured memory_bytes: 4616
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

int main(){
    int r, g, b, n;
    std::cin >> r >> g >> b >> n;

    int count = 0;
    int iLimit = n / r;
    for(int i = 0; i <= iLimit; ++i){
        int jLimit = (n - i * r) / g;
        for(int j = 0; j <= jLimit; ++j){
            if(0 == (n - i * r - j * g) % b){
                ++count;
            }
        }
    }
    
    std::cout << count << std::endl;

    return 0;
}


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

int main() {
  int n, r;
  cin >> n >> r;
  int ans;
  if (n >= 10) {
    cout << r << endl;
  } else {
    ans = r + 100 * (10 - n);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n,c,ans[100005];
bool vis[100005];
vector<pair<int,int> > g[100005];
void dfs(int x,int color)
{
	vis[x]=1;
	int cnt=0;
	for(int i=0;i<g[x].size();i++)
		if(!vis[g[x][i].first])
		{
			++cnt;
			if(cnt==color) ++cnt;
			c=max(c,cnt);
			ans[g[x][i].second]=cnt;
			dfs(g[x][i].first,cnt);
		}
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		g[a].push_back(make_pair(b,i));
		g[b].push_back(make_pair(a,i));
	}
	ans[1]=1;
	dfs(1,0);
	cout<<c<<endl;
	for(int i=1;i<=n-1;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
//ノート　isupperで大文字の判定　islowerで小文字の判定
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    int a,b;
    std::cin >> a>>b;
    if(a<=b)std::cout << a << std::endl;
    else std::cout << a-1 << std::endl;
}

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

int main() { 
    string n;
    cin >> n;
    if(n=="0"){
      cout << "Yes" << endl;
      return 0;
    }
    int cnt = 0;
    for (int i = 0; i < n.size(); i++) {
      cnt += n[i]-'0';
    }
    if(cnt%9==0) cout <<"Yes" <<endl;
    else cout <<"No" << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<stdio.h>
#include<string.h>
int main(){
    char a[11],b[11],c[11];
    scanf("%s",a);
    scanf("%s",b);
    scanf("%s",c);

    if(a[strlen(a)-1]==b[0]){
        if(b[strlen(b)-1]==c[0]){
            printf("YES\n");
        }
        else
            printf("NO\n");
    }
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val mod = 1000000007
    val (n,i) = readIntList()

    println(n-i+1)
}

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

Measured memory_bytes: 38128
#include <iostream>
#include <cassert>
#include <algorithm>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int N;

int main()
{
  cin >> N;
  string ans;
  if (N < 1000) ans = "ABC";
  else ans = "ABD";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include <set>


struct Edge {
	int from, to;
	std::string label;
};
int main() {
	while (true) {
		int n, a, start, goal; std::cin >> n >> a >> start >> goal; if (n == 0 && a == 0) break;
		std::vector<Edge> edges(a);
		for (auto& e : edges) {
			std::cin >> e.from >> e.to >> e.label;
		}
		std::vector<bool> can_reach(n, false);
		std::vector<std::string> spell(n); can_reach[goal] = true;
		std::vector<int> length(n, 1);
		bool changed = true;
		for (auto _i = 0; _i <= 6 * n && changed; ++_i) {
			changed = false;
			for (const auto& e : edges) if (can_reach[e.to]) {
				if (can_reach[e.from]) {
					if (e.label >= spell[e.from]) continue;
					const auto new_spell = e.label + spell[e.to];
					if (spell[e.from] > new_spell) {
						spell[e.from] = new_spell;
						changed = true;
						length[e.from] = length[e.to] + 1;
					}
				}
				else {
					can_reach[e.from] = true;
					spell[e.from] = e.label + spell[e.to];
					changed = true;
					length[e.from] = length[e.to] + 1;
				}
			}
		}
		if (length[start] > n || !can_reach[start]) {
			std::cout << "NO\n";
		}
		else {
			std::cout << spell[start] << '\n';
		}
	}
}


Measured memory_bytes: 3360
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, ain;
    cin >> n;
    priority_queue<long long> a;
    for(int i = 0; i < n; ++i){
        cin >> ain;
        a.push(ain);
    }
    long long ans = 0;
    ain = a.top(); a.pop();
    ans += ain;
    int sum = (n - 2) / 2;
    for(int i = 0; i < sum; ++i){
        ain = a.top(); a.pop();
        ans += 2 * ain;
    }
    if(n % 2 == 1){
        ain = a.top(); a.pop();
        ans += ain; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5356
n, m ,x =map(int, input().split())
a = list(map(int, input().split()))
ans_l = 0
ans_r = 0

for i in range(x,0,-1):
    if i in a:
        ans_l += 1

for j in range(x,n):
    if j in a:
        ans_r += 1

print(min(ans_l, ans_r))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define M_B 19

int board[M_B][M_B];
int n;

void print_board();
void mkbd(int x, int y, int count);
void board_clear();

int main(void) {
    scanf("%d",&n);
    while(n) {
        mkbd(n/2 +1, n/2, 1);
        print_board();
        scanf("%d",&n);
        board_clear();
    }
    return 0;
}

void print_board() {
    int i, j;
    for(i = 0; i < n; i++) {
        for(j = 0; j < n; j++) {
            printf("%4d",board[i][j]);
        }
        puts("");
    }
}

void mkbd(int x, int y, int count) {
    if(count == n*n + 1) {
        return ;
    }
    if(board[x][y]) {
        x++;
        y--;
        if(x >= n) {
            x = 0;
        }
        if(y >= n) {
            y = 0;
        }
        if(y < 0) {
            y = n-1;
        }
        mkbd(x, y, count);
    } else {
        board[x][y] = count;
        if(count == n*n) {
            return ;
        }
        x++;
        y++;
        count++;
        if(x == n) {
            x = 0;
        }
        if(y == n) {
            y = 0;
        }
        mkbd(x, y, count);
    }
}

void board_clear() {
    int i, j;
    for(i = 0; i < M_B; i++) {
        for(j = 0; j < M_B; j++) {
            board[i][j] = 0;
        } 
    }
}

Measured memory_bytes: 620
#include <stdio.h>

int main(void)
{
	int a1[4], a2[4];
	int i;
	int sum1, sum2;

	sum1 = sum2 = 0;

	for (i = 0; i < 4; i++){
		scanf("%d", &a1[i]);
		sum1 += a1[i];
	}
	for (i = 0; i < 4; i++){
		scanf("%d", &a2[i]);
		sum2 += a2[i];
	}

	if (sum1 > sum2){
		printf("%d\n", sum1);
	}
	else {
		printf("%d\n", sum2);
	}

	return (0);
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Replacing | diff Replacing.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Replacing.cpp && ./a.out

/*

 6/21/2020

 5:17-

 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i];
  LL sum=accumulate(A,A+N,0LL);
  map<int,int> cnt;
  REP(i,N) cnt[A[i]]++;
  int Q; cin>>Q;
  while(Q--) {
    int b,c; cin>>b>>c;
    if(cnt.count(b)) {
      sum-=(LL)b*cnt[b];
      sum+=(LL)c*cnt[b];
      cnt[c]+=cnt[b];
      cnt[b]=0;
    }
    cout<<sum<<endl;
  }

  return 0;
}


Measured memory_bytes: 7860
import sys

n = int(input())
li = []
for i in range(n):
    li.append(list(map(int, input().split())))
li.sort(key=lambda x:x[1])
total = 0
for i in range(n):
    total += li[i][0]
    if total > li[i][1]:
        print('No')
        sys.exit()
print('Yes')

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

using namespace std;
#define BUF (1000)
#define ll long long 

ll n,k;
ll ans = 0;
int main(void){

	cin >> n >> k;

	if(k%2){ //odd
		ll m = n/k;
		cout << m*m*m << endl;
	}else{   //even
		ll m = n/k;
		ll m_=n/(k/2)-m;
		cout << m*m*m + m_*m_*m_<< endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int max(int a,int b){
	if(a>=b){return a;}
	else{return b;}
}

int main() {

	int A,B,C,K;

	scanf("%d %d %d",&A,&B,&C);
	scanf("%d",&K);

	int i;

	int maxABC=max(max(A,B),C);

	int ans=A+B+C;

	ans-=maxABC;

	for(i=0;i<K;i++){
		maxABC*=2;
	}
	ans+=maxABC;

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

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll N, M, K; cin >> N >> M >> K;
  for (ll i = 0; i <= M; i++) {
  	for (ll j = 0; j <= N; j++) {
    	if (N * i + M * j - 2 * i * j == K) {
        	cout << "Yes";
          	return 0;
        }
    }
  }
  cout << "No";
}

Measured memory_bytes: 256
k=int(input())
K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(K[k-1])

Measured memory_bytes: 2940
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 11 + 1
vmax = 10 ** 5
dp = [[INF] * (vmax + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(vmax + 1):
        if j + wv[i][1] <= vmax:
            dp[i + 1][j + wv[i][1]] = min(dp[i][j] + wv[i][0], dp[i][j + wv[i][1]])

        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

for j in range(vmax, 0, -1):
    if dp[N][j] <= W:
        print(j)
        break


Measured memory_bytes: 121068
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) {
        cin >> a[i];
        a[i] -= (i+1);
    }
    vector<ll> b(n);

    b = a;

    sort(a.begin(), a.end());
    ll num = 0;
    if(n % 2 == 0) {
        num = (a[n/2]+a[n/2-1])/2;
    }
    else {
        num = a[n/2];
    }
    
    ll ans = 0;
    rep(i, 0, n) {
        ans += abs(b[i]-(num));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

#define DEBUG(x) cerr << #x << ": " << x << endl

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int X, Y, A, B, C;
   cin >> X >> Y >> A >> B >> C;

   VI red(A);
   REP(i, A)
      cin >> red[i];

   VI green(B);
   REP(i, B)
      cin >> green[i];

   VI colorless(C);
   REP(i, C)
      cin >> colorless[i];

   sort(red.begin(), red.end(), greater<int>());
   sort(green.begin(), green.end(), greater<int>());

   priority_queue< int, vector<int>, greater<int> > pq;
   REP(i, X)
      pq.push( red[i] );

   REP(i, Y)
      pq.push( green[i] );

   sort(colorless.begin(), colorless.end(), greater<int>());
   for (int d : colorless) {
   // cerr << "d:" << d << " top:" << pq.top() << endl;
      if (d <= pq.top())
         break;
      pq.pop();
      pq.push(d);
   }

   llong sum = 0;
   while (!pq.empty()) {
      int d = pq.top();
   // cerr << "d:" << d << endl;
      pq.pop();
      sum += d;
   }

   cout << sum << '\n';

   return 0;
}


Measured memory_bytes: 2552
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>
#include <queue>
#include <bitset>

using namespace std;

int main()
{
    long long n, k;
    long long maxa = 0;
    cin >> n >> k;
    vector<long long> a(n);
    vector<bitset<40>> b(n);
    vector<pair<int, int>> count(40);
    for (int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = static_cast<bitset<40>>(a[i]);
    }
    bitset<40> large_x;
    large_x.reset();
    for (int i=0; i<40; ++i){
        count[i] = make_pair(0, 0);
    }
    for (int i=0; i<40; ++i){
        for (int j=0; j<n; ++j){
            if(b[j][i] == 0){
                count[i].first++;
            }
            else {
                count[i].second++;
            }
        }
        // cout << i << ":" << count[i].first << ", " << count[i].second << endl;
    }
    long long num = 1;
    for (int i=0; i<40; ++i){
        if(count[i].first > count[i].second && num <= k){
            large_x[i] = 1;
        }
        else {
            large_x[i] = 0;
        }
        num *= 2;
        // cout << large_x[i];
    }
    // cout << endl;
    long long x = 0;
    for (int i=40; i>=0; --i){
        if(x + (large_x[i] * num) <= k){
            x += large_x[i] * num;
        }
        num /= 2;
    }
    // cout << "num is " << x << endl;
    long long ans = 0;
    for (int i=0; i<n; ++i){
        ans += x ^ a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

#define SUM_MAX (1e+9)
int main(void) {
    int num, k, sum;
    cin >> num >> k >> sum;
    int others = 1;
    for(int i = 1; i <= SUM_MAX; i++) {
        if(sum%i) { others = i; break; }
    }

    vector<int> ans(num);
    for(int i = 0; i < k; i++) {
        ans[i] = sum;
    }
    for(int i = k; i < num; i++) {
        ans[i] = others;
    }

    for(auto e: ans) cout << e << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3800
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,*a = map(int,read().split())

#dp[i] = 長さiのLISの最後尾の最小値 
from bisect import bisect_left
INF = 2*10**9
dp = [INF]*n
for ai in a:
    dp[bisect_left(dp,ai)] = ai
ans = bisect_left(dp,INF)
print(ans)



Measured memory_bytes: 16596
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll k,n;
		cin>>n >> k;
		// cin.ignore(); must be there when using getline(cin, s)
		ll x=1;
		while (n--) {
			if(x<=k)
				x = 2*x;
			else
				x += k;
		}
		cout << x;
		return 0;
	}


Measured memory_bytes: 3596
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int b[355];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string a;
    cin>>a;
    int n=a.length();
    long long ans=(long long)n*(n+1)/2+1;
    int i;
    for (i=0;i<n;i++)
    {
        b[a[i]]++;
    }
    for (i=0;i<255;i++)
    {
        ans-=(long long)b[i]*(b[i]+1)/2;
    }
    cout<<ans<<endl;
    return 0;
} 


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

bool is_kai(string s){
    for(int i=0;i<s.size()/2;i++) if(s[i] != s[s.size()-i -1]) return false;
    return true;
}
signed main()
{   
    gearup;
    string s; cin >> s;
    int n = s.size();
    //cout << s.substr(0,n/2) << endl;
    //cout << s.substr(n/2+1) << endl;
    if(is_kai(s) && is_kai(s.substr(0,n/2)) && is_kai(s.substr(n/2+1))) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a=sc.nextInt();
    int b=sc.nextInt();
    int c=sc.nextInt();
    int ab=b-a;
    int bc=c-b;
    if (ab==bc){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 998244353
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=200010;

int main()
{
	string x,y;
	cin>>x>>y;
	int r=0;
	for(int i=0;i<x.size();i++)
		r+=(x[i]==y[i]);
	cout<<r;
	return 0;
}

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

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

  	int p = 0;
    int maxP = 0;
    while(n--){
        int x;
        cin >> x;
        p += x;
        maxP = max(maxP, x);
    }
    cout << p - maxP / 2 << endl;
}

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

int a, b, c;
void swap(int *a, int *b){

int temp = *a;

*a=*b;

*b=temp;

}
int main(){

cin >>a >> b>>c;


if(a>b)
swap(&a,&b);

if(b>c)
swap(&b,&c);

cout <<c*10+a+b;
}


Measured memory_bytes: 256
//ITP 1_7_C
#include <iostream>
using namespace std;

int main() {
	int r,c; cin >> r >> c;
	int a[101][101]={};
	for(int i=0; i<r; i++)for(int j=0; j<c; j++) cin >> a[i][j];
	for(int i=0; i<r; i++)for(int j=0; j<c; j++) a[i][c]+=a[i][j];
	for(int i=0; i<c; i++)for(int j=0; j<r; j++) a[r][i]+=a[j][i];
	for(int i=0; i<r; i++)a[r][c]+=a[i][c];
	for(int i=0; i<=r; i++)
	{
		for(int j=0; j<=c; j++)
		{
			if(j)cout << " ";
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}




Measured memory_bytes: 3128
require 'matrix'
x1, y1, x2, y2 = gets.split.map &:to_i
u = Vector[x1, y1]
v = Vector[x2, y2]
n = gets.to_i
n.times {
    w = Vector[*gets.split.map(&:to_i)]
    a = v - u
    b = w - u
    x = u + a * a.inner_product(b) / a.r ** 2
    puts "#{x[0]} #{x[1]}"
}

Measured memory_bytes: 6992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; cin >> n;
    float sum = 0;
    rep(i, n){
        float x; cin >> x;
        string u; cin >> u;
        if(u == "JPY") sum += x;
        else sum += x * 380000.0;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
const int N=2e5+3,M=1e9+7;
struct node{int x,v;}a[N];
struct segment{int l,r;}c[N];
bool Cmpa(const node&a,const node&b){return a.x<b.x;}
bool Cmpc(const segment&a,const segment&b){return a.r<b.r;}
int n,b[N],f[N];
int main(){
	int s,t,m,mx;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].v);
	std::sort(a+1,a+1+n,Cmpa);
	b[0]=0;
	for(int i=1;i<=n;i++){
	  for(s=1,t=i;s<t;)m=s+t>>1,b[m]>a[i].v?t=m:s=m+1;
	  c[i].l=s;
	  b[i]=std::max(b[i-1],a[i].v);
	}
	b[n+1]=M;
	for(int i=n;i;i--){
	  for(s=i,t=n;s<t;)m=s+t+1>>1,b[m]<a[i].v?s=m:t=m-1;
	  c[i].r=t;
	  b[i]=std::min(b[i+1],a[i].v);
	}
	std::sort(c+1,c+1+n,Cmpc);
	mx=0,f[0]=1;
	for(int i=1,j=1;i<=n;i++){
	  f[i]=(2ll*f[i-1]-(mx?f[mx-1]:0)+M)%M;
	  for(;j<=n&&c[j].r<=i;j++)mx=std::max(mx,c[j].l);
	}
	printf("%d\n",(f[n]-f[mx-1]+M)%M);
	return 0;
}

Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 //freopen("input.txt", "r", stdin); 
 //freopen("output.txt", "w", stdout); 

string S,T;
cin>>S;
cin>>T;
int count=0;
for(int i=0;i<S.length();i++)
{
    if(S[i] != T[i])
    count++;
}
cout<<count<<endl;

return 0;
}

Measured memory_bytes: 3840
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]

N, K = inpl()
A = inpl()
gcda = A[0]
for i in A:
    gcda = gcd(i, gcda)
if not K%gcda and max(A) >= K:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 14480
from enum import Enum

class Type(Enum):
    win_Taro = 0
    win_Hanako = 1
    EVEN = 2

def comp_str(A,B):
    if (A>B):
        return Type.win_Taro
    elif (A<B):
        return Type.win_Hanako
    else:
        return Type.EVEN

game_num = int(input())

point_Taro = 0
point_Hanako = 0

for i in range(game_num):
        line = str(input()).split()
        ret_type=comp_str(line[0],line[1])
        if ret_type == Type.win_Taro:
            point_Taro += 3
        elif ret_type == Type.win_Hanako:
            point_Hanako += 3
        else:
            point_Taro += 1
            point_Hanako += 1

print("%d %d"%(point_Taro,point_Hanako))



Measured memory_bytes: 6332
#include <stdio.h>

int main() {

  long long i,j,k,n,m,l,a,b,c;
  long long A[101][101] = {0};
  long long B[101][101] = {0};
  long long C[101][101] = {0};

  scanf("%lld %lld %lld",&n,&m,&l);

  for(j=0; j<n; j++) {
    for(i=0; i<m; i++) {

      scanf("%lld", &a);
      A[j][i] = a;
    
    }
  }

  for(j=0; j<m; j++){
    for(i=0;i<l;i++){
      scanf("%lld",&b);
      B[j][i] = b;
    }
  }

    for(i=0 ;i<n; i++) {
      for(j=0; j<l; j++){
	C[i][j] = 0;
	for(k=0;k<m; k++) {
	   C[i][j] += A[i][k]*B[k][j];  
	   /*    printf("%d ",C[i][j]); */
	}
	/* printf("\n"); */
      }
    }


     for(i=0; i<n; i++) {
      for(j=0; j<l; j++) {
	printf("%lld",C[i][j]);
	if(j !=l-1) {
	  printf(" ");
	}
      }
      printf("\n");
      } 

    return 0;

  }


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstring>

using namespace std;

int n, m;
bool bad[20001];

int main(){
    while (cin >> n >> m && n | m){
        vector<vector<int>> record(m, vector<int>(3));
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                cin >> record[i][j];
            }
        }
        sort(record.begin(), record.end());
        memset(bad, 0, sizeof(bad));
        bad[1] = true;
        for (auto & r : record){
            bad[r[2]] |= bad[r[1]];
        }
        cout << count_if(bad + 1, bad + 1 + n, [](bool t){ return t; }) << endl;
    }
}

Measured memory_bytes: 2148
from collections import deque

h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]

def bfs(sx, sy):
    que = deque([])
    que.append((sx, sy))
    dx = [-1, 0, 1, 0]
    dy = [0, -1, 0, 1]
    d = [[-1] * w for i in range(h)]
    d[sy][sx] = 0
    while que:
        s = que.popleft()
        for i in range(4):
            nx = s[0] + dx[i]
            ny = s[1] + dy[i]
            
            if 0 <= nx < w and 0 <= ny < h and maze[ny][nx] != "#" and d[ny][nx] == -1:
                que.append((nx, ny))
                d[ny][nx] = d[s[1]][s[0]] + 1
    
    tmp = 0
    for i in range(h):
        for j in range(w):
            tmp = max(tmp, d[i][j])
    
    return tmp

ans = 0
for i in range(w):
    for j in range(h):
        if maze[j][i] == ".":
            ans = max(ans, bfs(i, j))

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define SIZE 6005
#define MX 2005
using namespace std;
typedef long long int ll;

ll dp[SIZE][MX];
int main()
{
	int n,MOD;
	scanf("%d %d",&n,&MOD);
	dp[0][0]=1;
	for(int i=0;i<3*n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			if(dp[i][j]==0) continue;
			dp[i+1][j]+=dp[i][j];
			if(dp[i+1][j]>=MOD) dp[i+1][j]-=MOD;
			dp[i+2][j+1]+=dp[i][j]*(ll) (i+1)%MOD;
			if(dp[i+2][j+1]>=MOD) dp[i+2][j+1]-=MOD;
			dp[i+3][j+1]+=dp[i][j]*(ll) (i+1)%MOD*(ll) (i+2)%MOD;
			if(dp[i+3][j+1]>=MOD) dp[i+3][j+1]-=MOD;
		}
	}
	ll ret=0;
	for(int i=0;i<=n;i++) ret+=dp[3*n][i];
	printf("%lld\n",ret%MOD);
	return 0;
}

Measured memory_bytes: 92800
# coding: UTF-8

n, m = map(int, input().split())
AC, WA = 0, 0
nWA = [0]*(n+1)
nAC = [0]*(n+1)

for i in range(m):
    cp, cS = input().split()
    cp = int(cp)
    if cS == 'AC':
        if nAC[cp] == 0:
            AC += 1
            WA += nWA[cp]
            nAC[cp] = 1
    else:
        nWA[cp] += 1
print(AC, WA)


Measured memory_bytes: 4596
import sys
input = sys.stdin.readline

N = int(input())

S = N if N&1 else N+1
E = [(x,y) for x in range(1,N+1) for y in range(x+1,N+1) if x+y != S]

print(len(E))
for x,y in E:
    print(x,y)

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int ten[100000];

int main(){
  int n, k, q;
  cin >> n >> k >> q;
  int tmp;
  for(int i=0;i<q;i++){
    cin >> tmp;
    ten[tmp-1]++;
  }
  
  for(int i=0;i<n;i++){
    if(ten[i]>q-k)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
use itertools::Itertools;
use num::clamp;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        a: [isize; n+1],
    }

    let mut cum = vec![0; n + 1];
    cum[0] = a[0];
    for i in 1..n + 1 {
        cum[i] = cum[i - 1] + a[i];
    }

    let mut ans = cum[n];
    let mut b = 0;
    for i in 0..n + 1 {
        let sum_a = cum[n] - cum[i];
        b = if i == 0 { 1 - a[0] } else  { min(2 * b - a[i], sum_a) };
        ans += b;
        if b < 0 {
            println!("-1");
            return;
        }
    }
    println!("{}", ans);
}


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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll diff = b - a;
    if (diff & 1) {
        ll ans = min(n - b, a - 1);
        ans++;
        diff--;
        ans += diff / 2;
        cout << ans << endl;
    } else {
        cout << diff / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int data[5];
    int k;
    
    for(int i=0; i<5; i++) {
        int temp;
        cin >> temp;
        data[i] = temp;
    }
    cin >> k;
    
    bool result = true;
    for(int i=0; i<4; i++) {
        for(int j=i+1; j<5; j++) {
            if(data[j]-data[i]>k) {
                result = false;
                break;
            }
        }
        if(!result) break;
    }
    
    if(result) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
lint powint(lint x,lint y){
	if(y==0)return 1;
	if(y%2)return x*powint(x,y-1);
	lint a = powint(x,y/2);
	return a*a;
}
int main(){
	int d,n,count=0;
	cin>>d>>n;
	lint num = powint(100,d);
	int i=0;
	while(1){
		i++;
		if(i%num==0){
			if(i/num%100)count++;
		}
		if(count==n){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, const char * argv[]) {
    
    while (1) {
        int m, f, r ;
        std::cin >> m >> f >> r ;
        if (m == -1 && f == -1 && r == -1) break ;
        
        
        int s = m + f ;
        if (m == -1 || f == -1) {
            printf("F\n") ;
        } else {
            m = (m == -1) ? 0 : m ;
            f = (f == -1) ? 0 : f ;
            r = (r == -1) ? 0 : r ;
            if (s >= 80) printf("A\n");
            else if (s >= 65) printf("B\n");
            else if (s >= 50) printf("C\n");
            else if (s >= 30) {
                if (r >= 50) {
                    printf("C\n");
                } else {
                    printf("D\n");
                }
            }
            else printf("F\n") ;
        }
        
    }
    
    
    return 0 ;
}



Measured memory_bytes: 3068
N,K = map(int,input().split())
P = list(map(int,input().split()))
A = [0 for _ in range(N)]
for i in range(N):
    A[i] = (P[i]+1)/2
cmax = sum(A[:K])
a = cmax
for i in range(1,N-K+1):
    a = a+A[i+K-1]-A[i-1]
    cmax = max(cmax,a)
print(cmax)

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0;
  while (1) {
    bool flg = false;
    rep(i, n) {
      if (h[i] == 0 && flg) break;
      else if (h[i] > 0) {
        flg = true;
        h[i]--;
      }
    }
    if (!flg) break;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256