akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        long K = sc.nextLong();

        double days = 5.0 * Math.pow(10, 15);  //兆:10^12, 1000兆: 10^15

        char ans = S.charAt(0);
        for(int i = 0; i < S.length(); i++){
            K -= Math.pow(Character.getNumericValue(S.charAt(i)), days);
            if(K <= 0){
                ans = S.charAt(i);
                break;
            }
        }

        out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI M_PI

using namespace std;

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

    if(b + c - a < 0) cout << 0 << endl;
    else cout << b + c - a << endl;
    
    return 0;
}

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

using int64 = long long;

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

  int64 all = 1;
  int64 odd = 1;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a % 2 == 0)
      odd *= 2;
    all *= 3;
  }
  cout << (all - odd) << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n, k;
  cin >> n >> k;
  vt<int> a(n);
  rep(i, 0, n) cin >> a[i];

  vt<bool> dp(k + 1, false);
  rep(i, 0, k) {
    rep(j, 0, n) {
      if(i + a[j] <= k) {
        dp[i + a[j]] = dp[i + a[j]] | !dp[i];
      }
    }
  }

  if(dp[k]) cout << "First\n";
  else cout << "Second\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(){
  string s[50];
  int h,w,c;
  cin >> h >> w;
  REP(i,h){
    cin >> s[i];
  }
  REP(i,h){
    REP(j,w){
      if (s[i][j]=='#'){
        c = 0;
      if (i>0) {
        if (s[i-1][j]=='#') c++;
      }
      if (i<h-1) {
        if (s[i+1][j]=='#') c++;
      }
      if (j>0) {
        if (s[i][j-1]=='#') c++;
      }
      if (j<w-1) {
        if (s[i][j+1]=='#') c++;
      }
      if (!c) {
        cout << "No";
        return 0;
      }
      }
    }
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
INF=2**31
n=int(input())
f=lambda:map(int,input().split())
s=t=INF
S=T=-INF
for _ in range(n):
  x,y=f()
  s=min(s,x+y)
  S=max(S,x+y)
  t=min(t,x-y)
  T=max(T,x-y)
print(max(S-s,T-t))

Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<utility>//swapでaとbの値を入れ替える
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whie(a) vector<vector<int>>

int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

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


int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a < 10)ans = b +(100* (10 - a));
	else ans = b;
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int a[3], roop, tmp;
  scanf("%d %d %d", &a[0], &a[1], &a[2]);

  if (a[0] > a[1]) {
    tmp = a[0];
    a[0] = a[1];
    a[1] = tmp;
  }

  if (a[1] > a[2]) {
    tmp = a[1];
    a[1] = a[2];
    a[2] = tmp;
  }

  if (a[0] > a[1]) {
    tmp = a[0];
    a[0] = a[1];
    a[1] = tmp;
  }

  printf("%d %d %d\n", a[0], a[1], a[2]);
  return 0;
}

Measured memory_bytes: 596
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,c);
  IN2(x,y);
  int d1 = x * a + y * b;
  int d2;
  if(x > y){
    d2 = y * c * 2 + (x-y) * a;
  } else {
    d2 = x * c * 2 + (y-x) * b;
  }
  int d3 = max(x,y) * c * 2;
  OUT(min({d1,d2,d3}));
}

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

constexpr int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(n, INF));
    for(int i=0; i<n; ++i) {
        d[i][i] = 0;

        int r, k;
        cin >> r >> k;
        for(int j=0; j<k; ++j) {
            int t;
            cin >> t;
            d[r-1][t-1] = 1;
        }
    }
    for(int k=0; k<n; ++k) {
        for(int i=0; i<n; ++i) {
            for(int j=0; j<n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    int p;
    cin >> p;
    for(int i=0; i<p; ++i) {
        int s, g, v;
        cin >> s >> g >> v;
        if(d[s-1][g-1] + 1 <= v) {
            cout << d[s-1][g-1] + 1 << endl;
        } else {
            cout << "NA" << endl;
        }
    }
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abcd = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var (a, b, c, d) = (abcd[0], abcd[1], abcd[2], abcd[3]);

        var max = new [] { a * c, a * d, b * c, b * d }.Max();

        Console.WriteLine(max);
    }
}


Measured memory_bytes: 28300
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	io_init;
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<int> p(A), q(B), r(C);
	for (int i = 0; i < A; i++)cin >> p[i];
	for (int i = 0; i < B; i++)cin >> q[i];
	for (int i = 0; i < C; i++)cin >> r[i];
	sort(p.begin(), p.end(), greater<>());
	sort(q.begin(), q.end(), greater<>());
	sort(r.begin(), r.end(), greater<>());
	vector<int> v;
	for (int i = 0; i < X; i++) v.push_back(p[i]);
	for (int i = 0; i < Y; i++) v.push_back(q[i]);
	for (int i = 0; i < C; i++) v.push_back(r[i]);
	sort(v.begin(), v.end(), greater<>());
	ll ans = 0;
	for (int i = 0; i < X+Y; i++) {
		ans += v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3572
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = map(int,input().split())

uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)

ans = 0
for i in range(n):
    ans = max(ans,uf.size(i))
print(ans)

Measured memory_bytes: 76008
/**
 *    author:  yoseph
 *    created: 28.08.2020 16:01:47      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, x, t;
	cin >> n >> x >> t;
	int ans;
	ans = (n / x) + ((n % x) > 0  ? 1 : 0);
	cout << ans * t << "\n";
	return 0;
}


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

int main(){
	int N;
    cin>>N;
	int ans=0;
	int yakusu;
	
	for(int i=1;i<N+1;i=i+2){
		yakusu=0;   
		for(int j=1;j<(i+1);j++){
		if(i%j==0){yakusu++;
                  }

        }

          	if(yakusu==8){ans++;
                     }
        }
  	cout <<ans<<endl;

	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;
const int M = 1e6 + 7;
const int INF = 1e9 + 7;
ll ans = 0, n;
map <ll, bool> m1;
void check(ll x)
{
    if(x == 1)
        return;
    ll m = n;
    while(m % x == 0)
        m = m / x;
    m = m % x;
    if(m == 1)
    {
        if(!m1[x])
        {
            ans++;
            m1[x] = 1;
        }
    }
}
void judge(ll x)
{
    for(ll i = 1; i * i <= x; i++)
    {
        if(x % i == 0)
        {
            check(i);
            check(x / i);
        }
    }
}

int main()
{

    cin >> n;
    judge(n - 1);
    judge(n);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int a,b,k;cin>>a>>b>>k;
  int cnt=0;
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==k){
      cout<<i<<endl;
      return 0;
    }
  }
}

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

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

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

	int mn=a[0],mx=a[0];
	for(int i=1;i<n;i++){
		if(mn>a[i])
			mn=a[i];
		if(mx<a[i])
			mx=a[i];
	}

	cout<<mx-mn<<endl;
}


Measured memory_bytes: 256
/*
ID: pktyagi1
LANG: C++
TASK: ttwo
*/
#include<stack>
#include<iostream>
#include<cstdio>
#include<stdio.h>
#include<cstring>
#include<vector>
#include<iostream>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include<string>
#define s(n) scanf("%d",&n)
#define p(n) printf("%d\n",n)
#include <iostream>
#include <fstream>
#define fs(n) fscanf(fin,"%d",&n)
#define fp(n) fprintf(fout,"%d\n",n)
using namespace std;
typedef long long ll;
int p[100010];
int father(int x)
{
	if(x==p[x])
	return x;
	else 
	return father(p[x]);
	
}
void unite(int x,int y)
{
	int xroot,yroot;
xroot=father(x);
yroot=father(y);
p[yroot]=xroot;
	}

int same(int x,int y){
	int xroot,yroot;
	xroot=father(x);
	yroot=father(y);
	if(xroot==yroot)
	return 1;
	else
	return 0;
	
}

 int main () {
   // FILE *fin  = fopen ("ttwo.in", "r");
   // FILE *fout = fopen ("ttwo.out", "w");
    //ofstream fout ("zerosum.out");
  //ifstream fin ("zerosum.in");
  int n,q;
  
  scanf("%d%d",&n,&q);
  for(int i=0;i<=n;i++)
  p[i]=i;
  int com,x,y;
 for(int i=0;i<q;i++)
  {scanf("%d%d%d",&com,&x,&y);
  if(com==0)
  unite(x,y);
  else
  printf("%d\n",same(x,y));
  }
return (0);
}

Measured memory_bytes: 1228
while True:
    m,nmi,nma = map(int,input().split())

    if m == 0:
        break

    P = []

    for i in range(m):

        p = int(input())
        P.append(p)


    ans = 0
    ap = 0

    for i in range(m-1):


        if nmi <= i+1 and i+1 <= nma and ans <= P[i]-P[i+1]:

            ans = max(ans,P[i]-P[i+1])
            ap = i+1

    print (ap)



Measured memory_bytes: 5620
// B - Grid Compression

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

char grid[100][100];

int main() {
	int H, W;
	cin >> H >> W;

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cin >> grid[i][j];
		}
	}

	set<int> i_skip, j_skip;

	for (int i=0; i<H; i++) {
		bool skip = true;
		for (int j=0; j<W; j++) {
			if (grid[i][j] == '#') skip = false;
		}
		if (skip) i_skip.insert(i);
	}

	for (int j=0; j<W; j++) {
		bool skip = true;
		for (int i=0; i<H; i++) {
			if (grid[i][j] == '#') skip = false;
		}
		if (skip) j_skip.insert(j);
	}

	for (int i=0; i<H; i++) {
		if (i_skip.find(i) != i_skip.end()) continue;
		for (int j=0; j<W; j++) {
			if (j_skip.find(j) != j_skip.end()) continue;
			cout << grid[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3620
n=int(input())
a=[]
b=[]
for i in range(n):
    tmpa,tmpb = map(int,input().split())
    a.append(tmpa)
    b.append(tmpb)

a.sort()
b.sort()

if n%2==1:
    print(b[n//2] - a[n//2] +1)
else:
    print((b[n//2]+b[n//2-1]) - (a[n//2]+a[n//2-1]) +1)


Measured memory_bytes: 25476
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  string S;
  int GX,GY;
  cin>>S;
  cin>>GX>>GY;
  VE X,Y;
  int L=S.size();
  bool update=true;
  FOR(i,0,L){
    if(S[i]=='T'){
      update=(update?false:true);
      continue;
    }
    int cnt=0;
    while(i<L&&S[i]=='F'){
      i++;
      cnt++;
    }
    i--;
    if(update){
      X.PB(cnt);
    }else{
      Y.PB(cnt);
    }
  }
  bitset<100000> xx;
  bitset<100000> yy;
  xx.reset();
  yy.reset();
  xx.set(50000);
  yy.set(50000);
  if(!X.empty()){
    if(S[0]=='F'){
      xx=(xx<<X[0]);
    }else{
      xx=(xx<<X[0])|(xx>>X[0]);
    }
  }
  FOR(i,1,(int)X.size()){
    xx=(xx<<X[i])|(xx>>X[i]);
  }
  FOR(i,0,(int)Y.size()){
    yy=(yy<<Y[i])|(yy>>Y[i]);
  }
  if(xx[GX+50000]&&yy[GY+50000]){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define cases           int T;cin>>T;for(int TC=1;TC<=T;TC++)
#define FastRead        ios_base::sync_with_stdio(0)
#define power(n,i)      (long long)ceil(pow(n,i))
#define ABS(x)          ((x)<0?-(x):(x))
const long long inf = 10000000000000;
int h[100005];
long long dp[100005];
int n,k;
long long call(int i)
{
    if(i==n-1)
      return 0;
    if(dp[i]!=-1)
      return dp[i];
    long long res=inf;
    for(int j=1; j<=k && (i+j)<n; j++)
    {
        long long temp=call(i+j)+ABS(h[i]-h[i+j]);
        res=min(res,temp);
    }
    return dp[i]=res;
}
int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    cin>>k;
    for(int i=0;i<n;i++)
      cin>>h[i];
    cout<<call(0)<<endl;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
int main()
{
  double  L;
  cin >> L;
  double a = L/3;
  double ans = pow(a, 3);
  cout <<fixed << ans<< endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;

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

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 2000 + 5;

int n,sum = 0;
int a[maxn];

bitset <maxn * maxn> status;

inline void Solve (){
	sort(a + 1,a + n + 1);
	for(int i = 1; i <= n; i++){
		sum += a[i];
		status |= status << a[i];
		status[a[i]] = 1;
	}
	int len = status.count() / 2;
	for(int i = sum; i; i--){
		if(status[i]){
			if(!len){
				printf("%d",i);
				return;
			}
			len--;
		}
	}
}

inline void Input (){
	n = read<int>();
	for(int i = 1; i <= n; i++){
		a[i] = read<int>();
	}
}

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

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

using namespace std;
using ll = long long;

#define gc getchar
int getint() { unsigned int c; int x = 0; while (((c = gc()) - '0') >= 10) { if (c == '-') return -getint(); if (!~c) exit(0); } do { x = (x << 3) + (x << 1) + (c - '0'); } while (((c = gc()) - '0') < 10); return x; }
int getstr(char *s) { int c, n = 0; while ((c = gc()) <= ' ') { if (!~c) exit(0); } do { s[n++] = c; } while ((c = gc()) > ' ' ); s[n] = 0; return n; }
template<class T> inline bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> inline bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }



int main () {
    int n = getint(), m = getint();
    map<int, int> cnt;
    for (auto k = 0; k < m; ++k) {
        auto a = getint();
        auto b = getint();
        cnt[a]++;
        cnt[b]++;
    }
    for (auto k = 1; k <= n; ++k) {
        cout << cnt[k] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,a,b,c,t=0;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){t=b;b=a;a=t;}
	if(a>c){t=c;c=a;a=t;}
	if(b>c){t=c;c=b;b=a;}
	printf("%d\n",c-a);
	return 0;
}


Measured memory_bytes: 128
n=int(input())
o=0
def pi(a):
    ans=0
    while(a!=0):
        if a%2==1:
            i=0
            break
        a//=2
        ans+=1
    return ans
        
for i in range(1,n+1):
    u=pi(i)
    if u>=o:
        ans=i
        o=u
    u=0
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
inline void isort(int *a, int n)
{
	for(int k=0;k<n;++k) printf("%d%c", a[k],k==n-1?'\n':' ');
	for(int i=1;i<n;++i)
	{
		int t=a[i];
		int j=i-1;
		for(;j>=0 && a[j]>t; --j)
			a[j+1]=a[j];
		a[j+1]=t;
		for(int k=0;k<n;++k) printf("%d%c", a[k],k==n-1?'\n':' ');
	}
}
int main()
{
	const int maxn=105;
	int a[maxn],n;
	scanf("%d", &n);
	for(int i=0;i<n;++i) scanf("%d", &a[i]);
	isort(a, n);
	return 0;
}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
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; }

int N;
int A[2][101];

int main() {
	cin >> N;
	for (int i = 0; i <2 ; i++)
	{
		for (int j = 0; j < N; j++)
		{
			cin >> A[i][j];
		}
	}
	int ans	 = 0;
	for (int j = 0; j < N; j++)
	{
		int tmp = 0;
		for (int k = 0; k <=j ; k++)
		{
			tmp += A[0][k];
		}
		for (int m = j; m < N; m++)
		{
			tmp += A[1][m];
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
fun main(array: Array<String>) {
    val S = readLine()!!
    var max = 0
    var cnt = 0
    S.forEach {
        if(it == 'A' || it == 'C' || it == 'G' || it == 'T') {
            cnt++
            max = cnt.coerceAtLeast(max)
        }
        else {
            cnt = 0
        }
    }
    print(max)
}

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

long int mygcd(long int a, long int b)
{
    if (b == 0) return a;
    if (a < b) return mygcd(b,a);
    return mygcd(a-b,b);
}

int main(void)
{
    long int a,b;

    while(cin >> a)
    {
        cin >> b;
        long int gcd = mygcd(a,b);
        long int lcm = a*b/gcd;

        cout << gcd << " " << lcm << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
import sys

def resolve():
    readline=sys.stdin.readline
    n=int(readline())
    answer=0

    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
        answer+=(table[i]*i)
    print(answer)

    return

resolve()

Measured memory_bytes: 151356
#include <stdio.h>
#include <limits.h>
 
#define MAX 2000000000
#define nMax 100000
 
typedef struct{
  int x;
  char c;
}card;
 
card M[nMax];
 
void mergeSort(int left, int right, card K[]){
  if((left + 1) < right){
    int mid = (left + right) / 2;
    mergeSort(left, mid, K);
    mergeSort(mid, right, K);
    merge(left, mid, right, K);
  }
}

void merge(int left, int mid, int right, card K[]){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  card L[nMax+1], R[nMax+1];
 
  for(i = 0; i < n1; i++){
    L[i] = K[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = K[mid+i];
  }
  L[n1].x = MAX;
  R[n2].x = MAX;
 
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i].x <= R[j].x)
      K[k]=L[i++];
    else
      K[k]=R[j++];
  }
}

int Partition(int e, int s){
  card tmp;
  int i, j, x;
  x = M[s].x;
  i = e - 1;
 
  for(j = e; j < s; j++){
    if (M[j].x <= x){
      i++;
      tmp = M[i];
      M[i] = M[j];
      M[j] = tmp;
    } 
  }
  tmp = M[i + 1];
  M[i + 1] = M[s];
  M[s] = tmp;
  return (i + 1);
}
   
void Quicksort(int e, int s){
  int w;
  if(e < s){
     w = Partition(e, s);
     Quicksort(e, w-1);
     Quicksort(w+1, s);
  }
}
 
int main(){
  int i, p, n;
  char c;
  card N[nMax];
 
  scanf("%d%c", &n, &c);
 
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &N[i].c, &N[i].x, &c);
    M[i] = N[i];
  }
 
  p = 0;
  mergeSort(0, n, N);
  Quicksort(0, n-1);
 
  for(i = 0; i < n; i++){
    if(N[i].c != M[i].c){
      printf("Not stable\n");
      break;
    }
    if(i == (n - 1))
      printf("Stable\n");
  }
   
  for(i = 0; i < n; i++){
    printf("%c %d\n", M[i].c, M[i].x);
    }
   
  return 0;
}

Measured memory_bytes: 2956
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

ll gcd(ll a, ll b){return b==0 ? a : gcd(b, a%b);}
ll lcm(ll a, ll b){return a / gcd(a,b) * b;}

int main()
{
  ll n,m; cin>>n>>m;
  string s,t; cin>>s>>t;
  ll l = lcm(n, m);
  ll g = gcd(n, m);

  ll x = n/g;
  ll y = m/g;
  for (int i=0; i<g; i++) {
    if (s[x*i] != t[y*i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;

  return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    int a[n];
    int b[n-1];
    rep(i,n-1)cin >> b[i];

    int ans = 0;

    rep(i,n){
        if(i == n-1){
            a[i] = b[i - 1];
        }else if(i==0){
            a[i] = b[i];
        }else{
            a[i] = min(b[i], b[i-1]);
        }
        ans += a[i];
    }

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


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

#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll l[11000];
int main(){
  ll n,ans=0;
  cin>>n;
  rep(i,0,n)cin>>l[i];
  sort(l,l+n);
  rep(i,0,n-1){
    irep(j,n-1,i){
      rep(k,i+1,j){
        if(l[k]+l[i]>l[j])ans++;
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = [0]*(len(B)+1)
A[0] = B[0]
A[1] = B[0]
cnt = 0
for i, x in enumerate(B):
    if i != 0:
        A[i + 1] = B[i]
        A[i] = min(A[i], B[i])
    cnt += A[i]
cnt += A[-1]
print(cnt)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
import numpy as np
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S, T = MAP()

for i in range(N):
	print(S[i], T[i], sep="", end="")
print()

Measured memory_bytes: 13000
#include <stdio.h>

int main(){
	
	int n[1000],x[10000];
	
	int i=0;
	
	while(1){
		
		if(i!=0)
			
			scanf("%*c");
		
		scanf("%d %d",&n[i],&x[i]);
		
		if(n[i]==0&&x[i]==0)
		
			break;
		
		i++;
		
	}

	int t;

	int a[i],b[i],c[i];
	
	int number[i];

	for(t=0;t<=i-1;t++){

		/*
		printf("%d %d\n",t,i);
		*/
		
		number[t]=0;
		
		for(a[t]=1;a[t]<=n[t];a[t]++){

			/*
			printf("a[%d]=%d\n",t,a[t]);
			*/
			
			for(b[t]=a[t];b[t]<=n[t];b[t]++){
				
				if(a[t]==b[t])
					b[t]++;
			
				if(b[t]>n[t])
					break;
				
				/*
				printf("b[%d]=%d\n",t,b[t]);
				*/
				
				for(c[t]=b[t];c[t]<=n[t];c[t]++){
					
					if(b[t]==c[t]||a[t]==c[t])
					
						c[t]++;
					
					if(c[t]>n[t])
						break;
					
					if(a[t]+b[t]+c[t]==x[t]){
					
						number[t]++;
					
						/*
						printf("%d %d %d match!\n",a[t],b[t],c[t]);
						*/

					}

					/*
					printf("c[%d]=%d\n",t,c[t]);
					*/

				}
				
			}
			
		}
		
	}
	
	int k;
	
	for(k=0;k<=i-1;k++){
		
		printf("%d\n",number[k]);
		
	}
	
	return 0;
	
}

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

int main() {
    int n;
    cin >> n;
    int* tableA = new int[n];
    for (int i = 0; i < n; i++) {
        int h, m;
        cin >> h >> m;
        tableA[i] = h * 100 + m;
    }
    int k;
    cin >> k;
    int* tableB = new int[k];
    for (int i = 0; i < k; i++) {
        int h, m;
        cin >> h >> m;
        tableB[i] = h * 100 + m;
    }
    int* mixed = new int[n + k];
    int marA = 0;
    int marB = 0;
    for (int i = 0; i < n + k; i++) {
        if ((marA < n) && (marB < k)) {
            if (tableA[marA] < tableB[marB]) {
                mixed[i] = tableA[marA];
                marA++;
            }
            else {
                mixed[i] = tableB[marB];
                marB++;
            }
        }
        else {
            if (marB == k) {
                mixed[i] = tableA[marA];
                marA++;
            }
            else {
                mixed[i] = tableB[marB];
                marB++;
            }
        }
    }
    if (mixed[0] % 100 < 10) {
        cout << mixed[0] / 100 << ":0" << mixed[0] % 100;
    }
    else {
        cout << mixed[0] / 100 << ":" << mixed[0] % 100;
    }
    for (int i = 1; i < n + k; i++) {
        if (mixed[i - 1] == mixed[i]) {
            continue;
        }
        if (mixed[i] % 100 < 10) {
            cout << " " << mixed[i] / 100 << ":0" << mixed[i] % 100;
        }
        else {
            cout << " " << mixed[i] / 100 << ":" << mixed[i] % 100;
        }
    }
    cout << endl;
    delete[] mixed;
    delete[] tableA;
    delete[] tableB;
    return 0;
}


Measured memory_bytes: 3128
#include <cstdio>
#include <iostream>

using namespace std;

int INFTY = 2000000000;
int cnt = 0;

void merge(int A[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;

	int L[n1];
	int R[n2];
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left + i];
	}
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid + i];
	}
	L[n1] = INFTY;
	R[n2] = INFTY;
	int i = 0;
	int j = 0;
	for (int k = left; k <= right - 1; ++k) {
		++cnt;
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i = i + 1;
		} else {
			A[k] = R[j];
			j = j + 1;
		}
	}
}

void mergeSort(int A[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

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

	int A[n];
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}

	mergeSort(A, 0, n);

	for (int i = 0; i < n; ++i) {
		if (i != 0) {
			cout << " ";
		}
		cout << A[i];
	}
	cout << endl;
	cout << cnt << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int t; cin >> t;
  ll a[t], b[t], c[t], d[t];
  for(int i=0;i<t;i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
  for(int i=0;i<t;i++){
    ll p = d[i] - b[i];
    if(d[i] - b[i] < 0){
      cout << "No" << endl;
      continue;
    }
    ll m = b[i];
    ll at = a[i] - b[i];
    ll ct = c[i];
    if(at < 0){
      cout << "No" << endl;
      continue;
    }
    ll g = gcd(p, m);
    // cout << g << endl;
    ll cm = -1;
    // cm = at + k * g > ctなる最小のcmを求める
    if(at <= ct){
      cm = at + ((ct - at)/g + 1) * g;
    }else{
      if((at - ct) %g == 0) cm = at - ((at - ct)/g - 1) * g;
      else cm = at - ((at - ct)/g) * g;
    }
    // cout << cm << endl;
    if(cm - m >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//https://cf17-exhibition-open.contest.atcoder.jp/tasks/cf17_exhibition_b
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 200020
#define inf 0x7fffffff
#define ll long long
int n,mn[N<<2],add[N<<2],b[N],a[N];
ll ans=0;
inline void pushup(int x){mn[x]=min(mn[x<<1],mn[x<<1|1]);}
inline void pushdown(int x){
	mn[x<<1]+=add[x];mn[x<<1|1]+=add[x];
	add[x<<1]+=add[x];add[x<<1|1]+=add[x];
	add[x]=0;
}
void build(int v,int l,int r){
	if(l==r){mn[v]=b[l];return;}
	int mid=l+r>>1;
	build(v<<1,l,mid);build(v<<1|1,mid+1,r);
	pushup(v);
}
void ins(int v,int l,int r,int x,int y){
	if(x>y) return;
	if(x<=l && r<=y){
		add[v]++;mn[v]++;
		return;
	}int mid=l+r>>1;pushdown(v);
	if(x<=mid) ins(v<<1,l,mid,x,y);
	if(mid<y) ins(v<<1|1,mid+1,r,x,y);
	pushup(v);
} 
int query(int v,int l,int r,int x,int y){
	if(x<=l && r<=y) return mn[v];
	int mid=l+r>>1,s=inf;pushdown(v);
	if(x<=mid) s=min(s,query(v<<1,l,mid,x,y));
	if(mid<y) s=min(s,query(v<<1|1,mid+1,r,x,y));
	return s;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=a[i];
	sort(b+1,b+n+1);int nn=unique(b+1,b+n+1)-b-1;
	build(1,1,nn);
	for(int i=1;i<=n;i++){
		int p=lower_bound(b+1,b+nn+1,a[i])-b;
		ans+=query(1,1,nn,p,nn)-a[i];
		ins(1,1,nn,1,p-1);
	}printf("%lld\n",ans);
	return 0;
}

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

int main(){
  long long N; cin >> N;

  long long ALL = 0, OUT = 0;
  rep1(i, N) {
    ALL += i * (N - i + 1);
  }

  rep(i, N - 1) {
    int u, v; cin >> u >> v;
    if (u > v) swap(u, v);
    OUT += u * (N - v + 1);
  }

  cout << ALL - OUT << endl;
}


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

using namespace std;

typedef long long ll;
typedef double long dl;
typedef pair < int , int > pii;
typedef pair < pii, pii > p2i;
const int maxn = (int) 3e5 + 1;
const int mod = (int) 1e9 + 7;
const ll inf = (ll)1e18;

#define fi first
#define se second
#define acel ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define next continue

int n;
int a[maxn];
int s[maxn], p[maxn];
int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        p[i] = s[i] = a[i];
    }
    for(int i = 1; i <= n; i++){
        p[i] = p[i - 1] + abs(a[i] - a[i - 1]);
    }
    for(int i = n; i >= 1; i--){
        s[i] = s[i + 1] + abs(a[i] - a[i + 1]);
    }
    for(int i = 1; i <= n; i++){
        ll ans = p[i - 1] + s[i + 1];
        ans += abs(a[i + 1] - a[i - 1]);
        cout << ans << "\n";
    }
}


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

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() {
  int A, B;
  cin >> A >> B;
  cout << Lcm(A, B) << endl;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	a, b := nextInt(), nextInt()
	num := 0
	for connect := 1; connect < b; {
		connect = connect - 1 + a
		num++
	}
	fmt.Println(num)
}


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

long a[222222], b[222222], t[222222], c[222222];
int main() {
	long n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		scanf("%ld", a + i);
	for (int j = 2; j--;) {
		for (int i = n; i--;) {
			b[i] = t[a[i]];
			t[a[i]] = i + j * n;
		}
	}
	long x = 0;
	int y = 0;
	do {
		c[y++] = x;
		x = x / n * n + b[x%n] + 1;
	} while (x%n);
	x /= n;
	int l = lower_bound(c, c + y, k%x*n) - c - 1;
	for (l = c[l] % n; l < n; l++) {
		if (b[l] < n) l = b[l];
		else cout << a[l] << ' ';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
typedef unsigned int uint;
#define rep(i,n) for(uint i=0;i<(n);i++)

uint f(uint bit,uint shift) {
    return ((bit>>shift)&1);
}

int main() {
    int N;
    cin>>N;
    while(N-->0) {
        uint a[9];
        uint sum,ans=0;
        rep(i,9) scanf("%x",a+i);
        rep(i,32) {
            sum=0;
            rep(j,8) sum+=a[j]^ans;
            ans |= (f(sum,i) != f(a[8],i))<<i;
        }
        printf("%x\n",ans);

    }
    return 0;
}

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

int main(){
    ll h;
    cin >> h;
    ll bilog = log2(h);

    ll res = 2*pow(2, bilog) -1;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p3[110];
int main(){
	int a;scanf("%d",&a);
	p3[0]=1;
	for(int i=1;i<15;i++)p3[i]=p3[i-1]*3;
	vector<pair<pair<int,int>,int> >v;
	for(int i=2;i<=14;i++){
		v.push_back(make_pair(make_pair(i,i+1),0));
		v.push_back(make_pair(make_pair(i,i+1),p3[14-i]));
		if(p3[14-i]*2<=1000000)v.push_back(make_pair(make_pair(i,i+1),p3[14-i]*2));
		
	}
	int cur=0;
	for(int i=12;i>=0;i--){
		if(a%p3[i+1]/p3[i]==2){
			v.push_back(make_pair(make_pair(1,15-i),cur+p3[i]));
		}
		if(a%p3[i+1]/p3[i]>=1){
			v.push_back(make_pair(make_pair(1,15-i),cur));
		}
		cur+=a%p3[i+1]/p3[i]*p3[i];
	}
	printf("15 %d\n",(int)v.size());
	for(int i=0;i<v.size();i++)printf("%d %d %d\n",v[i].first.first,v[i].first.second,v[i].second);
}


Measured memory_bytes: 256
#include<stdio.h>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

bool judge(string s){
  int n = s.size();
  bool result = true;

  for(int i = 0, end=(n-1)/2; i < end; i ++){
    // s[i], s[end-i-1], s[end+i+1], s[n-i-1]が同じ
    bool is_same = s[i] == s[end-i-1] && s[i] == s[end+i+1] && s[i] == s[n-i-1];
    if (!is_same){
      result = false;
      break;
    }
  }
  return result;
}

int main(){
  string s;
  cin >> s;
  bool result = judge(s);
  if (result){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int gcd(int x, int y){
    return (x==0?y:gcd(y%x, x));
}
void solve(){
    int n;
    cin>>n;
    vi v(n);
    unordered_map<int, int>u, cnt;
    int gc = 0, ok=1;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        cnt[v[i]]++;
        if(cnt[v[i]]>1&&v[i]>1)ok=0;
        gc=gcd(gc, v[i]);
    }
    if(gc>1){
        cout<<"not coprime";
        return;
    }
    if(!ok){
        cout<<"setwise coprime";
        return;
    }
    for(int i = 0; i < n; i++){  
        for(int j = 2; j <= sqrt(v[i]); j++){
            if(v[i]%j==0){
                u[j]++;
                if(u[j]>=2){
                    cout<<"setwise coprime";
                    return;
                }
                if(j*j!=v[i]){
                    u[v[i]/j]++;
                    if(u[v[i]/j]>=2){
                        cout<<"setwise coprime";
                        return;
                    }
                }
            }
        }
        if(v[i]>1)u[v[i]]++;
        if(u[v[i]]>=2){
            cout<<"setwise coprime";
            return;
        }
    }
    cout<<"pairwise coprime";
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}


Measured memory_bytes: 50492
import sys
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    len_m = len([x for x in X if x < 0])
    len_p = len([x for x in X if x > 0])
    ans = 10**10
    for i in range(max(0, len_m-K), min(len_m+K, N-K+1)):
        l = X[i]
        r = X[i+K-1]
        if l < 0 and r > 0:
            c = min(abs(l) * 2 + r, abs(l) + r * 2)
        else:
            c = max(abs(l), abs(r))
        ans = min(ans, c)

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14780
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n, m;
	cin >> n >> m;
	
	vector< vector<int> > G(n);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	vector<int> dist(n, 0);
	queue<int> q;
	int ans = -1;
	for(int i = 0; i < n; ++i) {
		if( dist[i] == 0 ) {
			
			dist[i] = 1;
			q.push(i);
			int cnt = 0;
			
			while( !q.empty() ) {
				int now = q.front();
				q.pop();
					
				for(auto& v : G[now]) {
					if( dist[v] == 0 ) {
						dist[v] = 1;
						q.push(v);
						cnt++;
					}
				}
			}
			
			ans = max(ans, cnt);
		}
	}
	
	cout << ans + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 15416
#include <bits/stdc++.h>
using namespace std;
int main()
{
	map<int, int> mp;
	int x,n, m=1000, ans;  cin>>x>>n; 
	for(int i=0; i<n; i++){
		int a; cin>>a;
		mp[a]=1;
	}
	for(int i=0; i<=x; i++){
		if(mp[x-i]==0){
			cout<<x-i<<endl;
			//cout<<i<<endl;
			break;
		}
		if(mp[x+i]==0){
			cout<<x+i<<endl;
			//cout<<i<<endl;
			break;
		}
	}


	//cout<<ans<<endl;
}

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

class Program {
  static void Main() {
    var s = Console.ReadLine();
    var d = new Stack<int>();
    var p = new Stack<KeyValuePair<int, int>>();
    int a = 0;
    for (int i = 0; i < s.Length; i++) {
      if (s[i] == '\\') {
        d.Push(i);
      } else if (s[i] == '/' && d.Count > 0) {
        int b = d.Pop();
        int t = i - b;
        a += t;
        while (p.Count > 0 && b < p.Peek().Key) {
          t += p.Pop().Value;
        }
        p.Push(new KeyValuePair<int, int>(b, t));
      }
    }
    Console.WriteLine(a);
    Console.Write(p.Count);
    foreach (var item in p.Select(x => x.Value).Reverse()) {
      Console.Write(" " + item);
    }
    Console.WriteLine();
  }
}


Measured memory_bytes: 18684
n,m = map(int,raw_input().split())

M = 1<<n
dp = [10**9]*M
dp[0] = 0
for i in xrange(m):
	a,b = map(int,raw_input().split())
	c = map(int,raw_input().split())
	mask = 0
	for x in c:
		mask += 1<<(x-1)
	for j in xrange(M):
		dp[j|mask] = min(dp[j|mask], dp[j]+a)
	#print dp
 
if dp[M-1] >= 10**9:
	print -1
else:
	print dp[M-1]

Measured memory_bytes: 2692
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
    int h, w;
    cin >> h >> w;
 
    char a[h+2][w+2];
    
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            cin >> a[i][j];
        }
    }
 
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(a[i][j] == '.') {
                a[i][j] = '0';
                if(a[i-1][j] == '#') a[i][j]++;
                if(a[i+1][j] == '#') a[i][j]++;
                if(a[i][j-1] == '#') a[i][j]++;
                if(a[i][j+1] == '#') a[i][j]++;
                if(a[i-1][j-1] == '#') a[i][j]++;
                if(a[i-1][j+1] == '#') a[i][j]++;
                if(a[i+1][j-1] == '#') a[i][j]++;
                if(a[i+1][j+1] == '#') a[i][j]++;
            }
        }
    }
 
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            cout << a[i][j];
        }
        cout << endl;
    }
 
}


Measured memory_bytes: 256
def z_algo(s):
    N = len(s)
    A = [0]*N
    i = 1; j = 0
    l = len(s)
    A[0] = l
    B = [0]*N
    while i < l:
        while i+j < l and s[j] == s[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k

    # 自身は含まない
    for i in range(N):
        B[i] = i
    #
    for i in range(N):
        A[i] = min(A[i],i)
#    print(B)
#    A[0] = 0
    return A

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

N = I()
S = str(input())
cur = int(0)
ans = int(0)
lenC = []

for i in range(N):
#    print(z_algo(S[i:]))
    lenC.append(max(z_algo(S[i:])))

#print(lenC)
ans = min(max(lenC),N//2)
print(ans)


Measured memory_bytes: 50780
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    char ch1,ch2;
    cin>>ch1>>ch2;
    if(ch1=='H')
     cout<<ch2;
    else
    {
      if(ch2=='H')
       cout<<'D';
      else
       cout<<'H';
    }
	return 0;
}


Measured memory_bytes: 256