akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBuffet solver = new BBuffet();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBuffet {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int[] ar = new int[n];
            in.scanInt(ar, n);
            long ans = 0;
            for (int i = 0; i < n; i++) ans += in.scanInt();
            int[] cr = new int[n - 1];
            in.scanInt(cr, n - 1);
            for (int i = 0; i < n - 1; i++) if (ar[i + 1] - 1 == ar[i]) ans += cr[ar[i] - 1];
            out.println(ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public void scanInt(int[] A, int size) {
            for (int i = 0; i < size; i++) A[i] = scanInt();
        }

    }
}



Measured memory_bytes: 24404
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define MAX_N 100001

using namespace std;

struct edge { int to, distance; };
struct vertex { vector<edge> es; int x; bool checked=false;};
vertex G[MAX_N];

bool flag = true;
void check(int i) {
    for (int j = 0; j < G[i].es.size(); ++j) {
        edge e = G[i].es[j];
        if (!G[e.to].checked) {
            G[e.to].x = G[i].x + e.distance;
            G[e.to].checked = true;
            check(e.to);
        } else {
            if (G[e.to].x != G[i].x + e.distance)
                flag = false;
        }
    }
}

int main() {
    
    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        G[l-1].es.push_back(edge{r-1, d});
        G[r-1].es.push_back(edge{l-1, -d});
    }
    
    for (int i = 0; i < N; ++i) {
        if (!G[i].checked) {
            G[i].x = 0;
            G[i].checked = true;
            check(i);
        }
    }
    
    if (flag)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}


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

using namespace std;

int n;

void Process()
{

}

void Input()
{
    ios_base::sync_with_stdio(0);   cin.tie(0);

    //freopen("abc.txt", "r", stdin);

    string s, s1;
    cin >> s >> s1;

    for (int i=0; i<=2; i++)
        if (s[i] == s1[i]) n++;

    cout << n;
}

int main()
{
    Input();
    Process();
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Problem solver = new Problem();
        solver.solve(0, in, out);
        out.close();
    }

    static class Problem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next(), t = in.next();
            int count = 0;
            for(int i = 0; i < s.length(); i++) {
                if(s.charAt(i) != t.charAt(i))
                    count++;
            }
            out.println(count);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int K,S;
  cin >> K >> S;
  int count = 0;
  for (int x = 0; x <= K; x++){
    for (int y = 0; y <= K; y++){
      int z = S - x - y;
      if(z >= 0 && z <= K) count++; 
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin>>n; int a[n], b[n];
	for(int i=0; i<n; i++) {cin>>a[i]; b[i]=a[i];}
	sort(a, a+n);
	int x = a[n/2], y = a[n/2-1];
	for(int i=0; i<n; i++){
		if(b[i]<x) cout<<x<<'\n';
		else cout<<y<<'\n';
	}
	return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int a;
  cin >> a;
  cout << pow(a, 3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 3009
using namespace std;
struct node{ 
	int l, r;
	bool operator < (const node &rhs) const{ 
		return (l < rhs.l) || (l == rhs.l && r > rhs.r);
	}
}a[maxn];
int n, m, dp[maxn][maxn], C[maxn][maxn], sum[maxn];
char s[maxn];
const int MOD = 1e9 + 7;

bool in(int L, int R, int x){
	return L <= x && x <= R;
}
long long solve(int L ,int R){
	if(L == R){
		return C[a[L].r - a[L].l + 1][sum[a[L].r] - sum[a[L].l - 1]];
	}

	for(int i = 0; i <= sum[a[L].r] - sum[a[L].l - 1]; i++){
		int part1 = a[L + 1].l - a[L].l;
		int part2 = a[L].r - a[L].l + 1 - part1;
		if(i > part2) 
			break;
		dp[L][i] = C[part1][sum[a[L].r] - sum[a[L].l - 1] - i];
	}


	for(int i = L + 1; i < R; i++){
		int part1 = a[i + 1].l - a[i].l;
		int part2 = a[i].r - a[i].l + 1 - part1;
		int one = sum[a[i].r] - sum[a[i - 1].r];

		for(int j = 0; j <= part2; j++){
			for(int k = max(0, j - one) ; k <= part1 + j - one; k++)
				dp[i][j] = (dp[i][j] + 1LL * C[part1][k + one - j] * dp[i - 1][k]) % MOD;
		}
	}

	int last1 = a[R - 1].r - a[R].l + 1;
	int one = sum[a[R].r] - sum[a[R - 1].r];

	long long ans = 0;
	for(int k = 0; k <= last1; k++)
		ans = (ans + 1LL * dp[R - 1][k] * C[a[R].r - a[R].l + 1][one + k]) % MOD;
	return ans;
}

int main(){
	cin >> n >> m;
	scanf("%s", s + 1);

	for(int i = 1; i <= n; i++)
		sum[i] = sum[i - 1] + (s[i] == '1');

	for(int i = 0; i <= n; i++){
		C[i][i] = C[i][0] = 1;
		for(int j = 1; j < i; j++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}

	for(int i = 1; i <= m; i++){
		scanf("%d%d", &a[i].l, &a[i].r);
	}
	sort(a + 1, a + 1 + m);

	int tot = 0, last = -1;
	for(int i = 1; i <= m; i++){
		if(a[i].r <= last)
			continue;
		++tot;
		a[tot] = a[i];
		last = a[i].r;
	}

	int cur = 1;
	long long ans = 1;
	while(cur <= tot){
		int L = cur;
		while(cur + 1 <= tot && in(a[cur].l, a[cur].r, a[cur+1].l))
			cur++;
		int R = cur;
		ans = ans * solve(L, R) % MOD;
		cur++;
	}

	cout<< ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 32512
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

X = int(input())

for i in range(X, 100004):
    if is_prime(i):
        break
    
print(i)

Measured memory_bytes: 38384
import java.util.Scanner;

class Main{

	static char[][] map;
	static int N;
	static int M;
	static boolean flag;
	static int ans;



	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		N = sc.nextInt();
		M = sc.nextInt();
		map  = new char[100][100];

		for(int i = 0;i < 100;i++){
			for(int j = 0;j <100;j++){
				if(j < 50){
					map[i][j] = '.';
				}else{
					map[i][j] = '#';
				}
			}
		}
		int count = 0;
		int num = 1;

		for(int i = 0;num < N;i= i+2){
			if(99-(i+1) <= 50){
				count = count+2;
				i = 0;
			}
			map[count+1][99-(i+1)] ='.';
			num++;

		}

		count = 0;
		num = 1;
		for(int i = 0;num < M;i = i+2){
			if(i+1 >= 49){
				count = count+2;
				i = 0;
			}
			map[count+1][i+1] ='#';
			num++;

		}

		System.out.println("100 100");
		for(int i = 0;i <100;i++){
			for(int j = 0;j<100;j++){
				System.out.print(map[i][j]);
			}
			System.out.println();

		}




	}


}

class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





Measured memory_bytes: 26428
import sys
input = sys.stdin.readline
from collections import *

MOD = 10**9+7

class Comb:
    def __init__(self, N):
        self.fac = [1] * (N+1)
        for i in range(2, N+1): self.fac[i] = self.fac[i-1] * i % MOD

    def pow(self, a, b):
        res = 1
        while b:
            if b & 1: res = res * a % MOD
            a = a**2 % MOD
            b >>= 1
        return res

    def comb(self, n, r):
        if r < 0 or r > n: return 0
        return (self.fac[n] * self.pow(self.fac[r], MOD-2)) % MOD * self.pow(self.fac[n-r], MOD-2) % MOD

    def permutation(self, n, r):
        if r == 0: return 1
        return self.fac[n] * self.pow(self.fac[n-r], MOD-2) % MOD

def main():
    N, K = list(map(int, input().split()))
    g = [0] * (N+1)
    
    for i in range(N-1):
        a, b = list(map(int, input().split()))
        g[a] += 1
        g[b] += 1
    
    comb = Comb(K)

    ans = K * comb.permutation(K-1, g[1]) % MOD
    K -= 2
    for i in range(2, N+1):
        if K < g[i]-1: ans = 0; break

        ans = ans * comb.permutation(K, g[i]-1) % MOD

    print(ans%MOD)
if __name__ == '__main__':
    main()


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF (int)1e9+7

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

int main() {
    ll N, B, ans = 0;
    cin >> N;
    for (ll i = (ll)pow(N, 0.5); i > 0; i--) {
        if(N%i == 0) {
            B = N/i;
            break;
        }
    }

    while(B != 0) {
        B /= 10;
        ans++;
    }
    
    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf\n", ans);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 512
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, r = na()

if n < 10:
    print(r + (100 * (10 - n)))
else:
    print(r)

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

// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

signed main() {
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }

  int ans = b[0];
  for (int i = 1; i < n - 1; i++) {
    ans += min(b[i], b[i - 1]);
  }
  ans += b[n - 2];
  cout << ans << endl;

  return 0;
}


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  int n;
  cin >> n;
  int a;
  deque<int> b;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (n%2==0) {
      if (i%2==0) {
        b.push_back(a);
      }
      else {
        b.push_front(a);
      }
    }
    else {
      if (i%2==0) {
        b.push_front(a);
      }
      else {
        b.push_back(a);
      }
    }
  }

  for(int i = 0; i < n; i++) {
    cout << b[i];
    if(i != n-1) {
      cout << ' ';
    }
    else {
      cout << endl;
    }
  }

  return 0;
}


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

using namespace std;
const int N=105;
int dp[N][N], n, m, tplt;
char a[N][N];
const int dx[]={0, 1};
const int dy[]={1, 0};
bool flag[101][101][101][101];

void MIN(int &a, int b) {
    if(a>b) a=b;
}

void DFS(int i, int j) {
    flag[i][j][i][j]=1;
    queue <pair<int, int  > > q;
    q.push({i, j});
    while(!q.empty()) {
        int u=q.front().first;
        int v=q.front().second;
        q.pop();
        for(int t=0 ; t<2 ; ++t) {
            int xx=u+dx[t];
            int yy=v+dy[t];
            if(xx<1 || xx>m || yy<1 || yy>n || a[xx][yy]=='.' || flag[i][j][xx][yy]) continue;
            flag[i][j][xx][yy]=1;
            q.push({xx, yy});
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    cin >> m >> n;
    for(int i=1 ; i<=m ; ++i)
        for(int j=1 ; j<=n ; ++j) {
            cin >> a[i][j];
        }
    for(int i=1 ; i<=m ; ++i) {
        for(int j=1 ; j<=n ; ++j) {
            if(a[i][j]=='#') {
                DFS(i, j);
            }
        }
    }

    for(int i=0 ; i<=m ; ++i)
        for(int j=0 ; j<=n ; ++j) dp[i][j]=2e9;
    if(a[1][1]=='#') dp[1][1]=1, dp[1][0]=dp[0][1]=0;
    else dp[1][1]=0;

    for(int i=1 ; i<=m ; ++i)
        for(int j=1 ; j<=n ; ++j) {
            if(i==1 && j==1) continue;
            if(a[i][j]=='.') {
                MIN(dp[i][j], min(dp[i-1][j], dp[i][j-1]));
            } else {
                for(int u=1 ; u<=i ; ++u)
                    for(int v=1 ; v<=j ; ++v) {
                        if(a[u][v]=='.') continue;
                        if(flag[u][v][i][j]) {
                            MIN(dp[i][j], min(dp[u-1][v], dp[u][v-1])+1);
                        }
                    }
            }
        }
    cout << dp[m][n];
    return 0;
}


Measured memory_bytes: 100224
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll p, q, r; cin >> p >> q >> r;
    cout << min({p+q, q+r, r+p}) << '\n';
    return 0;
}


Measured memory_bytes: 256
#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 = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld",&n,&m);
  result = 100*(n-m)+1900*m;
  result *= (ll)powl(2,m);
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 128
k=int(input())


if k<10:
    print(k)

else:
    q=[str(i+1) for i in range(9)]
    ans=9
    for i in range(20):
        nq = []
        for j in range(len(q)):
            if q[j][-1]=='0'or q[j][-1]== '9':
                if q[j][-1]=='0':
                    nq.append(q[j]+'0')
                    nq.append(q[j]+'1')
                else:
                    nq.append(q[j]+'8')
                    nq.append(q[j]+'9')

                ans+=2
                if ans>=k:
                    print(nq[-(ans-k+1)])
                    exit()
            else:
                nq.append(q[j] +str(int(q[j][-1])-1))
                nq.append(q[j] +str(int(q[j][-1])))
                nq.append(q[j]+ str(int(q[j][-1])+ 1))
                ans+=3
                if ans>=k:
                    print(nq[-(ans-k+1)])
                    exit()
        q=nq

Measured memory_bytes: 47960
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner in= new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
	int s = a * b;
	int l = 2 * (a + b);
        System.out.printf("%d %d%n", s,l);
    }   
}

Measured memory_bytes: 17180
#include<iostream>
using namespace std;
int main () {
  long long H, W;
  cin >> H >> W;
  long long ans = H * W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }
  ans ++;
  ans /= 2;
  cout << ans << endl;
}



Measured memory_bytes: 764
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n % 2 == 0) cout << n << endl;
  else cout << n * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans[500005];
ll x[500005],y[500005],z[100005];
ll dp[100],ma,mi;
char s[100005];

int main(){
	cin>>s;
	for(i=0;i<4;i++){
		if(s[i]=='+')a++;
		else b++;
	}
	p(a-b);

}

Measured memory_bytes: 5248
def prime_all(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = is_prime[1] = False
    i = 2
    while i*i <= n:
        if is_prime[i]:
            j = 2*i
            while j <= n:
                is_prime[j] = False
                j += i
        i += 1       
    #prime_list = [i for i, x in enumerate(is_prime) if x == True]
    return is_prime
  
q = int(input())

max_N = 10**5

primes = prime_all(max_N)

prime_count = [0]*(max_N+1)

j=0
for i in range(2, max_N+1):
    if primes[i] and primes[(i+1)//2]:
        prime_count[i] = prime_count[i-1] + 1
    else:
        prime_count[i] = prime_count[i-1]
        
for i in range(q):
    l,r = map(int,input().split())
    print(prime_count[r] - prime_count[l-1])

Measured memory_bytes: 5168
#include<stdio.h>

int main()
{
  int trump[4][14];
  int n, i,j,  number;
  char mark, dummy;


  for(i=0; i < 4; i++){
    for(j=0; j < 14; j++){
      trump[i][j]=0;
    }
  }

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%c", &dummy);
    scanf("%c %d", &mark, &number);
    //printf("mark = %c\n", mark);

    if(mark == 'S'){
      trump[0][number] = 1;
    }

    else if(mark == 'H'){
      trump[1][number] = 1;
    }

    else if(mark == 'C'){
      trump[2][number] = 1;
    }

    else if(mark == 'D'){
      trump[3][number] = 1;
    }
  }


  for(j=1; j < 14; j++){
    if(trump[0][j] != 1){
      printf("S %d\n", j);
    }
  }

 for(j=1; j < 14; j++){
    if(trump[1][j] != 1){
      printf("H %d\n", j);
    }
  }

 for(j=1; j < 14; j++){
    if(trump[2][j] != 1){
      printf("C %d\n", j);
    }
  }

 for(j=1; j < 14; j++){
    if(trump[3][j] != 1){
      printf("D %d\n", j);
    }
  }
 return 0;
}

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

int main() {
  int A, c;
  double B, a;
  cin >> A;
  a = A;
  c = A%2;
  if (c == 1)
    //kisu
    B = ((A/2)+1)/a;
  else
    //gusu
    B = (A/2)/a;
  
  cout << fixed << setprecision(10) << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> A;

    irep(i, n) {
        int tmp;
        cin >> tmp;
        A.push(tmp);
    }

    ll ans = 0;
    while(m) {
        int a = A.top(); A.pop();
        a = floor(a/2.0);
        A.push(a);
        m--;
    }
    
    while(A.size()) {
        int a = A.top(); A.pop();
        ans += a;
    }

    cout << ans << endl;

    return 0;
}
/** atcoder **/


Measured memory_bytes: 892
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<sys/time.h>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=100005,M=N*2;
int head[N],to[M<<1],nxt[M<<1],val[M<<1];
int num[N],vis[N],x1[M],x2[M],d[M];
inline void ade(int x,int y,int z)
{
	nxt[++nxt[0]]=head[x];
	head[x]=nxt[0];
	to[nxt[0]]=y;
	val[nxt[0]]=z;
}
void dfs(int x)
{
	vis[x]=1;
	for(int now=head[x];now;now=nxt[now])
	{
		if(vis[to[now]])	continue;
		num[to[now]]=num[x]+val[now];
		dfs(to[now]);
	}
}
int main()
{
	int n=ri(),m=ri(),i;
	for(i=1;i<=m;i++)
	{
		x1[i]=ri(),x2[i]=ri(),d[i]=ri();
		ade(x1[i],x2[i],d[i]);ade(x2[i],x1[i],-d[i]);
	}
	for(i=1;i<=n;i++)	if(!vis[i])	dfs(i);
	for(i=1;i<=m;i++)
	{
		if(num[x2[i]]!=num[x1[i]]+d[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 10624
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
     
using namespace std;
int main()
{
	int n , o, p , q, w;
    while(~scanf("%d", &n))
    {
    		o = n / 1000;
    		p = n / 100 - o * 10;
    		q = n / 10 - p * 10 - o * 100;
    		w = n % 10;
    	if(((o == p) &&(p ==q))|| ((p == q)&& (p ==w)))
    		printf("Yes");
    	else
    		printf("No");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
int main(){
FASTIO
string s;
cin>>s;
if(s[1]=='B'){
  s[1]='R';
}
else{
  s[1]='B';
}
cout<<s;
return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main()
{
	int c[4][13] = {}, n, i, j, num;
	char mark, m[] = {'S', 'H', 'C', 'D'};

	scanf("%d\n", &n);
	for(i = 0; i < n; i++) {
		scanf("%c %d\n", &mark, &num);
		if(mark == 'S') {
			c[0][num - 1] = 1;
		}else if(mark == 'H') {
			c[1][num - 1] = 1;
		}else if(mark == 'C') {
			c[2][num - 1] = 1;
		}else if(mark == 'D') {
			c[3][num - 1] = 1;
		}else {
			printf("error:[%c]\n", mark);
		}
	}

	for(i = 0; i < 4; i++) {
		for(j = 0; j < 13; j++) {
			if(c[i][j] == 0) printf("%c %d\n", m[i], j + 1);
		}
	}

	return 0;
}



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

void InsertDots(char * inputString, int * inputK)
{
    char * outputString = malloc(255 * sizeof(char));
    char * dotString = "...";
    
    strncpy(outputString,inputString,*inputK);
    strcat(outputString, dotString);
    
    
    printf("%s \n", outputString);
}

void CheckLength(char * inputString, int * inputK)
{
    long stringLength = strlen(inputString);
    
    if(stringLength > *inputK)
    {
        InsertDots(inputString, inputK);
    }
    else
    {
        printf("%s \n", inputString);
    }
}

void ReadInputS(char * inputString)
{
    //printf("Enter your string: \n");
    scanf("%s", inputString);
}

void ReadInputK(int * inputK)
{
    //printf("Enter value of K: \n");
    scanf("%d", inputK);
    
    while (*inputK > 100)
    {
        printf("Wrong input, value needs to be less 100 \n");
        ReadInputK(inputK);
        if(*inputK <= 100)
        {
          break;
        }
    }
}

int main(int argc, const char * argv[])
{

    int *inputK = malloc(255 * sizeof(int));
    char *inputString = malloc(255 * sizeof(char));
    
    
    ReadInputK(inputK);
    ReadInputS(inputString);
    CheckLength(inputString, inputK);
    
    return 0;
}


Measured memory_bytes: 1696
#include<stdio.h>
int main()
{
  int a,b=1,c;
  while(1){
    scanf("%d%d\n",&a,&b);
    if(a==0 && b==0){break;}
    else if(a>b)printf("%d %d\n",b,a);
    else printf("%d %d\n",a,b);
    
  }
  return 0;
}

Measured memory_bytes: 604
s = int(input())
a=[]
data = {}
a.append(s)
i = 0
while True:
    if a[i] not in data:
        data[a[i]] = 1
    else:
        print(i+1)
        exit()
    if a[i]%2 == 0:
        a.append(a[i]//2)
        i+=1
    else:
        a.append(3*a[i] + 1)
        i+=1


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

int main() {
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll ans = a*x+b*y;
  if(x<y) ans = min(ans,2*c*x+b*(y-x));
  else ans = min(ans,2*c*y+a*(x-y));
  ans = min(ans,2*c*max(x,y));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
int a[105],b[210];
int main()
{
	int n,i,j,k;
     while(~scanf("%d",&n))
	 {
		 k=0;
		 memset(b,0,sizeof(b));
	   for(i=0;i<n;i++)
	     scanf("%d",&a[i]);
	   sort(a,a+n);
	 for(i=a[0];i<=a[n-1];i++)
	 {
	   for(j=0;j<n;j++)
	   {
	    b[k]=b[k]+(i-a[j])*(i-a[j]);
	    
	   }
	
	 
	
	  k++;
	 }
	 sort(b,b+k);
	cout<<b[0]<<endl;
	 }



}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
  string s,t; cin>>s>>t;
  int a,b; cin>>a>>b;
  string u; cin>>u;
  
  if(s==u){a--;}
  else if(t==u){b--;}
  
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;

int main() {
    string N;
    cin>>N;
    int A=0;

    if(N[0]=='2'){
        A++;
    }
    if(N[1]=='2'){
        A++;
    }
    if(N[2]=='2'){
        A++;
    }
    if(N[3]=='2'){
        A++;
    }
    cout<<A<<endl;
}

Measured memory_bytes: 3616
package main

import (
	"fmt"
	"sort"
)

func gcd(a, b int) int {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}

func main(){
	var n, x, ans int
	fmt.Scan(&n, &x)
	cities := make([]int, n+1)
	cities[0] = x
	for i:=1; i<n+1; i++{
		fmt.Scan(&cities[i])
	}
	sort.Ints(cities)
	dis := make([]int, n)
	for i:=0; i<n; i++{
		dis[i] = cities[i+1] - cities[i]
	}
	ans = dis[0]
	for i:=1; i<n; i++{
		ans = gcd(ans, dis[i])
	} 
	fmt.Println(ans)
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,sumR=0,sumB=0;
  cin>>N;
  string s;
  cin>>s;
  for(int i=0;i<N;i++){
    if(s[i]=='R') sumR++;
    else sumB++;    
  }
  if(sumR>sumB) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}

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

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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(16);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    for(ll i=0; i<n; i++) cin >> t[i];
    for(ll i=0; i<n; i++) cin >> a[i];

    vector<ll> lo(n, 1), hi(n, 1e9);
    lo[0] = hi[0] = t[0];
    lo[n-1] = max(lo[n-1], a[n-1]);
    hi[n-1] = min(hi[n-1], a[n-1]);
    for(ll i=0; i<n-1; i++) {
        if(t[i] < t[i+1]) {
            lo[i+1] = max(lo[i+1], t[i+1]);
            hi[i+1] = min(hi[i+1], t[i+1]);
        }
        if(a[n-1-i] < a[n-2-i]) {
            lo[n-2-i] = max(lo[n-2-i], a[n-2-i]);
            hi[n-2-i] = min(hi[n-2-i], a[n-2-i]);
        }
    }
    for(ll i=0; i<n; i++)
        hi[i] = min({hi[i], t[i], a[i]});

    ll r = 1;
    for(ll i=0; i<n; i++) {
        if(lo[i] > hi[i]) r = 0;
        (r *= hi[i] - lo[i] + 1) %= MOD;
    }
    cout << r << endl;
}


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

struct Node {
  int key;
  struct Node *next, *prev;
};

struct Node *nil;

// リストの初期化
void init() {
  nil = (struct Node *)malloc(sizeof(struct Node));
  nil->prev = nil;
  nil->next = nil;
}

void insert(int key) {
  struct Node *x = (struct Node *)malloc(sizeof(struct Node));
  x -> key = key;
  x -> next = nil -> next;
  nil -> next -> prev = x;
  nil -> next = x;
  x -> prev = nil;
}

void deleteNode(struct Node *t) {
  if (t == nil) return;
  t -> prev -> next = t -> next;
  t -> next -> prev = t -> prev;
  free(t);
}

struct Node* listSearch(int key) {
  struct Node *cur = nil -> next;
  while( cur != nil && cur -> key != key) {
    cur = cur -> next;
  }
  return cur;
}
void delete(int key) {
  deleteNode(listSearch(key));
}

void deleteFirst() {
  deleteNode(nil -> next);
}

void deleteLast() {
  deleteNode(nil -> prev);
}

void printList() {
  struct Node *cur = nil -> next;
  // 最初のリスト
  while(cur) {
    printf("%d", cur -> key);
    cur = cur -> next;
    if (cur == nil){
      break;
    } else {
      printf(" ");
    }
  }
  printf("\n");
}

int main() {
  int n;
  char com[15];
  int key;
  scanf("%d\n", &n);
  init();
  for (int i = 0; i < n; i++) {
    scanf("%s%d", com, &key);
    if (com[0] == 'i') {
      insert(key);
    } else if (com[0] == 'd') {
      if (strlen(com) > 6) {
        if (com[6] == 'F') deleteFirst();
        else if (com[6] == 'L') deleteLast();
      } else {
        delete(key);
      }
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32932
n,x = map(int, input().split())
a = sorted(list(map(int, input().split())))

ans = 0
for i in range(n):
    if i != n-1 and a[i] <= x:
        ans += 1
        x -= a[i]
    if i == n-1 and a[i] == x:
        ans += 1
print(ans)

Measured memory_bytes: 9040
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


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

int main()
{
    fast;
    string s;
    cin >> s;
    ll sum = 0;
    for(int i=0;i<s.length();i++)
    	sum += s[i]-'0';
    if(sum%9==0)
    	cout << "Yes\n";
    else cout << "No\n";
}

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

public class ABC0126_A3 {
    private static void Main(string[] args) {
        var input = Console.ReadLine().Trim();
        Prepare(input);
    }

    private static void Prepare(string input) {
        var words = input.Split();
        var numOfFaces = int.Parse(words[0]);
        var standardToWin = int.Parse(words[1]);

        Compute(numOfFaces, standardToWin);
    }

    private static void Compute(int numOfFaces, int standardToWin) {
        var standard = Math.Min(numOfFaces, standardToWin);
        var numOfTimesToWinList = new List<int>();

        for (var roll = 1; roll <= standard; roll++) {
            numOfTimesToWinList.Add(CalculateNumOfTimesToWin(roll, standardToWin));
        }

        var numerator = CalculateNumerator(numOfTimesToWinList, numOfFaces);
        var denominator = (int)Math.Pow(2, numOfTimesToWinList[0]) * numOfFaces;
        var answer = numerator / (decimal)denominator;
        OutputAnswer(answer.ToString());
    }

    private static int CalculateNumOfTimesToWin(int initialPoint, int standardToWin) {
        var count = 0;
        var point = initialPoint;

        while (point < standardToWin) {
            count++;
            point *= 2;
        }
        return count;
    }

    private static int CalculateNumerator(List<int> numOfTimesToWinList, int numOfFaces) {
        var total = 0;

        foreach (var numOfTimesToWin in numOfTimesToWinList) {
            total += (int)Math.Pow(2, numOfTimesToWinList[0] - numOfTimesToWin);
        }

        if (numOfTimesToWinList.Count < numOfFaces) {
            total += (int)Math.Pow(2, numOfTimesToWinList[0]) * (numOfFaces - numOfTimesToWinList.Count);
        }

        return total;
    }

    private static void OutputAnswer(string text) => Console.WriteLine(text);
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

void solve(vector<int>& v1){
    vector<int> v2;
    while(v1.size() > 1) {
        rep(i, v1.size() - 1) {
            v2.push_back(abs(v1[i] - v1[i + 1]));
        }
        swap(v1, v2);
        v2.clear();   
    }
    cout << v1[0] << endl;
}

int count_two(int n) {
    int ret = 0;
    while(n > 0) {
        ret += n / 2;
        n /= 2;
    }
    return ret;
}

bool isadd(int r, int c) {
    if(count_two(r) - count_two(r - c) > count_two(c)) return false;
    else return true;
    
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string S;
    cin >> S;

    vector<int> v1, v2;
    if (N <= 12) {
        rep(i, N - 1) {
            v1.push_back(abs(S[i] - S[i + 1]));
        }
        solve(v1);
        return 0;
    }
    bool isall2 = false;
    rep(i, N) {
        if (S[i] == '1') continue;
        if (S[i] == '3') isall2 = true;
        if (S[i] == '2') {
            isall2 = false;
            break;
        }
    }
    rep(i, N) {
        if(isall2 && S[i] == '3') S[i] = '2';  
    }
    rep(i, N - 1) {
        v1.push_back(abs(S[i] - S[i + 1]));
    }
    int ans = 0;
    rep(i, v1.size()) {
        ans = (ans + isadd(v1.size() - 1, i) * v1[i]) % 2;
        //cout << v1.size() - 1 << " " << i << " " << isadd(v1.size() - 1, i) << endl;
    }
    // rep(i, v1.size()) cout << v1[i];
    // cout << endl;
    cout << ans * (isall2 + 1) << endl;


    return 0;
}


Measured memory_bytes: 8344
#include <iostream>
using namespace std;
int main(void){
int x1,x2;
cin>>x1>>x2;
if (x1<x2){
    cout<<x2-x1<<endl;
}else if (x1>x2){
    cout<<x1-x2<<endl;
}else if (x1==x2){
    cout<<x1-x2<<endl;
}
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;


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

    int a,b;
    cin >> a >> b;
    if(a*b %2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    static final int MOD = 1000000007;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        long ans = modpow(2, n, MOD) -1;
        long x = 1;
        for(int i = 0; i < a; i++){
            x *= n-i;
            x %= MOD;
        }
        for(int i = 1; i <= a; i++){
            x *= modinv(i, MOD);
            x %= MOD;
        }
        ans -= x;
        if(ans < 0) ans += MOD;
        
        x = 1;
        for(int i = 0; i < b; i++){
            x *= n-i;
            x %= MOD;
        }
        for(int i = 1; i <= b; i++){
            x *= modinv(i, MOD);
            x %= MOD;
        }
        ans -= x;
        if(ans < 0) ans += MOD;
        
        System.out.println(ans);
    }
    
    static long modpow(long a, long n, long mod){
        long res = 1;
        while(n > 0){
            if((n & 1) == 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }
    
    static long modinv(long a, long mod){
        return modpow(a, mod - 2, mod);
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

const int N = 1e7 + 4;
vector <int> factors(N+1);  //it will store smallest prime divisior of 'i'
bitset<N+10> primes;

void sieve(){
  primes.set();
  primes.reset(0);
  primes.reset(1);
  
  //if we have to check only primes then, it is better to do: i*i < N, in first loop,
  //no need to go to i < N
  for (ll i = 2; i < N; ++i){  
    if(primes[i]){
      factors[i] = i;
      for (ll j = i*i; j < N; j+=i){
        if(primes[j]){
          primes.reset(j);
          factors[j] = i;
        }
      }
    }
  }

}

int calc(int n) {
    unordered_map<int,int> mp;
    while (n > 1) {
        mp[factors[n]]++;
        n /= factors[n];
    }   
    ll res = 1;
    for (auto i: mp) {
        res *= (i.second + 1);
    }
    return res;
}

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

    sieve();

    int n; cin >> n;
    ll ans = 0;
    for (int i = 2; i <= n; ++i) {
        ll res = calc(i);
        ans += res * i;
    }

    ll res = calc(n);
    cout << ans + 1;


    return 0;
}


Measured memory_bytes: 43528
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <numeric>
using namespace::std;
int main(){

int n;
  cin>>n;
  int *p = new int[n];
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  int count = 0;
  
    for(int i=1;i<n-1;i++){
      if(p[i-1]<p[i]&&p[i]<p[i+1]){
        count++;
      }else if(p[i-1]>p[i]&&p[i]>p[i+1]){
        count++;
      }
    }
  cout<<count;
  
      
  
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int s;
	scanf("%d", &s);
	int answer = 4;
	while(s != 4 && s != 2 && s != 1){
		s = s & 1 ? s*3 + 1 : (s >> 1);
		answer++;
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

--getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c

solve str=sum (map (\(a,b)-> if(a>b) then 1 else 0 ) (zip str ssr)  )
    where ssr=sort(str)

main = do
    n <-getLine
    str <- getLine
    putStrLn(show (solve str))



    



Measured memory_bytes: 33292
/* dijkstra.cpp
    ダイクストラ法で、ある頂点から各頂点への最短距離を求めるアルゴリズム
    負の辺が含まれる場合はうまく計算出来ないので、ベルマンフォード法を用いる

    verified: AOJ GRL_1_A
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A&lang=jp
*/

#include <bits/stdc++.h>
using namespace std;

template <typename T>
struct Edge {
    int to;
    T cost;
};
using Graph = vector<vector<Edge<long long>>>;  // 距離/コストの型 T を指定する
const long long INF = (1LL << 60);              // 型 T のINF (完全な最大値は取らないように)

/* dijkstra(G,s,dis,prev)
    入力：グラフ G, 開始点 s, 距離を格納する dis, 最短経路の前の点を記録するprev
    計算量：O(|E|log|V|)
    副作用：dis, prevが書き換えられる
*/
template <typename T>
void dijkstra(const Graph &G, int s, vector<T> &dis, vector<int> &prev) {
    using P = pair<T, int>;

    int N = G.size();
    dis.resize(N, INF);
    prev.resize(N, -1);
    priority_queue<P, vector<P>, greater<P>> pq;  // the least element is top. first:cost, second: node
    dis[s] = 0;
    pq.emplace(dis[s], s);
    while (!pq.empty()) {
        P p = pq.top();  // the least element
        pq.pop();
        int v = p.second;
        if (dis[v] < p.first) {
            continue;
        }
        for (auto &e : G[v]) {
            if (dis[e.to] > dis[v] + e.cost) {
                dis[e.to] = dis[v] + e.cost;
                prev[e.to] = v;
                pq.emplace(dis[e.to], e.to);
            }
        }
    }
}

/* get_path(prev, t)
    入力：dijkstra で得た prev, ゴール t
    出力： t への最短路のパス
*/
vector<int> get_path(const vector<int> &prev, int t) {
    vector<int> path;
    for (int cur = t; cur != -1; cur = prev[cur]) {
        path.push_back(cur);
    }
    reverse(path.begin(), path.end());
    return path;
}

int main() {
    int V, E, r;
    cin >> V >> E >> r;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back({b, c});
    }
    vector<long long> dis;
    vector<int> prev;
    dijkstra(G, r, dis, prev);
    for (int i = 0; i < V; i++) {
        if (dis[i] != INF) {
            cout << dis[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 19708