akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	int A[10],ans=0,i;
	for(i=0; i<3; i++){
		scanf("%d",&A[i]);
	}
	if(A[0]<=A[1] && A[0]<=A[2]){
		if(A[1]<=A[2])
			ans+=A[2]-A[0];
		else
			ans+=A[1]-A[0];
	}
	else if(A[1]<=A[0] && A[1]<=A[2]){
		if(A[0]<=A[2])
			ans+=A[2]-A[1];
		else
			ans+=A[0]-A[1];
	}
	else{
		if(A[0]<=A[1])
			ans+=A[1]-A[2];
		else
			ans+=A[0]-A[2];
	}
	
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>
#include <bitset>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define INF 2147483600
const int V=200010;
using P=pair<int,int>;
vector<P> G[V];
int dist[V];
bool used[V];
void dijkstra(int s){
  fill_n(dist,V,INF);
  fill_n(used,V,false);
  priority_queue<P,vector<P>,greater<P>> q;
  q.push(P(0,s));
  while(!q.empty()){
    int d; int t;
    tie(d,t)=q.top();q.pop();
    if(used[t])continue;
    used[t]=true;dist[t]=d;
    for(P e: G[t]){
      if(dist[e.second]<=d+e.first)continue;
      q.push(P(d+e.first,e.second));
    }
  }
}

inline ll read(){
  ll ans=0,c=getchar_unlocked();
  while(c<'0'||c>'9')c=getchar_unlocked();
  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}
  return ans;
}
int main(){
  ll n,m,a,b;
  n=read();m=read();
  rep(i,m){
    a=read();b=read();
    G[a].emplace_back(1,b);
    G[b].emplace_back(1,a);
  }
  dijkstra(1);
  if(dist[n]<=2){
    printf("POSSIBLE\n");
  }else{
    printf("IMPOSSIBLE\n");
  }
  return 0;
}

Measured memory_bytes: 15208
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    string s;
    int k;
    cin >> k >> s;
    if(s.size() > k){
        rep(i, k) cout << s[i];
        cout << "..." << endl;
    }else cout << s << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		while(true){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			int[] num = new int[n];
			for(int i=0;i<n;i++){
				num[i] = scan.nextInt();
			}
			
			int max=num[0];
			int sum=num[0];
			
			for(int i=1;i<n;i++){
				sum = Math.max(sum+num[i],num[i]);
				max = Math.max(sum,max);
			}
			
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 26432
S = input()
K = int(input())

C = []
c = 0
s = S[0]
for i in range(len(S)):
    if S[i] == s:
        c += 1
    else:
        C.append(c)
        c = 1
        s = S[i]
C.append(c)

ans = 0
if S[0]!=S[-1]:
    for c in C:
        ans += (c//2)*K
else:
    if S == S[0]*len(S):
        ans = (len(S)*K)//2
    else:
        for i in range(1,len(C)-1):
            ans += K*(C[i]//2)
        ans += (K-1)*((C[0]+C[-1])//2)+C[0]//2+C[-1]//2
print(ans)

Measured memory_bytes: 38704
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
   int k;
   cin >> k; 

   int sum = 0;
   for(int a=1;a<=k;a++){
       for(int b=1;b<=k;b++){
           for(int c=1;c<=k;c++){
               int max;
               max = __gcd(a,__gcd(b,c));
               sum += max;
           }
       }
   }
   cout << sum << endl;
}

Measured memory_bytes: 3592
import java.util.Scanner;


public class Main {

	private static int[] value = new int[10];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		for(int i=0;i<n;i++){
			for(int j=0;j<10;j++){
				value[j] = sc.nextInt();
			}

			System.out.println(dfs(0,0,0));
		}
	}

	@SuppressWarnings("unused")
	private static String dfs(int left,int right,int i){
		if(i == 10) return "YES";
		if(left < value[i])
		{
			return dfs(value[i],right,i+1);
		}
		if(right < value[i])
		{
			return dfs(left,value[i],i+1);
		}

		return  "NO";
	}
}

Measured memory_bytes: 18412
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	UL A[300][600];

	void Solve(){
		UL N; cin >> N;
		rep(y, N) rep(x, N) {
			char c; cin >> c;
			A[x][y + N] = A[x][y] = (UL)c;
		}
		UL ans = 0;
		rep(i, N) {
			bool ok = true;
			rep(y, N) rep(x, N) {
				if (A[x][y + i] != A[y][x + i]) ok = false;
			}
			if (ok) ans++;
		}
		cout << (ans * N) << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)


int main(){
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    int tmp;
    if(X > Y){
        tmp = Y*C*2 + (X-Y)*A;
    }else{
        tmp = X*C*2 + (Y-X)*B;
    }
    cout << min(min(A*X + B*Y, max(X,Y)*C*2),tmp) << endl;
    //cout <<  (flag ? "Yes" : "No") << endl;
}


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

int main()
{
    ll a,b,t,i;
    char s[1000];
    cin>>s;
    a=strlen(s);

        if(s[a-1]=='s'){cout<<s;cout<<"es";}
        else {cout<<s;cout<<"s";}


}

Measured memory_bytes: 3632
n,m = gets.chomp.split(" ").map(&:to_i)
array = []

(1..n).each do
  local_array = gets.chomp.split(" ").map(&:to_i)
  local_array.delete_at(0)
  array.push(local_array.sort)
end

flag = Array.new(array[0].length, true)
cnt = array[0].length

array[0].each_with_index do |number,idx|
  array.each do |array|
    if !array.include?(number)
        cnt -= 1
        break
    end
  end
end

puts cnt

Measured memory_bytes: 3836
# include <iostream>
# include <string>
using namespace std;
int main()
{
    string O, E;
    string ans = "";
    cin >> O >> E;
    for (int i = 0; i < min(O.size(), E.size()); ++i)
    {
        ans = ans + O[i] + E[i];
    }
    if (O.size() > E.size())
        ans = ans + O[O.size() - 1];
    else if (O.size() < E.size())
        ans = ans + E[E.size() - 1];
    cout << ans;
}

Measured memory_bytes: 256
A, B, N = map(int, input().split())

if N < B:
    ans = ((A*N)//B) - A*(N//B)
elif B <= N < 2*B:
    ans = max((((A*N)//B) - A*(N//B)), (((A*(B-1))//B) - A*((B-1)//B)))
elif 2*B <= N:
    ans = max((((A*(B-1))//B) - A*((B-1)//B)), (((A*(2*B-1))//B) - A*((2*B-1)//B)), (((A*(3*B-1))//B) - A*((3*B-1)//B)))

print(ans)

Measured memory_bytes: 9236
import java.util.*;

class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double A = sc.nextInt();
		double B = sc.nextInt();
		double H = sc.nextInt();
		double M = sc.nextInt();
		
		double radH = 2*Math.PI*(H/12 + M/60/12);
		double radM = 2*Math.PI* M/60;
		double x1 = (double)A*Math.cos(radH), y1 = A*Math.sin(radH);
		double x2 = (double)B*Math.cos(radM), y2 = B*Math.sin(radM);
		double dx = x1 - x2, dy = y1- y2;
		double ansans = Math.pow(dx, 2) + Math.pow(dy,2);
		double ans = Math.sqrt(ansans);
		System.out.print(ans);
		
	}

}




Measured memory_bytes: 36132
N = int(input())
mod = 10**9+7
li = [0] * 1001
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if N ==1:
    print(1)
else:
    ans = 1
    for i in range(2,N+1):
        arr = factorization(i)
        n = len(arr)
        for j in range(n):
            x = arr[j][0]
            y = arr[j][1]
            li[x] += y
    for i in range(2,1000):
        k = li[i]+1
        ans = ans * k % mod
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	ll N, max = 0;
	cin >> N;

	vector<string> s(N);

	for (ll i = 0; i < N; i++)
	{
		cin >> s[i];
	}

	ll M = 0;
	vector<string> t(M);
	cin >> M;

	for (ll i = 0; i < M; i++)
	{
		string temp;
		cin >> temp;
		s.push_back(temp);
	}
	
	for (ll i = 0; i < M + N; i++)
	{
		ll cnt = 0;

		for (ll k = 0; k < N + M; k++) {
			if (s[i] == s[k]) {
				if (k < N) {
					cnt++;
				}
				else {
					cnt--;
				}
			}
		}

		if (cnt > max)
			max = cnt;
	}

	cout << max << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();
        if ((a * b) % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}


Measured memory_bytes: 21716
#include <stdio.h>

int main() {
    int x, a, b, distanceA, distanceB;
    scanf("%d %d %d", &x, &a, &b);

    //calculate the distance of A
    if (x > a)
    {
        distanceA = x - a;
    }else
    {
        distanceA = a - x;
    }
    
    //calculate the distance of B
    if (x > b)
    {
        distanceB = x - b;
    }else
    {
        distanceB = b - x;
    }
    
    //print the closest store
    if (distanceA < distanceB)
    {
        printf("A\n");
    }
    else
    {
        printf("B\n");
    }
    

    return 0;
}

Measured memory_bytes: 1592
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#define rep(i, n) for (int i=0;i<n;i++);
using namespace std;
typedef long long ll;

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

    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    for (int i = 0; i < N; i++) cin >> Q[i];

    if(P>Q) swap(P, Q);

    int cnt = 0;
    while(P < Q){
        next_permutation(P.begin(), P.end());
        cnt++;
    }

    cout << cnt << endl;
}

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

int main() {
	int x, y;
	cin >> x >> y;
	if (y % 2 == 1) {
		cout << "No\n";
	}
	else {
		bool flag = false;
		for (int i=0;i<=x;i++) {
			if (i * 2 + 4 * (x - i) == y) {
				cout << "Yes\n";
				flag = true;
				break;
			}
		}
		if (!flag) cout << "No\n";
	}
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<pair<ll, ll>> vs;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		vs.emplace_back(A + B, A);
	}
	sort(vs.rbegin(), vs.rend());
	ll res = 0, t = 1;
	for (auto p : vs) {
		res += t ? p.second : -(p.first - p.second);
		t ^= 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include<bits/stdc++.h>
typedef long long int ll;
const int maxn=1e6+7;
using namespace std;
//四步走，
//确定状态 1、最后一步2、化成子问题
//转移方程
//初始条件和边界情况
//计算顺序，确保要用到的都算过
int main()
{
   string ch;
   cin>>ch;
   int flag;
   if(ch=="SSS")
    flag=0;
   if(ch=="SSR"||ch=="SRS"||ch=="RSS"||ch=="RSR")
   flag=1;
   if(ch=="RRS"||ch=="SRR")
    flag=2;
   if(ch=="RRR")
    flag=3;
   printf("%d\n",flag);
    return 0;
}

Measured memory_bytes: 3720
/************************************************
*Author        :  Modesty
*Created Time  :  2019.11.07.08:36
*Mail          :  modestyscholarly@gmail.com
*Problem       :  pyramid
************************************************/
#include<bits/stdc++.h>
using namespace std;
const int maxn=1000005;
int n,a[maxn];
int read()
{
	int s=0,f=1;
	char ch=getchar();
	while (!isdigit(ch))
	{
		if (ch==45) 
		{
			f=-1;
		}
		ch=getchar();
	}
	while (isdigit(ch))
	{
		s=s*10+ch-48; 
		ch=getchar(); 
	}
	return s*f; 
}
bool check(int k)
{
	if ((a[n-1]<=k&&a[n]<=k)||(a[n]<=k&&a[n+1]<=k))
	{
		return 1;
	}
	if ((a[n-1]>k&&a[n]>k)||(a[n]>k&&a[n+1]>k))
	{
		return 0;
	}
	for (int i=1;i<n-1;i++)
	{
		if ((a[n+i]<=k&&a[n+i+1]<=k)||(a[n-i]<=k&&a[n-i-1]<=k))
		{
			return 1;
		}
		if ((a[n+i]>k&&a[n+i+1]>k)||(a[n-i]>k&&a[n-i-1]>k))
		{
			return 0;
		}
	}
	return a[1]<=k;
}
int main()
{
//	freopen("pyramid.in","r",stdin);
//	freopen("pyramid.out","w",stdout);
	cin>>n;
	for (int i=1;i<n*2;i++)
	{
		a[i]=read();
	}
	int l=1,r=n*2-1;
	while (l<r)
	{
		int mid=(l+r)>>1;
		if (check(mid))
		{
			r=mid;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

//#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

int g(int a, int b, int op){
    if(op == 0)return a + b;
    if(op == 1)return a - b;
    if(op == 2)return a * b;
    return 0;
}

bool f(vi d){
    string s = "+-*";
    rep(i,3)rep(j,3)rep(k,3){
        if(g(g(g(d[0],d[1],i),d[2],j),d[3],k) == 10){
            printf("(((%d %c %d) %c %d) %c %d)\n", d[0], s[i], d[1], s[j], d[2], s[k], d[3]);
            return true;
        }
        if(g(g(d[0],d[1],i),g(d[2],d[3],k), j) == 10){
            printf("((%d %c %d) %c (%d %c %d))\n", d[0], s[i], d[1], s[j], d[2], s[k], d[3]);
            return true;
        }
        if(g(g(d[0],g(d[1],d[2],j),i),d[3],k) == 10){
            printf("((%d %c (%d %c %d)) %c %d)\n", d[0], s[i], d[1], s[j], d[2], s[k], d[3]);
            return true;
        }
    }
    return false;
}

signed main(void) {
    vi v(4);
    while(1){
        rep(i,4)cin >> v[i];
        sort(all(v));
        if(v.back() == 0)break;
        bool ans = true;
        do{
            if(f(v)){
                ans = false;
                break;
            }
        }while(next_permutation(all(v)));
        if(ans)cout << 0 << endl;
    }
}



Measured memory_bytes: 3332
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

int N; int a[MAXN+1]; 
struct Seg{
	int mx[MAXN<<2];
	inline void build(int rt,int l,int r){
		mx[rt]=-1; if(l==r) return ; int mid=(l+r)>>1;
		build(rt<<1,l,mid); build(rt<<1|1,mid+1,r); 
	}
	inline int Query(int rt,int l,int r,int L,int R){
		if(L<=l&&R>=r) return mx[rt]; int mid=(l+r)>>1,ans=-1;
		if(L<=mid) ans=max(ans,Query(rt<<1,l,mid,L,R));
		if(R>mid) ans=max(ans,Query(rt<<1|1,mid+1,r,L,R)); return ans;
	}
	inline void Set(int rt,int l,int r,int k,int n){
		if(l==r) { mx[rt]=n; return ; } int mid=(l+r)>>1;
		if(k<=mid) Set(rt<<1,l,mid,k,n); else Set(rt<<1|1,mid+1,r,k,n);
		mx[rt]=max(mx[rt<<1],mx[rt<<1|1]);
	}
}T0,T1;
int N1;
inline bool Check(int lv,int c){
	if(c<0) return 0;
	if(c&1) return (T1.Query(1,1,N1,lv,N1)>=c);
	else return (T0.Query(1,1,N1,lv,N1)>=c);
} int val[MAXN+1],mx;
int q[MAXN+1],mxa,mxb,la,lb,lena,lenb;
char s[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); N1=N+1; int Sum=0;
	for(int i=1;i<=N;i++) {
		val[i]=1; a[i]=read(); mx=max(mx,a[i]);
		if(mx==a[i]) val[i]=2,++Sum;
		q[i]=Sum;
	} T0.build(1,1,N1); T1.build(1,1,N1);
	T0.Set(1,1,N1,N1,0);
	for(int i=N;i>=1;i--){
		int x0=T0.Query(1,1,N1,a[i],N1),x1=T1.Query(1,1,N1,a[i],N1);
		if(val[i]==1){
			if(x0!=-1) T1.Set(1,1,N1,a[i],x0+1); 
			if(x1!=-1) T0.Set(1,1,N1,a[i],x1+1);
		} else{
			if(x1!=-1) T1.Set(1,1,N1,a[i],x1+2); 
			if(x0!=-1) T0.Set(1,1,N1,a[i],x0+2);
		}
	} for(int i=1;i<=N;i++) q[i]=Sum-q[i];
	if((Sum&1)&&T1.Query(1,1,N1,1,N1)==-1){ puts("-1"); return 0;}
	for(int i=1;i<=N;i++){
		T0.Set(1,1,N1,a[i],0); T1.Set(1,1,N1,a[i],-1);
		int tma=max(mxa,a[i]),tmb=max(mxb,a[i]),la=lena,lb=lenb;
		if(tma==a[i]) ++la;
		if(Check(mxb,la+q[i]-lb)||Check(tma,lb+q[i]-la)) {
			s[i]='0'; lena=la; lenb=lb; mxa=tma;
		} else{
			la=lena,lb=lenb; if(tmb==a[i]) ++lb; lena=la; lenb=lb; mxb=tmb;
			s[i]='1';
		}
	} if(lena!=lenb){
		puts("-1"); return 0;
	} puts(s+1);
	return 0;
}

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

signed main() {

  string S, T;
  cin >> S >> T;

  if(T.compare(0, S.size(), S) == 0 && T[T.size() - 1] >= 'a' && T[T.size() - 1] <= 'z' ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int N;
int ans = 0;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int l,r;
        scanf("%d%d",&l,&r);
        ans += r - l + 1;
    }
    printf("%d\n",ans);
    return 0;
}


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

using namespace std;

class Solver{};

int main() {
	vector<bool> is_prime(10000005, true);
	vector<int> primes;
	for (int i = 2; i < is_prime.size(); i++) {
		if (!is_prime[i])continue;

		primes.emplace_back(i);
		for (int j = 2; i * j < is_prime.size(); j++) {
			is_prime[i * j] = false;
		}
	}

	vector<int> vals;
	for (int i = 3; i < primes.size(); i++) {
		if (primes[i - 1] == primes[i] - 2
			&& primes[i - 2] == primes[i] - 6
			&& primes[i - 3] == primes[i] - 8) {
			vals.emplace_back(primes[i]);
		}
	}

	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		int bottom = 0;
		int top = vals.size();
		while (bottom + 1 < top) {
			int mid = (bottom + top) / 2;
			if (vals[mid] <= n)bottom = mid;
			else top = mid;
		}

		cout << vals[bottom] << endl;
	}
}


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

int main() {
    long long int A, B;
    cin >> A >> B;
    if (A < B) {
        swap(A, B);
    }
    if ((A - B) % 2 == 1) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << A - (A - B) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
'use strict';
(function(stdin) {
  //declare function
  function indexCards(array) {
    var a = array[0];
    var num = Number(array[1]);
    allCards[a].some(function(v, i) {
      if (v === num) {
        return allCards[a].splice(i, 1);
      }
    });
  }

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var thereCards = inputs.map(function(v) {
    return v.split(' ');
  }).slice(1);
  var mark = ['S', 'H', 'C', 'D'];
  var allCards = {
    'S': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    'H': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    'C': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
    'D': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
  };
  var output = [];

  //main
  thereCards.map(indexCards);
  for (mark in allCards) {
    allCards[mark].map(function(v) {
      output.push(mark + ' ' + v);
    });
  }
  // console.log(allCards);
  if (output.length > 0) {
    console.log(output.join('\n'));
  }
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
	int ans;
	int N,K,X,Y;
	cin >> N>>K>>X>>Y;
	if(N<K){
		ans = N*X;
	}
	else{
		ans = K*X + (N-K)*Y;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,i,j;
    int A[100001];
    int B[100001];
    scanf("%d",&N);
    for(i = 1 ; i <= N ; i++){
        scanf("%d",&A[i]);
    }
    for(i = 1 ; i <= N ; i++){ //出席番号
        B[A[i]] = i;
    }
    for(j = 1 ; j <= N ; j++){
        printf("%d ",B[j]);
    }
    return 0;
}

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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int q;
    cin >> q;
    loop(q,i) {
        int n;
        cin >> n;
        int org = n;
        int ans = 0;
        while (n > 10) {
            string s = to_string(n);
            int m = 0;
            loop(s.size()-1, j) {
                int f = stoi(s.substr(0,j+1));
                int l = stoi(s.substr(j+1));
                //cout << j << ':' << f << ' ' << l << " = " <<  f*l << endl;
                m = max(m, f*l);
            }
            n = m;
            if (n == org) {
                ans = -1;
                break;
            }
            //cout << '=' << n << endl;
            ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3280
#include <iostream>
#include <string>
#include <algorithm>
#include <limits.h>
using namespace std;

int main(void){
    int n, m, a, b;
    int x[200020], y[200020], xlng = 0, ylng = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        if (a == 1) {
            x[xlng] = b;  xlng++;
        }
        if (b == n) {
            y[ylng] = a;  ylng++;
        }
    }
    
    sort(x, x + xlng);  sort(y, y + ylng);
    
    int i = 0, j = 0;
    while (i != xlng && j != ylng) {
        if (x[i] == y[j]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        if (x[i] < y[j]) i++;
        if (x[i] > y[j]) j++;
    }
    cout << "IMPOSSIBLE" << endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;


int solve(int inp) {
    return std::pow(inp, 3);
}

int main() {
    int n;
    cin >> n;
   // string str;
    //cin >> str;
    cout << solve(n);
//    vector<string> res = problems::solve(str);
//    cout << res.size() << endl;
//    for (int i = 0; i < res.size(); ++i) {
//        cout << res[i] << ' ';
//    }
    
    return 0;
}


Measured memory_bytes: 256
import sys

a, b = map(int, sys.stdin.readline().split())


def check(x):
    if x % 4 == 0:
        return x
    elif x % 2 == 0:
        return x + 1
    elif (x+1)/2 % 2 == 0:
        return 0
    else:
        return 1


a = check(a-1)
b = check(b)
print(a ^ b)


Measured memory_bytes: 2940
X, K, D = map(int, input().split())
X = abs(X)
if K > X / D:
    if X % D == 0:
        if (K - X // D) % 2 == 0:
            ans = 0
        else:
            ans = D
    elif (K - int(X / D)) % 2 == 0:
        ans = X % D
    else:
        ans = D - X % D
else:
    ans = X - D * K
print(ans)

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int a,b,h;
  cin >> a>>b>>h;
  cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B, N;
    cin >> A >> B >> N;

    ll q = min(B - 1, N);
    cout << (q * A) / B << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

template<typename value_type>
class fast_combination
{
public:
	value_type mod_value;

	vector<value_type> mod_inv;
	vector<value_type> fact;
	vector<value_type> fact_inv;

public:
	fast_combination(const value_type& limit, const value_type& m)
		: mod_value(m), mod_inv(), fact(), fact_inv()
	{
		mod_inv.assign(limit + 1, 0);
		fact.assign(limit + 1, 0);
		fact_inv.assign(limit + 1, 0);

		mod_inv[1] = 1;
		fact[0] = 1;
		fact[1] = 1;
		fact_inv[0] = 1;
		fact_inv[1] = 1;

		for (value_type i = 2; i <= limit; i++)
		{
			mod_inv[i] = mod_value - ((mod_value / i) * mod_inv[mod_value % i] % mod_value);
			fact[i] = (fact[i - 1] * i) % mod_value;
			fact_inv[i] = (fact_inv[i - 1] * mod_inv[i]) % mod_value;
		}
	}

public:
	value_type process(const value_type& n, const value_type& r)
	{
		if (n < 0 || r < 0) return 0;
		if (n < r) return 0;
		if (n == r) return 1;

		return (fact[n] * (fact_inv[r] * fact_inv[n - r] % mod_value)) % mod_value;
	}
};

//fast_combination<long long> fc(N, MOD);
//long long result = fc.process(n, r);

const int MOD = 1e9 + 7;

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

	fast_combination<long long> fc(3e6, MOD);

	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;

	long long result = fc.process(r2 + 1 + c2 + 1, r2 + 1);
	result = (result + (MOD - fc.process(r2 + 1 + c1, c1))) % MOD;
	result = (result + (MOD - fc.process(r1 + c2 + 1, c2 + 1))) % MOD;
	result = (result + fc.process(r1 + c1, c1)) % MOD;
	cout << result;

	return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
int main(){
  map<int,int>a;
  int n;cin>>n;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(a.count(tmp)){
      if(a.at(tmp)==0){
        a.at(tmp)++;
      }
      else{
        a.at(tmp)--;
      }
    }
    else{
      a[tmp]=1;
    }
  }
  int ans=0;
  for(auto num:a){
    ans+=num.second;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 8084
N = gets.to_i
digits = N.to_s.size
min = 2 << 60
(1...(10 ** (digits / 2 + 2))).each do |n|
  if N % n == 0
    m = N / n
    d = [n.to_s.size, m.to_s.size].max
    min = d if d < min
  end
end
puts min


Measured memory_bytes: 1788
import math

l = tuple(map(int, input().split()))

ans = 0

for i in range(1, l[0]+1):
    n = i
    v0 = n % 10
    n /= 10
    v1 = n % 10
    n /= 10
    v2 = n % 10
    n /= 10
    v3 = n % 10
    n /= 10
    v4 = n % 10
    sum = math.floor(v0) + math.floor(v1) \
     + math.floor(v2) + math.floor(v3) + math.floor(v4)
    if(l[1] <= sum and sum <= l[2]):
        ans += i
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
      cout<<1;
      else if(b==0)
        cout<<2;
         else if(c==0)
        cout<<3;
         else if(d==0)
        cout<<4;
            else if(e==0)
        cout<<5;
              return 0;
}
           

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

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


Measured memory_bytes: 4052
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

var r, s, p int

func getScore(hand byte) int {
	if hand == 'r' {
		return p
	} else if hand == 's' {
		return r
	} else {
		return s
	}
}

func main() {
	n, k := readInt(), readInt()
	r, s, p = readInt(), readInt(), readInt()
	t := readBytes()

	ans := 0
	handResults := make([]byte, n)
	for i := range t {
		if i-k < 0 {
			ans += getScore(t[i])
			handResults[i] = t[i]
		} else {
			if handResults[i-k] == t[i] {
				handResults[i] = 'a'
			} else {
				ans += getScore(t[i])
				handResults[i] = t[i]
			}
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1024
#include<stdio.h>
#define NUMBER 11

int main(void)
{
  while(1){
    int matrix[NUMBER][NUMBER]={0};
    int i,j;
    int number;
  
  scanf("%d",&number);
  if( number==0 )break;
  if( number>10 )break;
  if( number<0 )break;
 
  for( i=0; i<number; i++ ){
    for( j=0; j<number; j++ ){
      scanf("%d",&matrix[i][j]);
    }
  }
  for( i=0; i<number; i++ ){
    for( j=0; j<number; j++ ){
      matrix[i][number]+=matrix[i][j];
      matrix[number][j]+=matrix[i][j];
    }
  }
 
  for( i=0; i<number; i++ ){
   matrix[number][number]+=matrix[i][number];
  }
 
  for( i=0; i<number+1; i++ ){
    for( j=0; j<number+1; j++ ){
      printf("%5d",matrix[i][j]);
    }
    puts("");
  }
}
  return 0;
}

Measured memory_bytes: 616
from sys import stdin
input = stdin.readline

# map(int, input().rstrip().split())

def VI(N, init=0):
  return [init for _ in range(N)]
def VVI(N, M, init=0):
  return [[init for _ in range(M)] for _ in range(N)]

def VD(N, init=0.0):
  return [init for _ in range(N)]
def VVD(N, M, init=0.0):
  return [[init for _ in range(M)] for _ in range(N)]

N, M, Q = map(int, input().rstrip().split())

table = VVI(N+1, N+1)

for i in range(M):
  L, R = map(int, input().rstrip().split())
  table[L][R] += 1

for i in range(1, N+1):
  for j in range(1, N+1):
    table[i][j] += (table[i][j-1] + table[i-1][j] - table[i-1][j-1])


for i in range(Q):
  p, q = map(int, input().rstrip().split())
  ma = max(p, q)
  mi = min(p, q)
  print(table[ma][ma]-table[ma][mi-1]-table[mi-1][ma]+table[mi-1][mi-1])


Measured memory_bytes: 55644
import java.io.*;
class Main {
  public static void main (String[] args) throws Exception {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s;
    while(null != (s=in.readLine()))
          print(Integer.parseInt(s));
  }
  private static void print(int n){
    int s=((int)Math.pow(n,2)+n+2)/2;
    System.out.println(s);
  }
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  int i;
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  vector<int> dis(n);
  rep(i,n)dis[i]=a[i]-b[i];
  ll disp=0;
  ll dism=0;
  int countm=0;
  sort(all(dis));
  reverse(all(dis));
  rep(i,n)
  {
    if(dis[i]>=0)disp+=dis[i];
    else
    {
      dism+=dis[i];
      countm++;
    }
  }
  if(disp+dism<0)cout<<-1<<endl;
  else
  {
    int now=0;
    while(dism<0)
    {
      dism+=dis[now];
      now++;
    }
    cout<<now+countm<<endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {
  int X,Y;
  bool ans=false;
  cin >> X >> Y;

rep(i,51){
  rep(j,26){
    if(i+j!=X) continue;

    if(i*2+j*4==Y) ans=true;

  }
}

if(ans) cout << "Yes" << endl;

else cout << "No" << endl;

return 0;

}

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

int main() {
  int n,count=0; cin >>n;
  vector<int> p(n);
  rep (i,n) cin>>p[i];
  for(int i=1;i<n-1;i++) {
    if ((p[i]>p[i-1] && p[i]<p[i+1]) || (p[i]>p[i+1] && p[i]<p[i-1])) count++;
        }
  cout << count << endl;
}

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

using namespace std;
using ll = long long;


bool flag[111111];
ll v[111111];
ll c[111111];
vector<ll> n[111111];
ll cnt = 0;


void dfs(int node) {
  if (flag[node])
    return;
  flag[node] = true;
  for (int i = 0; i < n[node].size(); i++)
    dfs(n[node][i]);
  v[node] = c[cnt++];
}

int main() {
  ll N;
  cin >> N;
  for (int i = 0; i < N - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    n[a].push_back(b);
    n[b].push_back(a);
  }
  ll s = 0;
  for (int i = 0; i < N; ++i) {
    cin >> c[i];
    s += c[i];
  }
  sort(c, c + N);
  s -= c[N - 1];
  cout << s << endl;

  dfs(0);
  for (int i = 0; i < N; ++i) {
    cout << v[i] << " ";
  }
  cout << endl;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

bool flag=false;
int res;

int DFS(vector<int> c,int t){
	if(flag) return res;
	if(c.size()==1){
		flag=true;
		return c[0];
	}
	if(c[0]==t&&c.back()==t) return DFS(c,(t+1)%2);
	if(c[0]!=t&&c[1]==t) return DFS(vector<int>(c.begin()+1,c.end()),(t+1)%2);
	if(c.back()!=t&&c[c.size()-2]==t) return DFS(vector<int>(c.begin(),c.end()-1),(t+1)%2);
}

void Solve(){
	string s; cin >> s;
	vector<int> c;
	rep(i,0,s.size()){
		if(i==0||s[i]!=s[i-1]){
			if(s[i]=='o') c.push_back(0);
			else c.push_back(1);
		} 
	}

	res=DFS(c,0);
	if(res==0) cout << 'o' << endl;
	else cout << 'x' << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1208
N = int(input())
cnt = 0
A = []
B = []
C = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append((b-a)%b) 
cnt = C[-1]
for i in range(-2,-N-1,-1):
    C[i] = (C[i]-cnt)%B[i]
    cnt += C[i]
print(cnt)

Measured memory_bytes: 14976
import heapq

x,y,a,b,c = map(int,input().split())
p = sorted(list(map(int,input().split())))
q = sorted(list(map(int,input().split())))
r = sorted(list(map(int,input().split())))
pp=p[a-x:a]
qq=q[b-y:b]
heapq.heapify(pp)
heapq.heapify(qq)
for i in range(c):
     s=heapq.heappop(pp)
     t=heapq.heappop(qq)
     if r[c-i-1] > s or r[c-i-1] > t:
          if s >= t:
               heapq.heappush(pp, s)
               heapq.heappush(qq, r[c-i-1])
          else:
               heapq.heappush(qq, t)
               heapq.heappush(pp, r[c-i-1])


     else:
          heapq.heappush(pp, s)
          heapq.heappush(qq, t)
          break
print(sum(pp)+sum(qq))

Measured memory_bytes: 24224
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	while(true){
	vector<int>x1,x2;
	int N;
	scanf("%d",&N);
	if(N==0)return 0;
	bool f[200];
	for(int i=0;i<2*N;i++)f[i]=false;
	int X;
	for(int i=0;i<N;i++){
		scanf("%d",&X);
		f[X-1]=true;
	}
	for(int i=0;i<2*N;i++){
		if(f[i])x1.push_back(i);
		else x2.push_back(i);
	}
	int ba=-1;
	//１なら太郎、2なら花子
	int zyu=1;
	sort(x1.begin(),x1.end());
	sort(x2.begin(),x2.end());
	while(x1.size()>0&&x2.size()>0){
		if(zyu==1){
			for(int i=0;i<x1.size();i++){
				if(ba<x1[i]){
					ba=x1[i];
					zyu=2;
					for(int j=i;j<x1.size()-1;j++)x1[j]=x1[j+1];
					x1.erase(x1.end()-1);
					goto a1;
				}
			}
			ba=-1;
			zyu=2;
			a1:;
		}
		else{
			for(int i=0;i<x2.size();i++){
				if(ba<x2[i]){
					ba=x2[i];
					zyu=1;
					for(int j=i;j<x2.size()-1;j++)x2[j]=x2[j+1];
					x2.erase(x2.end()-1);
					goto a2;
				}
			}
			ba=-1;
			zyu=1;
			a2:;
		}
	}
	printf("%d\n%d\n",x2.size(),x1.size());
	}
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int K;
    string S;
    cin >> K >> S;
    if (S.size() <= K)
        cout << S << endl;
    else
    {
        cout << S.substr(0, K) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

int main() {

  vector<int>antenas;
  for(int i=0;i<5;i++){
    int x;
    cin>>x;
    antenas.push_back(x);
  }
  int k;
  cin>>k;
  for(int i=0;i<5;i++){
    for(int j=i;j<5;j++){
        if(antenas[i]+k<antenas[j]){
            cout<<":("<<endl;
            return 0;
        }
    }
  }
  cout<<"Yay!"<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	word := "hon"
	switch i := n % 10; i {
	case 0, 1, 6, 8:
		word = "pon"
	case 3:
		word = "bon"
	}

	fmt.Println(word)
}


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

string res;

void solve( string s, int cnt, int ans )
{
    if( cnt == 0 )
    {
        int sum = 0;
        for( int i = 0; i < s.size(); i++ )
        {
            if( s[i] == '+' )
                sum += (int)pow( 3.0, (double)i );
            else if( s[i] == '-' )
                sum -= (int)pow( 3.0, (double)i );
        }
        if( sum == ans )
            res = s;
        return;
    }

    solve( s + '+', cnt - 1, ans );
    solve( s + '-', cnt - 1, ans );
    solve( s + '0', cnt - 1, ans );
}

int main()
{    
    int n;

    cin >> n;

    int a = 1, cnt = 1;
    while( a < n )
    {
        a *= 3;
        cnt++;
    }

    string s = "";
    solve( s, cnt, n );

    string rev = "";
    int i = res.size() - 1;
    while( res[i] == '0' )
        i--;

    for( int j = i; j >= 0; j-- )
        rev += res[j];

    cout << rev << endl;

    return 0;
}


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

int main() {
	string S;
	long long i, K;
	char c;
	cin >> S;
	cin >> K;
	for(i = 0; S[i] == '1'; i++);
	c = S[i];
	if( K < i+1 ){
		cout << '1' << "\n";
	}else{
		cout << c << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n<=999){
    printf("ABC\n");
  }else{
    printf("ABD\n");
  }
  return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (int)(n); ++i)
#define fj(st,n) for (int j = (st); j <= (int)(n); ++j)
#define fk(st,n) for (int k = (st); k <= (int)(n); ++k)
#define fq(st,n) for (int q = (st); q <= (int)(n); ++q)
#define fw(st,n) for (int w = (st); w <= (int)(n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (int)(n); ++(i))
#define ei(st,n) for (int i = (st); i >= (int)(n); --i)
#define ej(st,n) for (int j = (st); j >= (int)(n); --j)
#define ek(st,n) for (int k = (st); k >= (int)(n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (int)(n); --(i))
#define ri(st,n) for (int i = (st); i < (int)(n); ++i)
#define rj(st,n) for (int j = (st); j < (int)(n); ++j)
#define rk(st,n) for (int k = (st); k < (int)(n); ++k)
#define rq(st,n) for (int q = (st); q < (int)(n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (int)(n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;
const int MX = (int) 1e5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(15);
//srand(time(0));

int n, p[maxn];

int main()
{
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n)
    {
    	cin >> p[i];
    }
    int prev = -1;
    int ans = 0;
    fi(1, n)
    {
    	if (p[i] == i)
    	{
    		if (prev == i - 1)
    		{
    			prev = -1;
    		}
    		else
    		{
    			++ans;
    			prev = i;
    		}
    	}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}

signed main()
{
#ifdef __LOCAL__
	freopen("in.txt","r",stdin);
#endif
	string s;
	cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++) cout<<"x";
	cout<<"\n";
#ifdef __LOCAL__
	cout<<"Time Used : "<<clock()<<endl;
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vc= vector<char>;
#define REP(i,x,n) for(int i=x; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()

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

  if(n%2){
    a=  (double)(n/2+1)/n;
  }
  else{
    a= 0.5;
  }
  cout << a << endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.E
{
	class Program
	{
		const long MOD = 998244353;

		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int m = cin.nextInt();
			int k = cin.nextInt();

			long ans = 0;
			long now = 1;
			for (int i = 1; i <= k; i++)
			{
				now *= n - i;
				now %= MOD;
				now *= modinv(i, MOD);
				now %= MOD;
			}
			now *= m;
			now %= MOD;
			for (int i = 0; i < n-k-1; i++)
			{
				now *= m - 1;
				now %= MOD;
			}
			ans += now;
			for (int i = 0; i <= k; i++)
			{
				now *= k - i;
				now %= MOD;
				now *= modinv(n - k + i, MOD);
				now %= MOD;
				now *= m - 1;
				now %= MOD;

				ans += now;
				ans %= MOD;
			}

			Console.WriteLine(ans);

			Console.Out.Flush();
		}

		static long modinv(long a, long m)
		{
			long b = m, u = 1, v = 0;
			while (b>0)
			{
				long t = a / b;
				a -= t * b; swap(ref a, ref b);
				u -= t * v; swap(ref u, ref v);
			}
			u %= m;
			if (u < 0) u += m;
			return u;
		}

		static void swap<T>(ref T a,ref T b)
		{
			var t = a;
			a = b;
			b = t;

		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 27536
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <map>
#include <set>
using namespace std;

int main()
{
	int32_t N;
	string S;
	cin >> N >> S;

	int32_t x = 0, res = 0;
	for (int32_t i = 0; i < N; i++) {
		if (S[i] == 'I')
			x++;
		else if (S[i] == 'D')
			x--;
		res = max(res, x);
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    int mn = 2 * 100000 + 1;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (mn >= p[i])
        {
            mn = p[i];
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024