akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    bool operator==(const mint a){
        return (x == a.x);
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    string S1,S2; cin >> S1 >> S2;

    int index = 0;

    mint ans = 1;
    int prev_type = 0;
    while(index < N){
        if (S1[index] == S2[index]){
            if(prev_type == 0){
                ans *= 3;
            }
            else if (prev_type == 1){
                ans *= 2;  
            }
            prev_type = 1;
            index++;
        }
        else{
            if(prev_type == 0){
                ans *= 6;
            }
            else if(prev_type == 1){
                ans *= 2;
            }
            else if(prev_type == 2){
                ans *= 3;
            }
            prev_type = 2;
            index += 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
int main() {
	int a,b;
	int i ,j;
	int result = 0;
	int s[6];
       scanf("%d%d",&a,&b);
	for (i = a; i <= b; i++) {
		j = i;
		s[0] = j % 10; j = (j - j % 10) / 10;
		s[1] = j % 10; j = (j - j % 10) / 10;
		s[2] = j % 10; j = (j - j % 10) / 10;
		s[3] = j % 10; j = (j - j % 10) / 10;
		s[4] = j % 10; j = (j - j % 10) / 10;

		if (s[0] == s[4] && s[1] == s[3]) { result++; }
	}
	printf("%d", result);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;

  // 解答
  cout << N * 800 - (N / 15) * 200 << endl;

  return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
if x == 1 or x == 2*n-1:
    print("No")
else:
    print("Yes")
    if n == 2:
        print(1)
        print(2)
        print(3)
    else:
        a = [0 for i in range(2*n-1)]
        if x == 2*n-2:
            a[n-3] = x-2
            a[n-2] = x+1
            a[n-1] = x
            a[n] = x-1
        else:
            a[n-3] = x+1
            a[n-2] = x-1
            a[n-1] = x
            a[n] = x+2
        y = 1
        for i in range(2*n-1):
            if y == x-1:
                y = x+3
            if a[i] == 0:
                a[i] = y
                y += 1
        for t in a:
            print(t)

Measured memory_bytes: 12484
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    ll n, q;
    cin >> n;
    //Use hash table to track freq of each number from 0 to 1e5
    vector<ll> count(1e5+1, 0);
    ll sum = 0;
    for(int i=0; i<n; i++) {
        ll a;
        cin >> a;
        count[a]++;
        sum+=a;
    }
    cin >> q;
    for(int i=0; i<q; i++) {
        ll b, c;
        cin >> b >> c;
        //find how many elements we are replacing
        ll subtract = count[b]*b;
        ll add = count[b]*c;
        count[c]+=count[b];
        count[b] = 0;
        sum-=subtract;
        sum+=add;
        cout << sum << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 4044
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+c*50==X:
                count+=1
            else:
                continue
print(count)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int IsPrime(int);
int main() {
  int i,count=0,n,*sosu;
    scanf("%d",&n);
    
    sosu = (int *)malloc(n * sizeof (int));
    
   
    
    for(i=n-1;i>=0;i--){
        scanf("%d",&sosu[i]);
        if(IsPrime(sosu[i]) == 1) count++;
    }
    printf("%d\n",count);
    return 0;
}

 int   IsPrime(int n){


    


   int i;

    if (n < 2)
        return 0;
    else if (n == 2)
        return 1;

    if (n % 2 == 0)
        return 0;

    for (i = 3; i <= n / i; i += 2)
         if (n % i == 0)
            return 0;
    return 1;

}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int a;
    cin >> a;
    vector<int> v(28,0);
    string t;
    cin >> t;
    for(int i=0;i < t.size();i++){
        v.at(t.at(i)-'a')++;   
    }
    
    for(int i=1;i < a;i++){
        string s;
        cin >> s;
        vector<int> u(28,0);
        for(int j=0;j < s.size();j++){
            u.at(s.at(j)-'a')++;
        }

        for(int k=0;k < 28;k++){
            v.at(k)=min(u.at(k),v.at(k));
        }
    }
    for(int l=0;l < 28;l++){
        while(v.at(l)!=0){
            char c = 'a'+l;
            cout << c;
            v.at(l)--;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
from operator import itemgetter as get
from heapq import *


def main():
	n, q = map(int, input().split())
	event = []
	Xs = []
	for _ in range(n):
		s, t, x = map(int, input().split())
		event.append((-2, s - x, x))
		event.append((-1, t - x, x))
		Xs.append(x)
	for _ in range(q):
		d = int(input())
		event.append((0, d, None))
	event.sort(key=get(1))
	active = {x: 0 for x in Xs}
	candidate = []
	ans = []
	for flg, time, x in event:
		if flg == -2:
			active[x] = 1
			heappush(candidate, x)
		elif flg == -1:
			active[x] = 0
		else:
			res = -1
			while candidate:
				c = heappop(candidate)
				if active[c]:
					heappush(candidate, c)
					res = c
					break
			ans.append(res)
	print("\n".join(map(str, ans)))


if __name__ == '__main__':
	main()


Measured memory_bytes: 107216
#include<bits/stdc++.h>
using namespace std;
int k,l=1,r=1,a1,a2;
bool vis[100005];
typedef pair<int, int> P;
deque<P> que;
int main()
{
    scanf("%d",&k);que.push_back(make_pair(1, 1));
    while(!que.empty())
    {
        P x=que.front();que.pop_front();
        if(vis[x.first]) continue;vis[x.first]=1;
        if(x.first==0){printf("%d",x.second);return 0;}
        que.push_front(make_pair(x.first*10 % k,x.second));
        que.push_back(make_pair((x.first+1)%k,x.second+1));
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	static int[] a = {500,100,50,10,5,1};
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		for(;;){
			int N = cin.nextInt();
			if(N==0)break;
			N=1000-N;
			int ans=0;
			int i = 0;
			while(N!=0){
				if(a[i]<=N){
					N-=a[i];
					ans++;
				}
				else{
					i++;
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>

#define M 1046527
#define L 14
#define NIL (-1)

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++)
    {
      h=(h1(key) + i * h2(key))% M;
      if(strcmp(H[h],str)==0) return 1;
      else if(strlen(H[h])==0) return 0;
    }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0; ;i++)
    {
      h=(h1(key) + i * h2(key))%M;
      if(strcmp(H[h],str)==0) return 1;
      else if (strlen(H[h])==0)
	{
	  strcpy(H[h],str);
	  return 0;
	}
    }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}



Measured memory_bytes: 16048
import java.util.Scanner;

public class Main {
    public static void main(String[] args)  {
       Scanner sc = new Scanner(System.in);
       while(true){
            int n= sc.nextInt();
            int m= sc.nextInt();
            if(n==0 &&  m==0) break;
            int max = 0;
            int [] price = new int[n];
            for(int i=0;i<n;i++){
                price[i]=sc.nextInt();
            }
            
            for(int i=0;i<n-1;i++){
                for(int j=i+1;j<n;j++){
                    if(price[i]+price[j]>max && price[i]+price[j]<=m){
                        max=price[i]+price[j];
                    }
                }
            }
            
            if(max==0){
                System.out.println("NONE");
            }else{
                System.out.println(max);
            }
       }
    }
}



Measured memory_bytes: 48272
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,a,b,c,cnt=0,ans=0;
string s,t;
int main(){
  cin >> n;
  if(n%2==0){
    cout << n << endl;
  }else{
    cout << n*2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c;
  if (a > b) {
    d = a;
    a = b;
    b = d;
  }
  if (b > c) {
    d = b;
    b = c;
    c = d;
  }
  if (a > b) {
    d = a;
    a = b;
    b = d;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int e;
  while(cin >> e, e){
    int x, y, z;
    int ans = INT_MAX;
    for(z = 0; z*z*z <= e; z++){
      y = sqrt(e-pow(z, 3));
      x = e - pow(z, 3) - pow(y,2);
      ans = min(ans, x+y+z);
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main()
{
	int H, W;


	while (1)
	{
		cin >> H >> W;
		
		if (H == 0 && W == 0)
		{
			break;
		}

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> city(N);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    
    ++city.at(a - 1);
    ++city.at(b - 1);
  }
  
  for (int i = 0; i < N; i++) {
    cout << city.at(i) << endl;
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
ans = ['t'] * n

for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] =='t' or ans[s-1] == str(c):
        ans[s-1]= str(c)
    else:
        print(-1)
        exit(0)
if ans[0] == 't' and n >1:
    ans[0]=str(1)

ans = ''.join(ans).replace('t', str(0))
ans = int(ans)
l = str(ans)
if len(l) != n:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int tk = (int)Math.ceil(a/(double)d);
        int ao = (int)Math.ceil(c/(double)b);
        if (tk<ao)System.out.println("No");
        else System.out.println("Yes");
    }
}


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

const int N = 3000+5;

int n, m;
string s;
string t;
bool vis[N][N];
int memo[N][N];
int choice[N][N];

int DP(int i, int j){
	if(i == n or j == m) return 0;
	if(vis[i][j]) return memo[i][j];
	vis[i][j] = true;
	if(s[i] == t[j]){
		choice[i][j] = 2;
		return memo[i][j] = 1 + DP(i+1,j+1);
	}
	else{
		if(DP(i+1,j) > DP(i,j+1)){
			choice[i][j] = 0;
		}
		else{
			choice[i][j] = 1;
		}
		return memo[i][j] = max(DP(i+1,j),DP(i,j+1));
	}
}

int main() {
	cin >> s >> t;
	n = s.size();
	m = t.size();
	memset(choice,-1,sizeof choice);
	int ans = DP(0,0);
	int i = 0, j = 0;
	while(i < n and j < m){
		assert(choice[i][j] != -1);
		if(choice[i][j] == 2){
			putchar(s[i]);
			i += 1;
			j += 1;
		}
		else{
			if(choice[i][j] == 0) i += 1;
			else j += 1;
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 80128
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024
#define ARRAY_SIZE 100


void selectionSort(int array[],int n,int& change_count)
{
	int min;
	for(int i = 0; i < n-1; i++){
		min = i;	//?????????
		for(int j = i+1; j < n; j++){
			if(array[j] < array[min]){
				min = j;
			}
		}
		if(i != min){
			swap(array[i],array[min]);
			change_count++;
		}
	}

}

int main(){

	char buf[BUF_SIZE];
	int n = atoi(fgets(buf,BUF_SIZE,stdin));
	int array[ARRAY_SIZE];
	int change_count = 0;

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

	selectionSort(array,n,change_count);

	for(int i = 0; i < n; i++){
		if(i != n-1){
			printf("%d ",array[i]);
		}else{
			printf("%d\n",array[i]);
		}
	}
	printf("%d\n",change_count);
}


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

const int N = 1e5+5;

int n;
int a[N] , cnt[N];

int main(){
	scanf("%d" , &n);
	int ans = 0;
	for(int i = 0;i < n;i++){
		scanf("%d" , a + i);
		cnt[a[i]]++;
	}
	for(int i = 0;i < N;i++){
		int d = cnt[i] + cnt[i + 1];
		if(i)d += cnt[i - 1];
		ans = max(ans , d);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

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

int n;

vector<vector<int>> adj;

vector<int> visited;

int res;

int dfs(int u)
{
    visited[u] = 1;

    int children = 0;
    int antennae = 0;

    int ret = 0;

    for (auto v : adj[u])
    {
        if (!visited[v])
        {
            children += 1;
            antennae += dfs(v);
        }
    }

    ret |= (antennae > 0);

    if (u != 0)
    {
        if (children > antennae + 1)  // assume antenna exists above
        {
            res += children - antennae - 1;
            ret = 1;
        }
    }
    else
    {
        // there will be at least two antennae in two different subtrees, covering the root (and each other)
        if (children >= 3)
        {
            if (children > antennae + 1)
            {
                res += children - antennae - 1;
                ret = 1;
            }
        }
        else if (children == 2 && antennae == 2)
        {
            ret = 0;
        }
        else
        {
            res += 1;
            ret = 1;
        }
    }

    return ret;
}

int main() {
    GI(n);

    int u, v;

    adj.resize(n);

    FORN(i, n-1)
    {
        GI(u);
        GI(v);

        adj[u].PB(v);
        adj[v].PB(u);
    }

    res = 0;

    visited.resize(n);
    dfs(0);

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 10752
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;
int INF = 100000;


int main() {
    int n,m;
    int c[21] = {};
    int dp[50001][21] = {};
    cin >> n >> m;
    rep(i,m) {
        cin >> c[i+1];
    }
    rep(i,n) {
        rep(j,m+1) {
            dp[i+1][j] = INF;
        }
    }
    FOR(i,1,n+1){
        FOR(j,1,m+1) {
                dp[i][j] = (i-c[j] >= 0) ? min(dp[i-c[j]][j]+1, dp[i][j-1]): dp[i][j-1];
        }
    }

    cout << dp[n][m] << endl;
	return 0;
}

Measured memory_bytes: 7204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	vi a(3);
	rep(i, 0, 3) cin >> a[i];
	sort(rall(a));
	int ans = abs(a[1] - a[0]) + abs(a[2] - a[1]);
	cout << ans << endl;
}

Measured memory_bytes: 256
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
count_min = 0
count_max = 0
for i in a:
  if x > i:
    count_min += 1
  else:
    count_max += 1
if count_min >= count_max:
  print(str(count_max))
else:
  print(str(count_min))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    long long int h;
    std::deque<long long int> deq;
    for (int i=0;i<n;i++) {
        cin>>h;
        deq.emplace_back(h);
    }
    sort(deq.begin(),deq.end());
    long long int min_num=2000000000;
    for (int j=0;j+k<=n;j++) {
        if (deq[j+k-1]-deq[j]<min_num) {
            min_num=deq[j+k-1]-deq[j];
        }
    }
    cout<<min_num<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
int N; int K; cin>>N>>K;
  int L=1;
  for(int i=0; i<N; i++){
    if(L*2>=L+K){
      L+=K;
    }
      else L*=2;
    }
    cout<<L<<endl;
  }


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    vector<int>n={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 k;
    cin>>k;

    cout<<n[k-1]<<endl;

}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int k=sc.nextInt();
        int n=sc.nextInt();
        int[] nums=new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        int max=0;
        for(int i=0;i<n-1;i++){
            max=Math.max(max, nums[i+1]-nums[i]);
        }
        max=Math.max(max, nums[0]+k-nums[n-1]);
        System.out.println(k-max);
    }
    
}

Measured memory_bytes: 76144
using System;
class Program
{
    static void Main()
    {
        int[] count = new int[30000];
        int alpha = int.Parse(Console.ReadLine());
        for (int i = 0; i <= alpha; i++)
        {
           if (i % 3 == 0 || i.ToString().Contains("3") ==true) count[i] = i;
            if (count[i] != 0) Console.Write(" "+ count[i]);
        }
       Console.WriteLine();
    }
}




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

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

const int mod = 1e9 + 7; 

int dp[60][2][2]; 
long long N;

int f(int i, int c, int ok) {
  if(i == 60) return !c && ok; 
  int &ret = dp[i][c][ok];
  if(~ret) return ret; 
  ret = 0; 
  
  int nbit = N >> i & 1;
  for(int a = 0; a <= 1; ++a) {
    for(int b = 0; b <= a; ++b) {
      int bit = a ^ b ^ c; 
      int carry = a + b + c >> 1; 
      int nok = bit == nbit ? ok : bit > nbit ? 0 : 1; 
      ret += f(i + 1, carry, nok); 
      if(ret >= mod) ret -= mod; 
    }
  }

  return ret; 
}

int main() {
  scanf("%lld", &N); 
  memset(dp, -1, sizeof dp); 
  printf("%d\n", f(0, 0, 1));   
}


Measured memory_bytes: 256
import numpy as np

N,M,C = map(int,input().split())
B = input().split()
B = np.array([int(x) for x in B])
A = []
for i in range(N):
    A.append(input().split())

cnt = 0
for i in range(N):
    A_ = np.array([int(x) for x in A[i]])
    if(np.dot(A_,B) + C > 0):
        cnt += 1

print(cnt)

Measured memory_bytes: 12436
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
k=0
for i in range(n):
    k+=min(a[i],b[i])
    if a[i]<b[i]:
        l=b[i]-a[i]
        if a[i+1]<l:
            k+=a[i+1]
            a[i+1]-=a[i+1]
        else:
            k+=l
            a[i+1]-=l
print(k)

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

int main()
{
  int N = 100005;
  bool prime[N];
  for(int i = 0; i < N; i++)
    	prime[i] = true;
  prime[0] = prime[1] = false;
  int i = 2;
  while(i*i <= N)
  {
    int j = i*i;
    while(j < N)
    {
     	prime[j] = false;
      	j += i;
    }
    do
    {
      i == 2 ? i++ : i += 2;
    }while(!prime[i] && i*i <= N);
  }
  long n;
  cin >> n;
  while(!prime[n])n++;
  cout<<n;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<vector<int>> cnt(n,vector<int>(26));
	rep(i,n){
		string s;cin >> s;
		rep(j,s.size()){
			cnt[i][s.at(j) - 'a']++;
		}
	}
	vector<int> ans(26, 100);
	rep(i,n){
		rep(j,26){
			ans[j] = min(ans[j], cnt[i][j]);
		}
	}
	rep(i,26){
		char c = i + 'a';
		rep(j,ans[i]) cout << c;
	}
	cout << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

// Definitions
#define MAXN 1000010
#define elif else if
typedef long long int64;
#define File(s) freopen(#s ".in", "r", stdin), freopen(#s ".out", "w", stdout)

// Variables
int n, ans;

// Functions
inline void Process() {
  for (int a = 1; a <= n; a++) {
    ans += (n % a) ? (n / a) : (n / a - 1);
  }
}
inline void ReadIn() {
  scanf("%d", &n);
}
inline void PrintAns() {
  printf("%d\n", ans);
}

int main() {
#ifndef ONLINE_JUDGE
  File(data);
#endif
  ReadIn();
  Process();
  PrintAns();
  return 0;
}
/*

*/

Measured memory_bytes: 1736
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int K,R,L;
double P,E,T;

double rec(int d,double l,double r,double p){
  if(d==K){
    double h=(l+r)/2;
    if(T-E<=h && h<=T+E) return p;
    return 0;
  }
  //cout << d << ' ' << l << ' ' << r << ' ' << p << endl;
  if(r<T-E || T+E<l) return 0;
  if(T-E <=l && r<=T+E) return p;

  double n=P;
  if((l+r)/2>=T) n=1-P;
  
  return
    rec(d+1,l,(l+r)/2,p*n)+rec(d+1,(l+r)/2,r,p*(1-n));
}

int main(int argc, char *argv[])
{
  cin >> K >> L >> R;
  cin >> P >> E >> T;

  printf("%.8f\n",rec(0,L,R,1));
  
  return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(all(d));
    vector<int> sums(1e5+1);
    rep(i,n){
        sums[d[i]]++;
    }
    rep(i,sums.size()){
        sums[i+1] += sums[i];
    }
    int ans = 0;
    for(int i = 1; i <= 1e5; i++){
        int abcNum = sums[i];
        if (abcNum == n/2) ans++;
    }
    cout << ans << endl;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> ostream& operator <<(ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":" ");return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator <<(ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}


int l[3];
int res[4];

int main()
{
  while(cin >> l[0] >> l[1] >> l[2]){
    sort(l, l+3);
    if(l[0] + l[1] <= l[2]){
      cout << res << endl;
      break;
    }
    int s = l[0] * l[0] + l[1] * l[1];
    int t = l[2] * l[2];
    res[0] += 1;
    if(s == t) res[1] += 1;
    if(s  > t) res[2] += 1;
    if(s  < t) res[3] += 1;
  }

  return 0;
}

Measured memory_bytes: 1176
fun main(args: Array<String>) {
    val K = nextInt()
    val ans = mutableListOf<Long>()
    (0 .. 9).forEach { ans.add(it.toLong()) }
    var p = 1
    while (p < K) {
        val x = ans[p++]
        for (a in -1 .. 1) {
            val d = x % 10 + a
            if (d < 0 || d > 9) continue
            ans.add(10 * x + d)
        }
    }
    println(ans[K])
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int i,j;
  i = 0; j = n-1;
  while(i<j){
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++; j--;
  }

  i = 0; j = n/2-1;
  while(i<j){
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++; j--;
  }

  i = n/2+1; j = n-1;
  while(i<j){
    if(s[i]!=s[j]){
      cout << "No" << endl;
      return 0;
    }
    i++; j--;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  int n = 1;
  while(n*(n+1)/2 <N) n++;
  int diff = n*(n+1)/2-N;
  srep(i,1,n+1) {
    if(i != diff) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

def f(a, b, theta):
  if math.pi / 2.00 - 1e-8 < theta:
    return 0.00
  else:
    if a * math.tan(theta) <= b:
      ret = a * a * b - a * a * a * math.tan(theta) / 2.00
    else:
      ret = b * b  / math.tan(theta) * a / 2.00
    return ret

a,b,x = map(float, input().split())

ok = math.pi / 2.00
ng = 0.00
for i in range(100000):
  mid = (ok + ng) / 2.00
  if(f(a, b, mid) < x):
    ok = mid
  else:
    ng = mid
print('{:.8f}'.format(ok / math.pi * 180.00))


Measured memory_bytes: 15660
H, W = list(map(int, input().split()))
S = [input() for _ in range(H)]


def f(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    return S[h][w] == '#'


for i in range(H):
    for j in range(W):
        if f(i, j) and not f(i-1, j) and not f(i+1, j) and not f(i, j-1) and not f(i, j+1):
            print('No')
            exit()

print('Yes')


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

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0)
    {
        cout << (t * (n)) / x << "\n";
    }
    else
    {
        cout << t * ((n) / x + 1) << "\n";
    }

    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

class Main {

	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(in.hasNext()){
			double v = in.nextDouble();
			System.out.println((int)Math.ceil((v*v/(9.8*2) + 5)/5));
		}
	}
	
}

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

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

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

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

long int M = 1e+9+7;
int inf = 1e+9;

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

    int n,a,b;
    cin >> n >> a >> b;
    string s="";
    cin >> s;
    int sum=0;
    int sumb=0;

    rep(i,n){
        if(a+b <= sum){
            cout << "No" << endl;
            continue;
        }
        if(s[i] == 'a'){
            cout << "Yes" << endl;
            sum++;
        }else if(s[i] == 'b'){
            if(b > sumb){
                cout << "Yes" << endl;
                sum++;
                sumb++;
            }else{
                cout << "No" << endl;
            }
        }else{
            cout << "No" << endl;
        }

    }
    //int ans=0;
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORX(i, a, b, x) for (int i = (a); i <= (b); i+=x)
#define debug(x) cerr << #x << " is= " << x << endl; //use for debugging
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 5] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
 
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vov        vector<vector<int>> 
#define pr         pair<ll,ll>
#define vpll       vector<pair<ll,ll>>
#define all(v)     v.begin(),v.end()
#define rall(v)    v.rbegin(),v.rend()  //reverse of above;
#define sz(container) int((container).sz())
#define cut(x) {cout<<x<<"\n"; continue;}
#define setprec(x) cout << fixed << showpoint << setprecision(8)<<x<<endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define time cout << clock() / double(CLOCKS_PER_SEC) << endl;
#define endl "\n"
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//*s.find_by_order(1);
//s.order_of_key() ->number of elements strictly smaller then our item;
//st.rbegin()->second; last element in set
//st.erase(prev(st.end())); delete last element in set;
const int N=1e5+5;
int main()
{
  fast_io;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  read(x);
  cout<<1-x;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#define MOD 1000000007
using namespace std;

int n, arr[100010];

long long int cvp=0, kalan=0;

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)cin>>arr[i];
	for (int i = 0; i < n; ++i){
		if(kalan==1&&arr[i]>0){
			arr[i]--;
			cvp++;
		}
		kalan=0;
		cvp+=arr[i]/2;
		if(arr[i]%2==1)kalan=1;
	}
	cout<<cvp;
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

# スペース区切りの整数の入力
A, B = map(int, input().split())

fare = 0

if A >= 13:
  fare = B

elif A >= 6 and A<=12:
  fare = int(B/2)

else:
  fare = 0

# 出力
print(fare)

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

int main() {
	
	int x, y;
	cin >> x >> y;
	
	if(y%2 == 0)
	{
		if(y >= 2*x && y <= 4*x) cout << "Yes\n";
		else cout << "No\n";
	}
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
 
#define ll long long
 
 
int main(){
  int N;
  cin >> N;
  map<string, int> mp;
  for(int i; i<N; i++){
    string s;
    cin >>s;
    mp[s]++;
  }
  cout<<"AC x "<<mp["AC"]<<endl;
  cout<<"WA x "<<mp["WA"]<<endl;
  cout<<"TLE x "<<mp["TLE"]<<endl;
  cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n%1000 == 0 {
		fmt.Println(0)
	} else {
		b := n/1000 + 1
		c := b*1000 - n
		fmt.Println(c)
	}
}


Measured memory_bytes: 1776
using namespace std;

#include <bits/stdc++.h>

int main(){
    int N;
    cin >> N;
    int a[N];
    for ( int i = 0; i < N; i ++ ){
        cin >> a[i];
    }
    int t = 0;
    for ( int i = 0; i < N; i ++ ){
        if ( a[i] != i + 1 ){
            a[a[i] - 1] = a[i];
            a[i] = i + 1;
            t ++;
        }
    }
    if ( t > 1 ) cout << "NO";
    else cout << "YES";
    return 0;
}



Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
A=get_i
if A.include?(K)
    puts "POSSIBLE"
elsif A.max<K
    puts "IMPOSSIBLE"
elsif (K% (A.inject(0){|res,x| res.gcd(x)})).zero?
    puts "POSSIBLE"
else
    puts "IMPOSSIBLE"
end

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

using namespace std;
int main() 
{
	int H,W, h,w;
	cin >> H >> W >> h >> w;
	if((H*W - (h*W + (H-h)*w)) >= 0) 
		cout << (H*W - (h*W + (H-h)*w)) << endl;
	else 
		cout <<"0"<<endl;
    return 0;
} 

Measured memory_bytes: 256
using System;

static class abc120b
{
    static void Main(string[] args)
    {
        var t = Console.ReadLine().Split();
        var A = int.Parse(t[0]);
        var B = int.Parse(t[1]);
        var K = int.Parse(t[2]);

        var count = 0;
        for (var i = Math.Min(A, B); i > 0; --i){
            if (A % i == 0 && B % i == 0){
                if(++count==K){
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


Measured memory_bytes: 11092
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    auto C = new long[](N);
    foreach (a; A)
        C[a]++;
    auto V = ((N & 1) ? [1] : []) ~ cycle([0, 2]).take(N & ~1).array;
    // writeln(C);
    // writeln(V);
    if (C != V)
    {
        writeln(0);
        return;
    }
    long ans = 1;
    foreach (_; 0 .. N / 2)
        ans = (ans << 1) % MOD;
    writeln(ans);
}


Measured memory_bytes: 6420
using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5");
            WillReturn.Add("WEEWW");
            //1
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("12");
            WillReturn.Add("WEWEWEEEWWWE");
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("8");
            WillReturn.Add("WWWWWEEE");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[1];
        int UB = S.Length - 1;

        var WestRuisekiDict = new Dictionary<int, int>();
        int WestRuiseki = 0;
        for (int I = 0; I <= UB; I++) {
            WestRuisekiDict[I] = WestRuiseki;
            if (S[I] == 'W') WestRuiseki++;
        }

        var EastRuisekiDict = new Dictionary<int, int>();
        int EastRuiseki = 0;
        for (int I = UB; 0 <= I; I--) {
            EastRuisekiDict[I] = EastRuiseki;
            if (S[I] == 'E') EastRuiseki++;
        }

        int Answer = int.MaxValue;
        for (int I = 0; I <= S.Length - 1; I++) {
            int CurrCost = WestRuisekiDict[I] + EastRuisekiDict[I];
            if (Answer > CurrCost)
                Answer = CurrCost;
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 30256
#include <stdio.h>

int main(void){

  int t,h,m,s;

  scanf("%d",&t);

  h = t/3600;
  m = (t%3600)/60;
  s = (t-(h*3600+m*60)); 

  printf("%d:%d:%d\n",h,m,s);

  return 0;
}

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

int n, x;
deque < int > ans;

signed main () { 
    scanf("%d %d", &n, &x);
    if (x != 1 && x != 2 * n - 1) {
        printf("Yes\n");
        ans.push_back(x);
        for (int d = 1; d < 2 * n && x != 2; ++d) {
            if (d & 1) {
                ans.push_back(x + d);
                ans.push_front(x - d);
            }
            else {
                ans.push_front(x + d);
                ans.push_back(x - d);
            }
        }
        for (int d = 1; d < 2 * n && x == 2; ++d) {
            if (d & 1) {
                ans.push_back(x - d);
                ans.push_front(x + d);
            }
            else {
                ans.push_front(x - d);
                ans.push_back(x + d);
            }
        }
        for (int i = 0; i < int(ans.size()); ++i) {
            if (ans[i] > 0 && ans[i] < 2 * n)
                printf("%d\n", ans[i]);
        }
    }
    else
        printf("No\n");
}


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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

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

 int a, b, c;
 cin >> a >> b >> c;

 if(b-a == c-b) cout << "YES" << endl;
 else cout << "NO" << endl;

 return 0;

}


Measured memory_bytes: 892
time = int(input())
xy = [map(int, input().split()) for _ in range(time)]
x, y = [list(i) for i in zip(*xy)]
sum = 0
for i in range(time):
    if x[i] == y[i]:
        sum += 1
        if sum == 3:
            print("Yes")
            break
    else:
        sum = 0

if sum < 3:
    print("No")


Measured memory_bytes: 9180