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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    string O = "RUD";
    string E = "LUD";
    bool flg = true;
    REP (i, S.length()) {
        if ((i + 1) % 2 && string::npos == O.find (S[i])) {
            flg = false;
            break;
        }
        if (i % 2 && string::npos == E.find (S[i])) {
            flg = false;
            break;
        }
    }
    cout << (flg ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3632
fun main() {
    val n = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var a = 0
    var b = 0

    for (i in 1 until n){
        for (k in n-1 downTo i){
            if (numList[k]>numList[k-1]){
                val tmp = numList[k]
                numList[k] = numList[k-1]
                numList[k-1] = tmp
            }
        }
    }

    for (i in numList.indices){
        if (i%2==0){
            a += numList[i]
        }else{
            b += numList[i]
        }
    }

    println(a-b)
}

Measured memory_bytes: 36444
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
	else{
		priority_queue<int> pq;
		pq.push(a);
		pq.push(b);
		pq.push(c);
		pq.pop();
		LL ans=1LL;
		ans*=pq.top();
		pq.pop();
		ans*=pq.top();
		cout<<ans;
	}
    return 0;
}


Measured memory_bytes: 256
S = input()
acgt = ["A", "T", "G", "C"]

def main(S):
    cnt = 0
    m = 0
    for s in S:
        if s not in acgt:
            cnt = 0
        else:
            cnt += 1
        m = max(m, cnt)
    return m

print(main(S))

Measured memory_bytes: 3060
n=int(input())
s=list(input())

r=[]
g=[]
b=[]
for i in range(n):
    if s[i]=='R':
        r.append(i)
    elif s[i]=='G':
        g.append(i)
    else:
        b.append(i)

import bisect
def binary_search(a, x):
    # 数列aのなかにxと等しいものがあるか返す
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return True
    else:
        return False

ans=0
for i in range(len(r)):
    for j in range(len(g)):
        p=0
        if r[i]<g[j]:
            if binary_search(b,g[j]-r[i]+g[j]):
                p+=1
            if binary_search(b,r[i]+(g[j]-r[i])/2):
                p+=1
            if binary_search(b,r[i]-(g[j]-r[i])):
                p+=1
        else:
            if binary_search(b,r[i]-g[j]+r[i]):
                p+=1
            if binary_search(b,g[j]+(r[i]-g[j])/2):
                p+=1
            if binary_search(b,g[j]-(r[i]-g[j])):
                p+=1
        ans+=len(b)-p

print(ans)






Measured memory_bytes: 83456
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int s;
  cin >> s;

  vector<vector<ll> > dp(s+2, vector<ll>(s+2));
  dp[0][0] = 1;
  for (int i = 0; i < s; i++) {
    ll total = 0;
    for (int j = 0; j + 3 <= s; j++) {
      total = (total + dp[i][j]) % mod;
      dp[i+1][j+3] = total;
    }
  }

  ll ans = 0;
  for (int i = 0; i < s; i++) ans = (ans + dp[i][s]) % mod;

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(m) rep(i,m)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl
#define vint vector<int>
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define yn(a) cout<<((a)?"Yes":"No")<<endl;
#define YN(a) cout<<((a)?"YES":"NO")<<endl;
#define call(a) for(auto i:(a))cout<<i<<" ";cout<<endl;
#define SORT(a) sort(all(a))
#define ENDL printf("\n");
#define INF 1LL<<60
#define sentinels(a) a.pb(-INF);a.pb(INF);SORT(a);
signed main(){
  int n,m;
  cin>>n>>m;
  vint a(m),b(m);
  repi(m)cin>>a[i]>>b[i];
  vint c,d;
  repi(m)if(b[i]==n)c.pb(a[i]);
  repi(m)if(a[i]==1)d.pb(b[i]);
  bool can=false;
  sentinels(c);sentinels(d)
  rep(i,200000){
    int s=lower_bound(all(d),i)-d.begin();
    int e=lower_bound(all(c),i)-c.begin();
    if(d[s]!=INF&&d[s]!=-INF)if(c[e]!=INF&&c[e]!=-INF)if(d[s]==c[e])can=true;
  }
  cout<<(can?"POSSIBLE":"IMPOSSIBLE")<<endl;

  return 0;
}


Measured memory_bytes: 5748
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort()
ans = float('inf')
for d1 in x:
    for d2 in x:
        tmp = n
        if d1 == d2:
            continue
        p = d1[0] - d2[0]
        q = d1[1] - d2[1]
        s = set()
        for idx, d3 in enumerate(x):
            for d4 in x:
                if tuple(d4) not in s and d3 != d4 and (d4[0] - d3[0] == p and d4[1] - d3[1] == q or d4[0] - d3[0] == -p and d4[1] - d3[1] == -q):
                    tmp -= 1
                    break
            s.add(tuple(d3))
        ans = min(ans, tmp)
if n == 1:
    print(1)
else:
    print(max(1, ans))


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

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

    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    int m   = max(max(A, B), C);
    vector<int> mList;
    if (m - A != 0) mList.push_back(m - A);
    if (m - B != 0) mList.push_back(m - B);
    if (m - C != 0) mList.push_back(m - C);

    if (mList.size() == 1) {
        ans += (mList[0] + 1) / 2;
        if (mList[0] % 2 == 1) ans++;
    } else if (mList.size() == 2) {
        ans += min(mList[0], mList[1]);
        ans += (max(mList[0], mList[1]) - min(mList[0], mList[1]) + 1) / 2;
        if ((max(mList[0], mList[1]) - min(mList[0], mList[1])) % 2 == 1)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define eef(i,x)for(int i=head[x],y=e[i].to;i;i=e[i].next,y=e[i].to)if(y!=fa)
typedef long long LL;
int read()
{
	char c=getchar();int d=0,f=1;
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());
	return d*f;
}
const int N=2010;
int n,k,cnt,head[N];
struct xint{int to,next;}e[N*2];
void addedge(int x,int y){
	e[++cnt]=(xint){y,head[x]};head[x]=cnt;
}
void Addedge(int x,int y){
	addedge(x,y);addedge(y,x);
}
int f[N][N],p[N];
void dfs(int fa,int x){
	eef(i,x) dfs(x,y);
	int m=0;
	eef(i,x) p[++m]=y;
	f[x][0]=0;
	if(m==0) ref(i,1,n)f[x][i]=1;
	if(m==1)
	{
		ref(i,0,k)f[x][i+1]=f[p[1]][i]+1;
		ref(i,k+2,n)f[x][i]=f[x][i-1];
	}
	if(m>=2)
	{
		ref(i,0,k)
		{
			int sum=0,res=0,I=min(i,k-i);
			ref(j,1,m)sum+=f[p[j]][I];
			ref(j,1,m)res=max(res,sum-f[p[j]][I]+f[p[j]][i]);
			f[x][i+1]=res+1;
		}
		ref(i,1,n)f[x][i]=max(f[x][i],f[x][i-1]);
	}
}
int main()
{
	n=read(),k=read();
	ref(i,2,n)Addedge(read(),read());
	dfs(0,1);
	int ans=0;
	ref(i,1,n)ans=max(ans,f[i][n]);
	cout<<n-ans<<endl;
}

Measured memory_bytes: 16000
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        int n = Integer.parseInt(buffer.readLine());
        String [] inp = buffer.readLine().split(" ");
        int [] arr = new int[n];
        arr[0] = Integer.parseInt(inp[0]);
        int xor = arr[0];
        for (int pos = 1; pos < n; pos++) {
            arr[pos] = Integer.parseInt(inp[pos]);
            xor ^= arr[pos];
        }
        for (int pos = 0; pos < n; pos++) {
            sb.append((xor^arr[pos])+" ");
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 67908
/*input

*/
#include "bits/stdc++.h"
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	long long a, b;
	cin >> a >> b;
	cout << (a*b/__gcd(a,b)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int n;
	cin>>n;
	int a[n-1];
	int cnt[n];
	fill(cnt,0);
	rep(i,n-1){
		cin>>a[i];
		cnt[a[i]-1]++;
	}
	rep(i,n){
		cout<<cnt[i]<<endl;
	}
	re 0;
}

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

int main(){
    long long N, M;
    cin >> N >> M;
    long long H[N+1];
    long long i,j;
    for(i=1; i<=N; i++){
        cin >> H[i];
    }
    vector<long long> G[N+1];
    long long A, B;
    for(i=1; i<=M; i++){
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    long long counta =0;
    bool yoi;
    for(i=1; i<=N; i++){
        yoi=1;
        for(j=0; j<G[i].size(); j++){
            if(H[i]<=H[G[i][j]]){
                yoi=0;
            }
        }
        if(yoi==1){
            counta++;
        }
    }
    cout<< counta << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 10240
def main():
    import sys
    sys.setrecursionlimit(10 ** 7)

    s = input()

    def calc(cur=1, t=s[0]):
        if cur == len(s):
            return eval(t)
        return calc(cur + 1, t + s[cur]) + calc(cur + 1, t + '+' + s[cur])

    print(calc())


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AlmostEverywhereZero solver = new AlmostEverywhereZero();
        solver.solve(1, in, out);
        out.close();
    }

    static class AlmostEverywhereZero {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String n = in.next();
            int k = in.nextInt();

            out.println(digitDP(n, k));
        }

        static long digitDP(String num, int z) {

            char[] s = num.toCharArray();
            int size = s.length;

            // 桁数 | 未満フラグ | 条件
            long[][][] dp = new long[size + 1][2][z + 1];
            dp[0][0][0] = 1;
            for (int i = 0; i < size; i++) {
                int limit = s[i] - '0';
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k <= z; k++) {
                        int dMax = (j == 1) ? 9 : limit;
                        for (int d = 0; d <= dMax; d++) {
                            int nextJ = (j == 1) || (limit > d) ? 1 : 0;
                            int nextK = d == 0 ? k : k + 1;
                            if (nextK <= z) {
                                dp[i + 1][nextJ][nextK] += dp[i][j][k];
                            }
                        }
                    }
                }
            }
            return dp[size][1][z] + dp[size][0][z];
        }

    }
}



Measured memory_bytes: 35876
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Resistors in Parallel
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  double sum = 0.0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    sum += 1.0 / ai;
  }

  printf("%.14lf\n", 1.0 / sum);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
    int n,i,j;string s,t;cin >> n;
    while(cin >> s >> t){
        int dp[s.size()+1][t.size()+1] = {};
        for(i=1;i<=s.size();i++){
            for(j=1;j<=t.size();j++){
                if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1]+1;
                else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
        cout << dp[s.size()][t.size()] << endl;
    }
}


Measured memory_bytes: 7084
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        if(N <= K){
            System.out.println(0);
            return;
        }
        long[] H = new long[N];
        long sum = 0;
        for (int i = 0; i < N; i++) {
            H[i] = sc.nextLong();
            sum+= H[i];
        }
        Arrays.sort(H);
        int k = H.length -1;
        while (0 < K ){
            sum = sum - H[k];
            k--;
            K--;
        }
        System.out.println(sum);
    }
}

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

#define ll long long
const int MOD=1e9+7;
const int mxN=500000;

ll mod(ll a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

ll inv[mxN+1];
ll fact[mxN+1];
ll factinv[mxN+1];

void calc(int n) {
	inv[1] = 1;
	fact[0] = fact[1] = 1;
	factinv[0] = factinv[1] = 1;
	for (int i = 2; i <= n; i++) {
		inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
		fact[i] = i * fact[i-1] % MOD;
		factinv[i] = inv[i] * factinv[i-1] % MOD;
	}
}
 
ll comb(ll n,ll k) {
	return fact[n] * (factinv[k] * factinv[n-k] % MOD) % MOD;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n, m;
	cin >> n >> m;
	calc(m);
	ll a = comb(m, n) * fact[n] % MOD;
	ll c = 0;
	for (int i = 1, sign = 1; i <= n; i++, sign *= -1) {
		c = mod(c + mod(sign) * comb(n, i) % MOD * comb(m-i, n-i) % MOD * fact[n-i] % MOD);
	}
	ll b = mod(a - c);
	ll ans = a * b % MOD;
	cout << ans << endl;
    
}

Measured memory_bytes: 15300
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ok = 0
for _ in range(n):
  a = list(map(int,input().split()))
  sum = c
  for i in range(m):
    sum += a[i]*b[i]
  if sum > 0:
    ok += 1
print(ok)

Measured memory_bytes: 62012
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  ll k;
  cin >> k;
  ll sum = 0;

  for(ll i=1; i<=k; ++i) {
    for(ll j=1; j<=k; ++j) {
      for(ll l=1; l<=k; ++l) {
        sum += gcd(i, gcd(j, l));
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3636
using System;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();

        for (int i = 0; i <= 200000; i++)
        {
            int aa = (i * 8) / 100;
            int bb = (i * 10) / 100;
            if (aa == a && bb == b)
            {
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine("-1");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <string>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;


int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int i;
    vector<int> arr(n);
    for(i = 0; i < n; i++) {
        cin >> arr[i];
    }
    int step = 0;
    int curr = 0;
    set<int> done;
    while(curr != 1 && done.count(curr) == 0) {
        done.insert(curr);
        step++;
        curr = arr[curr] - 1;
    }
    if(curr == 1) {
        cout << step;
    }
    else {
        cout << -1;
    }


    return 0;
}



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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<'\n'

int main(){
    int n,c,k;
    cin >> n >> c >> k;
    int t[n];
    REP(i,n)cin >> t[i];
    sort(t,t+n);
    int count=1,bus=0;
    for(int i=0;i<n;i++){
        int num = t[i];
        while(count!=c){
            i++;
            if(t[i]<=num+k) count++;
            else{
                i--;
                break;
            }
        }
        bus++;
        count=1;
    }
    COUT(bus);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int count=0;
    string s;
    getline(cin,s);
    if(s[0]=='R' && s[1]=='S' && s[2]=='R')
        printf("%d\n",1);
    else
    {
        for(int i=0; s[i]!='\0'; ++i)
        {
            if(s[i]=='R')
                ++count;
        }
        printf("%d\n",count);
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = a[0];
    rep(i,n)
        ans = __gcd(ans, a[i]);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
double INF=1000000000.0;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    double xs,ys,xg,yg;
    cin>>xs>>ys>>xg>>yg;

    int n;
    cin>>n;
    double t[2100][3];
    rep2(i,1,n){
        cin>>t[i][0]>>t[i][1]>>t[i][2];
    }
    t[0][0]=xs;t[0][1]=ys; t[0][2]=0;
    n++;
    t[n][0]=xg;t[n][1]=yg; t[n][2]=0;
    double d[2100]={};
    d[0]=0.0000000000;
    int visited[1100]={};
    visited[0]=1;

    rep2(i,1,n){d[i]=-1;}
    int pos=0;
    
    while(1){
        double minimum=0.0;
        int minimumnum=2000;
        rep2(i,0,n){
            if(!visited[i]){
                if(d[i]!=-1)
            d[i]=min(d[i],d[pos]+max((double)0,sqrt((pow(t[pos][0]-t[i][0],2)
            +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2]));
            else d[i]=d[pos]+max((double)0,sqrt((pow(t[pos][0]-t[i][0],2)
            +pow(t[pos][1]-t[i][1],2)))-t[pos][2]-t[i][2]);
            }
        }
        rep2(i,0,n){if(!visited[i]){minimum=d[i]; minimumnum=i;break;}}
        rep2(i,0,n){
            if(d[i]<minimum&&!visited[i]){
                minimum=d[i]; minimumnum=i;
            }
        }
        pos=minimumnum; visited[minimumnum]=1;
        if(minimumnum==n){
            printf("%.15f",d[n]); return 0;
        }
        
    }
}

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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


ll x[200005];
ll y[200005];

signed main() {
    //my-code
    ll n, d; cin >> n >> d;
    REP(i, n) cin >> x[i] >> y[i];
    ll ans = 0;
    REP(i, n) {
        if (x[i]*x[i] + y[i]*y[i] <= d*d) {
            ans++;
        }
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 6772
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <boost/math/common_factor_rt.hpp>

#define ll long long

using namespace std;

int ar[512345] = {};
int a[212345] = {};

int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	int left = 212345, right = left + 1;

	for (int i = 0; i < n; i++)
	{
		if (i % 2 == (n - 1) % 2) {
			ar[left--] = a[i];
		}
		else {
			ar[right++] = a[i];
		}
	}
	for (int i = left+1; i < right; i++)
	{
		cout << ar[i];
		cout << " ";
	}

	return 0;
}

int dsum(ll a) {
	int ans = 0;
	while (a != 0) {
		ans += a % 10;
		a /= 10;
	}
	return ans;
}


Measured memory_bytes: 3712
package main

import (
	"fmt"
)

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

	ns := make(map[int]int)
	for i := 0; i < q; i++ {
		var a int
		fmt.Scan(&a)
		ns[a] = ns[a] + 1
	}

	for i := 1; i <= n; i++ {
		if (q-ns[i]) >= k {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}

}


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

int countDigit(ll num) {
  int count = 0;

  while (num > 0) {
    num /= 10;
    count++;
  }
  return count;
}

int main(void) {
  ll n;
  cin >> n;

  int ans = countDigit(n);
  ll maxL = (ll)sqrt((double)n);
  maxL++;
  for (ll a = 1LL; a <= maxL; ++a) {
    if (n % a != 0) continue;

    ll b = n / a;
    int cur = max(countDigit(a), countDigit(b));
    if (ans > cur) {
      ans = cur;
    }
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define ll_1e9 (ll)1e9
using namespace std;

struct quadset{
    ll a,b,c,d;
};
struct datasize{
    ll n,m,q;
};


void dfs(ll current_i,datasize &d,vector<ll> &A,vector<quadset> &qs,ll &ans){
    ll min_i = A[A.size()-1];

    if(current_i == d.n-1){
        ll temp = 0;
        rep(j,0,d.q){
            if(A[qs[j].b-1] - A[qs[j].a-1] == qs[j].c) temp += qs[j].d;
        }  
        ans = max(ans,temp);
        return;
    }

    rep(i,min_i,d.m+1){
        A.push_back(i);
        dfs(current_i+1,d,A,qs,ans);
        A.pop_back();
    }
    return;
}


int main(){
    datasize d;
    cin >> d.n >> d.m >> d.q;
    vector<quadset> qs(d.q);
    vector<ll> A;
    ll ans = 0;

    rep(i,0,d.q) cin >> qs[i].a >> qs[i].b >> qs[i].c >> qs[i].d;
    
    rep(i,1,d.m+1){
        A.push_back(i);
        dfs(0,d,A,qs,ans);
        A.pop_back();
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
  ll h;
  cin >> h;
  ll p = 1;
  ll ans = 0;
  while(h > 0) {
    ans += p;
    p *= 2;
    h /= 2;
  }
  cout << ans << endl;
  return 0;
}

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


def insertionSort(li: list, n: int):
    for i in range(n):
        v = li[i]
        j = i - 1
        while 0 <= j and v < li[j]:
            li[j+1] = li[j]
            j -= 1
        li[j+1] = v
        print(*li)


insertionSort(A, N)



Measured memory_bytes: 5976
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ic pair <int, char>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    int n,m;
    sf(n);

    while(n--){
        int a;
        sf(a);
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    int len=v.size();
    int cnt=0;

    sf(m);
    while(m--){
        int a;
        sf(a);

        int first=0;
        int last=len;
        int mid;

        while(first!=last){
            mid=(first+last)/2;

            if(v[mid]==a){
                cnt++;
                break;
            }
            else if(v[mid]<a) first = mid+1;
            else last = mid;
        }
    }
    pf("%d\n",cnt);

    return 0;
}



Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    ll N; cin >>N;
    vector<ll> h(N); cin >> h;
    
    vll dp(N+1, LLONG_MAX);
    dp[1] = 0;

    for (int i = 1; i < N; i++) {
        if (i + 1 <= N)
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i-1]- h[i]));
        if (i + 2 <= N)
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i-1]- h[i+1]));
    }

    cout << dp[N] << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n,v[200001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    cout<<v[n/2+1]-v[n/2];
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll Z=0;
string s;
cin>>s;
ll rui=0;
ll a=0;
ll f=0;
ll s1=s.size();
ll b[s1+1];
ll c[s1+1];
for (ll i=0;i<s1;i++){
if(s.at(i)=='1'){
a++;}
else{
a--;}
b[i]=a;
c[i]=a;
Z=max(Z,a);}
for (ll i=s1-2;i>=0;i--){
b[i]=max(b[i],b[i+1]);}
for (ll i=0;i<s1;i++){
if(s.at(i)=='1'){
rui++;}
else if(s.at(i)=='0'){
rui--;}
else{
if(rui-c[i-1]+b[i]+2<=Z){
rui++;}
else{
rui--;}}
f=min(f,rui);}
ll Z1=Z+1;
ll f1=0;
rui=0;
for (ll i=0;i<s1;i++){
if(s.at(i)=='1'){
rui++;}
else if(s.at(i)=='0'){
rui--;}
else{
if(rui+b[i]-c[i-1]+2<=Z1){
rui++;}
else{
rui--;}}
f1=min(f1,rui);}
ll ans=min(Z-f,Z1-f1);
if(s.at(0)=='?'&&s1==1){
ans=1;}
cout<<ans<<endl;}


Measured memory_bytes: 20076
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

map<i64, i64> mp;

i64 f(i64 x)
{
    if (mp.count(x))
    {
        return mp[x];
    }
    if (x == 1)
    {
        return mp[x] = 1;
    }
    return mp[x] = 2 * f(x / 2) + 1;
}

void solve()
{
    i64 h;
    cin >> h;
    cout << f(h) << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(b>a){
			n = a;
			a = b;
			b = n;
		}
		int c = sc.nextInt();
		if(c>a){
			n = a;
			a = c;
			c = n;
		}
		if(a==(b+c)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
c = Counter(a)
c1,c2,c3 = c[1],c[2],c[3]
dp = [[[0 for i in range(c3+1)] for j in range(c2+c3+1)] for k in range(c1+c2+c3+1)]
#dp[i][j][k] := 1個×i皿、2個×j皿、3個×k皿における期待値
for k in range(c3+1):
  for j in range(c2+c3+1):
    for i in range(n+1):
      if i+j+k > n or i == j == k == 0:
        continue
      x = (n-i-j-k)/n
      dp[i][j][k] = 1
      if 0<i :
        dp[i][j][k] += dp[i-1][j][k]*(i/n)
      if 0<j and i+1<=n:
        dp[i][j][k] += dp[i+1][j-1][k]*(j/n)
      if 0<k and j+1<=c2+c3:
        dp[i][j][k] += dp[i][j+1][k-1]*(k/n)
      dp[i][j][k] /= 1-x
print(dp[c1][c2][c3])


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e6 + 5;
const ll MOD = 998244353;

int parent[N];

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

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

void solve() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    for(int i=0;i<n;i++) {
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    for(int i=0;i<m;i++) {
        cin >> b[i+1];
        b[i+1] += b[i];
    }
    int res = 0;
    for(int i=0,j=m;i<=n;i++) {
        if(a[i] > k) break;
        while(a[i] + b[j] > k) j--;
        res = max(res, i + j);
    }
    cout << res << endl;
    return;
}

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += a[i];
    cout << ans << endl;
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int lt = t.length();
  int ls = s.length();
  int ans = 1000;
  rep(i,ls) {
    if(i + lt > ls) continue;
    int res = 0;
    rep(j,lt) if(t[j] != s[i+j]) res++;
    ans = min(ans,res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
main(void){
	int a,b,c,i,x=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

const int sup = 1 << 30;

typedef struct {
	int left, right, min;
} seg_node;

void init_seg_tree(seg_node v[], int p[], int k, int l, int r)
{
	int i;
	v[k].left = l;
	v[k].right = r;
	v[k].min = sup;
	if (l < r) {
		init_seg_tree(v, p, k * 2, l, (l + r) / 2);
		init_seg_tree(v, p, k * 2 + 1, (l + r) / 2 + 1, r);
	} else p[l] = k;
}

int get_min(seg_node v[], int k, int l, int r)
{
	int tmp[2];
	if (v[k].left >= l && v[k].right <= r) return v[k].min;
	else if (v[k].right < l || v[k].left > r) return sup;
	else {
		tmp[0] = get_min(v, k * 2, l, r);
		tmp[1] = get_min(v, k * 2 + 1, l, r);
		return (tmp[0] < tmp[1])? tmp[0]: tmp[1];
	}
}

int main()
{
	int i, N, a[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int j, p[200001], pos[200001];
	seg_node v[600001];
	init_seg_tree(v, p, 1, 1, N);
	for (i = 1; i <= N; i++) {
		pos[a[i]] = i;
		for (j = p[i]; j >= 1; j /= 2) if (v[j].min > a[i]) v[j].min = a[i];
	}
	
	int l[2], r[2], m;
	long long ans = 0;
	for (i = 1; i <= N; i++) {
		l[0] = 1;
		r[0] = pos[i];
		while (l[0] < r[0]) {
			m = (l[0] + r[0]) / 2;
			if (get_min(v, 1, m, pos[i] - 1) > i) r[0] = m;
			else l[0] = m + 1;
		}
		l[1] = pos[i];
		r[1] = N;
		while (l[1] < r[1]) {
			m = (l[1] + r[1] + 1) / 2;
			if (get_min(v, 1, pos[i] + 1, m) > i) l[1] = m;
			else r[1] = m - 1;
		}
		ans += (long long)(pos[i] - l[0] + 1) * (l[1] - pos[i] + 1) * i;
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 10228
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    char ch;
    cin >> ch;
    printf("%c", ch+1);
    return 0;
}

Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string text;
    string revisedText;
    cin >> text;

    revisedText = text.substr(0,5) + " " + text.substr(6,7) + " " + text.substr(14, 5);

    cout << revisedText << endl;
    return 0;
}

Measured memory_bytes: 256
import heapq

def main():
    x,y,a,b,c = tuple([int(t)for t in input().split()])
    p = [int(t)for t in input().split()]
    q = [int(t)for t in input().split()]
    r = [int(t)for t in input().split()]

    p = sorted(p)[a-x:]
    q = sorted(q)[b-y:]

    r = sorted(r)

    while(len(r)>0):
        r_ = heapq.heappop(r)
        if r_-p[0]>=0 or r_-q[0]>=0:
            if r_-p[0]>r_-q[0]:
                heapq.heappop(p)
                heapq.heappush(p,r_)
            else:
                heapq.heappop(q)
                heapq.heappush(q,r_)

    print(sum(p)+sum(q))

if __name__ == "__main__":
    main()

Measured memory_bytes: 116392
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

ll lcm(ll a, ll b) {
  if(a < b) swap(a, b);
  return (a/__gcd(a, b))*b;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  ll ans = 1ll;
  while(n--) {
    ll x;
    cin >> x;
    ans = lcm(x, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import fractions
import itertools

a, b = list(map(int, input().split()))
c = min(a, b)
d = max(a, b)


def factorize(n: int) -> list:
    # 試し割り法
    f_list = []
    while n % 2 == 0:
        f_list.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            f_list.append(f)
            n //= f
        else:
            # 偶数はすでにチェックしているので+2ずつカウントアップ
            f += 2

    if n != 1:
        f_list.append(n)
    return f_list


a_list = factorize(a)
b_list = factorize(b)

common = (set(a_list) & set(b_list)) | {1}
count = len(common)

print(count)


Measured memory_bytes: 5176
(let* ((n (read))
       (m (read))
       (counts (make-array (1+ m) :initial-element 0))
       (table ))
  (loop for i below n
     do
       (let ((ki (read)))
         (loop for j below ki
            do
              (incf (aref counts (read))))))
  (format t "~A~%"
          (loop for i from 1 to m
             count (= (aref counts i) n))))


Measured memory_bytes: 6504
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a>b)
    {
        for(int i=0;i<a;i++)cout<<b;
    }
    else for(int i=0;i<b;i++)cout<<a;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	char c; cin >> c;
    int num = c - 'a';
    if(0 <= num && num < 26) {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
using namespace std;
string S; vector<int>vec;
int main() {
	cin >> S;
	int maxn = 1, cnt = 1, p = 0, OK = 0;
	while (p < S.size()) {
		if (S[p] == 'e') {
			vec.push_back(0); p += 3;
		}
		if (S[p] == 'c') {
			vec.push_back(1); p += 7;
		}
	}
	for (int i = 1; i < vec.size(); i++) {
		if(vec[i - 1] != vec[i])cnt++;
		else {
			if (maxn < cnt) { maxn = cnt; OK = vec[i]; }
			cnt = 1;
		}
	}
	if (maxn < cnt) { maxn = cnt; OK = vec[vec.size() - 1]; }
	if (OK == 0)cout << "egg" << endl;
	if (OK == 1)cout << "chicken" << endl;
	return 0;
}

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

#n以下の素数列挙(O(n log(n))
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass


mod = 10**9+7
n = int(input())
a = tuple(map(int,input().split()))

pr = primes(10**3+1)

d = defaultdict(lambda : 0)

for elt in a:
    for p in pr:
        if elt < p:
            break
        c = 0
        while not elt%p:
            c += 1
            elt //= p
        if c > d[p]:
            d[p] = c
    if elt > 1 and d[elt] == 0:
        d[elt] = 1



lcm  = 1
for elt in d:
    lcm = lcm*pow(elt,d[elt],mod)%mod

res = 0
for e in a:
    res = (res + pow(e,mod-2,mod))%mod
print(res*lcm%mod)



Measured memory_bytes: 44252
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int ans=0;
int n;
long long a[100005]={0}; 
int main(){
cin>>n;
for(int i=1;i<=n;i++){
	scanf("%lld",&a[i]);
	if(a[1]==i)ans++;
}
if(ans==0){
	cout<<0;
	return 0;
}
ans=0;
for(int i=1;i<=n;i++){
	if(a[i]==i){
		ans++;
		swap(a[i],a[i+1]);
	}
}
cout<<ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

string s;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> s;
    if(s=="SUN") cout << 7;
    else if(s=="MON") cout << 6;
    else if(s=="TUE") cout << 5;
    else if(s=="WED") cout << 4;
    else if(s=="THU") cout << 3;
    else if(s=="FRI") cout << 2;
    else cout << 1;
    cout << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    string s;
    cin >> s;

    int l = s.length();
    string ans = "";
    rep(i, l){
        ans += 'x';
    }
    OP(ans);
}


Measured memory_bytes: 256