akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.NoSuchElementException;

 
public class Main{
	
	public static void main(String args[])throws Exception{
		FastScanner sc = new FastScanner();
		int c = 1;
		while(true){
			int x = sc.nextInt();
			
			if(x==0){
				return;
			}else{
				System.out.println("Case " + c + ": " + x);
				c++;
			}
		}
	}
}









class FastScanner {
    private final java.io.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 static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); 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() {
        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 (int) (minus ? -n : n);
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}





Measured memory_bytes: 30832
#include<stdio.h>

int main()
{
 int a, b;
 scanf("%d %d", &a, &b);
 if(a < b) {
  printf("a < b\n");
 }
 if(a == b) {
  printf("a == b\n");
 }
 if(a > b) {
  printf("a > b\n");
 }
 return 0;
}

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

#define scanl(x) scanf("%ld", &x)
#define scans(x) scanf("%s", x)

#define INF 1000000000

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	char s[1000];
	int i;
	int c = 0, f = 0;
	
	scans(s);
	for(i=0;i<strlen(s);i++) {
		if(s[i] == 'C') c = 1;
		if(c == 1 && s[i] == 'F') f = 1;
	}
	
	if(c & f) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

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

int main() {
	string s;
	long long pos;
	cin>>s>>pos;
	
	for(int i=0;i<pos;i++)
		if (s[i]!='1') {
			cout<<s[i]<<endl;
			return 0;
		}
	cout<<s[pos-1]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
//Nは荷物の数
//Wはナップサックの容量
//配列wは
//配列vは
long N, W, w[200] = {0}, v[200] = {0}, i, j, dp[200][100100] = {0}, count = 0;

void max(long *a, long b){
    if(*a < b){
        *a=b;
    }
}

int main() {


    scanf("%ld", &N);
    scanf("%ld", &W);

    for (i = 0; i < N; i++) {
        scanf("%ld", &w[i]);
        scanf("%ld", &v[i]);
    }
    


    for (i = 0; i <= N; i++) {
       
        for (j = 0; j <= W; j++) {

            if (j >= w[i]) {
                max(&dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
            max(&dp[i + 1][j], dp[i][j]);
            

        }
        
    }
    printf("%ld\n", dp[N][W]);
}    

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define rep(I,n) for (int I = 0; I < (n); ++I)
using namespace std;
typedef long long ll;
 
int main() {
    
   int a,b;
   cin>>a>>b;
   
   if(1<=a && a<=9 && 1<=b && b<=9 && a%1==0 && b%1==0){
       
       cout<< a*b <<endl;
   }
   
   else{
       
       cout<< -1 <<endl;
   }
  
  
    
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=100005;
using namespace std;
long long b[N],g[N];
int n,m,a[N],c[N],no[N],re[N],p[N],f[N],
to[N*2],hd[N*2],lk[N],cnt;
bool vis[N];
inline void add(int u,int v){
	to[++cnt]=v,hd[cnt]=lk[u],lk[u]=cnt;
}int u,v;
int get(int x){return p[x]?p[x]=get(p[x]):x;}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
	scanf("%d%lld",a+i,c+i),
	no[i]=i,a[i]-=c[i];
	sort(no,no+n,[](int x,int y){
		return a[x]<a[y];
	});
	sort(a,a+n);
	for(int i=0;i<n;i++)
	b[i]=c[no[i]],re[no[i]]=i,g[i]=max(a[i],0);
	for(;m--;)
	scanf("%d%d",&u,&v),
	u=re[u-1],v=re[v-1],
	add(u,v),add(v,u);
	for(int i=0,j,s;i<n;i++){
		vis[i]=1;
		for(j=lk[i];j;j=hd[j])
		if(vis[s=to[j]]){
			if((u=get(s))<i)
			f[u]=p[u]=i,g[i]=1e18;
		}
	}
	for(int i=0;i<n;i++){
		if(i<n-1)b[f[i]]+=b[i];
		g[f[i]]=min(g[f[i]],max(a[f[i]]-b[i],g[i]));
	}
	printf("%lld",g[n-1]+b[n-1]);
}

Measured memory_bytes: 6144
/**
*    author:  yuya1234
*    created: 24.06.2020 17:13:08
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n;
    cin>>n;
    bool ans=false;

    FOR(i,1,9)
    {
        FOR(j,1,9)
        {
            if(i*j==n)
            {
                ans=true;
                break;
            }
        }
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int h,w;
    cin >> h >> w;
    int cnt = 0;
    char a;
    REP(i,h){
        REP(j,w){
            cin >> a;
            if(a == '#') cnt++;
        }
    }
    if(cnt == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
from collections import deque, Counter
from itertools import permutations, combinations
from heapq import heapify, heappop, heappush
from bisect import bisect, bisect_left

def solve():
    input = sys.stdin.readline
    N, R = map(int, input().split())
    if N < 10: R += 100 * (10 - N)
    print(R)

    return 0

if __name__ == "__main__":
    solve()

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

using namespace std;

int main()
{
  string A, B, C;
  cin >> A >> B >> C;
  if(A.back() == B.front() && B.back() == C.front()) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define INF 10'000'000'000
i64 N;
i64 H[MAX_N];
i64 dp[2 * MAX_N];

void solve() {
    fill(dp, dp + 2 * MAX_N, INF);
    dp[0] = 0;
    REP(i, N) {
        chmin(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
    }
    cout << dp[N - 1] << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> H[i];

    solve();

    return 0;
}

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

struct data
{
	int x,i;
	data():x(0),i(0) {}
	data(int y,int j):x(y),i(j) {}
	friend bool operator<(const data &dt1,const data &dt2)
	{
		return dt1.x<dt2.x;
	}
};

stack<int> s;
int n,x[80001],idx,tot,id[80001],low[80001],dfn[80001],scc,cid[80001];
vector<data> vec;
vector<int> point[80001];

void build(int o,int l,int r)
{
	id[o]=++tot;
	if(o>1)point[id[o>>1]].push_back(tot);
	if(l==r)
	{
		int v=vec[l-1].i;
		point[id[o]].push_back(v<=n?v+n:v-n);
		return;
	}
	int m=l+r>>1;
	build(o<<1,l,m),build(o<<1|1,m+1,r);
}

void update(int o,int l,int r,int a,int b,int x)
{
	if(a>b)return;
	if(l==a&&r==b)
	{
		point[x].push_back(id[o]);
		return;
	}
	int m=l+r>>1;
	if(m>=b)update(o<<1,l,m,a,b,x);
	else if(m<a)update(o<<1|1,m+1,r,a,b,x);
	else update(o<<1,l,m,a,m,x),update(o<<1|1,m+1,r,m+1,b,x);
}

pair<int,int> get(int i,int m)
{
	pair<int,int> res;
	int l=1,r=i,mid;
	while(l<=r)if(vec[i-1].x-vec[(mid=l+r>>1)-1].x>=m)l=mid+1;
		else r=mid-1;
	res.first=r+1,l=i,r=n<<1;
	while(l<=r)if(vec[(mid=l+r>>1)-1].x-vec[i-1].x<m)l=mid+1;
		else r=mid-1;
	res.second=l-1;
	return res;
}

void dfs(int u)
{
	low[u]=dfn[u]=++idx;
	s.push(u);
	for(int v:point[u])if(!dfn[v])
		{
			dfs(v);
			low[u]=min(low[u],low[v]);
		}
		else if(dfn[v]>0)low[u]=min(low[u],dfn[v]);
	if(low[u]==dfn[u])
	{
		int x;
		++scc;
		while(x!=u)x=s.top(),s.pop(),dfn[x]=-dfn[x],cid[x]=scc;
	}
}

bool check(int m)
{
	memset(low,scc=idx=0,sizeof(low)),memset(dfn,0,sizeof(dfn));
	for(int i=1; i<=80000; ++i)point[i].clear();
	build(1,1,tot=n<<1);
	for(int i=1; i<=n<<1; ++i)
	{
		int r=vec[i-1].i;
		pair<int,int> pr=get(i,m);
		update(1,1,n<<1,pr.first,i-1,r),update(1,1,n<<1,i+1,pr.second,r);
	}
	for(int i=1; i<=n<<1; ++i)if(!dfn[i])dfs(i);
	for(int i=1; i<=n; ++i)if(cid[i]==cid[i+n])return false;
	return true;
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; ++i)scanf("%d%d",x+i,x+n+i),vec.push_back(data(x[i],i)),vec.push_back(data(x[i+n],i+n));
	sort(vec.begin(),vec.end());
	int l=0,r=1000000000,m;
	while(l<=r)if(check(m=l+r>>1))l=m+1;
		else r=m-1;
	printf("%d",l-1);
}

Measured memory_bytes: 12640
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	int l;
	cin>>l;
	int h,w;
	int cnt = 0;
	while(l--){
		if(cnt++!=0){
			cout <<endl;
		}
		int dir =-1;//1→2↑3←4↓
		cin>>h>>w;
		char board[22][22];
		int px,py;
		rep(i,22)rep(j, 22)board[i][j]='\0';
		for(int i =0;i < h;i++){
			for(int j =0;j <w;j++){
				cin>>board[i][j];
				if(board[i][j]=='>'){
					dir =1;
					px =j;
					py =i;
				}
				if(board[i][j]=='^'){
					dir =2;
					px =j;
					py = i;
				}
				if(board[i][j]=='<'){
					dir =3;
					px =j;
					py = i;
				}
				if(board[i][j]=='v'){
					dir =4;
					px =j;
					py = i;
				}
			}
		}
		int n;
		cin>>n;
		board[py][px]='.';
		for(int i =0;i < n;i++){
			char cad;
			cin>>cad;
			if(cad=='U'){
				dir =2;
				if(py-1>=0&&board[py-1][px]=='.'){
					py =py-1;
				}
			}else if(cad=='D'){
				dir =4;
				if(py+1<h&&board[py+1][px]=='.'){
					py =py+1;
				}
			}else if(cad=='L'){
				dir =3;
				if(px-1>=0&&board[py][px-1]=='.'){
					px =px-1;
				}
			}else if(cad=='R'){
				dir = 1;
				if(px+1<w&&board[py][px+1]=='.'){
					px =px+1;
				}
			}else{
				if(dir==1){//→
					for(int j =px+1;j<w;j++){
						if(board[py][j]=='#')break;
						if(board[py][j]=='*'){
							board[py][j]='.';
							break;
						}
					}
				}else if(dir==2){//↑
					for(int j =py-1;j >=0;j--){
						if(board[j][px]=='#')break;
						if(board[j][px]=='*'){
							board[j][px]='.';
							break;
						}
					}
				}else if(dir==3){//←
					for(int j =px-1;j >=0;j--){
						if(board[py][j]=='#')break;
						if(board[py][j]=='*'){
							board[py][j]='.';
							break;
						}
					}
				}else if(dir==4){//↓
					for(int j =py+1;j <h;j++){
						if(board[j][px]=='#')break;
						if(board[j][px]=='*'){
							board[j][px]='.';
							break;
						}
					}
				}
			}
		}
		if(dir==1){
			board[py][px]='>';
		}else if(dir==2){
			board[py][px]='^';
		}else if(dir==3){
			board[py][px]='<';
		}else if(dir==4){
			board[py][px]='v';
		}
		for(int i =0;i <h;i++){
			for(int j =0;j <w;j++){
				cout <<board[i][j];
			}
			cout <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1156
d=int(input()) #365
c=list(map(int,input().split()))
s=[]
for i in range(d):
  s.append(list(map(int,input().split())))

ll=[0 for i in range(26)]
l=[]
ans=[]
for i in range(d):
  for j in range(26):
    ll[j]+=1
  m=-(10**10)
  for j in range(26):
    t=s[i][j]-ll[j]*c[j]
    if m<t:
      m=t
      tt=j
  l.append(ll[tt])
  ans.append(tt)
  ll[tt]=0
print("\n".join(map(lambda x:str(x+1),ans)))

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 100'000

struct Edge {
    i64 to, cost;
    Edge(i64 to, i64 cost) : to(to), cost(cost) {}
};

vector<Edge> G[MAX_N];

int main() {
    i64 N; cin >> N;
    REP(i, N - 1) {
        i64 a, b, c; cin >> a >> b >> c;
        a--, b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    i64 Q, K; cin >> Q >> K;
    K--;

    using P = pair<i64, i64>;
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<i64> d(N, numeric_limits<i64>::max());
    d[K] = 0;
    pq.emplace(0, K);
    while (!pq.empty()) {
        P p = pq.top(); pq.pop();
        if (d[p.second] < p.first) continue;

        for (Edge &edge : G[p.second]) {
            i64 nd = p.first + edge.cost;
            if (chmin(d[edge.to], nd)) {
                pq.emplace(nd, edge.to);
            }
        }
    }

    vector<i64> ans(Q);
    REP(i, Q) {
        i64 a, b; cin >> a >> b;
        a--, b--;
        ans[i] = d[a] + d[b];
    }

    for (i64 x : ans) cout << x << endl;

    return 0;
}

Measured memory_bytes: 11504
fn input() -> String {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	s.trim().to_owned()
}

fn input_c() -> std::io::Cursor<String> {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	std::io::Cursor::new(s.trim().to_owned())
}

fn read_t<T: std::str::FromStr>(r: &mut std::io::Read) -> T {
	use std::io::Read;
	use std::iter::Iterator;
	r.bytes().map(|b| b.ok().unwrap() as char).skip_while(|c| c.is_whitespace() == true).take_while(|c| c.is_whitespace() == false).collect::<String>().parse().ok().unwrap()
}

fn main() {
	let mut c = input_c();
    let     n = read_t::<usize>(&mut c);
    let     k = read_t::<usize>(&mut c);
    let     s = input();
    let     b = s.as_bytes();
    let mut d = 0;
    
    for i in 1..n {
    	if b[i - 1] != b[i] {
        	d += 1;
        }
    }
    
    if k * 2 <= d {
    	println!("{}", n - 1 - (d - k * 2));
    } else {
    	println!("{}", n - 1);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+20;
inline int read(void){int x=0,f=1;char c=cin.get();while(!isdigit(c)){f=c=='-'?-1:1;c=cin.get();}while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=cin.get();}return x * f;}
int sum1[maxn],sum2[maxn],n,ans = 0x7fffffff; 
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	char x;
	n=read();
	for(int i=1;i<=n;i++){
		cin>>x;
		sum1[i]=sum1[i-1]+(x=='E');
		sum2[i]=sum2[i-1]+(x=='W');
	}
	for(int i=1;i<=n;i++){
		ans=min(ans,sum1[n]-sum1[i]+sum2[i-1]);
	}
	cout << ans << endl;
	return 0;
}



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

using namespace std;
#define endl "\n"

const int MOD = 1e9 + 7;

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


	int n,m;
	cin >> n >> m;
	vector<bool> ac(n,false);
	vector<int> acn(n,0);

	int ansa = 0, ansb = 0;
	for(int i=0; i<m; i++){
		int a;
		string s;
		cin >> a;
		cin >> s;

		if(!(ac.at(a-1))){
			if(s == "AC"){
				ansa += 1;
				ansb += acn.at(a-1);
				ac.at(a-1) = true;
			} else if(s == "WA"){
				acn.at(a-1) = acn.at(a-1) + 1;
			}
		}
	}




	cout << ansa << " " << ansb << endl;



	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

	int m4 = 0, m2 = 0;
	rep (i, n) {
		int a;
		cin >> a;
		if (a % 4 == 0) m4++;
		else if (a % 2 == 0) m2++;
	}

	n -= (m2 / 2) * 2;
	cout << (m4 >= n / 2 ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = input()
a = n.count("7")
ans = "No"
if a > 0:
    ans = "Yes"
print(ans)

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

const int ALPHABET = 26;
int main() {
	string S;
	cin >> S;
	bool abc[ALPHABET]; // 既にその文字が出てきたか
	for (int i = 0;i < ALPHABET;i ++) abc[i] = false; // 初期化
	for (int i = 0;i < S.length();i ++) {
		if (abc[S[i] - 'a']) { // もし既にその文字が出てきているなら
			cout << "no";
			return 0;
		}
		abc[S[i] - 'a'] = true;
	} // もし1つも文字が被らなかったら
	cout << "yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

文字が2回以上出てきたか否かのみを判定すれば良いので、各文字については今までにその文字が出たか否かのみが分かれば良い
よって、今までにその文字が出たか否かを記憶する配列を作れば良い
あ、ちなみにSをソートして、連続した二文字が等しいか否かで判定する方法もあるよ
*/

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)

void solve() {
  int x, y, H, W;
  cin >> x >> y >> H >> W;
  int N; cin >> N;
  int ans = 0;
  REP(i, N) {
      int a, b; cin >> a >> b;
      if (x <= a && a <= x + W &&
          y <= b && b <= y + H)
          ++ans;
  }
  cout << ans << endl;
}

int main() {
  int T; cin >> T;
  while(T--)
      solve();
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		int a = sc.nextInt ();
		int b = sc.nextInt ();

		if ( a < b ) {
			System.out.println ( "a < b" );
		} else if ( b < a  ){
			System.out.println ( "a > b" );
		} else {
			System.out.println ( "a == b" );
		}
	}
}

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





int main() {
  int N,K;
  cin>>N>>K;
  vector<int> data(N);
  for (int i=0;i<N;i++){
    cin>>data.at(i);
  }
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  int answer=0;
  for (int i=0;i<K;i++){
    answer+=data.at(i);
  }
  cout<<answer<<endl;
}
  













Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())

g = []
for _ in range(h):
    tmp = list(input())
    g.append(tmp)

dp = [[1000000 for _ in range(w)] for __ in range(h)]

dp[0][0] = 0
# q = deque([(0, 0)])

# while q:
#     x, y = q.popleft()
#     if x+1 < h:
#         if g[x+1][y] != g[x][y]:
#             dp[x+1][y] = min(dp[x+1][y], dp[x][y]+1)
#         else:
#             dp[x+1][y] = min(dp[x+1][y], dp[x][y])
#         q.append((x+1, y))
#     if y+1 < w:
#         if g[x][y+1] != g[x][y]:
#             dp[x][y+1] = min(dp[x][y+1], dp[x][y]+1)
#         else:
#             dp[x][y+1] = min(dp[x][y+1], dp[x][y])
#         q.append((x, y+1))

for i in range(h):
    for j in range(w):
        if i == 0 and j != 0:
            if g[i][j] != g[i][j-1]:
                dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = dp[i][j-1]
        elif i != 0:
            if j == 0:
                if g[i][0] != g[i-1][0]:
                    dp[i][0] = dp[i-1][0] + 1
                else:
                    dp[i][0] = dp[i-1][0]
            else:
                if g[i][j] != g[i][j-1]:
                    dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
                else:
                    dp[i][j] = min(dp[i][j], dp[i][j-1])

                if g[i][j] != g[i-1][j]:
                    dp[i][j] = min(dp[i][j], dp[i-1][j]+1)
                else:
                    dp[i][j] = min(dp[i][j], dp[i-1][j])


if g[0][0] == '.' and g[h-1][w-1] == '.':
    print(dp[h-1][w-1]//2)
elif g[0][0] != g[h-1][w-1]:
    print((dp[h-1][w-1]+1)//2)
else:
    print(1 + (dp[h-1][w-1]//2))


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> R(N);
    REP(i,N){
        string s;
        int p;
        cin >> s >> p;
        R[i] = make_tuple(s,-p,i+1);
    }
    sort(ALL(R));

    REP(i,N){
        cout << get<2>(R[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 3528
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
int INF=1e6;
ll int MAX_N=1e18;
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

ll int n,s;
bool calc(ll int a){
    ll int m=n,x=0;
    while(m){
        x+=(m%a);
        m/=a;
    }
    return (x==s);
}
main(){
    cin>>n>>s;
    ll int ans=MAX_N;
    rep2(i,2,400000){
        if(calc(i)){
            ans=i; break;
        }
    }
    if(ans!=MAX_N) { cout<<ans; return 0;}
    for(ll int i=400000;i>0;i--){
        if(i>s) continue;
        if(i*i>=n) continue;
        if((n-s)%i) continue;
        ll int m=(n-s)/i+1;
        ll int p=s-i;
        if(m<=p||m<=i) continue;
        if(m*i+p==n) {ans=m; break;}
    }

    if(ans==MAX_N) {if(s==n){ cout<<s+1; return 0;} cout<<-1; return 0;}
    cout<<ans;
    return 0;
}

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

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

int main() {
	ll n, s;
	vector<ll> v;
	ll sum = 0;
	bool flag = false;

	cin >> n;

	REP(i, n) {
		cin >> s;
		v.push_back(s);
		sum += s;
	}

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

	if (sum % 10 == 0) {
		REP(i, n) {
			if (v[i] % 10 != 0) {
				sum -= v[i];
				break;
			}

			if (i == n - 1) {
				sum = 0;
			}
		}
	}

	cout << sum << endl;
}


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

using namespace std;

int main() {

	int n, k, x, y; scanf("%d %d %d %d", &n, &k, &x, &y);

	if (n <= k) printf("%d", x * n);
	else {

		int cost = k * x;

		printf("%d", cost + (n - k) * y);

	}

	return 0;

}

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

long long pow(long long x){
  return x*x*x*x*x;
}
int main(){
  long long x;
  cin >> x;
  for(long long i=120;i>-120;i--){
    for(long long j=i;j>-120;j--){
      if(pow(i)-pow(j)==x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3592
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

assert (gcd(10, 3) == 1)

def solve(N, As):
    k = min(As)
    for a in As:
        k = gcd(k, a)
    return k

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 14224
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string,int> mp;
inline void init()
{
	mp["SUN"]=0;mp["MON"]=1;
	mp["TUE"]=2;mp["WED"]=3;
	mp["THU"]=4;mp["FRI"]=5;
	mp["SAT"]=6;
}
int main()
{
    init();
    string str;cin>>str;
    int val=mp[str];
    int ans=7-val;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
S = [0] * M
C = [""] * M

for i in range(M):
  s,C[i] = input().split()
  S[i] = int(s) - 1

for i in range(1000):
  s = str(i)
  if len(s) != N:
    continue
  for j in range(M):
    if s[S[j]] != C[j]:
      break
  else:
    print(i)
    break
else:
  print(-1)
  

Measured memory_bytes: 9212
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var x = Arrays.stream(br.readLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();

      for (int i = 0; i < x.length; i++) {
        if (x[i] == 0) {
          System.out.println(i + 1);
        }
      }
    }
  }
}


Measured memory_bytes: 34216
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias PY = Tuple!(int, "i", int, "p", int, "y", string, "n");

PY[10^^5] CS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];

    foreach (i; 0..M) {
        auto py = readln.split.to!(int[]);
        CS[i] = PY(i, py[0], py[1], "");
    }

    sort!"a.p == b.p ? a.y < b.y : a.p < b.p"(CS[0..M]);

    int p, c;
    foreach (i, ref py; CS[0..M]) {
        if (py.p != p) {
            p = py.p;
            c = 0;
        }
        py.n = format("%06d%06d", py.p, ++c);
    }
    sort!"a.i < b.i"(CS[0..M]);
    foreach (cs; CS[0..M]) writeln(cs.n);
}

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

#define ll      		long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb push_back
#define vll vector<ll> 
#define f(i,x,y)  for(i=x;i<y;i++)
#define INF     LLONG_MAX
#define fast    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define p2(n,x)    cout << fixed << setprecision(x) <<n<<endl; 
#define pll    pair<ll,ll> 
#define ff first
#define ss second
#define blt(x)   __builtin_popcount(x)
bool check(ll a,ll b,ll c)
{
	if(a+b>c && b+c>a && a+c>b)
		return true;
	return false;
}
void solve()
{
	ll i,j,k,n;
	cin>>n;
	vll v(n);
	scan(v);
	ll ans=0;
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			for(k=j+1;k<n;k++)
			{
				if(v[i]!=v[j] && v[j]!=v[k] && v[i]!=v[k])
				{
					if(check(v[i],v[j],v[k]))
					{
						ans++;
						//cout<<i<<" "<<j<<" "<<k<<endl;
					}
				}
			}
		}
	}
	cout<<ans;
}

int main()
{
	
	fast
	ll t = 1;

	

	while(t--)
	solve();
	
	return 0;
}

Measured memory_bytes: 3656
// Problem : B - 1%
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll start = 100;
	REP(i, 4000) {
		start += start / 100;
		if (start >= n) {
			cout << i + 1 << "\n";
			break;
		}
	}
	return 0;
}
 


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007,n;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll n;cin>>n;
    long double a;
    a=n/3.0;
    a=a*a*a;
    cout<<fixed<<setprecision(10);
    cout<<a;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <ll, ll> P;

const ll MOD=1000000007;
int N,M;
vector<ll> A;
vector<P> B;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    A.resize(N);
    B.resize(M);
    ll sum=0;
    rep(i,0,N){
        cin>>A[i];
        sum+=A[i];
    }
    rep(i,0,M) cin>>B[i].sc>>B[i].fr;
    sor(A);
    sor(B);
    rev(B);
    int pos=0;
    rep(i,0,M){
        rep(j,0,B[i].sc){
            if(pos==N) break;
            if(A[pos]<B[i].fr){
                sum+=B[i].fr-A[pos];
                pos++;
            }
            else break;
        }
    }
    cout <<sum<<"\n";
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n;
int a[N];
int b[N];

int cmp(int x, int y)
{
	return b[x] < b[y];
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) cin >> a[i] >> b[i];
	vector<int> idx(n);
	iota(ALL(idx), 0);
	sort(ALL(idx), cmp);
	
	LL chas = 0;
	for(auto i: idx)
	{
		chas += a[i];
		if (chas > b[i])
		{
			cout << "No\n";
			return 0;
		}
	}
	
	cout << "Yes\n";
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>

using namespace std;
 string s; int a=1; int maX=0;
int main()
{
    cin >> s;
    for(int x=0; x<s.length();x+=1)
    if (s[x] == 'R')
    {
        if(s[x]==s[x-1])
            a=a+1;
        else 
            a=1;
        
        maX = max (maX,a);  
    }
    cout << maX;

}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) { // 要素xが含まれる集合の大きさ
    return -data[root(x)];
  }
};

int main2() {
  int N = nextInt();
  int K = nextInt();
  int L = nextInt();

  UnionFind A(N);
  REP(i, K) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    A.link(a, b);
  }
  UnionFind B(N);
  REP(i, L) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    B.link(a, b);
  }

  map< pair<int,int>, int > count;
  REP(i, N) {
    count[ { A.root(i), B.root(i) } ]++;
  }
  REP(i, N) {
    if (i > 0) printf(" ");
    printf("%d", count[ { A.root(i), B.root(i) } ]);
  }
  printf("\n");

  return 0;

}


int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 13568
#include<cstdio>
#include<cstdlib> 
#include<iostream>
#include<stack>
#include<string>
using namespace std;


int main()
{
	string str[105];
	int i = 0;
	stack<int> s;
	while(cin>>str[i])
	{
		int a1, a2;
		if(str[i]=="+")
		{
			a1 = s.top(); s.pop();
			a2 = s.top(); s.pop();
			s.push(a1 + a2);
		}
		else if(str[i] == "-")
		{
			a1 = s.top(); s.pop();
			a2 = s.top(); s.pop();
			s.push(a2 - a1);
		}
		else if(str[i] == "*")
		{
			a1 = s.top(); s.pop();
			a2 = s.top(); s.pop();
			s.push(a1 * a2);
		}
		else
		{
			s.push(atoi(str[i].c_str()));
		}
	}
	printf("%d\n", s.top());
	return 0;
}

Measured memory_bytes: 3216
// see: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{s: String}

    let mut s = s.clone();

    let mut result = false;
    loop {
        if s.len() == 0 {
            break;
        }

        if s.len() == 1 || s.remove(0) != 'h'{
            result = false;
            break;
        }



        if s.remove(0) == 'i' {
            result = true;
            continue
        }
    }


    println!("{}", if result {"Yes"} else {"No"});
}


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

c = [[0]*10 for _ in range(10)]
for i in range(1,n+1):
    s = str(i)
    a = int(s[0])
    b = int(s[-1])
    c[a][b] += 1

ans = 0
for j in range(1,10):
    for k in range(1,10):
        ans += (c[j][k] * c[k][j])


print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
struct people{
    int id,time;
    bool operator<(const people &rhs)const{
        return time < rhs.time;
    }
};
vector<people>v;
int main()
{
    int n,tmp;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>tmp;
        v.push_back({i,tmp});
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        if(i==0)
            cout<<v[i].id;
        else
            cout<<' '<<v[i].id;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1780
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    816 Hours of Solitude
    Quarantine_Day : 34
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005

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

	int n; cin>>n;
	string s; cin>>s;
	int ans = 0;
	int x = 0;

	REP(i, s.size()){
		if(s[i] == 'I') x++;
		else x--;

		ans = max(ans, x);
	}
	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
typedef struct
{
  char moji;
  int value;
}card;
  int main()
{
  int i,j,n,min,c=0;
  card A[36],C[36],a,b;
  scanf("%d",&n);
    for(i=0;i<n;i++)
      {
        scanf(" %c%d",&C[i].moji,&C[i].value);
  A[i].moji=C[i].moji;
  A[i].value=C[i].value;
       }
  for(i=0;i<n-1;i++)
    {
      for(j=n-1;j>i;j--)
        {
          if(C[j].value<C[j-1].value)
            {
              a=C[j];
              b=C[j-1];
              C[j]=b;
              C[j-1]=a;
            }
        }
    }
  for(i=0;i<=n;i++)
    {
      min=i;
      for(j=i;j<n;j++)
        {
          if(A[j].value<A[min].value)
            {
              min=j;
            }
        }
      a=A[i];
      b=A[min];
      A[i]=b;
      A[min]=a;
    }
  for(i=0;i<n-1;i++)
    {
      printf("%c%d ",C[i].moji,C[i].value);
    }
  printf("%c%d\n",C[n-1].moji,C[n-1].value);
  printf("Stable\n");
  for(i=0;i<n-1;i++)
    {
      printf("%c%d ",A[i].moji,A[i].value);
    }
  printf("%c%d\n",A[n-1].moji,A[n-1].value);
  for(i=0;i<=n-1;i++)
    {
      if(C[i].moji!=A[i].moji)
        {
          c=1;
        }
    }
  if(c==1)
    printf("Not stable\n");
  else
    printf("Stable\n");
  
      
  return 0;
}



Measured memory_bytes: 2100
import sys
readline = sys.stdin.buffer.readline

s = readline().rstrip().decode('utf-8')

n = len(s)

def judge(k):
    l = len(k)
    if l%2==0:
        a = k[:l//2]
        b = k[l//2:]
        b = b[::-1]
        if a==b:
            return True
        else:
            return False
    else:
        a = k[:l//2]
        b = k[l//2+1:]
        b = b[::-1]
        if a==b:
            return True
        else:
            return False
if judge(s) and judge(s[:(n-1)//2]) and judge(s[(n+3)//2-1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;


int main(){
	int N,K;
	scanf("%d %d", &N, &K);

	int ans = 1;
	for(int i=0;i<N;i++){
		if(ans<K) ans *= 2;
		else ans += K;
	}

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

	return 0;
}


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

int main(){
    while(1){
        int a,b;
        char c;
        cin>>a>>c>>b;
        if(c=='?')break;
        if(c=='+')cout<<a+b<<endl;
        if(c=='-')cout<<a-b<<endl;
        if(c=='*')cout<<a*b<<endl;
        if(c=='/')cout<<a/b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int main(){
	int c[3][3];
	REP(i,3){
		REP(k,3){
			cin >> c[i][k];
		}
	}
	
	int po;
	
	REP(i,3){
		po =  c[i%3][0]-c[(i+1)%3][0];
		if(po!=c[i%3][1]-c[(i+1)%3][1] || po!=c[i%3][2]-c[(i+1)%3][2]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	REP(i,3){
		po =  c[0][i%3]-c[0][(i+1)%3];
		if(po!=c[1][i%3]-c[1][(i+1)%3]|| po!=c[2][i%3]-c[2][(i+1)%3]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define ld                 long double
#define ff                 first
#define ss                 second
#define P                 pair<int,int>
#define pb                 push_back
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
const int N = 105;//change it when needed
const int K = 100005;
int dp[K];
int n, k;
int a[N];
void solve() {
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= k; i++) {
        int winTaro = 1;
        for (int j = 0; j < n; j++) {
            if (i >= a[j])
                winTaro &= (dp[i - a[j]]);
        }
        dp[i] = !(winTaro);
    }
    if (dp[k])cout << "First" << endl;
    else    cout << "Second" << endl;
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t; cin >> t; while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ret = sum(A)
    A = Counter(A)

    dic = {}
    for i,v in A.items():
        dic[i]=v
    Q = int(input())
    for q in range(Q):
        b , c = map(int, input().split())
        x = dic.get(b,0)
        dic[c] = dic.get(c,0)+x
        dic[b] = 0
        ret += c*x-b*x

        print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25488
import copy

n = int(input())
cards = list(map(str, input().split()))

def BubbleSort(NUM_LIST):
    for i in range(1, len(NUM_LIST)):
        for j in range(len(NUM_LIST)-1, i-1, -1):
            if NUM_LIST[j-1][1] >NUM_LIST[j][1]:
                NUM_LIST[j], NUM_LIST[j-1] = NUM_LIST[j-1], NUM_LIST[j]

def SelectionSort(NUM_LIST):
    for i in range(len(NUM_LIST)):
        minj = i
        for j in range(i, len(NUM_LIST)):
            if NUM_LIST[minj][1] > NUM_LIST[j][1]:
                minj = j
        NUM_LIST[minj], NUM_LIST[i] = NUM_LIST[i], NUM_LIST[minj]

bubble_cards = copy.copy(cards)
selection_cards = copy.copy(cards)

BubbleSort(bubble_cards)
SelectionSort(selection_cards)


print(" ".join(bubble_cards))
print("Stable")

print(" ".join(selection_cards))
if bubble_cards == selection_cards:
    print("Stable")
else:
    print("Not stable")


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

int main()
{
  int n;
  cin >> n;
  vector<long long int> v(n);
  long long int sum =0;
  for(int i = 0;i<n;i++)
  {  
    cin >> v[i];
    sum += v[i];
  }
  vector<vector<long long int> > dp(n,vector<long long int>(n,0));
  
  for(int i = 0;i<n;i++)
    dp[i][i] = v[i];
  for(int i = 0;i< n-1;i++)
    dp[i][i+1] = max(v[i],v[i+1]);
  for(int l =3 ; l <= n;l++)
  {
    int i = 0;
    int j = i+l-1;
    while(j < n)
    {
      dp[i][j] = max(v[i] + min(dp[i+1][j-1],dp[i+2][j]),
                                v[j] + min(dp[i+1][j-1],dp[i][j-2]));
      i++;j++;
    }
  }
  cout << (2*dp[0][n-1] - sum) << endl; 
  return 0;
}

Measured memory_bytes: 73664