akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
#include<assert.h>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int  MOD = 1e9 + 7, OO = 1e9;
const int  N = 2e5 + 10;
int n, a[N];
ll sum;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		if (i % 2 == 1)sum -= a[i];
		else sum += a[i];
	}
	vector<int> sol;
	sol.push_back(sum / 2);
	for (int i = 1; i < n; ++i) {
		sol.push_back(a[i - 1] - sol[i-1]);
	}
	for (int i = 0; i < n; ++i) {
		cout << sol[i]*2 << " ";
	}
	cout << endl;
}

Measured memory_bytes: 2296
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

string s;
void solve(){
  int n, k; cin >> n >> k;
  vector<long long int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  long long int ans = 0;
  if(a[0] > k){
    ans += a[0] - k;
    a[0] -= a[0] - k;
  }
  for(int i = 1; i < n; i++){
    if(a[i - 1] + a[i] > k){
      ans += a[i - 1] + a[i] - k;
      a[i] -= a[i - 1] + a[i] - k;
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


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

using namespace std;

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

int main(){
  
  int h,w;
  cin >> h >> w;
  vector<string>  v(h);
  bool flag = true;
  for(int i = 0;i < h;i++)cin >> v[i];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(v[i][j] == '#'){
        bool exist = false;
        for(int k = 0;k < 4;k++){
          if(i+dy[k] < 0 || i+dy[k] >= h || j+dx[k] < 0 || j+dx[k] >= w)continue;
          if(v[i+dy[k]][j+dx[k]] == '#')exist = true;
        }
        if(!exist)flag = false;
      }
    }
  }
  if(flag)cout << "Yes" << endl;
  else cout << "No" << endl;
            
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	int q;
	int s[10101];
	int t[505];
	int check[505];
	rep(i,n) cin>>s[i];
	cin>>q;
	rep(i,q) cin>>t[i];

	int ans=0;
	rep(i,n){
		rep(j,q){
			if(s[i]==t[j]) check[j]=1;
		}
	}
	rep(i,q)if(check[i]==1) ans++;
	cout<<ans<<endl;

}




Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;

unordered_map<string,int> tbl;
int calc(vector<string>&v,int s){
	vector<int>z;
	for(;v[s]!=")";){
		if(v[s]=="("){
			z.push_back(calc(v,s+1));
			int cnt=1;
			for(s++;cnt;s++){
				if(v[s]=="(")cnt++;
				if(v[s]==")")cnt--;
			}
		}else if('0'<=v[s][0]&&v[s][0]<='9'){
			z[z.size()-1]*=strtol(v[s].c_str(),NULL,10);
			s++;
		}else{
			z.push_back(tbl[v[s]]);
			s++;
		}
	}
	int i=0,r=0;
	for(;i<z.size();i++)r+=z[i];
	return r;
}
int main(){
	string mole;
	for(;cin>>mole;){
		if(mole=="END_OF_FIRST_PART")break;
		int n;
		cin>>n;
		tbl[mole]=n;
	}
	for(;cin>>mole&&mole!="0";){
		vector<string> v;
		//tokenize
		for(int i=0;i<mole.size();){
			if(mole[i]=='('){
				v.push_back("("),i++;
			}else if(mole[i]==')'){
				v.push_back(")"),i++;
			}else if('0'<=mole[i]&&mole[i]<='9'){
				int j=i+1;
				for(;'0'<=mole[j]&&mole[j]<='9';j++);
				v.push_back(mole.substr(i,j-i));
				i=j;
			}else if('A'<=mole[i]&&mole[i]<='Z'){
				int j=i+1;
				for(;'a'<=mole[j]&&mole[j]<='z';j++);
				string x=mole.substr(i,j-i);
				if(tbl.find(x)==tbl.end()){cout<<"UNKNOWN"<<endl;goto NEXT;}
				v.push_back(x);
				i=j;
			}
		}
		v.push_back(")");
		cout<<calc(v,0)<<endl;
NEXT:;
	}
}

Measured memory_bytes: 1276
n = int(input())
s = []
for i in range(n):
    s.append(input())

set_s = sorted(set(s[0]))
nn = int(len(set_s))
ans = [[] for i in range(nn)]
for i in range(nn):
    for j in s:
        ans[i].append(j.count(set_s[i]))

ans_2 = []
c = 0
for i in ans:
    i = min(i)
    for j in range(i):
        ans_2.append(set_s[c])
    c += 1

for j in ans_2:
    print(j,end="")


Measured memory_bytes: 64960
#include <stdio.h>
#include <stdlib.h>


int main(void)
{
    char s[5],t[5];
    int n=0,b[5],l[100][100],r[100][100];
    int answer,i,j;
answer=0;
    scanf("%s",s);
    scanf("%s",t);

for(i=0; i<3; i++)
{
    if(s[i]==t[i])
    {
        answer+=1;
    }
}
printf("%d",answer);

   
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define N 1000000
#define M N/2+1

int main(void){
	int i = 1,k;
	int n;
	int primeTable[N] = {0};

	primeTable[0] = 1;
	primeTable[1] = 1;
	k = 2;

	/* 2の倍数 */
	while(2*k < N){
		primeTable[2*k] = 1;
		k++;
	}
	/* 3以上の倍数 */
	for( i = 3 ; i < M ; i=i+2){
		k = 2;
		while(i*k < N){
			primeTable[i*k] = 1;
			k++;
		}
	}

	while(scanf("%d", &n) != EOF){
		int count = 0;
		for(i = 2 ; i <= n ; i++){
			if(primeTable[i] == 0) count++;
		}
		printf("%d\n", count);
	}

	return 0;
}

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

using namespace std;

long long n,i,k,cost,ct1,ct2,mini,poz,j,v[410],cost_d[410][410],d[410][410];

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

    for(i=n;i>=1;i--)
    {
        for(j=i+1;j<=n;j++)
        {
            d[i][j]=LONG_LONG_MAX/2;
            for(k=i;k<j;k++)
                {
                    cost=cost_d[i][k]+cost_d[k+1][j]+d[i][k]+d[k+1][j];

                    if(cost<d[i][j])
                    {
                        d[i][j]=cost;
                        cost_d[i][j]=cost_d[i][k]+cost_d[k+1][j];
                    }
                }
        }
    }

    cout<<d[1][n];
    return 0;
}


Measured memory_bytes: 2816
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	double w, h, x, y;
	cin >> w >> h >> x >> y;

	cout << w * h / 2.0;
	cout << " ";

	if (x == w / 2.0 && y == h / 2.0)
	{
		cout << 1;
	}
	else
	{
		cout << 0;
	}
	cout << endl;
}

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

using namespace std;

int n, fir1, fir2, cnt1 = 0, cnt2 = 0, tes1=0, tes2=0;
int p1=0,p2=0, q1,q2;
vector<int>vec1, vec2, ans1, ans2;

int main() {
	cin >> n;
	for (int k = 0; k < n / 2; k++) {
		cin >> fir1 >> fir2;
		vec1.push_back(fir1);
		vec2.push_back(fir2);
	}
	vec1.push_back(999999);
	vec2.push_back(999999);
	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());

	for (int i = 0; i < n / 2; i++) {
		cnt1++;
		if (vec1[i] != vec1[i + 1]) {
			if (p1 <= cnt1) {
				p1 = cnt1;
				q1 = vec1[i];
			}
			ans1.push_back(cnt1);
			cnt1 = 0;
		}
		cnt2++;
		if (vec2[i] != vec2[i + 1]) {
			if (p2 <= cnt2) {
				p2 = cnt2;
				q2 = vec2[i];
			}
			ans2.push_back(cnt2);
			cnt2 = 0;
		}
	}
	ans1.push_back(0);
	ans2.push_back(0);
	sort(ans1.rbegin(), ans1.rend());
	sort(ans2.rbegin(), ans2.rend());
	if (q1 != q2) {
		cout << n - ans1[0] - ans2[0] << '\n';
	}
	else {
		cout << min(n-ans1[0] - ans2[1], n-ans2[0] - ans1[1])<< '\n';
	}
	cin >> n;

	return 0;

}

Measured memory_bytes: 1404
// copied by Nurstan Duisengaliev
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
ll a, b, gcd;
int prime[(int)1e6 + 123];
void solve () {	
	cin >> a >> b;
	gcd = __gcd (a, b);
	prime[1] = 1;
	for (int i = 2; i <= (int)1e6; i ++) {
		if (prime[i] == 0 && i * 1ll * i <= (int)1e6) {
			for (int j = i * i; j <= (int)1e6; j += i) {
				prime[j] = 1;
			}	
		}
	}	
	int kol = 0;
	for (int i = 2; i <= (int)1e6; i ++) {
		if (prime[i] == 0 && gcd % i == 0) {
			kol ++;
		    while (gcd % i == 0) gcd /= i;
		}
	}
	if (gcd != 1) kol ++;
	cout << kol + 1;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    string S;
    int a[10];
    cin >> S;
    long long ans=0;
    int s=S.size();
    for(int i=0;i<s;i++){
        a[i]=(S[i]-'0');
        for(int j=0;j<s-i;j++){
            ans+=a[i]*pow(10,j)*pow(2,i)*pow(2,max(0,s-i-2-j));
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  char a;
  cin >> a;
  
  if(a>='a' && a<='z'){
    cout << 'a' << endl;
  }else{
    cout<<'A'<<endl;
  }
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	int N;
	string S, T;
	cin >> N >> S >> T;

	for (int i = 0; i < N; i++) {
		string tmpS, tmpT;
		for (int j = i; j < N; j++) tmpS.push_back(S[j]);
		for (int j = 0; j < N - i; j++) tmpT.push_back(T[j]);
		if (tmpS == tmpT) {
			cout << N + i << endl;
			return 0;
		}
	}
	cout << 2 * N << endl;

	return 0;
}

Measured memory_bytes: 256
class SegmentTree:
    """
    演算子は要素とセットでモノイドを形成するようなものでなければならない。
    すなわち、結合律が成り立ち単位元が存在する必要がある。(ただし単位元は添加可能)
    """
    @classmethod
    def all_identity(cls, operator, identity, size):
        return cls(operator, identity, [identity]*(2 << (size-1).bit_length()))

    @classmethod
    def from_initial_data(cls, operator, identity, data):
        size = 1 << (len(data)-1).bit_length()
        temp = [identity]*(2*size)
        temp[size:size+len(data)] = data
        data = temp

        for i in reversed(range(size)):
            data[i] = operator(data[2*i],data[2*i+1])
        return cls(operator, identity, data)

    # これ使わずファクトリーメソッド使いましょうね
    def __init__(self, operator, identity, data):
        self.op = operator
        self.id = identity
        self.data = data
        self.size = len(data)//2

    def _interval(self, a, b):
        a += self.size
        b += self.size
        ra = self.id
        rb = self.id

        data = self.data
        op = self.op
        while a < b:
            if a & 1:
                ra = op(ra,data[a])
                a += 1
            if b & 1:
                b -= 1
                rb = op(data[b],rb)
            a >>= 1
            b >>= 1
        return op(ra,rb)

    def __getitem__(self, i):
        if isinstance(i, slice):
            return self._interval(
                                    0 if i.start is None else i.start,
                                    self.size if i.stop is None else i.stop)
        elif isinstance(i, int):
            return self.data[i+self.size]

    def __setitem__(self, i, v):
        i += self.size
        data = self.data
        op = self.op
        while i:
            data[i] = v
            v = op(data[i^1],v) if i & 1 else op(v,data[i^1])
            i >>= 1

    def __iter__(self):
        return iter(self.data[self.size:])

max2 = lambda x,y: x if x > y else y
min2 = lambda x,y: x if x < y else y

def solve(K,P):
    N = len(P)
    maxseg = SegmentTree.from_initial_data(max2, -1, P)
    minseg = SegmentTree.from_initial_data(min2, N, P)

    delta = [b-a for a,b in zip(P,P[1:])]
    deltaseg = SegmentTree.from_initial_data(min2, N, delta)

    c = 1
    sorted_ever_counted = deltaseg[:K-1] > 0
    for i in range(N-K):
        a = maxseg[i+1:i+K]
        b = minseg[i+1:i+K]
        is_sorted = deltaseg[i+1:i+K] > 0

        if b < P[i] or a > P[i+K]:
            if is_sorted:
                c += int(not sorted_ever_counted)
                sorted_ever_counted = True
            else:
                c += 1

    return c

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = list(map(int,input().split()))
    print(solve(K,P))

Measured memory_bytes: 115612
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n;cin>>n;
	int arr[n];
	memset(arr,0,sizeof(arr));
	for(int i=0;i<n-1;i++){
		int a;cin>>a;
		arr[a-1]++;
	}
	for(int i=0;i<n;i++){
		cout<<arr[i]<<endl;
	}
}


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

int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t Ans=0;
  Ans+=(N/(A+B))*A;
  N-=(N/(A+B))*(A+B);
  N=min(A, N);
  Ans+=N;
  cout << Ans << endl;
}

Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

#DIV = (10**9) + 7
DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,M,K = isRaw()
    As = isRaw()
    Bs = isRaw()
    sAs = [0]
    for a in As:
        t = a + sAs[-1]
        if t>K:
            break
        sAs.append(t)

    sBs=[0]
    for b in Bs:
        t = b + sBs[-1]
        if t>K:
            break
        sBs.append(t)
    sBs = sBs[1:]
    ans = 0
    for sai,sa in enumerate(sAs):
        
        sbi = bisect.bisect_right(sBs,K-sa)
        ans = max(ans,sai+sbi)
    print (ans)


main()


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

vector<int> f(int n) {
    int ans = 0;
    int n_sq = ::sqrt(n);
    vector<int> vec(n);

    for(int x = 1; x <= n_sq + 1; x++) {
        for(int y = 1; y <= n_sq + 1; y++) {
            for(int z = 1; z <= n_sq + 1; z++) {
                int v = x * x + y * y + z * z + x * y + y * z + z * x;
                if(v <= n)
                    vec[v] += 1;
            }
        }
    }
    return vec;
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >> n;

    vector<int> vec = f(n);
    rep(i, n) cout << vec[i + 1] << endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;

ll calc(ll a) {
	ll ans = 0;
	for (ll i = a/4*4; i <= a; i++) {
		ans ^= i;
	}
	return ans;
}

int main() {
	ll a, b;
	cin >> a >> b;
	ll ans= calc(a - 1) ^ calc(b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int N,kind=0,c[100000]={0};
  int i,j;

	scanf("%d",&N);
	int a[N];

	for (i = 0; i < N; i++){
		scanf("%d",&a[i]);
		c[a[i]] = 1;
	}
        for(i=0; i<100000; i++){
	  if(c[i])kind++;
	}        	
	if(kind%2==0)
	  printf("%d\n",kind-1);
	else
	  printf("%d\n",kind);
	return 0;
}


Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	string s; cin >> s;
	int n = s.length() + 1;
	vector<int> a(n, 0);
	for (int i = 0; i < n - 1; ++i) {
		if (s[i] == '<') {
			a[i + 1] = max(a[i] + 1, a[i + 1]);
		}
	}
	for (int i = n - 2; i >= 0; --i) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	cout << accumulate(a.begin(), a.end(), (int)0);
	return 0;
}

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

using LL = long long;
using LD = long double;
 
LL mod = 1e9+7;

int main()
{
	LL s, w;
	cin >> s >> w;

	if (w >= s) {
		cout << "unsafe\n";
	}
	else {
		cout << "safe\n";
	}
}



Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val x = sc.nextLong()
    val y = sc.nextLong()
    println(problem083c(x, y))
}

fun problem083c(x: Long, y: Long): Int {
    val a = mutableListOf(x)
    while (a[a.size - 1] <= y) {
        a.add(a[a.size - 1] * 2)
    }
    a.removeAt(a.size - 1)
    return a.size
}

Measured memory_bytes: 31268
#include<bits/stdc++.h>
using namespace std;
#define ll long  long int 

int main()
{   
    ll n;
    cin>>n;
    vector<ll>v;
    map<ll, ll>f;
    for(long int i=0;i<n;i++)
    {
           ll x;
           cin>>x;
           v.push_back(x);
           if(f.count(x))
           {
               f[x]+=1;
           }
           else{
               f.insert(make_pair(x, 1));
           }
    }
    map<ll , ll>m;
    ll all=0;
    for(auto x:f)
    {
        ll y=x.second;
        ll val=y*(y-1)/2;
        m.insert(make_pair(x.first, val));
        all+=val;
    }
      
        ll tall=all;
       for(ll i=0;i<n;i++)
       {
              all-=m[v[i]];
              ll val=f[v[i]];
              val--;
              all+=val*(val-1)/2;
              cout<<all<<endl;
             all=tall;
       }
    return 0;
}

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

int main(){
	int H,W;
	cin >> H >> W;
	char a[H+2][W+2];
	for(int i=0;i<H+2;i++){
		for(int j=0;j<W+2;j++){
			if(i==0||j==0||i==H+1||j==W+1) a[i][j]='#';
			else cin >> a[i][j];
		}
	}
	
	for(int i=0;i<H+2;i++){
		for(int j=0;j<W+2;j++){
			cout << a[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
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; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
//fixed<<setprecision(10)<<ans<<endl;

int64 gcd(int64 a, int64 b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int64 lcm(int64 n, int64 m){
    return n * (m / gcd(n, m));
}

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

    int upper = 3500;
    int64 numerator,denomirator;
    for(int64 h=1;h<=upper;h++){
        for(int64 n=h;n<=upper;n++){
            numerator = 4*h*n - N*n - N*h;
            denomirator = h*n*N;

            if(numerator <= 0 or denomirator <= 0) continue;
            if(denomirator%numerator==0){
                cout << h << " " << n << " " << denomirator/numerator << "\n";
                return 0;
            }

        }
    }    
}

Measured memory_bytes: 256
N = int(input())
S = input()
k = [0]*10
now = S[0]
ren = 1
ls1 = [S[0]]
ans = 0
#文字列を圧縮する
for i in range(1,N):
    if S[i] == now:
        ren += 1
        if ren <= 3:
            ls1.append(S[i])
    else:
        now = S[i]
        ren = 1
        ls1.append(S[i])
pless = ''.join(ls1)
#0から9までの各文字について考える
for i in range(0,10):
    x = pless.find(str(i))
    #もしiが含まれていたら
    if x == -1:
        continue
    for j in range(0,10):
        #もしstr(i)が含まれている文字以降にstr(j)が含まれていたら
        y = pless.find(str(j),x+1)
        if y == -1:
            continue
        for k in range(0,10):
            #もしstr(j)が含まれている文字以降にstr(k)が含まれていたら
            z = pless.find(str(k),y+1)
            if z != -1:
                ans += 1
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>
int main(void) {
    char str[200], tmp[200] = {};
    int s,n,a,i,j;
     
    while (scanf("%s", str), str[0] != '-'){
        s=strlen(str);
         
        scanf("%d", &n);
         
        for (i = 0; i < n; i++){
            scanf("%d", &a);
            for (j = 0; j < a; j++)  tmp[j] = str[j];
            for (j = 0; j < s - a; j++) str[j] = str[j+a];
            for (j = 0; j < a; j++) str[s-1 - j] = tmp[a-1 - j];
        }
        printf("%s\n", str);
    }
         
    return 0;
}


Measured memory_bytes: 2060
#include <stdio.h>

int main(void)
{
    int n, m;
    scanf("%d%d", &n, &m);
    int likes[m];
    for (int i = 0; i < m; i++)
    {
        likes[i] = 0;
    }

    int i = 0;
    while (i < n)
    {
        int k;
        scanf("%d", &k);
        for (int j = 0; j < k; j++)
        {
            int tmp;
            scanf("%d", &tmp);
            likes[tmp-1]++;
        }
        i++;
    }

    int count = 0;
    for (i = 0; i < m; i++)
    {
        if (likes[i] == n)
        {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
	int stu[4];
	int ave = 0;

	for (int i = 0; i < 5; i++){
		cin >> stu[i];
		if (stu[i] < 40){
			stu[i] = 40;
		}
		ave += stu[i];
		if (i == 4){
			cout << ave / 5 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	long long int M;
	cin>> M;
	long long int bigGold,smallGold;
	bigGold = 0;
	smallGold = 0;
	bigGold = M / 500;
	M = M - 500 * bigGold;
	smallGold = M /5;
	cout<< bigGold * 1000 + smallGold * 5<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int isprime(int);

int main(){
  int i;
  int a,d,n;

  while(1){
    i=0;
    scanf("%d %d %d",&a,&d,&n);
    if(a==0&&d==0&&n==0)break;

    while(1){
      if(isprime(a)==1) i++;
      if(i==n){
	printf ("%d\n",a);
	break;
      }
      a+=d;
     
    }
    
  }

  return 0;
}

int isprime(int x){
  int i=3;

  if(x==2) return 1;

  if(x<2||x%2==0)return 0;

  while(i<=sqrt(x)){
    if(x%i==0)return 0;
    i+=2;
  }

  return 1;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int32_t main()
{  lli x,k,d;
   cin>>x>>k>>d;
   x=abs(x);
   if((x/d)<k)
   { k=k-x/d;
     if(k%2==0)   cout<<x%d;
     else     cout<<abs((x%d)-d);
   }
   else cout<<abs(x-(k*d));
   return 0;
}//main


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

int main(){

	int N;
	scanf("%d",&N);

	int* table = new int[N+1];

	for(int i = 1; i <= N; i++)scanf("%d",&table[i]);

	double** dp = new double*[N+1];
	for(int i = 1; i <= N; i++){
		dp[i] = new double[200000];
		for(int k = 0; k < 200000; k++)dp[i][k] = 1.0;
	}

	double ans = 1.0;

	for(int i = 1; i < 2*table[1]; i++)dp[1][i] = (double)(abs(i-table[1])/(double)table[1]);

	for(int i = 1; i < N; i++){
		for(int k = 1; k < 2*table[i]; k++){
			for(int a = 1; k*a < 2*table[i+1];a++){
				dp[i+1][k*a] = min(dp[i+1][k*a],max(dp[i][k],(double)(abs(k*a-table[i+1])/(double)table[i+1])));
			}
		}
	}

	for(int i = 1; i < 2*table[N];i++)ans = min(ans,dp[N][i]);

	printf("%.12lf\n",ans);

	return 0;
}

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

using namespace std;

int main(void) {
    string s, t;
    bool ok = false;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    bool match = true;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] - t[i] < 0) {
            ok = true;
            break;
        } else if (s[i] - t[i] > 0) {
            match = false;
        }
    }

    if (match && s.length() < t.length()) ok = true;

    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  if (13<=A){
    cout << B << endl;
  }
  else if (6 <=A && A <= 12){
    cout << B/2 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

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

int main(){
  long long  x;
  cin >> x;
  bool flag = 0;
  for(long long i=-1000; i < 1000; i++){
    for(long long  j=-1000; j < 1000; j++){
      if(i*i*i*i*i - j*j*j*j*j == x) {
        cout << i << " " << j << endl;
        flag = 1;
        break;
      }
    }
    if(flag) break;
  }
}


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

int main() {
    lint N, K, L, R;
    cin >> N >> K >> L >> R;
    vector<lint> a(N / 2), b(N / 2 + (N % 2 == 1 ? 1 : 0));
    rep(i, a.size()) cin >> a[i];
    rep(i, b.size()) cin >> b[i];

    vector<vector<lint>> La(N + 1, vector<lint>(0));
    for (int bit = 0; bit < (1 << a.size()); bit++) {
        int k    = 0;
        lint sum = 0;
        for (int i = 0; i < a.size(); i++) {
            if (bit & (1 << i)) {
                sum += a[i];
                k++;
            }
        }
        La[k].push_back(sum);
    }

    for (int i = 0; i <= N; i++)
        sort(La[i].begin(), La[i].end());

    lint ans = 0;
    for (int bit = 0; bit < (1 << b.size()); bit++) {
        int k    = 0;
        lint sum = 0;
        for (int i = 0; i < b.size(); i++) {
            if (bit & (1 << i)) {
                sum += b[i];
                k++;
            }
        }
        if (K < k) continue;
        ans += upper_bound(La[K - k].begin(), La[K - k].end(), R - sum) -
               lower_bound(La[K - k].begin(), La[K - k].end(), L - sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12332
open System

[<EntryPoint>]
let main argv =
    let ab = Console.ReadLine().Split() |> Array.map int
    let a, b = ab.[0], ab.[1]
    (if (a - b) % 2 = 0 then (a + b) / 2 |> string else "IMPOSSIBLE") |> Console.WriteLine
    0

Measured memory_bytes: 13268
N, M = map(int, input().split())
cnt = [0]*M
for _ in range(N):
    ka = list(map(int, input().split()))
    for a in ka[1:]:
        cnt[a-1] += 1
res = 0
for num in cnt:
    if num == N:
        res += 1
print(res)

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>

using namespace std;

int main(){
  int N, K;
  int l[64];
  int sum = 0;
  cin >> N >> K;
  for( int i = 0; i < N; i++ ){
	cin >> l[i];
  }
  sort(&l[0], &l[N]);
  for( int i = 0; i < K; i++ ){
	sum += l[N-i-1];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = [int(i) for i in input().split()]

res = 0

for i in range(1, a+1):
    for j in range(1, b+1):
        ten, one = (j // 10), j % 10
        if ten >= 2 and one >= 2 and ten * one == i:
            res += 1

print(res)

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

int main() {

  string input,ans;
  getline( cin, input );

  for ( int i = 0; i < input.size(); i++ ) {

    char c = input[i];

    if ( c >= 'a' && c <= 'z' ) {
      c += 'A' - 'a';
    }else if ( c >= 'A' && c <= 'Z' ) {
      c += 'a' - 'A';
    }
    ans += c;

  }

  cout << ans << endl;

  return 0;

}

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

int main() {
	string s; cin>>s;
	int ret=1e9;
	for (char x='a'; x<='z'; x++) {
		int cur=0, mx=0;
		for (auto y : s) {
			if(y==x) cur=0;
			else cur++, mx=max(mx,cur);
		}
		ret=min(ret,mx);
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let 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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; 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 > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, k: isize, a: [isize; n] };
    let mut b = vec![0];
    b.extend(
        a.iter()
            .scan(0, |acc, &x| {
                *acc += x;
                Some(*acc)
            })
            .collect::<Vec<_>>(),
    );
    for i in 0..n {
        b[i + 1] -= i as isize + 1;
        b[i + 1] %= k;
        b[i + 1] += k;
        b[i + 1] %= k;
    }
    let mut ans = 0usize;
    let mut set = std::collections::HashMap::new();
    for j in 1..n + 1 {
        *set.entry(b[j - 1]).or_insert(0) += 1;
        if j >= k as usize {
            *set.entry(b[j - k as usize]).or_insert(0) -= 1;
        }
        ans += *set.get(&b[j]).unwrap_or(&0);
    }
    println!("{}", ans);
}


Measured memory_bytes: 23180
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<ll> march(5,0);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    if(S[0] == 'M'){
      march[0]++;
    }else if(S[0] == 'A'){
      march[1]++;
    }else if(S[0] == 'R'){
      march[2]++;
    }else if(S[0] == 'C'){
      march[3]++;
    }else if(S[0] == 'H'){
      march[4]++;
    }
  }
  ll ans=0;
  for(int bit=1; bit<(1<<5); bit++){
    if(__builtin_popcount(bit) != 3) continue;
    ll res=1;
    for(int i=0; i<5; i++){
      if(bit & (1<<i)){
        res *= march[i];
      }
    }
    ans += res;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!
    int N;
    cin >> N;
    LL mod = 1e9+7;
    vector<LL> cnt(26, 1);
    for (int i = 0; i < N; i++) {
        char c;
        cin >> c;
        cnt[c-'a']++;
    }
    LL res = 1;
    for (int i = 0; i < 26; i++) res = res * cnt[i] % mod;
    res--;
    cout << res << "\n";
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
A = [i for i in A if i % 2 == 0]
c = 0
while len(A) != 0:
    for i in range(len(A)):
        A[i] = A[i] // 2
        c += 1
    A = list(filter(lambda x: x%2==0, A))
print(c)

Measured memory_bytes: 4148
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 31 19:26:05 JST 2020
 **/

signed main() {
    Int n;
    std::cin >> n;
    std::vector<Int> a(n + 1);
    REP(i, n + 1) std::cin >> a[i];
    std::vector<Int> mas(n + 1 + 1);
    for (Int i = n; i >= 0; i--) {
        mas[i] = mas[i + 1] + a[i];
    }
    Int ans = 0, cur = 1;
    REP(i, n + 1) {
        cur = std::min((i == 0 ? 1 : cur * 2), mas[i]);
        ans += cur;
        cur -= a[i];
        if (cur < 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }
    assert(cur == 0);
    std::cout << ans << std::endl;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s; std::cin >> s;
    vs vec = {"Sunny", "Cloudy", "Rainy"};
    int idx = 0;
    rep(i, 3) if (vec[i] == s) idx = i;
    std::cout << vec[(idx+1)%3] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int MAX_N = (int)2e5 + 5;

int N, M;
bool used[MAX_N];
vector<int> G[MAX_N];

bool dfs(int curr, int depth){
	if (depth > 2){
		return false;
	} // end if

	if (curr == N - 1){
		return true;
	} // end if

	bool res = false;
	for (int i = 0; i < (int)G[curr].size(); ++i){
		int next = G[curr][i];
		if (used[next]){
			continue;
		} // end if
		used[next] |= true;
		res |= dfs(next, depth + 1);
		used[next] = false;
	} // end for

	return res;
}
int main()
{
	memset(used, false, sizeof(used));
	rep (i, MAX_N) G[i].clear();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> M;
	rep (i, M){
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	} // end rep

	used[0] = true;
	bool res = dfs(0, 0);
	
	cout << (res ? "POSSIBLE" : "IMPOSSIBLE") << endl;

	return 0;
}

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

int main()
{
    int K, N;
    vector<int> A;

    cin >> K >> N;
    A.resize(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int maxDist = A[0] + K - A[N - 1];
    for (int i = 1; i < N; i++)
    {
        maxDist = max(maxDist, A[i] - A[i - 1]);
    }

    cout << K - maxDist << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i < 10; i++) {
		if (i <= n and n%i == 0 and n / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

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

const ll mod = 1000000007;

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

  int x;
  cin >> x;

  vector<bool> erathosthenes(200000, true);
  int i = 2;
  while (i * i < 200000) {
    if (erathosthenes[i]) {
      for (int j = i * i; j < 200000; j += i) {
        erathosthenes[j] = false;
      }
    }
    i++;
  }

  int p = x;
  for (;p < 200000; p++) {
    if (erathosthenes[p]) {
      cout << p << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;




int main() {
    set <string>a;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        a.insert(s);
    }
    cout<<a.size()<<endl;



    return 0;
}


Measured memory_bytes: 19176
import java.util.*;


public class Main {
	
	int a, d, n;
	
	final int N_MAX = 1000000;
	int[] sieve = new int[N_MAX + 1];
	
	void initSieve() {
		sieve[1] = 1;
		for (int i = 2; i < sieve.length; i++) {
			if (sieve[i] == 0) {
				for (int j = i * 2; j < N_MAX + 1; j += i) {
					sieve[j] = 1;
				}
			}
		}
	}
	
	int solve() {
		int primes = 0;
		int i;
		for (i = a; i < N_MAX; i += d) {
			if (sieve[i] == 0) {
				primes++;
				if (primes == n) {
					break;
				}
			}
		}
		return i;
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		String output = "";
		initSieve();
		while (sc.hasNext()) {
			a = sc.nextInt();
			d = sc.nextInt();
			n = sc.nextInt();
			if (a == 0 && d == 0 && n == 0) {
				break;
			} else {
				output += solve() + "\n";
			}
		}
		sc.close();
		System.out.print(output);
	}

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

}

Measured memory_bytes: 27356
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    for(int i = 0; i < 50;i++) {
        int m,f,r;
        cin >> m >> f >> r;

        if(m == -1 && f == -1 && r == -1) {
            break;
        }

        if(m == -1 || f == -1) {
            cout << "F" << endl;
        } else if( m + f >= 80 ) {
            cout << "A" << endl;
        } else if( m + f >= 65 ) {
            cout << "B" << endl;
        } else if( m + f >= 50 || r >= 50) {
            cout << "C" << endl;
        } else if( m + f >= 30) {
            cout << "D" << endl;
        } else {
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main()
{
  int A[100];
  int i=0, j=0, n=0, N=0;
  int a;
  int flag=1;
  
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  while(flag){
    flag = 0;
    for(j=N-1; 0<j; j--){
      if(A[j] < A[j-1]){
	a = A[j];
	A[j] = A[j-1];
	A[j-1] = a;
	flag = 1;
	n++;
      }
    }
  }
  for(i=0; i<N; i++){
    printf("%d", A[i]);
    if(i==N-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n", n);
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  char c;
  cin >> c;
  if (c >= 'a' && c <= 'z') {
    cout << 'a' << '\n';
  } else {
    cout << 'A' << '\n';
  }

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;
 
int main()
{
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    vector<ll> B; 
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    map<ll,ll> c;
    ll ima=0; 
    ll ne;
    B.push_back(ima);
    c[ima] = 1;
    int ind = 2;
    while(1){
        ne = A[ima] - 1; 
        
        if(c[ne] != 0){
            B.push_back(ne);
            break;
        }
        c[ne] = ind;
        B.push_back(ne);
        ima = ne;
        ind++;
    }
 
    
    
    ll owari = B.size();
 
    ll hajime = c[B.back()];
 	
  if(hajime >= K){
  	cout << B[K]+1;
    return 0;
  }
    
    ll ko = owari - hajime;
    K -= (hajime-1);
    ll g = K % ko;
 
   cout << B[hajime -1 + g] +1;
 
    
    
 
    return 0;
}

Measured memory_bytes: 18472