akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int n;
    cin >> n;

    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());

    ll ans = 0;
    int rest = n - 1;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            --rest;
            ans += a[i];
        } else {
            int hoge = min(rest, 2);
            ans += a[i] * hoge;
            rest -= hoge;
        }
    }
    cout << ans << newl;

    return 0;
}

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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int n, k;
        cin >> n >> k;
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                int x;
                cin >> x;
                ans += 2 * min(x, k - x);
        }
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  double S;
  S=0;
  cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    S+=(double)1/A[i];
  }
  double ans;
  ans = 1/S;
  cout<<ans<<endl;
  return 0;
}


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

const int LLINF = 1LL << 60;

char ch[] = "ENWS";
int mx[] = {1, 0, -1, 0};
int my[] = {0, 1, 0, -1};

signed main()
{
  int N, M;
  while(cin >> N, N) {
    
    bool mas[25][25] = {0};
    int A, B; char C;
    int x, y, cnt = 0; x = y = 10;

    Rep(i, N) {
      cin >> A >> B; mas[B][A] = true;
    }
    if(mas[10][10]) mas[10][10] = false, cnt++;
    cin >> M;
    while(M--) {
      cin >> C >> A;
      Rep(i, 4) {
	if(C == ch[i]) {
	  Rep(j, A) {
	    y += my[i], x += mx[i];
	    if(mas[y][x]) mas[y][x] = false, cnt++;
	  }
	}
      }
    }

    if(cnt == N) cout << "Yes" << endl;
    else cout << "No" << endl;
   
  }
  return 0;
}

Measured memory_bytes: 3076
N = int(input())
S = input()

w = 0
e = S[1:].count('E')
score = w + e

for i in range(1, N):
    if S[i] == 'E':
        e -= 1
    if S[i-1] == 'W':
        w += 1
    score = min(score, w + e)

print(score)

Measured memory_bytes: 3700
#include <iostream>
#include <string>

using namespace std;

string sheepAndWolf(int sh, int wl) {
    string retrunValue{ "unsafe" };
    if (sh > wl) retrunValue = "safe";

    return retrunValue;
}

int main() {
    int sheep, wolf;
    cin >> sheep;
    cin >> wolf;

    cout << sheepAndWolf(sheep, wolf) << endl;
    return 0;
}

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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 1000000007
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define vi vector<int> 
#define vll vector<ll>
#define all(c) c.begin(),c.end()
#define tr(it,c) for( typeof(c.begin()) it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }

int main()
{
    boost;
    int n,a,b,c,i,preva,prevb,prevc;
    
    cin>>n;
    cin>>preva>>prevb>>prevc;
    
    for(i=1;i<n;i++)
    {
        cin>>a>>b>>c; int ta,tb,tc ;
        ta = a + max(prevb,prevc);
        tb = b + max(preva,prevc);
        tc = c + max(preva,prevb);
        preva=ta;prevb=tb;prevc=tc;
    }
    cout<<max({preva,prevb,prevc})<<endl;
    return 0;
}

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

#define int long long

using namespace std;

class Solver {
};
signed main() {
	vector<bool> isPrime(10005, true);
	vector<int> primes;
	for (int i = 2; i < isPrime.size(); i++) {
		if (!isPrime[i])continue;

		primes.emplace_back(i);

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

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

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

		int max = 0;
		for (int i = 0; i < vals.size(); i++) {
			if (vals[i] > n)break;
			max = vals[i];
		}
		cout << max - 2 << ' ' << max << endl;
	}
}


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

bool judge(string s) {
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i])
            return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    if (judge(s)) {
        cout << 0 << endl;
        return 0;
    }

    int p = 0;
    int q = s.size() - 1;
    int count = 0;
    while (p <= q) {
        if (s[p] == 'x' && s[q] == 'x') {
            p++;
            q--;
            continue;
        }
        if (s[p] == 'x') {
            p++;
            count++;
            continue;
        }
        if (s[q] == 'x') {
            q--;
            count++;
            continue;
        }

        if (s[p] != s[q]) {
            cout << -1 << endl;
            return 0;
        }
        p++;
        q--;
    }
    cout << count << endl;
    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	for (int i=0; i<s.length(); i++) {
		if (s[i] != t[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 3616
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> p(N);
  rep(i,N)cin >> p[i];
  vector<double> q(N);
  rep(i,N)q[i] = double(1 + p[i])/double(2);
  double max = 0.0;
  rep(i,K)max += q[i];
  double ans = max;
  rep(i,N-K){
    max -= q[i];
    max += q[i+K];
    if(max > ans)ans = max;
    //cout << ans << endl;
  }
  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 6408
import java.util.*;
import java.math.BigDecimal;

public class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    if(n%27!=0){
      BigDecimal x=BigDecimal.valueOf(n*25);
      BigDecimal dia=new BigDecimal("27");
      BigDecimal mua=new BigDecimal("1.08");
      BigDecimal one=new BigDecimal("1");
      BigDecimal oneo=new BigDecimal("-1");
      BigDecimal x1=x.divide(dia,0,BigDecimal.ROUND_HALF_UP);
      BigDecimal x2=x1.add(one);
      BigDecimal x3=x1.add(oneo);
      BigDecimal y1=x1.multiply(mua);
      BigDecimal y2=x2.multiply(mua);
      BigDecimal y3=x3.multiply(mua);
      y1=y1.setScale(0,BigDecimal.ROUND_DOWN);
      y2=y2.setScale(0,BigDecimal.ROUND_DOWN);
      y3=y3.setScale(0,BigDecimal.ROUND_DOWN);
      int s1=y1.intValue();
      int s2=y2.intValue();
      int s3=y3.intValue();
      if(s1==n){
        System.out.println(x1);
      }else if(s2==n){
        System.out.println(x2);
      }else if(s3==n){
        System.out.println(x3);
      }else{
        System.out.println(":(");
      }
    }else{
      System.out.println(n/27*25);
    }
  }
}

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

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n - i; j++) {
			if (9 * i + 4 * j == y / 1000 - n) {
				cout << i << " " << j << " " << n - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

int main() {
  char c;
  bool a[10][5];
  bool b[5][5][4];
  char label[4] = {'R', 'D', 'L', 'U'};
  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0}; 
  int x, y, d, nd;

  for (int i=0; i<9; i++) {
    int r = (i%2) ? 5 : 4;
    for (int j=0; j<r; j++) {
      cin >> c;
      a[i][j] = c - '0';
    }
  }

  for (int i=0; i<5; i++) {
    for (int j=0; j<5; j++) {
      b[i][j][0] = (j<4) ? a[2*i][j] : false;
      b[i][j][1] = (i<4) ? a[2*i+1][j] : false;
      b[i][j][2] = (j) ? a[2*i][j-1] : false;
      b[i][j][3] = (i) ? a[2*i-1][j] : false;
    }
  }

  d = 0;
  cout << label[d];
  x = 0; y = 1;
  do {
    for (int i=0; i<4; i++) {
      nd = (d+i+3)%4;
      if (b[x][y][nd]) {
        d = nd;
        break;
      }
    }
    cout << label[d];
    x += dx[d]; y+= dy[d];
  } while (x || y);
  cout << endl;

  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

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

  if (a > 9 || b > 9) {
    cout << -1 << endl;
  }
  else {
    cout << a * b << endl;
  }

  return 0;
}

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

using namespace std;

const int INF=100000000;

int main(){

	int m;
	cin>>m;
	for(int v = 0; v < m; v++){
		int n;
		cin>>n;
		string str;
		cin>>str;

		int pos=0;
		int cost=0;
		for(int i = 0; i <= 2*n; i+=2){
			if(i==0){
				bool b=false;
				if(str[i]=='Y'){
					cost+=1;
					pos=n+1;
					b=true;
				}
				if(str[2*n]=='Y'){
					if(!b)
						cost+=3;
					else
						cost+=2;
					pos=3*n+3;
				}
			}
			else if(i==2*n){
				if(pos!=0){
					if(str[4*n-1]=='Y'){
						if(pos>=3*n+3&&pos<=4*n+3){
							cost+=(4*n+3-pos)*2+2;
						}
						else{
							cost+=(4*n+3-(pos+2*n+2))*2+2;
						}
						pos=4*n+3;
					}
					if(str[2*n-1]=='Y'){
						if(pos>=n+1&&pos<=2*n+1){
							cost+=(2*n+1-pos)*2+2;
						}
						else{
							cost+=(2*n+1-(pos-2*n-2))*2+2;
						}
						pos=2*n+1;
					}
				}
				else{
					bool b=false;
					if(str[2*n-1]=='Y'){
//						if(!b)
						cost+=2*n+1;
						b=true;
	//					else
		//					cost+=2;
						pos=2*n+1;
					}
					if(str[4*n-1]=='Y'){
						if(!b)
							cost+=2*n+3;
						else
							cost+=2;
						pos=4*n+3;
						//b=true;
					}
				}
			}
			else{
				if(pos!=0){
					if(str[2*n+i]=='Y'||str[2*n+i-1]=='Y'){
						if(pos>=3*n+3&&pos<=4*n+3){
							cost+=(3*n+3+i/2-pos)*2+2;
						}
						else{
							cost+=(3*n+3+i/2-(pos+2*n+2))*2+2;
						}
						pos=3*n+3+i/2;
					}
					if(str[i-1]=='Y'||str[i]=='Y'){
						if(pos>=n+1&&pos<=2*n+1){
							cost+=(n+1+i/2-pos)*2+2;
						}
						else{
							cost+=(n+1+i/2-(pos-2*n-2))*2+2;
						}
						pos=n+1+i/2;
					}
				}
				else{
					bool b=false;
					if(str[i-1]=='Y'||str[i]=='Y'){
						cost+=i+1;
						pos=n+1+i/2;
						b=true;
					}
					if(str[2*n+i]=='Y'||str[2*n+i-1]=='Y'){
						if(!b)
							cost+=i+3;
						else
							cost+=2;
						pos=3*n+3+i/2;
					}
				}
			}
		}

		if(pos>=3*n+3&&pos<=4*n+3){
			cost+=(4*n+3-pos)*2+3;
		}
		else{
			cost+=(4*n+3-(pos+2*n+2))*2+2;
		}

		cout<<(cost)/2<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
/* ITP1_6_C: Official House */

#include <iostream>
#include <cstring>
#include <cstdio>

const int N_BUILDINGS = 4;
const int N_FLOORS = 3;
const int N_ROOMS = 10;

int main() {
    int ohouse[N_BUILDINGS][N_FLOORS][N_ROOMS] = {};
    int n_movings;
    int b_num, f_num, r_num;
    int n_people;

    std::cin >> n_movings;
    for (int i = 0; i < n_movings; i++) {
        std::cin >> b_num >> f_num >> r_num >> n_people;
        ohouse[b_num - 1][f_num - 1][r_num - 1] += n_people;
    }

    char divider[20];
    memset(divider, '#', sizeof(char) * 20);

    for (int i_b = 0; i_b < N_BUILDINGS; i_b++) {
        for (int i_f = 0; i_f < N_FLOORS; i_f++) {
            for (int i_r = 0; i_r < N_ROOMS; i_r++) {
                n_people = ohouse[i_b][i_f][i_r];
                printf(" %d", n_people);
            }
            printf("\n");
        }
        if (i_b < N_BUILDINGS - 1) {
            printf("%s\n", divider);
        }
    }
}

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

int a[200001];
bool vis[200001];

int dfs(int s)
{
	if(vis[s])
		return s;
	vis[s]=true;
	return dfs(a[s]);
}

int main()
{
	int n;
	long long k;
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	if(k>=100000000ll)
	{	
		int temp=dfs(1);
		
		int i=1,cnt=0;
		while(1)
		{
			i=a[i];
			cnt++;
			if(i==temp)
				break;
		}
		k-=cnt;
		cnt=0;
		
		while(1)
		{
			i=a[i];
			cnt++;
			if(i==temp)
				break;
		}
		k%=cnt;
		
		for(int i=1;i<=k;i++)
			temp=a[temp];
		cout<<temp<<endl;
	}
	else
	{
		int temp=1;
		for(int i=1;i<=k;i++)
			temp=a[temp];
		cout<<temp<<endl;
	}
	return 0;
}

Measured memory_bytes: 4612
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, x[100], y[100], h[100], outX, outY, outH;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	for (int X = 0; X <= 100; X++) {
		for (int Y = 0; Y <= 100; Y++) {
			bool check = true;
			int H;
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					H = h[i] + abs(X - x[i]) + abs(Y - y[i]);
				}
			}
			for (int i = 0; i < N; i++) {
				if (h[i] != max(H - abs(X - x[i]) - abs(Y - y[i]), 0)) check = false;
			}
			if (check) {
				outX = X;
				outY = Y;
				outH = H;
			}
		}
	}
	cout << outX << " " << outY << " " << outH;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd =1e5+10;
int abs(int x)
{
    if(x < 0) return -x;
    return x;
}
int a[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    int n,l,ans = 1e9,sum = 0;
    scanf("%d %d",&n,&l);
    for(int i=1;i<=n;i++)
    {
        a[i] = i + l -1;
        sum += a[i];
    }
    for(int i=1;i<=n;i++)
    {
        if( abs((sum - a[i]) - sum)< abs( ans - sum ))
            ans = sum - a[i];
    }
    printf("%d",ans);
    return 0;
}  

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main() {
	int a[11] = {};
	int b;
	cin >> b;
	a[b]++;
	cin >> b;
	a[b]++;
	cin >> b;
	a[b]++;

	ansYES(a[5] == 2 && a[7] == 1);
}

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

int main(){
	int n,a=0,l=0;
  	cin >> n;
  	vector<int> vec(n);
  	for(int i=0;i<n; i++){
    	cin >> vec.at(i);
    }
  	for (int i=0;i<n;i++){
    a=vec.at(a)-1;
    l++;
    if (a==1) break;
    }
  	if (a==1) cout << l <<endl;
  	else cout << -1 << endl;
}

Measured memory_bytes: 640
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    gcd=a
    return gcd

    
N=int(input())
HP=list(map(int,input().split()))

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

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

int main() {
  long long a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  long long ans = b - a + 1;
  ans -= b / c;
  ans += (a - 1) / c;
  ans -= b / d;
  ans += (a - 1) / d;
  ans += b / (c * d / __gcd(c, d));
  ans -= (a - 1) / (c * d / __gcd(c, d));
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int a, b, dif, height_w=0, height_e=1;
    cin >> a >> b;
    dif = b-a;
    for(int i=1; i<1000; i++){
        height_w += i;
        height_e += i+1;
        if(height_e - height_w == dif) break;
    }
    cout << height_w - a;
}

Measured memory_bytes: 256
k = int(input())
X,Y = map(int,input().split())
x = max(abs(X),abs(Y))
y = min(abs(X),abs(Y))
c = (k-(x+y)%k)%k
if k%2 == 0 and (x+y)%2 == 1:
  print(-1)
  exit()
  
import math
ans = []
m = math.ceil((x+y)/k)
if (x+y)/k == int((x+y)/k):
  for i in range(m):
    ans.append((min(x,k*i+k),max(0,k*i+k-x)))
    
elif m == 1:
  if (x+y)%2 == 1:
    ans.append((x,x-k))
    ans.append((x+(k+x-y)//2,(-k+x+y)//2))
    ans.append((x,y))
  else:
    ans.append(((x+y)//2,-k+(x+y)//2))
    ans.append((x,y))
               
elif c%2 == 0 and x+y >= k:
  a = abs((k*m-x-y)//2)
  for i in range(m-1):
    l = k*i+k
    if a >= l:
      ans.append((0,-l))
    elif a < l <= x+a:
      ans.append((l-a,-a))
    elif x+a < l:
      ans.append((x,l-x-2*a))
  ans.append((x,y))
  
else:
  m += 1
  a = abs((k*m-x-y)//2)
  for i in range(m-1):
    l = k*i+k
    if a >= l:
      ans.append((0,-1))
    elif a < l <= x+a:
      ans.append((l-a,-a))
    elif x+a < l:
      ans.append((x,l-x-2*a))
  ans.append((x,y))
  
print(len(ans))
for i,j in ans:
  if abs(X) < abs(Y):
    i,j = j,i
  if X < 0:
    i *= -1
  if Y < 0:
    j *= -1
  print(i,j)

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

 
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 int t=1;
    // cin>>t;
  while(t--){
    string s;
    cin>>s;
    int n = s.length();
    if(s[n-1]=='s'){
        cout<<s.substr(0,n)<<"es";
    }else{
        cout<<s<<"s";
    }
  }
}

Measured memory_bytes: 3664
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a > b)cout << ">";
	else if (a < b)cout << "<";
	else cout << "=";


	return 0;
}





Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

int n,x;
char s[20];

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	rep(i,1,n) if (s[i]=='x') x++;
	if (x>7) puts("NO"); else puts("YES");
	return 0;
}

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

int main(){
  int n,l; cin>>n>>l;
  int ind;
  vector<int> a(n);
  bool flag=false;
  
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++){
    if(a[i]+a[i+1] >= l){
      flag = true;
      ind = i;
      ind++;
      break;
    }
  }

  if(flag){
    cout<<"Possible"<<endl;
    
    for(int i=n-1; i>ind; i--) cout<<i<<endl;
    for(int i=1; i<ind; i++) cout<<i<<endl;
    cout<<ind<<endl;
  }else
    cout<<"Impossible"<<endl;

  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string s, t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        if(s[i] != t[2-i]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;


vector<ULL> Divs(ULL a, ULL p = 2) {
	if (a == 1) return { 1 };
	for (; a % p != 0; p++) if (p * p > a) return { 1, a };
	ULL n = 1;
	for (; a % p == 0; n++) a /= p;
	vector<ULL> buf = Divs(a, p + 1 | 1);
	ULL i = buf.size(), l = buf.size();
	buf.resize(i * n);
	for (; i < buf.size(); i++) buf[i] = buf[i - l] * p;
	return buf;
}

struct Problem {

	void Solve() {
		ULL N; cin >> N;
		vector<ULL> ans = Divs(N - 1);
		auto fN = Divs(N);
		for (auto f : fN) {
			if (f == 1) continue;
			ULL tmp = N;
			while (tmp % f == 0) tmp /= f;
			if ((tmp - 1) % f == 0) ans.push_back(f);
		}
		cout << (ans.size() - 1) << endl;
	}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
using namespace std;
inline LL read(){
	int ret=0,p=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){if (ch=='-') p=-1;ch=getchar();}
	while (ch>='0' && ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*p;
}
int n;
char a[300000+3];
int sum1,sum2;
int main(){
	n=read();
	scanf("%s",a+1);
	sum1=sum2=0;
	for (int i=2;i<=n;i++){
		if (a[i]=='E') sum2++;
	}
	int ans=1000000000;
	for (int i=1;i<=n;i++){
		ans=min(ans,sum1+sum2);
		if (a[i]=='W') sum1++;
		if (a[i+1]=='E') sum2--;
	}
	printf("%d\n",ans);
	return 0;
}

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

string s;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> s;
    ll ans = 0, ac = 0;
    for (int i = 0; i < (int)s.size() - 1; i++) {
        if (s[i] == 'A') ac++;
        else if (s[i] == 'B' && s[i + 1] == 'C') {
            ans += ac;
            i++;
        } else ac = 0;
    }
    cout << ans;
}   
    


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

int main() {
    int s = 0;
    int w = 0;
    cin >> s >> w;
    
    if(s > w){
        cout << "safe" << endl;
    }else{
        cout << "unsafe" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>

int main(){
  int n;
  std::cin >> n;
  std::cout << n << ":";
  
  int i = 2;
  int odd = 0;
  while(i<=n){
    if(n%i==0){
        std::cout << " " << i;
        n /= i;
        i = 2;
        odd = 0;
     }else{
        if(i==2 && odd==0){
          odd = 1;
          i = 3;
        }
        else if(i>n/2){
        i = n;
        }else{
          if(odd==1) i += 2;
          else       i++;
        }
     }
  }
  std::cout << std::endl;
  
  return 0;
}

Measured memory_bytes: 3080
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

#define len(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define all(a) (a).begin(), (a).end()
#ifdef LOCAL
	#define dbg(x) cout << #x << " = " << x << endl;
#else 
	#define dbg(x)
#endif 

using namespace std;

void solve(); signed main() {
#ifdef LOCAL
    freopen("file1.txt", "r", stdin);                                       
    freopen("file2.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
}

const int INF = 1e9, MAXN = 1e5 + 10;                 	

void solve() {                         
	int a, b;
	cin >> a >> b;
	
	int cnt = 1; 
	for (int i = 0; i < 100; ++i) {
	 	if (cnt >= b) {
	 	 	cout << i << endl;
	 	 	return;
	 	}
	 	cnt += (a - 1);
	}

	cout << cnt << endl;
}	


Measured memory_bytes: 256
import math
N = int(input())
S = input()
outexp = 0

def comb(n, r):
  comb = math.factorial(n) / (math.factorial(r) * math.factorial(n - r))
  return comb

R = S.count('R')
G = S.count('G')
B = S.count('B')

if R >= 3:
  Rnum = comb(R, 2) * (N - R) + comb(R, 3)
if R == 2:
  Rnum = N - R
if R <= 1:
  Rnum = 0

if B >= 3:
  Bnum = comb(B, 2) * (N - B) + comb(B, 3)
if B == 2:
  Bnum = N - B
if B <= 1:
  Bnum = 0

if G >= 3:
  Gnum = comb(G, 2) * (N - G) + comb(G, 3)
if G == 2:
  Gnum = N - G
if G <= 1:
  Gnum = 0

for i in range(N - 2):
  m = 1
  while 2 * m + i <= N - 1:
    if not S[i] == S[i + m]:
      if not S[i + m] == S[i + 2 * m]:
        if not S[i] == S[i + 2 * m]:
          outexp += 1
    m += 1

sum = comb(N, 3) - Rnum - Bnum - Gnum - outexp

print(int(sum))

Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>

using namespace std;

unordered_map<int, set<int> *> visited;
struct Node {
  int d;
  int i;
  vector<Node *> neighbors;

  Node(int _d, int _i) { 
    d=_d; i=_i; 
  }
  void Add(Node *n) {
    neighbors.push_back(n);
  }

  void DFS(set<int> &iList) {
    visited[i] = &iList;
    iList.insert(i);

    for(auto neighbor : neighbors) {
      if(visited[neighbor->i])
	continue;
      neighbor->DFS(iList);
    }
  }
};

int main() {
  int n, m;
  vector<Node*> nodes;
  cin>>n>>m;
  for(int i=0; i<n; i++) {
    int d;
    cin>>d;
    nodes.push_back(new Node(d, i+1));    
  }

  for(int i=0; i<m; i++) {
    int x, y;
    cin>>x>>y;
    nodes[x-1]->Add(nodes[y-1]);
    nodes[y-1]->Add(nodes[x-1]);
  }

  int count=0;
  for(auto n : nodes) {
    if(visited[n->i]) {
      if(visited[n->i]->find(n->d)!=visited[n->i]->end())
	count++;
    }
    else {
      set<int> *iList = new set<int>();
      n->DFS(*iList);
      if(iList->find(n->d)!=iList->end())
	count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 22516
n, m = map(int, input().split())
aa = [int(ak) % m for ak in input().split()]
mod = {}
ans = 0
zi = 0
for a in aa:
    zi = (zi - a) % m
    ai = (zi + a) % m
    mod.setdefault(ai,0)
    mod[ai] += 1
    ans += mod.get(zi,0)
print(ans)


Measured memory_bytes: 13904
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <functional>
#include <algorithm>
using namespace std;

int main(){
    string s;
    char chr;
    bool p = false;
    cin >> s;
    int k;
    
    if(s.length()%2==1){
        k = (s.length()+1)/2;
        chr = s[(s.length()-1)/2];
        for(int i = 1;i<=(s.length()-1)/2;i++){
            if(s[(s.length()-1)/2 + i] == chr && s[(s.length()-1)/2 -i] == chr){
                k++;
            }
            else if(i == (s.length()-1)/2 && (s[(s.length()-1)/2 + i] == chr && s[(s.length()-1)/2 -i] == chr)){
                k = s.length();
            }
            else{
                break;
            }
        }
    }
    else{
        k = s.length()/2;
        chr = s[s.length()/2];
        for(int i = 0;i<s.length()/2;i++){
            if(s[s.length()/2 + i] == chr && s[s.length()/2 -1 -i] == chr){
                k++;
            }
            else if(i==s.length()-1){
                k = s.length();
            }
            else{break;}
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 10010;

int main(void){
    int square[MAX];
    for (int i=1; i < MAX+1; i++) square[i-1] = i*i;
    
    while (true){
        int n,size;
        int raw_mod[MAX],mod[MAX],hist[MAX] = {};
        
        cin >> n;
        if (n == 0) break;
        int m = (n-1)/2;
        
        for(int i = 0; i < n-1; i++) raw_mod[i] = square[i]%n;
        sort(raw_mod,raw_mod+n-1);
        
        mod[0] = raw_mod[0];
        for(int i = 1, j = 1; i < n-1; i++){
            if (mod[j-1] != raw_mod[i]){
                mod[j] = raw_mod[i];
                j++;
            }
            size = j;
        }

        for (int i = 0; i < size-1; i++)
            for (int j = i+1; j < size; j++){
                
                int tmp1 = mod[i]-mod[j];
                if (tmp1 < 0) tmp1 += n;
                if (tmp1 > m) tmp1 = n-tmp1;
                
                int tmp2 = mod[j]-mod[i];
                if (tmp2 < 0) tmp2 += n;
                if (tmp2 > m) tmp2 = n-tmp2;
                
                hist[tmp1-1] += 1;
                hist[tmp2-1] += 1;
            }

        for(int i = 0; i < m; i++)
            cout << hist[i] << endl;
    }
    return 0;    
}

Measured memory_bytes: 1340
#!/usr/bin/env python3

N = int(input())
H = list(map(int, input().split(" ")))
H.append(10 ** 10)

result = 0
maxcount = -1
current = -1

for i in range(N):
    if H[i] <= current:
        result += 1
    else:
        maxcount = max(maxcount, result)
        result = 0
    # print(f"{i} {H[i]} {result}")
    current = H[i]

maxcount = max(maxcount, result)
print(maxcount)


Measured memory_bytes: 15020
while (m, f, r = gets.split.map(&:to_i)) != [-1, -1, -1]
    m = f = 0 if m == -1 || f == -1
    case m + f
    when 80..100
        puts "A"
    when 65...80
        puts "B"
    when 50...65
        puts "C"
    when 30...50
        puts r >= 50 ? "C" : "D"
    else
        puts "F"
    end
end

Measured memory_bytes: 8664
import numpy as np
a, b = map(int, input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
n = gcd(a, b)

table = []
i = 2
while i*i <= n:
    if n%i == 0:
        table.append(i)
        n //= i
    else:
        i += 1
if n > 1:
    table.append(n)

print(len(set(table))+1)

Measured memory_bytes: 12852
lines = readlines.map(&:strip)

n, a, b, c, d = lines.shift.split.map(&:to_i)
s = lines.shift.chomp.chars

blocker_index = []
(n-1).times do |index|
  blocker_index.push(index) if (s[index..index+1].join)=='##'
end

blocker_index.each do |index|
  if (a-1 <= index && index <= c-1) || (b-1 <= index && index <= d-1)
    puts 'No'
    exit
  end
end

if (d < c)
  space_index = []
  (n-2).times do |index|
    space_index.push(index) if (s[index..index+2].join)=='...'
  end

  space_index.each do |index|
    if ((b-2 <= index && index <= d-2))
      puts 'Yes'
      exit
    end
  end
  puts 'No'
else
  puts 'Yes'
end


=begin
9 1 2 8 7
..#..#...

7 1 3 7 5
....#.#.#.

```
if ((b-1 <= index && index <= d-1))
```
is not good because slipping for 1 box, it does not consider B don't move from start point, and B cannot move right than d.
3 boxes from d-1 is over 1 box from B movable spaces
so 3 boxes from d-2 is right
=end


Measured memory_bytes: 22332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define lower_index(v,a) (int)distance(v.begin(), lower_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
typedef long long ll;
const int inf = 1<<28;
const ll INF = 1LL<<57;
const ll MOD = 1e9+7;

int main(){ 
    ll N,W; cin >> N >> W;
    vector<ll> v(N), w(N);
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    rep(i,N) cin >> v[i] >> w[i];
    rep(i,N)rep(j,W+1){
        chmax(dp[i+1][j],dp[i][j]);
        if (0<=j-w[i]) chmax(dp[i+1][j],dp[i+1][j-w[i]] + v[i]);
        if (0<j) chmax(dp[i+1][j],dp[i+1][j-1]);
    }
    cout << dp[N][W] << endl;
}


Measured memory_bytes: 10800
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<i64>();
    let mut is_ok = false;
    for i in 1..10 {
        if n % i == 0 && n / i < 10 {
            is_ok = true;
        }
    }
    println!("{}", if is_ok { "Yes" } else {"No"});
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int n, a;
int x[100];
long long ans = 0;
long long m[50][51][2510];
long long solve(int i, int p, int q) {
    if (p == 0 && q == 0) {
        return 1;
    }
    if (q < 0) {
        return 0;
    }
    if (i == n) {
        return 0;
    }
    if (n-i < p) return 0;
    if (m[i][p][q] != -1) return m[i][p][q];
    return m[i][p][q] = solve(i+1, p-1, q-x[i]) + solve(i+1, p, q);
}
int main () {
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 51; j++) {
            for (int k = 0; k < 2510; k++) {
                m[i][j][k] = -1;
            }
        }
    }
    cin >> n >> a;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    sort(x, x+n);
    for (int i = 1; i <= n; i++) {
        ans += solve(0, i, i*a);
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	h[0]--;
	for (int i = 1; i < n; i++) {
		if (h[i] - 1 >= h[i - 1]) {
			h[i]--;
		}
		if (h[i] < h[i - 1]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define M 10000
int main(){
  int n,i,j,t,r=0,P[M],s,c;
  char p[M*2]={1,1};
  for(i=2;i<M;i++){
    if(p[i])continue;
    P[r++]=i;
    for(j=i*i;j<M;j+=i)p[j]=1;
  }
  P[r]=M;
  while(scanf("%d",&n),n){
    for(t=r=c=s=0;P[t]<M;t++){
      while(s<n)s+=P[r++];
      if(s==n)c++;
      s-=P[t];
    }
    printf("%d\n",c);
  }
  return 0;
}
  

Measured memory_bytes: 636
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var ans = line[0];

        var list = new List<int>();

        for(int i = 1; i < 10; i++)
        {
            for(int j = 1; j < 10; j++)
            {
                list.Add(i * j);
            }
        }
        System.Console.WriteLine(list.Contains(ans) ? "Yes" : "No");
    }
}



Measured memory_bytes: 13276
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

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

int main() {
  int N; cin >> N;
  vector<int> Av(N);
  set<int> A;
  for (int i = 0; i < N; ++i) {
    int x; cin >> x;
    Av[i] = x;
    A.insert(x);
  }

  map<int, bool> b;
  int vmax = 0;
  for (int a : A) vmax = max(vmax, a);

  for (int a : Av) {
    if (b.count(a)) {
      b[a] = false;
      continue;
    }

    for (int j = 2; a * j <= vmax; ++j) {
      if (A.count(a * j)) {
        b[a * j] = false;
      }
    }

    b[a] = true;
  }

  int cnt = 0;
  for (auto [k, v] : b) {
    if (v) ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 22708
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    string s;
    cin>>s;
    ll sum1=0;
    for (int i=0;i<s.length();i++)
    {
        sum1=sum1+1LL*(s.at(i)-'0');
    }
    if (sum1%9==0)
    printf("Yes\n");
    else 
    printf("No\n");
    return 0;
}

Measured memory_bytes: 3720
def test():

	inputs = list(map(int,input().split()))
	
	if inputs[0] > inputs[1]:
		a = inputs[0]
		b = inputs[1]
	else:
		a = inputs[1]
		b = inputs[0]

	while b > 0:

		r = a % b
		a = b
		b = r

	print(a)


if __name__ == "__main__":
	test()



Measured memory_bytes: 5596
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[3];
		
		for(int i = 0; i <3;i++) a[i] = sc.nextInt();
		
		Arrays.sort(a);
		
		System.out.println(((a[2]*10)+a[1])+a[0]);
		
	}
}

Measured memory_bytes: 21076
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
q = int(input())
Count = Counter(A)
s = sum(A)
B = []
C = []
for i in range(q):
    b,c = map(int,input().split())
    B.append(b)
    C.append(c)
for i in range (q):
    s += (C[i]-B[i])*Count[B[i]]
    print(s)
    Count[C[i]] += Count[B[i]]
    Count[B[i]] = 0

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

int linearSearch(int* S,int* T,int n, int q){
    int C=0,i,j,k;
    for (i=0;i<q;i++){
        k=0;
        for(j=0;j<n;j++){
            if(k == 0 && T[i]==S[j]){
                C+=1;
                k=1;
            }
        }
    }
    return C;

}

int main(){
    int S[10000],T[1000];
    int n;
    int q;
    int a;
    int C;
    cin >> n;
    for(a=0;a<n;a++){
        cin>>S[a];
    }
    cin>>q;
    for(a=0;a<q;a++){
        cin>>T[a];
    }
    C=linearSearch(S,T,n,q);
    cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main()
{
  int k = 0;
  int n = 0;
  int a[200000];
  int max = 0;
  int buf = 0;
  
  scanf("%d %d",&k,&n);
  for(int i = 0;i < n;i++)
  {
    scanf("%d",&a[i]);
  }
  
  max = k -a[n-1] + a[0];
  for(int j = 0;j <( n -1);j++)
  {
    buf = a[j + 1]-a[j];
    if (buf > max)
    {
      max = buf;
    }
  }

  max = k-max;
  
  printf("%d",max);
    return 0;
}

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var AC = "AC";
            var WA = "WA";
            var TLE = "TLE";
            var RE = "RE";
            var num = UInt32.Parse(Console.ReadLine());
            var result = new Dictionary<string, int>()
            {
                { AC, 0 },
                { WA, 0 },
                { TLE, 0 },
                { RE, 0 }
            };

            for (int i = 0; i < num; i++)
            {
                var ans = Console.ReadLine();
                if (ans == AC) { result[AC]++; }
                if (ans == WA) { result[WA]++; }
                if (ans == TLE) { result[TLE]++; }
                if (ans == RE) { result[RE]++; }
            }

            Console.WriteLine($"{AC} x {result[AC]}");
            Console.WriteLine($"{WA} x {result[WA]}");
            Console.WriteLine($"{TLE} x {result[TLE]}");
            Console.WriteLine($"{RE} x {result[RE]}");
        }
    }
}


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

typedef long long int ll;

int main () {
	ll n;
	cin >> n;
	
	string s;
	cin >> s;
	
	ll red = 0;
	for (ll i=0 ; i<n ; i++) {
		if (s[i]=='R') red++;
	}
	
	ll ans = 0;
	
	for (ll i=0 ; i<red ; i++) {
		if (s[i]=='W') ans++;
	}
	
	cout << ans << "\n";
}


Measured memory_bytes: 3740
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct point {
  int x;
  int y;
  int h;
};

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

  int N;
  cin >> N;
  vector<point> vec;
  for (int i = 0; i < N; i++) {
    int x, y, h;
    cin >> x >> y >> h;
    vec.push_back(point{x, y, h});
  }

  point ans{};
  for (int cx = 0; cx <= 100; cx++) {
    for (int cy = 0; cy <= 100; cy++) {
      bool ok = true;
      int H = 0;

      for (int i = 0; i < vec.size(); i++) {
        if (vec[i].h != 0) {
          H = vec[i].h + abs(vec[i].x - cx) + abs(vec[i].y - cy);
        }
      }

      for (int i = 0; i < vec.size(); i++) {
        int hi = H - abs(vec[i].x - cx) - abs(vec[i].y - cy);
        if (vec[i].h == 0) {
          if (hi > 0) {
            ok = false;
          }
        } else {
          if (hi != vec[i].h) {
            ok = false;
          }
        }
      }

      if (ok) {
        ans.x = cx;
        ans.y = cy;
        ans.h = H;
        goto BREAK;
      }
    }
  }

BREAK:
  cout << ans.x << " " << ans.y << " " << ans.h << "\n";
  return 0;
}

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

signed main() {
  int N;
  cin >> N;
  
  int A;
  int odd = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    if( A % 2 == 1 ) odd++;
  }
  
  if( odd % 2 == 1 ){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
}



Measured memory_bytes: 256
N = gets.chomp.to_i
a = Array.new(100,0)
b = 1
for i in 1..N do
    b = i >= 10**b ? b+1 : b
    min = i%10
    max = i/(10**(b-1))
    x = max * 10 + min
    a[x] += 1
end

answer = 0
for i in 1..9 do
    x = i*11
    answer += a[x]*a[x]
end
for i in 1..9 do
    for j in 1..9 do
        if i != j
            x = i*10+j
            y = i+j*10
            answer += a[x] * a[y]
        end
    end
end
puts answer

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;
LL n, x,k,ans;

LL pd(LL x, LL n){
	if(n % x == 0){
		return n * 2 - x;
	}
	else{
		k = (n / x) * 2 * x + pd(n % x, x);
		return k;
    }
}
int main()
{
	cin >> n >> x;
	ans = n + pd(x , n - x);
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
s = input()

e = [0]
w = [0]
ei = 0
wi = 0

for c in s:
    if c == "E":
        ei += 1
    else:
        wi += 1
    e.append(ei)
    w.append(wi)
e.append(ei)
w.append(wi)

ans = n
for i in range(n):
    cand = i - e[i] + n - i - 1 - (w[-1] - w[i+1])
    ans = min(ans, cand)
print(ans)


Measured memory_bytes: 75100
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

s=input().rstrip()
u=list(s)
if (u[0]==u[1] and u[0]==u[2]) or (u[3]==u[1] and u[3]==u[2]):
    print("Yes")
else:
    print("No")

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

int N;
int A[200000];

signed main() {
  cin >>N;
  for(int i=0;i<N;i++) cin >> A[i];

  multiset<int> s;
  for(int i=0;i<N;i++) s.insert(A[i]);

  for(int i=0;i<N;i++) {
    s.erase(s.find(A[i]));
    cout << *s.rbegin() << endl;
    s.insert(A[i]);
  }
}


Measured memory_bytes: 11776