akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;


int dp[1005][(1LL<<13)];
int32_t main(){
    ios::sync_with_stdio(false);

    int n, m;
    cin>>n>>m;
    vi a(m+1);
    vi mask(m+1,0);
    for(int i=1;i<=m;i++){
        cin>>a[i];
        int B;
        cin>>B;
        for(int j=0;j<B;j++){
            int T;
            cin>>T;
            T--;
            mask[i]=mask[i]|(1LL<<T);
        }
    }
    int finalmask=(1<<n)-1;
    memset(dp,0,sizeof(dp));
    for(int i=0;i<=m;i++){
        for(int j=1;j<=finalmask;j++){
            dp[i][j]=1e18;
        }
    }
    // deb(mask);
    for(int i=1;i<=m;i++){
        int Mask=mask[i];
        for(int j=0;j<=finalmask;j++){
            dp[i][j]=dp[i-1][j];
        }
        for(int j=0;j<=finalmask;j++){
            // if(i!=1)
            dp[i][Mask|j]=min({dp[i][Mask|j],a[i]+dp[i-1][j],dp[i-1][Mask|j]});
            // else{
                // dp[i][Mask|j]=min({dp[i][Mask|j],a[i]+dp[i-1][j]});
            // }
        }
    }
    // deb(finalmask);
    int ans=dp[m][finalmask];
    // for(int i=0;i<=m;i++){
    //     for(int j=0;j<=finalmask;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    if(ans>=(1e18)){
        cout<<-1<<"\n";
    }
    else{
        cout<<ans<<"\n";
    }




    return 0;
}

Measured memory_bytes: 64640
int main(void) {
    int a,b;
    scanf("%d%d",&a,&b);
    int x,y,z;
    for (x = 0; x <= a; x++) {
        for (y = 0; y <= a; y++) {
            z = a - x - y;
            if (z < 0) {
                continue;
            }
            if (x * 10000 + y * 5000 + z * 1000 == b) {
                printf("%d %d %d\n",x,y,z);
                return 0;
            }
        }
    }
end:
    printf("-1 -1 -1\n");
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

int N,Q;
vint G[222222];
int ans[222222];

void dfs(int v,int p){
	for(auto u:G[v]){
		if(u==p)continue;
		ans[u]+=ans[v];
		dfs(u,v);
	}
}
signed main(){
	cin>>N>>Q;
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);G[b].pb(a);
	}
	rep(i,Q){
		int p,x;
		cin>>p>>x;
		p--;
		ans[p]+=x;
	}
	dfs(0,-1);
	rep(i,N){
		if(i)cout<<" ";
		cout<<ans[i];
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 24832
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();
    if (a<b&&b<c){
      System.out.println("Yes");
    }else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 26344
fun main(arr:Array<String>) {
    dic.add(1)
    patDic.add(1)
    for(i in (1..50)) {
        dic.add(dic.last() * 2 + 3)
        patDic.add(patDic.last() * 2 + 1)
    }
    val (n,x) = readLine()!!.split(" ").map { it.toLong() }
    val ans = getAns(x, n.toInt())
    println(ans)
}

fun getAns(remain:Long, depth:Int):Long {
    if(remain == 0L) {
        return 0
    }
    if(depth == 0) {
        return 1
    }
    if(remain - 1 <= dic[depth - 1]) {
        return getAns(remain - 1, depth - 1)
    }
    if(remain - 1 == dic[depth-1] + 1 ) {
        return patDic[depth-1] + 1
    }
    if(remain - 1 < dic[depth-1]*2 + 1) {
        return patDic[depth-1] + 1 + getAns(remain - 2 - dic[depth-1], depth - 1)
    }
    return patDic[depth]
}

val dic = mutableListOf<Long>()
val patDic = mutableListOf<Long>()



Measured memory_bytes: 38212
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int k=0,n,z=0,i=0,sum=0;
  cin >> n;
  vector<long long int> arr;
  for(i=0;i<n;i++){
  	cin >> z;
    arr.push_back(z);
  }
  sort(arr.begin(),arr.end());
  sum += arr[n-1] ;
  n = n-1;
  k = n;
  while(k>1){
  	if(k>=3){sum += 2*arr[n-1];
             n = n-1;
            k--;k--;
            }
    else{
    	sum += arr[n-1];
      	n--;k--;
    }
  }
  cout << sum <<endl;
}

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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    int res = 0;
    res += (1<<m) * m * 1900;
    res += (1<<m) * (n-m) * 100;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 1000
#define MAX(a, b) (((a) > (b)) ? (a): (b))
int lcs(char*, char*);
int main(void)
{
  int i, n;
  char s1[N+1], s2[N+1];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%*c%s%*c%s", s1, s2);
    printf("%d\n", lcs(s1, s2));
  }
}
int lcs(char *s1, char *s2)
{
  int i, j, maxl = 0, c[N+1][N+1], m = strlen(s1), n = strlen(s2);
  for (i = 1; i <= m; i++) c[i][0] = 0;
  for (j = 1; j <= n; j++) c[0][j] = 0;
  for (i = 1; i <= m; i++) {
    for (j = 1; j <= n; j++) {
      if (s1[i-1] == s2[j-1]) {
        c[i][j] = c[i-1][j-1] + 1;
      } else {
        c[i][j] = MAX(c[i-1][j], c[i][j-1]);
      }
      maxl = MAX(maxl, c[i][j]);
    }
  }
  return c[m][n];
}


Measured memory_bytes: 5628
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int nLen = String.valueOf(n).length();
        int result = 0;
        for (int i = 0; i < nLen / 2; i++) {
            result += 9 * (int)Math.pow(100, i);
        }
        if (nLen % 2 != 0) {
            int start = (int)Math.pow(10, nLen - 1);
            result += n - start + 1;
        }
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
class MF{//max flow
	public:
	int n;
	vector<vector<edge> >G;//[MAX];
	vi level,iter;//[MAX];
	MF(int size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(int from, int to, int cap){
		edge q={to,cap,int(G[to].size())};
		G[from].push_back(q);
		q={from,0,int(G[from].size()-1)};
		G[to].push_back(q);
	}
	void bfs(int s){
		level=vi(n,-1);
		queue<int>q;
		level[s]=0;
		q.push(s);
		while(!q.empty()){
			int v=q.front();q.pop();
			for(int i=0;i<G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0&&level[e.to]<0){
					level[e.to]=level[v]+1;
					q.push(e.to);
				}
			}
		}
	}
	int dfs(int v,int t, int f) {
		if(v==t)return f;
		for(int &i=iter[v];i<G[v].size();i++){
			edge &e=G[v][i];
			if(level[v]>=level[e.to]||e.cap<=0) continue;
			int d =dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
		return 0;
	}
	int mf(int s,int t) {//from s to t,ford_fulkerson
		int flow=0;
		while(1){
			bfs(s);
			if(level[t]<0)return flow;
			iter=vi(n);
			int f;
			while((f=dfs(s,t,inf))>0)flow+=f;
		}
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	MF mf(n);
	while(m--){
		int a,b,c;
		cin>>a>>b>>c;
		mf.add_edge(a,b,c);
	}
	cout<<mf.mf(0,n-1)<<endl;
}

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

int main() {
  int N, M;
  long long A[50][2], B[50][2], res[50];
  long long distance;
  long long minimum = 3000000000;

  cin >> N >> M;

  for (int i = 0; i < N; i++) cin >> A[i][0] >> A[i][1];
  for (int i = 0; i < M; i++) cin >> B[i][0] >> B[i][1];

  for (int i = 0; i < N; i++) {
    minimum = 3000000000;
    for (int j = 0; j < M; j++) {
      distance = abs(A[i][0] - B[j][0]) + abs(A[i][1] - B[j][1]);
      if (distance < minimum) {
        minimum = distance;
        res[i] = j + 1;
      }
    }
  }

  for (int i = 0; i < N; i++) cout << res[i] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R(i,n) for(int i=0;i<n;i++)
using namespace std;
main(){
int N,M,i,j;
cin>>N>>M;
vector<int>D(N);
vector<int>C(M);
R(i,N){cin>>D[i];}
R(i,M){cin>>C[i];}
vector<vector<int> >dp(M+1,vector<int>(N+1,1<<30));dp[0][0]=0;
R(i,M){R(j,N+1){
if(j==0){dp[i+1][j]=dp[i][j];}
else{dp[i+1][j]=min(dp[i][j],dp[i][j-1]+C[i]*D[j-1]);}}}
cout<<dp[M][N]<<endl;
return 0;}

Measured memory_bytes: 5836
var
	N,L,out:Longint;
begin
	read(N,L);
	if(L<=0)and(0<=L+N-1)then begin
		out:=0;
	end else if (L+N-1<0)then begin
		out:=L+N-1;
	end else begin
		out:=L;
	end;
	writeln(N*(N-1)div 2+L*N-out);
end.


Measured memory_bytes: 128
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	s := make([]int, m)
	c := make([]int, m)
	check := true
	for i := 0; i < m; i++ {
		fmt.Scanf("%d %d", &s[i], &c[i])
		if s[i] != n && c[i] == 0 {
			check = false
		}
		if check && i != 0 {
			for j := 0; j < i; j++ {
				if s[i] == s[j] {
					if c[i] != c[j] {
						check = false
					} else {
						s[i] = 0
						c[i] = 0
					}
				}
			}
		}
	}
	if check == false {
		fmt.Println("-1")
		return
	}

	ans := 0
	for i := 0; i < m; i++ {
		ans += int(math.Pow(10, float64(n-s[i]))) * c[i]
	}
	if ans < int(math.Pow(10, float64(n-1))) && n > 1 {
		ans += int(math.Pow(10, float64(n-1)))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

const int N = 1e4 + 10;
int val[N];

void init() {
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= x; y++) {
            for (int z = 1; z <= y; z++) {
                int p = x * x + y * y + z * z + x * y
                    + x * z + y * z;
                if (p <= 10000) {
                    if(x == y && x == z) val[p]++;
                    else{
                        if(x == y) val[p]+=3;
                        else if(x == z) val[p]+=3;
                        else if(y == z) val[p]+=3;
                        else val[p]+=6;
                    }
                }
            }
        }
    }
}

int main() {
    init();
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) printf("%d\n", val[i]);
    return 0;
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <malloc.h>

#define char_max 200000

int Pow(int n, int m);
int Max(int N[], int n);
int Min(int N[], int n);
int Sum(int N[], int n);





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

	int n = N;

	while (1) {
		
		if (n % 10 == n % 100 / 10) {
			if (n % 10 == n / 100) {
				printf("%d", n);
				return 0;
			}
		}
		n++;
	}


	return 0;
}

int Pow(int n, int m) {
	int ret = 1;

	for (int i = 0; i < m; i++) {
		ret *= n;
	}

	return ret;
}

int Max(int N[], int n) {
	int max = N[0];

	for (int i = 0; i < n; i++) {
		max = max < N[i] ? N[i]: max;
	}

	return max;
}

int Min(int N[], int n) {
	int min = N[0];

	for (int i = 0; i < n; i++) {
		min = min > N[i] ? N[i] : min;
	}

	return min;
}

int Sum(int N[], int n) {
	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += N[i];
	}

	return sum;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cmath>

using namespace std;
long long n,ans;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n;
    long long ans = (n*(n-1))/2;
    cout << ans << endl;
    return 0;
}


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

int main(){
int N;
cin>>N;
vector<int> a(N);
long long v=0;
for(int i=0;i<N;i++){
   cin>>a[i];
}
int maxx =a[0];
for(int i=1;i<N;i++){
maxx=max(maxx,a[i]);
if(a[i]!=maxx){
   v+=(maxx-a[i]);
}
}
cout<<v<<endl;
return 0;

}


Measured memory_bytes: 4020
N,M = map(int,input().split())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
b = []
for j in range(M):
    b.append(int(input()))

for i in range(N):
    mult = 0
    for j in range(M):
        mult += a[i][j]*b[j]
    print(mult)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[200100];
ll DP[200100][5];
int main(){
    int L;
    cin >> L;
    REP(i,L){
        ll a;
        cin >> a;
        A[i] = a;
    }

    for(int j = 0; j < 5; j++) DP[0][j] = LLONG_MAX;
    DP[0][0] = 0;

    for(int i = 1; i < L+1; i++){
        ll a = A[i-1];
        ll m = DP[i-1][0];
        for(int j = 0; j < 5; j++) {
            DP[i][j] = m;
            if(j+1 < 5)
                m = min(m, DP[i-1][j+1]);
        }

        DP[i][0] += a;
        DP[i][1] += (a == 0) ? 2 :
                    (a % 2 == 0) ? 0 : 1;
        DP[i][2] += (a == 0) ? 1 :
                    (a % 2 == 0) ? 1 : 0;
        DP[i][3] += (a == 0) ? 2 :
                    (a % 2 == 0) ? 0 : 1;
        DP[i][4] += a;
    }

    //for(int i = 0 ; i < L+1; i++){
    //    for(int j = 0; j < 5; j++){
    //        printf("%lld ", DP[i][j]);
    //    }
    //    printf("\n");
    //}

    ll ans = LLONG_MAX;
    for(int j = 0; j < 5; j++){
        ll dp = DP[L][j];
        ans = min(ans, dp);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int i,j,k,n,m,c,t,y,mx,x;
    cin>>n>>x>>y;
    if(x>y) swap(x,y);k=y-x-1;//k=max(k,0);
    map<int,int>mp;
    for(i=1;i<n;i++){
        for(j=i+1;j<=n;j++){
            c=j-i;
            c=min(c,abs(i-x)+abs(j-y)+1);
           // c=min(c,abs(i-y)+abs(j-x));
            mp[c]++;
           // cout<<i<<" "<<j<<" ="<<c<<endl;
        }
    }
    for(i=1;i<n;i++){
        printf("%d\n",mp[i]);
    }
    return 0;
}


Measured memory_bytes: 3824
n, m = map(int, input().split())
ab = []
for i in range(m):
    a, b = map(int, input().split())
    ab.append([a, b])
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(n)
for i in range(m):
    uf.union(ab[i][0] - 1, ab[i][1] - 1)
    
ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))
print(ans)



Measured memory_bytes: 43772
#include <stdio.h>

long long func(long long x,long long y){
    if(y==0)return 1;
    else if(y%2==0){
        return func(x*x%1000000007,y/2);
    }else{
        return x*func(x,y-1)%1000000007;
    }
}

int main(){
    int m,n;
    
    scanf("%d %d",&m,&n);
    
    printf("%lld\n",func(m,n)%1000000007);
}



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

int main() {
  int n, S = 0;
  cin >> n;
  vector<int> v(n);
  for(int i = 0;i < n;i++) cin >> v[i];
  for(int i = 0;i < n;i++) {
    for(int j = i+1;j < n;j++) {
      for(int k = j+1;k < n;k++) {
        if(v[i]+v[j]>v[k] && v[j]+v[k]>v[i] && 
           v[k]+v[i]>v[j] && (v[i]-v[j])*(v[j]-v[k])*(v[k]-v[i])!=0) S++;
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int w,a,b;
	cin>>w>>a>>b;
	int a2 = a+w, b2 = b+w;
	int y = b-a2, y2 = a-b2;
	if(a<=b2 && a2>=b2)
		cout<<0<<endl;
	else if(a2>=b && a2<=b2)
		cout<<0<<endl;
	else 
	{
		int h = min(y,y2);
		if(h>0)
			cout<<h<<endl;
		else
			cout<<(y+y2-h)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
// 省略
#define ll long long
#define ld long double
#define Vi vector<int>
#define Vl vector<ll>
#define Vs vector<string>
// for
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Repp(i, a, b) for (int i = a; i <= (int)(b); i++)
#define Repm(i, a, b) for (int i = a; i <= (int)(b); i—-)
// 入力
#define ini(x) int x; cin >> x;
#define inl(x) ll x; cin >> x;
#define ind(x) double x; cin >> x;
#define inc(x) char x; cin >> x;
#define ins(x) string x; cin >> x;
// 出力
#define co(x) cout << x;
#define ce cout << endl;
#define cs cout << “ “;
#define keta(x) cout << fixed << setprecision(x);
// 配列
#define Sort(x) sort(x.begin(), x.end()); // 小順
#define Rev(x) reverse(x.begin(), x.end());

string alp(int a){
  switch(a){
    case 0: return "z"; break;
    case 1: return "a"; break;
    case 2: return "b"; break;
    case 3: return "c"; break;
    case 4: return "d"; break;
    case 5: return "e"; break;
    case 6: return "f"; break;
    case 7: return "g"; break;
    case 8: return "h"; break;
    case 9: return "i"; break;
    case 10: return "j"; break;
    case 11: return "k"; break;
    case 12: return "l"; break;
    case 13: return "m"; break;
    case 14: return "n"; break;
    case 15: return "o"; break;
    case 16: return "p"; break;
    case 17: return "q"; break;
    case 18: return "r"; break;
    case 19: return "s"; break;
    case 20: return "t"; break;
    case 21: return "u"; break;
    case 22: return "v"; break;
    case 23: return "w"; break;
    case 24: return "x"; break;
    case 25: return "y"; break;
    default: break;
  }
}

int main() {
  inl(N)
  Vs name(12, "");
  rep(i, 12){
    name[i] = alp(N%26);
    if (N % 26 == 0) N-=26;
    if (N < 26) break;
    N /= 26;
  }
  
  Rev(name)
  rep(i, 12){
    co(name[i])
  }
  
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();

        int x3 = 0;
        int y3 = 0;
        int x4 = 0;
        int y4 = 0;

        int xdelta = x2 - x1;
        int ydelta = y2 - y1;

        x3 = x2 - ydelta;
        y3 = y2 + xdelta;
        x4 = x3 - xdelta;
        y4 = y3 - ydelta;

        System.out.printf("%d %d %d %d",x3,y3,x4,y4);


    }
}

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

int N, C, D[35][35], c[505][505];
int S[3][35];

signed main(){
  
  cin>>N>>C;
  
  for(int i=0;i<C;i++){
    for(int j=0;j<C;j++) cin>>D[i][j];
  }
  
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++) cin>>c[i][j];
  }

  
  for(int i=0;i<N;i++){
      
    for(int j=0;j<N;j++){
      
      for(int k=0;k<C;k++){
	
	S[(i+j)%3][k] += D[c[i][j]-1][k];
	
      }
      
    }
    
  }
  
  int ans = 1e9;
  
  for(int i=0;i<C;i++){

    for(int j=0;j<C;j++){

      for(int k=0;k<C;k++){
	
	if( i == j || j == k || k == i ) continue;
	
	ans = min( ans, S[0][i] + S[1][j] + S[2][k] );
	
      }
      
    }
    
  }

  cout<<ans<<endl;
      
  return 0;
}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
 *
 * @author Y
 */
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] x = new int[n];
        int[] y = new int[n];
        String[] s = new String[n];
        
        s = br.readLine().split(" ");
        for(int i=0;i<n;i++){
            x[i] = Integer.parseInt(s[i]);
        }
        
        s = br.readLine().split(" ");
        for(int i=0;i<n;i++){
            y[i] = Integer.parseInt(s[i]);
        }
        
        for(int i = 1;i<=3;i++){
            minkowski(i,x,y);
        }
        
        int[] z = new int[n];
        double D = 0;
        for(int i = 0;i<x.length;i++){
            z[i] = Math.abs(x[i]-y[i]);
            
            D = Math.max(z[i],D);
            
        }
        System.out.println(D);
        
        
        
    }
    
    static void minkowski(int p, int[] x, int[] y){
        int n = x.length;
        double D=0;
        for(int i = 0;i<n;i++){
            D += Math.pow( Math.abs(x[i]-y[i]), p );
        }
        D = Math.pow(D,1.0/p);
        System.out.println(D);
    }
             
}

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

typedef long long ll;

void correct (int &a, int &b){
    if (a>b){
        if ((a+b)%2 != 0) {
            a = (a+b)/2;
            b = a;
            a++;
        }
        else {
            a = (a+b)/2;
            b = a;
        }
    }
    else{
        if ((a+b)%2 != 0){
            a = (a+b)/2;
            b = a+1;
        }
        else{
            a = (a+b)/2;
            b = a;
        }
    }
}

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

    string s;
    cin>>s;

    int NR = 0, NL = 0;
    int i = 0, n = (int)s.size();

    while (i<n){
        if (s[i] == 'R'){
            if (NL == 0) NR++;
            else {
                NR = 1;
                NL = 0;
            }
        }
        if (s[i] == 'L'){
            if (NL > 0) NL++;
            else if (NL == 0){
                for (int j=i;j<n;++j){
                    if (s[j] == 'L') NL++;
                    else {
                        i = j-1;
                        break;
                    }
                }
                int maxi = max(NR, NL);
                int NRR = NR, NLL = NL;

                correct(NR, NL);    

                for (int k=0;k<NRR-1;++k) cout<<"0 ";
                maxi--;
                if (maxi%2 == 0) cout<<NR<<" "<<NL<<" ";
                else cout<<NL<<" "<<NR<<" ";
                for (int k=0;k<NLL-1;++k) cout<<"0 ";
            }
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;

	vector<vector<int> > switches(m + 1, vector<int> ());
	int k;
	for (int i = 1; i <= m; ++i) {
		cin >> k;
		int s;
		for (int j = 0; j < k; ++j) {
			cin >> s;
			switches[i].push_back(s);
		}
	}

	vector<int> p(m + 1);
	for (int i = 1; i <= m; ++i) {
		cin >> p[i];
	}

	int ways = 0;
	for (int i = 0; i < (1 << n); ++i) {
		vector<int> curr(n + 1);
		for (int j = 0; j < n; ++j) {
			if (i & (1 << j)) {
				curr[j + 1] = 1;
			}
		}

		bool valid = true;
		for (int j = 1; j <= m; ++j) {
			int on = 0;
			for (int k = 0; k < switches[j].size(); ++k) {
				if (curr[switches[j][k]] == 1) {
					++on;
				}
			}

			if (on % 2 != p[j]) {
				valid = false;
				break;				
			}
		}

		if (valid) {
			++ways;
		}
	}

	cout << ways << "\n";

	return 0;

}

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

int main()
{
  int64 N, X;
  cin >> N >> X;
  int64 Line = (N - 1) * 3; 
  cout << Line - (__gcd(N, X) - 1) * 3 << endl;
}


Measured memory_bytes: 256
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int64_t i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
  ios::sync_with_stdio(NULL);
  cin.tie(NULL); cout.tie(NULL);
  int n;  cin >> n;
  cout << arr[n-1] << endl; 
  return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != t.at(i)) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
const int INF=1e9 +5;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n,k;cin>>n>>k;
    vector<int> dp(n,INF);int h[n];
    rep(i,n)cin>>h[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++)
        {   if(i-j>=0)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }  
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
//Resting_Prince
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000009
#define inf 1e18
#define PI 3.141592653589
#define fi first
#define se second 
#define sv(v) sort(all(v));reverse(all(v))
#define all(v) v.begin(),v.end()
#define rep(i,a,b)    for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define en '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ld dp[3005][3005]={0};
int main()
{   cout<<fixed<<setprecision(12);
    ll n,i,j,l,o,p;
    ld a[3005],k=0;
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    dp[0][0]=1;
    rep(i,1,n)
    {
        rep(j,0,i)
        {
            if(j==0)
            {
                dp[i][j]=dp[i-1][j]*(1-a[i-1]);
            }
            else
            {
                dp[i][j]=dp[i-1][j]*(1-a[i-1])+dp[i-1][j-1]*a[i-1];
            }
        }
    }k=0;
    rep(i,n/2+1,n)k+=dp[n][i];
    cout<<k;
    return 0;
}


Measured memory_bytes: 139264
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int A,B,x1,x2,x3,x4,x5,count;
  cin >> A>>B;
  
  for(int i=0;i<(B-A+1);i++) 
  {
  
  	x1=(A+i)/10000;
  	x2=((A+i)-(x1*10000))/1000;
  	x3=((A+i)-(x1*10000)-(x2*1000))/100;
  	x4=((A+i)-(x1*10000)-(x2*1000)-(x3*100))/10;
  	x5=(A+i)-(x1*10000)-(x2*1000)-(x3*100)-x2*10;
  	
  if ((x1==x5)&&(x2==x4)) count++;
  }
	cout<<count<<endl;
 }
	

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    
    while(1) {
        C -= B;
        if (C <= 0){
            cout << "Yes" << endl;
            break;   
        }
        A -= D;
        if (A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}


Measured memory_bytes: 3620
A,B,C,D=map(int,input().split())

flag_T=False
flag_A=False

while flag_T==False and flag_A==False:
  C=C-B
  if C<=0:
    flag_T=True
  A=A-D
  if A<=0:
    flag_A=True
  
if flag_T==True:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9120
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pll pair < ll , ll >
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ld long double
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;


int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map < string , int > mp;
    for( int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size();
}


Measured memory_bytes: 19188
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long X = input.nextLong();
		long GCD = Math.abs(X-input.nextLong());
		for (long i = 1; i < N; i++) {
			long x = Math.abs(X-input.nextLong());
			GCD=GCD(GCD,x);
		}
		System.out.println(GCD);
	}
	public static long GCD(long a, long b) {
		if (a==0) return b;
		if (b==0) return a;
		if (a==b) return a;
		if (a>b) return GCD(a%b,b);
		return GCD(b%a,a);
	}
}

Measured memory_bytes: 48492
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var i = 0;
            while ((1 << i) <= N) i++;

            Console.WriteLine(1 << (i - 1));
        }
    }
}


Measured memory_bytes: 27516
#include<stdio.h>
long long MIN(long long a,long long b){return a<b?a:b;}
int main(){
  long long n,m,d;
  scanf("%lld %lld %lld",&n,&m,&d);
  if(n<0)n=-n;
  if(n/d>m){
    printf("%lld\n",n-(m*d));
    return 0;
  }
  m-=n/d;
  n%=d;//printf("%lld %lld\n",d,n);
  printf("%lld\n",m%2?d-n:n);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    ll h, w;
    cin >> h >> w;

    if (w == 0){
        cout << 0 << endl;
        return 0;
    }

    if (h == 1 || w == 1){
        cout << 1 << endl;
        return 0;
    }

    else{
        cout << (h*w+1) / 2 << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    uint32 N;
    cin >> N;

    uint32 ans = 0;
    for(uint32 i=0; i<N; i++){
        uint32 l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;

    return;
}



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

int main(){
    unsigned long long a,b,c;
    unsigned long long h_a,h_b,h_c,cnt=0;

    cin>>a>>b>>c;
    while(!(a&1) && !(b&1) && !(c&1)){
        if(a==b&&b==c){
            cout<<-1<<endl;
            return 0;
        }
        h_a=a/2;
        h_b=b/2;
        h_c=c/2;
        a=h_b+h_c;
        b=h_a+h_c;
        c=h_a+h_b;
        cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include<queue>

using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

int main(){
    string s;
    cin >> s;

    ll len = s.size();
    ll res = len;
    for(ll i = 1; i < len; ++i){
        if(s[i-1] == s[i])continue;
        if(i > len-i)res = min(i, res);
        else res = min(len-i, res);
    }
    cout << res << endl;
}

Measured memory_bytes: 512
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();

    os.println(search(s));

  }
  private static long search(String s) {

    int n = s.length();

    long sum = 0;
    int j = 0;
    while (0 <= j &&j < n){

      if (s.charAt(j) != 'A') {
        j = s.indexOf("A", j + 1);
        continue;
      }

      // for each, find A
      // found A

      int aCount = 0;
      int i = j;
      while (i < n && (s.charAt(i) == 'A' || i < n - 1 && (s.charAt(i) == 'B' && s.charAt(i + 1) == 'C'))) {
        if (s.charAt(i) == 'A') {
          aCount++;
          i++;
        } else {
          sum += aCount;
          i += 2;
        }
      }
      j = i;
    }
    return sum;
  }
//  private static long search(String s) {
//
//    s = s.replaceAll("BC", "D");
//
//    int n = s.length();
//
//    long sum = 0;
//    int j = 0;
//    while (j < n){
//
//      if (s.charAt(j) != 'A') {
//        j++;
//        continue;
//      }
//
//      // for each, find A
//      // found A
//
//      int aCount = 0;
//      int i = j;
//      while (i < n && (s.charAt(i) == 'A' || s.charAt(i) == 'D')) {
//        if (s.charAt(i) == 'A') {
//          aCount++;
//        }
//        if (s.charAt(i) == 'D') {
//          sum += aCount;
//        }
//        i++;
//      }
//      j = i;
//    }
//    return sum;
//  }
}

Measured memory_bytes: 26500
n, l=map(int, input().split())
ans=0
if l>=0:
    for i in range(2, n+1):
        ans=ans+l+i-1
else:
    if n+l>=1:
        for i in range(1, n+1):
            if not l+i-1==0:
                ans=ans+l+i-1
    else:
        for i in range(1, n):
            ans=ans+l+i-1

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define max1 1000005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
typedef pair<ll,ll> pr;
#define rte cout<<"Correct";exit(0);
int intlog(double x) {
    return (int)(log(x) / log(2));
}
double max(double x,double y)
{
    if(x>=y)
    {
        return x;
    }
    else
    {
        return y;
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  ll ans=inf;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
        ll l=i,r=n/i;
        ans=min(ans,l+r-2);
    }
  }
  cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <stdio.h>

#define NUM_ALPHABETS 26

int main(void) { 
  char ch;
  int count[NUM_ALPHABETS] = {}, num_alph;
  while ( scanf("%c" , &ch) != EOF ) {
    if( 'A' <= ch && ch <= 'Z' )  num_alph = ch - 'A';
    else if( 'a' <= ch && ch <= 'z' )  num_alph = ch - 'a';
    else continue;
    count[num_alph]++;
  }
  for( num_alph = 'a' ; num_alph  <= 'z' ; num_alph++ ) {
    printf("%c : %d\n", num_alph, count[num_alph - 'a'] );
  }
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int x;
    cin >> x;
    int ans = 1;
    while(true){
        if(x*ans%360 == 0){
            break;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
	int n;
	int a[100100]={0};
	int i;
	int h,flg,tmp;
	int l,r;
	int del=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	h=n;
	flg=0;
	while(h>1||flg){
		if(h>1) h=h/1.3;
		if(h==10||h==9) h=11;
		flg=0;
		for(i=0;i<n-h;i++){
			if(a[i]>a[i+h]){
				tmp=a[i];
				a[i]=a[i+h];
				a[i+h]=tmp;
				flg=1;
			}
		}
	}
	l=-1;r=n;
	while(r-l>2){
		l++;r--;
		while(r-l>2&&a[l]!=a[l+1]) l++;
		while(r-l>2&&a[r]!=a[r-1]) r--;
		if(a[l]==a[l+1]||a[r]==a[r-1]){
			del+=2;
		}
	}
	printf("%d\n",n-del);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define INF LLONG_MAX
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin >> n >> k;
    vint a(n + 1);
    fr(i, 0, n)
    {
        cin >> a[i + 1];
    }
    int now = 0, node = 1, ans = -1;
    vint vis(n + 1, 0), le(n + 1, 0);
    while (vis[node] == 0)
    {
        if (now == k)
        {
            ans = node;
        }
        vis[node] = 1;
        le[node] = now;
        node = a[node];
        now++;
    }
    if (ans == -1)
    {
        vint c;
        k -= le[node];
        c.pb(node);
        int ch = a[node];
        while (node != ch)
        {
            c.pb(ch);
            ch = a[ch];
        }
        k = k % sz(c);
        ans = c[k];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6448
#include <iostream>

using namespace std;

int main() {
    int a;
    int max = 0;
    int min = 1000;
    int N;
    cin >> N;
    int i;
    for (i=0; i<N; i++) {
        cin >> a;
        if (a>=max) {
            max = a;
        }
        if (a<=min) {
            min = a;
        }
    }
    int minDistance = max - min;
    cout << minDistance << "\n";
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,W = map(int,input().split())
wv = [list(map(int,input().split())) for i in range(N)]
f_max = 10**9+100 

dp = [[f_max] * (10**5 +100) for _ in range(N+1)]
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
def chmax(a,b):
    if a < b:
        return b
    else:
        return a
def main():
    # 初期条件
    dp[0][0]=0
    for i in range(1,N+1):
        w,v = wv[i-1][0], wv[i-1][1]
        for sum_v in range(10**5+1):
            if sum_v - v >= 0:
                dp[i][sum_v] = chmin(dp[i][sum_v], dp[i-1][sum_v-v]+ w)
            
            dp[i][sum_v] = chmin(dp[i][sum_v],dp[i-1][sum_v])
    
    ans = 0
    for i in range(10**5+100):
        if dp[N][i] <= W:
            ans = i
    
    print(ans)  

            
 

if __name__ == "__main__":
    main()

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

int main()
{ int n;
 int a[10000];
 int b[10000];
 int k=0;int l=0;
cin>>n;
 
 for (int i=0;i<n;i++) 
   cin>>a[i];
 
  for (int i=0;i<n;i++)
     cin>>b[i];
for (int i=0;i<n;i++)
{
  for (int j=0;j< n-i-1;j++)
  { if (a[j]>a[j+1])
    {  a[j] = a[j] * a[j+1]; // x now becomes 15 
    a[j+1] = a[j] / a[j+1]; // y becomes 10 
    a[j] = a[j] / a[j+1]; 
     
     b[j] = b[j] * b[j+1]; // x now becomes 15 
    b[j+1] = b[j] / b[j+1]; // y becomes 10 
    b[j] = b[j] / b[j+1]; 
     }
   }


}
 for (int i=0;i<n;i++)
 { if (a[i]>b[i])
     {k+=a[i];l+=b[i]; }
    else 
      continue;
  
 
 
 
 }
cout<<k-l;
return 0;


}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    int n, m; cin >> n >> m;
    vector<P> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;

    sort(all(a));

    priority_queue<int, vector<int>, less<int>> q;
    int jud = 0;
    ll ans = 0;

    for(int i = 1; i <= m; i++){

        while((a[jud].first <= i)){
            q.push(a[jud].second);
            jud++;
        }

        if(!q.empty()){
            ans += q.top();
            q.pop();
        }

    }

    cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
	}

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

	for(int i=0;i<N-1;i++){
		if(A.at(i) == A.at(i+1)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 1024
# AGC030A - Poisonous Cookies
def main():
    a, b, c = list(map(int, input().rstrip().split()))
    if c > b:
        print(b * 2 + 1 + min(a, c - b - 1))
    else:
        print(b + c)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
from itertools import combinations


def solve(n, k):
    max = (n - 1) * (n - 2) // 2
    if max < k:
        print('-1')
        return
    edge = (n * (n - 1)) // 2 - k
    print(edge)
    ind = 1
    for i, j in combinations([i + 1 for i in range(n)], 2):
        print(i, j)
        ind += 1
        if ind > edge:
            break


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


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

int		main(void)
{
	string S;
	string T;
	int s_len, t_len;
	int idx;

	cin >> S;
	cin >> T;
	s_len = S.length();
	t_len = T.length();

	idx = 0;
	while (idx < s_len)
	{
		if (S[idx] != T[idx])
		{
			cout << "No" << endl;
			return (0);
		}
		idx++;
	}
	cout << "Yes" << endl;

	return (0);
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using std::cout;
using std::cin;
using std::endl;

int main()
{
    char str[1201], c;
    int i;
    for (i = 0; i < 1200; i++)
    {
        c = getchar();
        if (c=='\n')
        {
            str[i] = c;
            break;
        }
        else if (islower(c))
            str[i] = std::toupper(c);
        else if (isupper(c))
            str[i] = std::tolower(c);
        else
        {
            str[i] = c;
        }
    }

    i = 0;
    while (str[i]!='\n')
    {

        
        cout<<str[i]<<std::flush;

        i++;
        
    }

    cout<<endl;
    
    return 0;
}


Measured memory_bytes: 3084