akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main()
{
	int n;
	while(cin >> n){
		if(!n)
			break;
		bool field[21][21];
		for(int i=0;i<21;i++){
			for(int j=0;j<21;j++){
				field[i][j] = false;
			}
		}
		int x,y;
		for(int i=0;i<n;i++){
			cin >> x >> y;
			field[y][x] = true;
		}
		int m;
		cin >> m;
		int count = 0;
		x = 10; y = 10;
		if(field[y][x] == true)
			count++;
		for(int i=0;i<m;i++){
			char h;
			int l;
			cin >> h >> l;
			switch(h){
				case 'N':
					for(int j=0;j<l;j++){
						y++;
						if(field[y][x]==true){
							count++;
							field[y][x] = false;
						}
					}
					break;
				case 'E':
					for(int j=0;j<l;j++){
						x++;
						if(field[y][x]==true){
							count++;
							field[y][x] = false;
						}
					}
					break;
				case 'S':
					for(int j=0;j<l;j++){
						y--;
						if(field[y][x]==true){
							count++;
							field[y][x] = false;
						}
					}
					break;
				case 'W':
					for(int j=0;j<l;j++){
						x--;
						if(field[y][x]==true){
							count++;
							field[y][x] = false;
						}
					}
					break;
			}
		}
		if(n == count)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if (W>=x+r&&H>=y+r&&x-r>=0&&y-r>=0){
    printf("Yes\n");
}
else {
    printf("No\n");
}
return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  cout << setprecision(20) << fixed;
  int n, k; cin >> n >> k;
  double ans = 0;

  for (int i = 1; i <= n; i++) {
    int t = i;
    double win = 1;
    while (t < k) {
      win *= 0.5;
      t *= 2;
    }
    ans += win;
  }
  ans /= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define nax (int)1e5+2
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n" 
#define INF (int)1e9
#define eps (long double)1e-9
using namespace std;

vector<int> adj[nax];

int main(){
	fast;
	int n,m;
	cin >> n >> m;
	vector<int> v(n+1);
	for(int i =1 ;i<=n;i++){
		cin >> v[i];
	}
	for(int i =0 ;i<m;i++){
		int u,vi;
		cin >> u >> vi;
		adj[u].pb(vi);
		adj[vi].pb(u);
	}
	int cnt = 0;
	for(int i = 1;i<=n;i++){
		int ma = v[i];
		bool ok = true;
		for(auto it : adj[i]){
			if(ma <= v[it]){
				ok = false;
			}
		}
		if(ok)
			cnt++;
	}
	cout<<cnt;
	
	return 0;
}
	


Measured memory_bytes: 8744
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    println!("{}", s.rfind('Z').unwrap() - s.find('A').unwrap() + 1)
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int total,money;
  while(1){
    cin >> total;
    if(total==0){
      break;
    }
    for(int i=0;i<9;i++){
      cin >> money;
      total=total-money;
    }
    cout << total << endl;
  }
  return (0);
}

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

int main() {
  string  S,a;
  cin >> S;
   
      for (int i = 0; i < S.size() ; i++) {
        
        if( S.at(i) == '0'){
             a += '0';
        }
          
        else if (S.at(i) == '1'){
             a += '1';
         }
        else if (S.at(i) == 'B'){
          if( a.size() >0){
            a.pop_back();
          }
        }
      }
          cout << a << endl;
}
            
          
          
        


Measured memory_bytes: 256
numInput = int(input())

numSequence = list(map(int, input().split(' ')))

numOdd = 0
for i in range(0, len(numSequence)):
    if numSequence[i] % 2 == 1:
        numOdd += 1
        
if numOdd % 2 == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 14112
n = int(input())
P = list(map(int, input().split()))

dist = [[min(i, j, n - i - 1, n - j - 1) for j in range(n)] for i in range(n)]
is_sit = [[True for _ in range(n)] for _ in range(n)]

ans = 0
for p in P:
    i, j = divmod(p - 1, n)
    is_sit[i][j] = False
    ans += dist[i][j]

    q = [(i, j, dist[i][j])]
    while q:
        i, j, cur_cost = q.pop()

        if i > 0 and dist[i - 1][j] > cur_cost:
            dist[i - 1][j] = cur_cost
            q.append((i - 1, j, cur_cost + is_sit[i - 1][j]))

        if j > 0 and dist[i][j - 1] > cur_cost:
            dist[i][j - 1] = cur_cost
            q.append((i, j - 1, cur_cost + is_sit[i][j - 1]))

        if i < n - 1 and dist[i + 1][j] > cur_cost:
            dist[i + 1][j] = cur_cost
            q.append((i + 1, j, cur_cost + is_sit[i + 1][j]))

        if j < n - 1 and dist[i][j + 1] > cur_cost:
            dist[i][j + 1] = cur_cost
            q.append((i, j + 1, cur_cost + is_sit[i][j + 1]))

print(ans)


Measured memory_bytes: 191148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0},b[LIMIT1]={0};
  char s[LIMIT1];
  
  scanf("%lld",&n);
  rep(i,n-1) scanf("%d",&b[i]);
  a[0]=b[0];
  a[n-1]=b[n-2];
  result = (ll)a[0]+(ll)a[n-1];
  for(i=1;i<n-1;i++){
    a[i]=min(b[i],b[i-1]);
    result+=(ll)a[i];
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 2944
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

nums = [a,b,c,d,e]
ans = 5 + (n - min(nums)) // min(nums)
if n % min(nums) != 0: ans += 1
print(ans)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"os"
)

const (
	MIN = -1000000
	MAX = 1000000
)

func main(){
	var k, x int
	fmt.Fscanf(os.Stdin, "%d %d", &k, &x)
	min := x - (k -1)
	max := x + (k -1)
	if min < MIN {
		min = MIN
	}

	if max > MAX {
		max = MAX
	}
	for i := min; i <= max; i++ {
		fmt.Printf("%d ", i)
	}
	fmt.Print("\n")
}


Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>


using namespace std;
int main(){

    string a,b,c;
    double d;

    cin >> a>>b;
    d=sqrt(stod(a+b));

    if(d==floor(d)){    
        c="Yes";
    }else{
        c="No";
    };
    
    cout<<c<<endl;
    return 0;   
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

long long npow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}

signed _main(){
  int A,B; cin >> A >> B;
  bitset<40> ans;
  rep(i,40){
    if(i==0){
      if(A%2==0 && B%2==0){
        ans[i]=((B-A)/2)%2;
      }
      else ans[i]=((B-A+2)/2)%2;
    }
    else{
      int tmp=0;
      int N=npow(2,i);
      int num1=(N+A)/N;
      int num2=(N+B)/N;
      if(num1==num2){
        if(num1%2==0){
          tmp=B-A+1;
        }
      }
      else{
        if(num1%2==0){
          tmp+=N-(N+A)%N;
        }
        if(num2%2==0){
          tmp+=(N+B)%N+1;
        }
      }
      ans[i]=tmp%2;
    }
  }
  cout << ans.to_ullong() << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	t1, t2 := x2-x1, y2-y1
	fmt.Println(x2-t2, y2+t1, x1-t2, y1+t1)
}


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

int main(){
	int n , m;
	int b[100];
	int a[100][100]={0,0};
	int c[100]={0};
	cin >> n >> m;
	for(int i=0 ; i<n ; i++){
		for(int j=0 ; j<m ; j++){
			cin >> a[i][j];
		}
	}
	for(int i=0 ; i<m ; i++){
		cin >> b[i];
	}
	for(int i=0; i<n ; i++){
		for(int j=0; j<m ; j++){
			c[i]+=a[i][j]*b[j];
		}
	}
	for(int i=0 ; i<n ; i++){
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll N, M;
    cin >> N;
    vector<string> s(N);
    REP(i, N) cin >> s[i];
    cin >> M;
    vector<string> t(M);
    REP(i, M) cin >> t[i];

    ll res = 0;
    REP(nr, N) {
        string say = s[nr];
        ll nc = 0;
        ll mc = 0;
        REP(n, N) {
            if (say == s[n]) nc++;
        }
        REP(m, M) {
            if (say == t[m]) mc++;
        }
        chmax(res, nc-mc);
    }

    cout << res << "\n";
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int x, n, ans = 0, best = 1e9;
	cin >> x >> n;
	vector<bool> vis(101);
	for (int i = 0; i < n; ++i){
		int foo; 
		cin >> foo;
		vis[foo] = 1;
	}
	for (int i = 0; i <= 101; ++i){
		if (!vis[i] && abs(i - x) < best){
			best = abs(i - x);
			ans = i;
		}
	}
	cout << ans << '\n';
}




Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int L = int.Parse(Console.ReadLine());
		long[]A = new long[L];
		for(var i=0;i<L;i++){
			A[i] = long.Parse(Console.ReadLine());
		}
		long ans = 0;
		long[]D = new long[L+1];
		long[]D0 = new long[L+1];
		long[]D1 = new long[L+1];
		long[]D2 = new long[L+1];
		long[]D3 = new long[L+1];
		for(var i=0;i<L;i++){
			D[i+1] = D[i]+A[i];
			if(A[i]==0){
				D0[i+1] = Math.Min(D0[i]+A[i]%2+2,D[i]+A[i]%2+2);
			} else {
				D0[i+1] = Math.Min(D0[i]+A[i]%2,D[i]+A[i]%2);
			}
			D1[i+1] = Math.Min(D1[i]+(A[i]+1)%2,Math.Min(D0[i]+(A[i]+1)%2,D[i]+(A[i]+1)%2));
			if(A[i]==0){
				D2[i+1] = Math.Min(D2[i]+A[i]%2+2,Math.Min(D1[i]+A[i]%2+2,Math.Min(D0[i]+A[i]%2+2,D[i]+A[i]%2+2)));
			} else {
				D2[i+1] = Math.Min(D2[i]+A[i]%2,Math.Min(D1[i]+A[i]%2,Math.Min(D0[i]+A[i]%2,D[i]+A[i]%2)));
			}
			D3[i+1] = Math.Min(D3[i]+A[i],Math.Min(D2[i]+A[i],Math.Min(D1[i]+A[i],Math.Min(D0[i]+A[i],D[i]+A[i]))));
			//Console.WriteLine(D[i+1]+" "+D0[i+1]+" "+D1[i+1]+" "+D2[i+1]+" "+D3[i+1]);
		}
		ans = Math.Min(D3[L],Math.Min(D2[L],Math.Min(D1[L],Math.Min(D0[L],D[L]))));
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 24412
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,m; cin >> n >> m;
  
  vl cardnum(n);
  ll sum = 0;
  
  rep(i,n){
    cin >> cardnum[i];
    sum += cardnum[i];
  }
  
  sort(all(cardnum));
  
  vector<pair<ll,ll>> change(m);
  
  
  rep(i,m){
    ll a,b; cin >> a >> b;
    change[i] = make_pair(b,a);
  }
  
  sort(all(change));
  reverse(all(change));
  
  /*for(auto p : change){
    cout << p.first << p.second;
  }
  for(ll x : cardnum){
    cout << x; 
  }*/
  
  ll nowcard = 0;
  for(auto p : change){
    for(ll i=0; i < p.second; i++){
      if(nowcard != n and cardnum[nowcard] < p.first){
        sum += p.first - cardnum[nowcard];
        nowcard++;
      }
      else{
        cout << sum << endl;
        return 0;
      }
    }
  }
  
  cout << sum << endl;
  
  
}

Measured memory_bytes: 5540
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    String scores[] = new String[N];
    for (int count = 0; count < N; count++){
      String a = sc.next();
      scores[count] = a;
    }
		if(Arrays.asList(scores).contains("P") && Arrays.asList(scores).contains("W") &&
		Arrays.asList(scores).contains("G") && Arrays.asList(scores).contains("Y")){System.out.println("Four");}
		else{System.out.println("Three");}
   }
 }


Measured memory_bytes: 23508
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
for i in range(n):
    if b[i]<=a[i]:
        d+=a[i]-b[i]
    else:
        k=b[i]-a[i]
        if k%2==1:
            d+=1
            c+=(k+1)//2
        else:
            c+=k//2
print("Yes" if c>=d else"No")

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

#include <iostream>
#include <string>
#include <map>
using namespace std;

long long A[100002] = {0};
long long  S[100002] = {0};
map<long long, long long> m;

int main(int argc, char* argv[]){
	int N;
	long long M; //N 1.. 100000 M 2..1000000000 

	cin >> N >> M ;

	A[0] = 0, S[0] = 0;
	for(int i=1; i<=N; i++){
		cin >> A[i];
		S[i] = ( S[i-1]+A[i] ) % M;
		if(m.count(S[i])==0){
			m[S[i]] = 1;
		}
		else{
			long long r = m[S[i]];
			m[S[i]] = r+1;
		}
	}

	unsigned long long ans = 0;
	for(auto it=m.begin(); it!=m.end(); ++it){
		long long k, v;
		k = it->first;
		v = it->second;
		if(k==0){
			ans = ans + v + (v*(v-1))/2; //重複OK
		}
		else{
			ans = ans + (v*(v-1))/2;
		}
	}
	printf("%llu\n", ans);
	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>

typedef struct {
	char m_aLetter[4];
}Squares;

int main(void) {
	int i;
	//構造体変数の定義
	Squares astSquares[3];

	//変数にアルファベットを入力
	scanf("%c    %c %c", &astSquares[0].m_aLetter[0], &astSquares[0].m_aLetter[1], &astSquares[0].m_aLetter[2]);
	scanf("%*c%c %c %c", &astSquares[1].m_aLetter[0], &astSquares[1].m_aLetter[1], &astSquares[1].m_aLetter[2]);
	scanf("%*c%c %c %c", &astSquares[2].m_aLetter[0], &astSquares[2].m_aLetter[1], &astSquares[2].m_aLetter[2]);

	printf("\n");
	//並んだアルファベットの中で左上、中央、右下の3つを順番に表示
	for (i = 0; i < 3; i++) {
		printf("%c",astSquares[i].m_aLetter[i]);
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 2052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(vals.Sum() - N);
        }
    }
}


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

int main(){
	int N;
	cin >> N;
	while(N--){
		string order, mess;
		cin >> order >> mess;
		for(int i = order.size() - 1; i >= 0; i--){
			char c;
			switch(order[i]){
				case 'J':
					c = mess[mess.size() - 1];
					for(int j = mess.size() - 1; j > 0; j--){
						mess[j] = mess[j - 1];
					}
					mess[0] = c;
					break;
				case 'C':
					c = mess[0];
					for(int j = 1; j < mess.size(); j++){
						mess[j - 1] = mess[j];
					}
					mess[mess.size() - 1] = c;
					break;
				case 'E':
					if(mess.size() % 2){
						mess = mess.substr(mess.size() / 2 + 1) + mess[mess.size() / 2] + mess.substr(0, mess.size() / 2);
					}else{
						mess = mess.substr(mess.size() / 2) + mess.substr(0, mess.size() / 2) ;
					}
					break;

				case 'A':
					reverse(mess.begin(), mess.end());
					break;
				case 'P':
					for(int i = 0; i < mess.size(); i++){
						c = mess[i];
						if('0' <= c && c <= '9'){
							mess[i] = (c - '0' + 9) % 10 + '0';
						}
					}
					break;
				case 'M':
					for(int i = 0; i < mess.size(); i++){
						c = mess[i];
						if('0' <= c && c <= '9'){
							mess[i] = (c - '0' + 1) % 10 + '0';
						}
					}
					break;
			}
		}
		cout << mess << endl;
	}

}

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

int main(void) {
	char s[200010];
	char t[200010];
	int i=0;
	int imax = 0;
	int count = 0;
	
	scanf("%s",s);
	scanf("%s",t);
	//printf("%s\n",s);
	
	//printf("%d\n",strlen(s));
	

	for(i=0;i<strlen(s);i++){
		if(s[i] != t[i]){
			//printf("%d %c",i,s[i]);
			count = count + 1;
		}
	}
	
	printf("%d",count);
	
	
	/*
	for(i=0;i<200005;i++){
		printf("%c",s[i]);
		if(t[i]="\n"){
			break;
		}
	}
	*/
	
	//scanf("%d",&a);
	//printf("%d",a+(a*a)+(a*a*a));
	return 0;
}


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

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  rd(int, x);
  if (x >= 30) {
    wt("Yes");
  } else {
    wt("No");
  }
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

struct node{
  int c, v, a, b;
  vector<node*> suc;
};

int main(){
  int n, m; cin >> n >> m;
  string s; cin >> s;
  vector<node> g(n);
  vector<bool> use(n, true);

  REP(i, n){
    g[i].c = s[i] == 'A';
    g[i].v = i;
  }

  REP(i, m){
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].suc.emplace_back(&g[b]);
    g[b].suc.emplace_back(&g[a]);
  }

  //既に満たしていない点をチェック
  queue<int> q;
  REP(i, n){
    REP(j, g[i].suc.size()){
      if(g[i].suc[j]->c) g[i].a++;
      else g[i].b++;
    }
    if(g[i].a==0 || g[i].b==0){
      q.push(i);
      use[i] = false;
    }
  }
  
  //条件を満たしていない点を取り除いて行く
  int cnt = 0;
  while(!q.empty()){
    int v = q.front(); q.pop();
    cnt++;
    REP(i, g[v].suc.size()){
      node* next = g[v].suc[i];
      if(v == next->v) continue;

      if(g[v].c == 1) next->a--;
      else next->b--;

      if(next->a == 0 || next->b == 0){
        if(use[next->v]){
          use[next->v] = false;
          q.push(next->v);
        }
      }
    }
  }

  if(cnt == n) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 14980
#include<iostream>
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){
 int i;
 cin >> i;
 call(i);
}

Measured memory_bytes: 3076
#include<stdio.h>

int main(void){
	
	int x,y;
	
	int i;   //????????????????????¶?????¨?????°
	
	for(i=1;i<=3000;i++){
	
		for(;;){
			
			// 0<=x,y<=10000
			do{
				scanf("%d %d",&x,&y);
			}while((x<0)||(y<0)||(x>10000)||(y>10000));   
			
			if((x==0)&&(y==0)){
				break;
			}
			
			
			int tmp;   //x,?????\???????????¨????????°
			
			if(x>y){
				tmp=y;
				y=x;
				x=tmp;
			}
			
			
			printf("%d %d\n",x,y);
		
			}
		
		if((x==0)&&(y==0)){
				break;
			}
		
	}
	
	
	return 0;
}

Measured memory_bytes: 600
// Rectangle.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	int area = a * b;
	int lap = 2 * (a + b);
	cout << area << " " << lap << endl;
}


Measured memory_bytes: 3096
from collections import deque
h, w = map(int, input().split())
a = [input() for _ in range(h)]
inf = 10 ** 7

d = [[inf for _ in range(w)] for _ in range(h)]
que = deque()

for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((i, j))
            d[i][j] = 0

while que:
    px, py = que.popleft()
    for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        qx, qy = px + dx, py + dy
        if 0 <= qx < h and 0 <= qy < w:
            if d[qx][qy] > d[px][py] + 1:
                d[qx][qy] = d[px][py] + 1
                que.append((qx, qy))

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, d[i][j])

print(ans)

Measured memory_bytes: 88796
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++){
		cin >> A[i] >> B[i];
	}
	long long ans = 0;
	int X = 0;
	for (int i = 29; i >= 0; i--){
		if (K >> i & 1){
			int Y = X + (1 << i) - 1;
			long long tmp = 0;
			for (int j = 0; j < N; j++){
				if ((Y & A[j]) == A[j]){
					tmp += B[j];
				}
			}
			ans = max(ans, tmp);
			X += 1 << i;
		}
	}
	long long tmp = 0;
	for (int i = 0; i < N; i++){
		if ((K & A[i]) == A[i]){
			tmp += B[i];
		}
	}
	ans = max(ans, tmp);
	cout << ans << endl;
}

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

int main(){
  int a, b, c; cin>>a>>b>>c;

  if((a == b and a != c) or (a == c and a != b) or (b == c and b != a)){
    cout<<"Yes\n";
    }else{
        cout<<"No\n";
      }
  return 0;
  }


Measured memory_bytes: 256
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def prob():
    d = Debug()
    d.off()
    N = getInt()
    V = getIntList()
    C = getIntList()
    d.dmp((N),'N')
    d.dmp((V),'V')
    d.dmp((C),'C')
    smMarg = 0
    for i in range(N):
        marg = V[i]-C[i]
        if marg > 0:
            smMarg += marg
            #d.dmp((i,marg,smMarg),'(i,marg,smMarg)')
    return smMarg

ans = prob()
print(ans)

Measured memory_bytes: 3064
//#define FILE_INPUT
#define _CRT_SECURE_NO_WARNINGS
//                 _                      
//                (_)                     
// _ __ ___   __ _ _  ___  _ __ _ __ ___  
//| '_ ` _ \ / _` | |/ _ \| '__| '__/ _ \ 
//| | | | | | (_| | | (_) | |  | | | (_) |
//|_| |_| |_|\__,_| |\___/|_|  |_|  \___/ 
//               _/ |                     
//              |__/                      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
  
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vbl;
typedef tree<
    pll,
    null_type,
    less<pll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;

#define majorro cout.precision(20); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define forn(i, n) for(ll (i) = 0; (i) < (n); ++(i))
#define fornm(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define rfornm(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define readvec(vector, n) {ll temp_vec_val;forn(inc, n){cin >> temp_vec_val;vector.push_back(temp_vec_val);}}
#define printvec(vector, delimeter) {ll length_of_vector=vector.size();\
                                    forn(elementvec, length_of_vector){cout << vector[elementvec] << delimeter;}}
#define printarr(arr, length, delimeter) {forn(elementarr, length){cout << arr[elementarr] << delimeter;}}
#define all(vector) (vector).begin(), (vector).end()
#define rall(vector) (vector).rbegin(), (vector).rend()
#define endl "\n"
  
struct pair_hash
{
    template <class T1, class T2>
    std::size_t operator() (const std::pair<T1, T2>& pair) const
    {
        return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
    }
};
 
const ldbl EPS = 1e-6;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const ll MOD = 3037000499;
// const ull MOD = 1000000000000000003;
const ll INF = 1e18;
const ldbl pi = 2 * acos(0.0);
ll n, m, k, p, q, t, sum = 0, cnt= 0;
ll mx = -INF;
ll mn = INF;
bool flag = 0;
vll v;
str s = "", s1, s2;
 
void bad_solve(){}

void solve() //set.merge() -> c++17
//DELET DEBUG OUTPUT!11!1
//"YES"/"NO" OUTPUT!!!!
//__builtin_popcountll() -> __popcnt64() from <intrin.h>
{
    cin >> k >> s;
    n = s.size();
    forn(i,min(k,n)) cout << s[i];
    if(k < n) cout << "...";
}

int main()
{
#ifdef FILE_INPUT
    freopen("F:\\repos\\projects\\contests_vsc\\in.txt", "r", stdin);
    freopen("F:\\repos\\projects\\contests_vsc\\out.txt", "w", stdout);
#endif
    majorro
    
    solve();
  
    // freopen("test.txt", "w", stdout);
    // bad_solve();
  
//  memset(v, INT_MAX, 1000*2000*sizeof(int));
  
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int A[30][31];
  for (int i = 0; i < N; i++) {
    cin >> A[i][0];
    for (int j = 1; j <= A[i][0]; j++) cin >> A[i][j];
  }

  int food[30] = {};
  for (int i = 0; i < N; i++) for (int j = 1; j <= A[i][0]; j++) food[A[i][j] - 1]++;

  int ans = 0;
  for (int i = 0; i < M; i++) if (food[i] == N) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){L d;Z[a]=1;for(map<L,L>::iterator I=T[a].begin();I!=T[a].end();I++)
    d=I->first,d-P[a]?P[d]=a,E[d]=E[a]+1,C[d]=I->second,D(d),Z[a]+=Z[d],!H[a]|Z[H[a]]<Z[d]?H[a]=d:0:0;}
#define G(a)((r=A[a]+A[P[a]]+C[a])%k?r:0)
L M(L i){return i?B[i]+M(i^i&-i):0;}
L S(L x,L i){for(x=G(x)+M(i++)-M(i);i<1<<17;i+=i&-i)B[i]+=x;}
L K(L a){p=X[a];n=X[b];return p-n?E[p]<E[n]?swap(p,n),swap(a,b),0:0,M(O[a])-M(O[p])+G(p)+K(P[p]):abs(M(O[a])-M(O[b]));}
main(){for(cin>>n>>k;++p<n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?cout<<K(a)<<endl,0:A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}

Measured memory_bytes: 33488
#include <iostream>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;


using P = pair<int, int>;


int n;
int q;
P seg[3000000];


int parent(int c){
	return (c - 1) / 2;
}


int nodeN(int i){
	return n + i - 1;
}


int otherC(int node){
	return (2 * parent(node) + 1) < node ? node - 1: node + 1;
}


void update(int c1){
	int c2 = otherC(c1);
	int p = parent(c1);
	while(c1 != 0){
		if(seg[c1].second == seg[c2].second){
			seg[p].first = min(seg[c1].first, seg[c2].first);
			seg[p].second = seg[c1].second;
		}
		else if(seg[c1].second > seg[c2].second){
			seg[p] = seg[c1];
		}
		else {
			seg[p] = seg[c2];
		}
		c1 = p;
		c2 = otherC(c1);
		p = parent(c1);
	}
}


int main(){
	cin >> n >> q;
	n = (int)pow(2, ceil(log2(n)));
	for(int i = 0;i < q;i++){
		int a, v;
		cin >> a >> v;
		a--;
		int node = nodeN(a);
		seg[node].first = a + 1;
		seg[node].second += v;
		update(node);
		cout << seg[0].first << ' ' << seg[0].second << endl;
	}

	return 0;
}

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

bool is_753_number(ll num)
{
    auto num_s = to_string(num);
    auto count_3 = count(begin(num_s), end(num_s), '3');
    auto count_5 = count(begin(num_s), end(num_s), '5');
    auto count_7 = count(begin(num_s), end(num_s), '7');

    return (count_3 > 0 && count_5 > 0 && count_7 > 0
        && count_3 + count_5 + count_7 == (ll)num_s.size());
}

void main_()
{
    ll N;
    cin >> N;

    queue<ll> que;
    que.push(3);
    que.push(5);
    que.push(7);

    ll ans = 0;
    while (true) {
        auto n = que.front();
        que.pop();
        if (n > N) {
            cout << ans << endl;
            return;
        }
        if (is_753_number(n)) {
            ans++;
        }
        que.push(n * 10 + 3);
        que.push(n * 10 + 5);
        que.push(n * 10 + 7);
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  int x;
  cin >> x;
  for (int a = x; a <= inf; a++) {
    bool flag= true;
    for (int j = 2; j < a; j++) {
      if (a % j == 0) flag = false;
        
    }
    if (flag) {
      cout << a << endl;
      return 0;
    }
  }
}


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

int main(){
    string s;
    cin >> s;
    long long ans = 0;
    rep(i,s.size()){
        int num = s[i] - '0';
        ans += num;
    }
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

struct Node {
    std::vector<int> edge;
};

int n;
Node *tree;
bool *painted;

int opening(int, int);
int dfs(int);

int main()
{
    scanf("%d", &n);
    tree = new Node[n];
    painted = new bool[n];
    std::fill(painted, painted + n, false);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a--; b--;
        tree[a].edge.push_back(b);
        tree[b].edge.push_back(a);
    }
    
    opening(0, 0);
    std::fill(painted, painted + n, false);
    if (dfs(0) > dfs(n - 1)) printf("Fennec\n");
    else printf("Snuke\n");

    delete[] tree;
    delete[] painted;
    return 0;
}

int opening(int pos, int depth)
{
    if (painted[pos]) return -1;
    if (pos == n - 1) return depth;
    painted[pos] = true;
    for (auto &e: tree[pos].edge)
    {
        int snuke_depth = opening(e, depth + 1);
        if (snuke_depth == -1) continue;
        if (depth != snuke_depth / 2) return snuke_depth;
        std::swap(tree[e].edge.back(), *std::find(tree[e].edge.begin(), tree[e].edge.end(), pos));
        tree[e].edge.pop_back();
        std::swap(tree[pos].edge.back(), *std::find(tree[pos].edge.begin(), tree[pos].edge.end(), e));
        tree[pos].edge.pop_back();
        return snuke_depth;
    }
    return -1;
}

int dfs(int pos)
{
    if (painted[pos]) return 0;
    painted[pos] = true;
    int count{1};
    for (auto &e : tree[pos].edge)
    {
        count += dfs(e);
    }
    return count;
}

Measured memory_bytes: 12032
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=5e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

const int MSQ = sqrt(N) + 5;


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

	int n,m;

	scanf("%d %d",&n,&m);

	std::vector<int> a(m);

	for(auto &x:a)scanf("%d",&x);

	sort(all(a));

	std::vector<int> wa;

	for(int i=1;i<m;i++)wa.pb(a[i]-a[i-1]);

	sort(all(wa));
	ll ans = 0;
	for(int i=0;i<m-n;i++){
		ans+=wa[i];
	}
	printf("%lld\n",ans );
}		



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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

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

	cout << 2 * c - a << endl;
	return 0;
}


Measured memory_bytes: 384
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
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
}

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	s := scanString()

	if len(s) == 2 {
		if s[0] == s[1] {
			fmt.Fprintln(wr, 1,2)
		} else {
			fmt.Fprintln(wr, -1,-1)
		}
		return
	}

	for i := 0; i < len(s)-2; i++ {
		if s[i] == s[i+1] || s[i+1] == s[i+2] || s[i+2] == s[i] {
			fmt.Fprintln(wr, i+1, i+3)
			return
		}
	}

	fmt.Fprintln(wr, -1,-1)
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
signed main(){
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	vector<int>d(n);
	vector<int>w(n,1);
	map<int,int>mm;
	for(int i=0;i<n;i++){
		cin>>d[i];
		mm[d[i]]=i;
	}
	vector<pii>res;
	for(int iit=0;iit<n-1;iit++){
		auto it=mm.rbegin();
		int i=it->S;
		int x=d[i]-(n-w[i])+w[i];
		if(!mm.count(x)||mm[x]==i)return puts("-1"),0;
		int j=mm[x];
		res.pb(mp(i,j));
		w[j]+=w[i];
		mm.erase(--mm.end());
	}
	vector<int>v(n,-1);
	vector<vector<int> >G(n);
	v[0]=0;
	for(auto&p:res){
		G[p.F].pb(p.S);
		G[p.S].pb(p.F);
	}
	vector<int>qq(1,0);
	for(int b=0;b<(int)(qq.size());b++)
		for(int j:G[qq[b]])
			if(v[j]==-1){
				qq.pb(j);
				v[j]=v[qq[b]]+1;
			}
	if(accumulate(v.begin(),v.end(),0LL)!=d[0])return puts("-1"),0;
	for(auto&p:res)cout<<p.F+1<<' '<<p.S+1<<endl;
	return 0;
}


Measured memory_bytes: 12660
#include <iostream>
#include <queue>
#define N 21
using namespace std;
bool a[N][N];
queue<pair<int,int>>q;
int n,m, dl[4]={0,1,0,-1}, dc[4]={1,0,-1,0}, v[N][N],mx=1;
void lol(int i,int j){
    while(!q.empty())
        q.pop();
    for(int o=1; o<=n; ++o){
        for(int k=1; k<=m; ++k){
            v[o][k]=0;
        }
    }
    v[i][j]=1;
    q.push({i,j});
    while(!q.empty()){
        i=q.front().first;
        j=q.front().second;
        mx=max(mx,v[i][j]);
        for(int k=0; k<4; ++k){
            i+=dl[k], j+=dc[k];
            if(i>=1 && i<=n && j>=1 && j<=m && !v[i][j] && !a[i][j]){
                v[i][j]=v[i-dl[k]][j-dc[k]]+1;
                q.push({i,j});
            }
            i-=dl[k], j-=dc[k];
        }
        q.pop();
    }
}
int main(){
    int i,j;
    char c;
    cin>>n>>m;
    for(i=1; i<=n; ++i){
        for(j=1; j<=m; ++j){
            cin>>c;
            a[i][j]=(c!='.');
        }
    }
    for(i=1; i<=n; ++i){
        for(j=1; j<=m; ++j){
          	if(!a[i][j])
            	lol(i,j);
        }
    }
    cout<<mx-1;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N;
int a[100], s;
long long dp[100][1000];

long long solve(int now, int m) {
	if (!(0 <= m && m <= 20)) {
		return 0;
	}

	if (now == N - 1) {
		if (m == s) {
			return 1;
		}
		else {
			return 0;
		}
	}

	if (dp[now][m] != -1) return dp[now][m];

	dp[now][m] = solve(now + 1, m + a[now]) + solve(now + 1, m - a[now]);

	return dp[now][m];
}

int main() {
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> a[i];

		for (int j = 0; j < 1000; j++) {
			dp[i][j] = -1;
		}
	}
	cin >> s;

	cout << solve(1, a[0]) << endl;


	return 0;

}



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

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int power( int a, int b )
{
    if( b == 0 )
        return 1;
    int c = 1;
    for( int i = 0; i < b; i++ )
        c *= a;
    return c;
}

struct divisor
{
    int value, cnt;
};

int main()
{
    int n, m;
    vector<divisor> v(100);

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

        m = n;

        for( int i = 0; i < v.size(); i++ )
        {
            v[i].value = 0;
            v[i].cnt = 0;
        }

        if( judgePrimeNumber(n) == 1 )
            cout << "deficient number" << endl;
        else
        {
            while( n != 1 )
            {
                for( int i = 2; i <= n; i++ )
                    if( n % i == 0 )
                    {
                        for( int j = 0; j < v.size(); j++ )
                        {
                            if( v[j].value == 0 )
                            {
                                v[j].value = i;
                                v[j].cnt++;
                                break;
                            }
                            if( v[j].value == i )
                            {
                                v[j].cnt++;
                                break;
                            }
                        }
                        n /= i;
                        break;
                    }
            }

            int dcnt = 0;
            for( int i = 0; i < v.size(); i++ )
            {
                if( v[i].value == 0 )
                    break;
                dcnt++;
            }

            int div[dcnt], res = 0;
            for( int i = 0; i < dcnt; i++ )
                div[i] = 0;
            while( 1 )
            {
                bool judge = false;
                for( int i = 0; i < dcnt; i++ )
                    if( v[i].cnt != div[i] )
                        judge = true;
                
                int sum = 1;
                for( int i = 0; i < dcnt; i++ )
                    sum *= power( v[i].value, div[i] );

                res += sum;

                if( judge == false )
                    break;

                div[0]++;
                for( int i = 0; i < dcnt; i++ )
                {
                    if( div[i] > v[i].cnt )
                    {
                        div[i] = 0;
                        div[i+1]++;
                    }
                }
            }
            if( res - m < m )
                cout << "deficient number" << endl;
            else if( res - m > m )
                cout << "abundant number" << endl;
            else
                cout << "perfect number" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3008
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    println(ifelse(join(sort(collect(chomp(readline()))))<join(sort(collect(chomp(readline())),rev=true)),"Yes","No"))
end
main()

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

int main(void){
  int n,i;
  double hensa2,bunsan,sum,heikin;
  while(1){
    hensa2=0;
    sum=0;
    scanf("%d",&n);
    if(n==0) break;
    double s[n];
    for(i=0;i<n;i++){
      scanf("%lf",&s[i]);
      sum+=s[i];
    }
    heikin=sum/n;
    for(i=0;i<n;i++){
      hensa2+=(s[i]-heikin)*(s[i]-heikin);
    }
    bunsan=hensa2/n;
    printf("%lf\n",sqrt(bunsan));
  }
  return 0;
}


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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
const int N=2e5+5;
int a[N],nex[N];

int main()
{
	//freopen("1.in","r",stdin);
	int n;cin>>n;
	rep(i,1,n)scanf("%d",a+i);
	nex[n+1]=n+1;
	per(i,n,1)nex[i]=a[i]?i:nex[i+1];
	s64 ans=0;int r=n,now=0;
	per(l,n,1)
	{
		while(now&a[l])
		{
			now-=a[r];
			--r;
		}
		ans+=r-l+1;
		now+=a[l];
	}
	cout<<ans;
}

Measured memory_bytes: 1792
def bubbleSort(A, N):
    flag = 1
    count = 0
    while flag == 1:
        flag = 0
        for i in range(1, N)[::-1]:
            if A[i] < A[i - 1]:
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = 1
                count += 1

    print(" ".join(map(str, A)))
    print(count)

n = int(input())
A = list(map(int, input().split()))

bubbleSort(A, n)

Measured memory_bytes: 7824