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

vector<string> split(const string &str,char sep){

    vector<string> v;
    stringstream ss(str);
    string buffer;
    while(getline(ss,buffer,sep)){
        v.push_back(buffer);
    }
    return v;

}

bool comp(const pair<int,string>& p1,const pair<int,string>& p2){
    if(p1.first == p2.first){
        return p1.second < p2.second;
    }
    return p1.first > p2.first;
}

map<char,int> al;

int main() {

    al['a'] = 0;
    al['b'] = 1;
    al['c'] = 2;
    al['d'] = 3;
    al['e'] = 4;
    al['f'] = 5;
    al['g'] = 6;
    al['h'] = 7;
    al['i'] = 8;
    al['j'] = 9;
    al['k'] = 10;
    al['l'] = 11;
    al['m'] = 12;
    al['n'] = 13;
    al['o'] = 14;
    al['p'] = 15;
    al['q'] = 16;
    al['r'] = 17;
    al['s'] = 18;
    al['t'] = 19;
    al['u'] = 20;
    al['v'] = 21;
    al['w'] = 22;
    al['x'] = 23;
    al['y'] = 24;
    al['z'] = 25;



    while(1){

        int n;

        cin >> n;

        if(n==0) break;

        string s;

        cin.ignore();

        vector<string> vec[26];
        map<string,int> mp[26];

        int index;

        for(int i=0;i<n;i++) {

            /*while (getline(cin, s, ' ')) {

                index = al[s[0]];
                bool pushed = se[index].insert(s).second;
                if (pushed) {
                    vec[index].push_back(s);
                }
            }*/

            getline(cin,s);

            vector<string> sve = split(s,' ');

            for(int i=0;i<sve.size();i++) {
                index = al[sve[i][0]];
                map<string,int>::iterator it;
                it = mp[index].find(sve[i]);
                if(it != mp[index].end()){
                    mp[index][sve[i]] += 1;
                }
                else{
                    mp[index][sve[i]] = 1;
                }

            }

        }


        char c;

        cin >> c;

        index = al[c];

        int ro = min(5,(int)mp[index].size());

        if(ro!=0) {

            map<string,int>::iterator itr = mp[index].begin();

            vector<pair<int,string> > ansvec;

            for (int i=0;i<mp[index].size() ; i++) {
                ansvec.push_back(make_pair(itr->second,itr->first));
                itr++;
            }

            sort(ansvec.begin(),ansvec.end(),comp);

            for (int i=0;i<ro-1; i++) {
                cout << ansvec[i].second << ' ';
            }

            cout << ansvec[ro-1].second << endl;

        }
        else{
            cout << "NA" << endl;
        }


    }


    return 0;
}

Measured memory_bytes: 3224
def main():
    A, B = map(int, input().split())
    S = input()
    s = S.split('-')
    if len(s) != 2:
        print('No')
    else:
        x = s[0]
        y = s[1]
        print(
            'YNeos'[
                not (
                    len(x) == A and
                    len(y) == B and
                    x.isdecimal() and
                    y.isdecimal()
                )::2
            ]
        )


main()


Measured memory_bytes: 2940
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3

    # for f in range(3,int(n**0.5)+1,2):
    #     if n%f == 0:
    #         a.append(f)
    #         n //= f
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = list(map(int,input().split()))
A, B = set(prime_factorize(a)), set(prime_factorize(b))
C = A&B
# print(A,B,C)

print(len(C)+1)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll gcd( ll a, ll b )
{
	// // 引数に０がある場合は０を返す
	// if ( ( 0 == m ) || ( 0 == n ) )
	// 	return 0;
	
	// // ユークリッドの方法
	// while( m != n )
	// {
	// 	if ( m > n ) m = m - n;
	// 	else         n = n - m;
	// }
	// return m;
   if (b == 0) return a;
   return gcd(b, a%b);
}//gcd

ll lcm( ll m, ll n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main() {
   int N;
   cin >> N;
   ll ans = 1;
   rep (i, N) {
      ll t;
      cin >> t;
      ans = lcm(ans, t);
      // debug(ans)
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <math.h>
#define ll long long int 
using namespace std;


int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int s,w;
	cin>>s>>w;
	cout<<(w>=s?"unsafe":"safe");
	
	return 0; 
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(void){
	char s[51],t[51];
	scanf("%s%s",s,t);
	int i,len1 = strlen(s), len2 = strlen(t),j,k;
	
	for(i=len1-len2;i>=0;i--){
		for(j=0;j<len2;j++){
			if(s[i+j] != t[j] && s[i+j] != '?') break;
			else if (j == len2-1){
				for(k=0;k<len2;k++){
					s[i+k] = t[k];
				}
				for(k=0;k<len1;k++){
					if(s[k] == '?') s[k] = 'a';
				}
			printf("%s",s);
			return 0;
			}
		}	
	}

	printf("UNRESTORABLE");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		final long MOD = 1000000007L;
		long[][] dp = new long[n + 1][4];
		dp[0][0] = 1;
		for(int i = 0; i < n; i++) {
			if(s.charAt(i) == 'A' || s.charAt(i) == '?') {
				for(int j = 0; j < 4; j++) {
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
					if(j == 0) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
				}
			}
			if(s.charAt(i) == 'B' || s.charAt(i) == '?') {
				for(int j = 0; j < 4; j++) {
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
					if(j == 1) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
				}
			}
			if(s.charAt(i) == 'C' || s.charAt(i) == '?') {
				for(int j = 0; j < 4; j++) {
					dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
					if(j == 2) dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
				}
			}
		}
		System.out.println(dp[n][3]);
	}
}


Measured memory_bytes: 31804
#include <iostream>
#include <cstdio>
#define N 1005
#define M 20005
using namespace std;

int h, n, mn = 1e9, a[N], b[N], d[M];
int main()
{
	int i, j;
	cin >> h >> n;
	for (i = 0; i < n; i++) scanf("%d %d", &a[i], &b[i]);
	for (i = 1; i < M; i++) {
		d[i] = 1e9;
		for (j = 0; j < n; j++) {
			if (a[j] <= i) d[i] = min(d[i], d[i - a[j]] + b[j]);
		}
	}
	for (i = h; i < M; i++) mn = min(mn, d[i]);
    cout << mn << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int hyaku = n/100;
  int juu = (n-hyaku*100)/10;
  int ichi = (n-hyaku*100-juu*10);
  
  int ans;
  
  if (hyaku >= juu){
    if ((hyaku > juu)||(hyaku == juu &&juu >= ichi)){
      ans = hyaku*100+hyaku*10 + hyaku;
    }
    else{
      ans = (hyaku+1)*100 + (hyaku+1)*10 + hyaku+1;
    }
  }
  else{
    ans = (hyaku+1)*100 + (hyaku+1)*10 + hyaku+1;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
// #pragma GCC target("avx")  // 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>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
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 = 3100000;
const int UF_SIZE = 3100000;
namespace{
	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;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			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 UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int t[20][20];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<20;i++)for(int j=0;j<20;j++)t[i][j]=-1;
	for(int i=0;i<a;i++){
		int b;scanf("%d",&b);
		for(int j=0;j<b;j++){
			int x,y;scanf("%d%d",&x,&y);
			x--;
			t[i][x]=y;
		}
	}
	int ret=0;
	for(int i=0;i<(1<<a);i++){
		bool ok=true;
		for(int j=0;j<a;j++){
			if(!(i&(1<<j)))continue;
			for(int k=0;k<a;k++){
				if(t[j][k]==-1)continue;
				if(t[j][k]==0&&(i&(1<<k)))ok=false;
				if(t[j][k]==1&&!(i&(1<<k)))ok=false;
			}
		}
		if(ok)ret=max(ret,__builtin_popcount(i));
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll LNF = 1LL<<60;

ll v[110];
ll w[110];
ll dp[110][100010];

int main(){
    int N; cin >> N;
    int r=0,b=0;
    string S; cin >> S;
    for(int i=0;i<N;i++){
        if(S[i]=='B'){
            b++;
        }else{
            r++;
        }
    }
    cerr << r << " " << b << endl;
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int size = 0;
int S[2000000] = {0};

int parent(int i){
  if(i % 2 == 1)return (i - 1) / 2;
  else          return (i - 2) / 2;
}

void insert(int *S, int k){
  int i = size++;

  while(i > 0){
    int p = parent(i);
    if(S[p] >= k) break;
    else{
      S[i] = S[p];
      i = p;
    }
  }
  S[i] = k;
}

int extractMax(int *S){
  int ret = S[0];
  int x = S[--size];

  int i = 0;
  while(i * 2 + 1 < size){
    int l = i * 2 + 1, r = i * 2 + 2;
    if(r < size && S[r] > S[l]) l = r;
    if(S[l] <= x)break;
    S[i] = S[l];
    i = l;
  }
  S[i] = x;
  return ret;
}

int main(){
  string s;
  int k;
  while(1){
    cin >> s;
    if(s == "end"){
      break;
    }else if(s == "insert"){
      cin >> k;
      insert(S, k);
    }else {
      cout << extractMax(S) << endl;
    }
  }
}

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

using namespace std;
typedef long long ll;


int main(){
  ll n;
  cin>>n;
  vector<ll> A;
  ll sum=0;
  map <ll,ll> M;
  for(int i=0;i<n;i++){
    ll in;
    cin>>in;
    A.push_back(in);
    if(M.find(in)==M.end()){
      M.insert(make_pair(in,1));
    } else {
      M[in] = M[in]+1;
    }
  }

  for(map<ll,ll>::iterator it = M.begin();it!=M.end(); it++){
    ll r = it->second;
    ll cnt = (r)*(r-1);
    cnt/=2;
    sum+=cnt;
    // cout<<it->first<<" "<<it->second<<endl;
  }
  for(int i=0;i<n;i++){
    ll cur = A[i];
    cout<<sum-(M[cur]-1)<<endl;
  }
}

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}
int main(){
int n,k;
cin>>n>>k;
vector<int>p(n);
for(int i=0;i<n;i++){
  cin>>p[i];
}
sort(p.begin(),p.end());
int ans=0;
for(int i=0;i<k;i++){
  ans+=p[i];
}
cout<<ans<<endl;

  return 0;
  
  
}


Measured memory_bytes: 3604
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 998244353;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
int dp[305][305][305];
int sum1[305][305][305];
int sum2[305][305][305];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	vi v(1);string s;int K;
	cin>>s>>K;s='0'+s;
	int cnt=0;
	for(int i=s.length()-1; i>=0; i--)
	{
		if(s[i]=='1') cnt++;
		else 
		{
			v.eb(cnt);
			cnt=0;
		}
	}
	reverse(begin(v)+1, end(v));
	int n=v.size()-1;
	for(int i=1; i<=n; i++)
	{
		for(int j=0; j<=min((int)s.length(), K); j++) 
		{
			for(int k=0; k<=j; k++) 
			{
				if(i==1 and j==k) dp[i][j][k]=1;
				else if(i>1) dp[i][j][k]=sum1[i-1][j][k]+sum2[i-1][j][k]-sum2[i-1][j][min(j+1, k+v[i]+1)]-dp[i-1][j][k];
				dp[i][j][k]%=MOD;
				if(k) sum1[i][j][k]=(sum1[i][j-1][k-1]+dp[i][j][k])%MOD;
				else sum1[i][j][k]=dp[i][j][k];
			}
			for(int k=j; k>=0; k--)
				sum2[i][j][k]=(sum2[i][j][k+1]+dp[i][j][k])%MOD;
		}
	}
	int ans=0;
	for(int j=0; j<=min((int)s.length(), K); j++)
	{
		ans+=dp[n][j][0];
		ans%=MOD;
	}
	while(ans<0) ans+=MOD;
	cout<<ans;
}




Measured memory_bytes: 330304
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;
long long int a,b,c[100010],d;

int main(){
  cin >> a >> b;
 for(int i=0;i<a;i++){
   cin >> c[i];
 }
  
  sort(c,c+a);
  d =1000000007;
  for(int i=0;i<=a-b;i++){
   d = min(d,(c[i+b-1]-c[i]));
  }
  
  cout << d << endl;
}
    
    
  


Measured memory_bytes: 1024
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
using namespace std;
int main()
{
    rj
    int a,b,c,sum=0;
    cin>>a>>b;
    while(b--)
    {
       cin>>c;
       sum+=c;

    }
    if(sum>a) cout<<"-1"<<endl;
    else cout<<a-sum<<endl;


    return 0;
}



Measured memory_bytes: 3612
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let M = parseInt(input[0][1], 10);
    let Q = parseInt(input[0][2], 10);
    let arr = [];
    for (let i = 0; i < N; i++){
        arr.push(Array.from({length: N}, () => 0));
    }

    let line;
    for (let i = 0; i < M; i++){
        line = input[i + 1].map(e => parseInt(e, 10));
        arr[line[0] - 1][line[1] - 1]++;
    }

    let arr_ruiseki = [];
    arr_ruiseki.push(Array.from({length: N + 1}, () => 0));
    for  (let i = 0; i < N; i++){
        arr_ruiseki.push([0]);
        for (let j = 0; j < N; j ++){
            arr_ruiseki[i + 1].push(arr_ruiseki[i][j + 1] - arr_ruiseki[i][j] + arr_ruiseki[i + 1][j] + arr[i][j]);
        }
    }

    let v_ans = [];

    for (let i = 0; i < Q; i++){
        line = input[i + M + 1].map(e => parseInt(e, 10));
        v_ans.push(arr_ruiseki[line[1]][line[1]] - arr_ruiseki[line[1]][line[0] - 1] - arr_ruiseki[line[0] - 1][line[1]] + arr_ruiseki[line[0] - 1][line[0] - 1]);
    }

    // console.log(arr_ruiseki);
    console.log(v_ans.join("\n"));

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 127332
n , k = map(int, input().split())
x = list(map(int, input().split()))

ans = float('inf')
for i in range(n - k + 1):
    ans = min(
            ans,
            abs(x[i]) + abs(x[i + k - 1] - x[i]),
            abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i])
        )
print(ans)

Measured memory_bytes: 14252
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;

fn main() {
    input! {
        a: [usize]
    }

    let cum = a
        .iter()
        .scan(0, |state, x| {
            *state += x;
            *state %= 1000000007;
            Some(*state)
        })
        .collect_vec();

    let mut ans = 0;
    for i in 1..(a.len()) {
        ans += cum[i - 1] * a[i];
        ans %= 1000000007;
    }

    println!("{}", ans);
}


Measured memory_bytes: 7436
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <vector>

namespace null_null {

using int64 = std::int_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

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

int64 lcm(int64 a, int64 b) {
  int64 x = gcd(a, b);
  return (a / x) * b;
}

} // namespace null_null

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  int64 A, B, C, D;
  std::cin >> A >> B >> C >> D;

  auto calc = [&](int64 a, int64 b) {
    return a / b;
  };

  int64 ans = B - calc(B, C) - calc(B, D) + calc(B, lcm(C, D));
  ans -= A - 1 - calc(A - 1, C) - calc(A - 1, D) + calc(A - 1, lcm(C, D));

  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr first
#define sc second
#define ll  long long
#define mp make_pair
#define mod 1000000007

#define triplet pair<pair<int,int>,int>

using namespace std;

int n;

pll st,en;

pll a[1010];
long double r[1010];
long double dist[1010];

long double dis(pll b,pll c){
    long double r2 = (long double)(b.fr - c.fr);
    r2 *= r2;
    long double r1 = (long double)(b.sc - c.sc);
    r1 *= r1;
    return sqrt(r2+r1);
}

long double dik(){
    if(st == en)
        return 0;
    priority_queue<pair<long double,int> , vector<pair<long double,int> > ,greater<pair<long double,int> > >q;
    for(int i=0 ; i<=n ; i++){
        dist[i] = max(dis(st,a[i]) - r[i],(long double)0);
        q.push(mp(dist[i],i));
    }

    while(!q.empty()){
        pair<long double,int>t = q.top();
        q.pop();
        if(dist[t.sc] < t.fr)
            continue;
        for(int i=0; i<=n ; i++){
            long double r1 = dis(a[i],a[t.sc]) - r[i] - r[t.sc];
            r1 = max(r1,(long double)0);
            if(r1 + t.fr < dist[i]){
                dist[i]= r1 + t.fr;
                q.push(mp(dist[i],i));
            }
        }
    }
    return dist[n];
}

int main(){
    ios::sync_with_stdio(0);
    cin>>st.fr>>st.sc;
    cin>>en.fr>>en.sc;
    cin>>n;

    for(int i=0 ; i<n ;i++){
        cin>>a[i].fr>>a[i].sc>>r[i];
    }
    a[n] = en;
    cout<<fixed<<setprecision(10)<<dik();

    return 0;
}


Measured memory_bytes: 8684
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int n;
vvi in,G;
vi out,used;
void dfs(int a){
	used[a]=1;
	rep(i,G[a].size()){
		int to=G[a][i];
		if(used[to])continue;
		dfs(to);
	}
}
bool f(){
	G=vvi(51);
	rep(i,50)if(!out[i])
		rep(j,51)G[j].pb(j%(i+1));
	
//	show2d(G);
	bool h=true;
	rep(i,n){
		used=vi(51);
		dfs(in[0][i]);
		if(!used[in[1][i]])h=false;
	}
	
	return h;
}
int main(){
	cin>>n;
	in=vvi(2,vi(n));
	rep(i,2)rep(j,n)cin>>in[i][j];
	
	out=vi(50);
	if(!f()){
		cout<<-1<<endl;
		return 0;
	}
	for(int i=49;i>=0;i--){
		out[i]=1;
		if(!f())out[i]=0;
	}
	ll ans=0;
	rep(i,50)if(!out[i])ans+=1ll<<(i+1);
	cout<<ans<<endl;
}









Measured memory_bytes: 256
from collections import defaultdict
 
n, m = [int(x) for x in input().split(' ')]
py = [tuple(input().split(' ')) for _ in range(m)]
 
d = defaultdict(list)
 
for x, y in py:
    d[x].append(int(y))
 
ans = {}
 
for k, v in d.items():
    for i, x in enumerate(sorted(v), start=1):
        ans[(k, str(x))] = k.zfill(6) + str(i).zfill(6)
 
for x in py:
    print(ans[x])

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

typedef long long ll;

const int mod = 1e9 + 7;

int N, M;
ll X;
struct Edge {
    int u, v, w;
    bool operator <(const Edge &i) const {
        return w < i.w;
    }
};
Edge edge[2010];
int fa[1010];
void init() { for(int i = 0; i < N; i++) fa[i] = i; }
int f(int u) {
    if(fa[u] == u) return u;
    else return fa[u] = f(fa[u]);
}
void mrg(int u, int v) { fa[ f(v) ] = f(u); }
int po[2010];

int main() {
    po[0] = 1;
    for(int i = 1; i < 2010; i++) {
        po[i] = po[i - 1] * 2 % mod;
    }

    scanf("%d %d %lld", &N, &M, &X);

    for(int i = 0; i < M; i++) {
        int u, v, w; scanf("%d %d %d", &u, &v, &w);
        u--; v--;

        edge[i] = {u, v, w};
    }

    sort(edge, edge + M);

    init();

    ll mn = 0;
    for(int i = 0; i < M; i++) {
        int u = edge[i].u;
        int v = edge[i].v;
        int w = edge[i].w;

        if(f(u) != f(v)) {
            mrg(u, v);
            mn += w;
        }
    }

    if(mn > X) {
        printf("0");
        return 0;
    }

    int cnt1 = 0;
    int cnt2 = 0;
    for(int e = 0; e < M; e++) {
        init();
        ll sum = 0;

        mrg(edge[e].u, edge[e].v);
        sum += edge[e].w;

        for(int i = 0; i < M; i++) if(i != e) {
            int u = edge[i].u;
            int v = edge[i].v;
            int w = edge[i].w;

            if(f(u) != f(v)) {
                mrg(u, v);
                sum += w;
            }
        }

        if(sum < X) cnt1++;
        if(sum == X) cnt2++;
    }
    if(mn == X) {
        int ans = po[M] + mod - 2 * po[M - cnt2] % mod;
        ans %= mod;
        printf("%d", ans);
        return 0;
    }
    int ans = 2 * po[M - cnt1] % mod;
    ans += mod - 2 * po[M - cnt1 - cnt2] % mod;
    ans %= mod;
    printf("%d", ans);
}


Measured memory_bytes: 384
//
//  respect the past, embrace the future
//

#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define W (ll) (5e3 + 7)
#define N (ll) (2e6 + 7)
#define M (ll) (1e9 + 7)
#define INF (ll) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

ll a, b, ans = INF;
int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  cin >> a >> b;
  if (b - a >= 2018)
    cout << 0;
  else {
    for (ll i = a; i <= b; i++)
      for (ll j = i + 1; j <= b; j++)
        ans = min(ans, i * j % 2019);
    cout << ans;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repr(i, a, b) for (int i = (int)a; i > (int)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vii a(n);
    rep(i, n){ cin >> a[i];
        a[i]--;
    }
    vector<pii> query;
    ll res = 0;
    rep(i,n-1){
        if (a[i]<=a[i+1])
            res += a[i + 1] - a[i];
        else
            res += a[i + 1] + m - a[i];
        if (a[i] + 2 <= a[i + 1])
            query.eb(mp(a[i] + 2, a[i + 1]));
        else if (a[i]>a[i+1]){
            if (a[i]+2<=a[i+1]+m)
                query.eb(mp(a[i] + 2, a[i + 1] + m));
        }
    }
    sort(all(query));
    ll have = 0;
    ll now = 0;
    int idx = 0;
    multiset<pii> goal;
    vll x(2 * m, 0);
    //開始地点なら、haveに足す、goalに終点を追加。
    //now：いまの効用。１進むとhave増える
    //goalのはじめの要素を超えたら、ｈａｖｅを減らす。nowを減らす。goalの頭を消す
    //nowを減らすために、goalにどれだけ効用を得るかも合わせて記録
    rep(i,2*m){
        while (idx<query.size() && query[idx].F==i){
            have++;
            goal.insert(mp(query[idx].S, query[idx].S - query[idx].F + 1));
            idx++;
        }
        now += have;
        x[i] += now;
        while (!(goal.empty()) && (*goal.begin()).F==i){
            have--;
            now -= (*goal.begin()).S;
            goal.erase(goal.begin());
        }
    }
    ll ans = 0;
    rep(i, m) ans = max(x[i]+x[i+m], ans);
    cout << res - ans << ENDL;
}

Measured memory_bytes: 7668
# -*- coding: utf-8 -*-
from itertools import combinations
n = int(input())
d = {
    "M": 0
    ,"A": 0
    ,"R": 0
    ,"C": 0
    ,"H": 0
}

for _ in range(n):
    s = input()
    if s[0] in d:
        d[s[0]] += 1

res = 0
for c in combinations(d.keys(), 3):
    res += d[c[0]]*d[c[1]]*d[c[2]]
print(res)


Measured memory_bytes: 3060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = input()

for i in range(len(S)):
	if S == T:
		print("Yes")
		sys.exit()
	else:
		S = S[-1]+S[:-1]
print("No")


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

#define int long long

const int INF = 1e9;

int N, M;
vector<int> A, B;
int dp[51][51][51][51][2][3];

int dfs(int n, int m, int a, int b, int t, int con) {
	if ( con == 2 ) return 0;	
	if ( n == N && m == M ) {
		int nn = n-1;
		int mm = m-1;
		bool fa = true, fb = true;
		int sumA = 0, sumB = 0;
		if ( !t ) {
			while ( 1 ) {
				if ( mm < b ) break;
				if ( B[mm] < 0 ) fa = false;
				if ( fb && B[mm] >= 0 ) sumB += B[mm];
				if ( nn < a ) break;
				if ( A[nn] < 0 ) fb = false;
				if ( fa && A[nn] >= 0 ) sumA += A[nn];
				nn--; mm--;			
			}
		} else {
			while ( 1 ) {		
				if ( nn < a ) break;
				if ( A[nn] < 0 ) fb = false;
				if ( fa && A[nn] >= 0 ) sumA += A[nn];
				if ( mm < b ) break;
				if ( B[mm] < 0 ) fa = false;
				if ( fb && B[mm] >= 0 ) sumB += B[mm];
				nn--; mm--;			
			}
		}
		return sumA-sumB;		
	}	
	if ( dp[n][m][a][b][t][con] != -INF ) return dp[n][m][a][b][t][con];	
	
	int ret;
	if ( !t ) { // player1
		ret = -INF;		
		if ( n < N ) ret = max(ret, dfs(n+1, m, a, b, !t, 0));
		int nn = n-1;
		int mm = m-1;
		bool fa = true, fb = true;
		int sumA = 0, sumB = 0;
		while ( 1 ) {
			if ( mm < b ) break;
			if ( B[mm] < 0 ) fa = false;
			if ( fb && B[mm] >= 0 ) sumB += B[mm];
			if ( nn < a ) break;
			if ( A[nn] < 0 ) fb = false;
			if ( fa && A[nn] >= 0 ) sumA += A[nn];
			nn--; mm--;			
		}
		if ( sumA || sumB )
			ret = max(ret, dfs(n, m, n, m, !t, 0)+sumA-sumB);
		else {		 
			ret = max(ret, dfs(n, m, n, m, !t, con+1)+sumA-sumB);
		}
	} else { // player2
		ret = INF;
		if ( m < M ) ret = min(ret, dfs(n, m+1, a, b, !t, 0));
		int nn = n-1;
		int mm = m-1;
		bool fa = true, fb = true;
		int sumA = 0, sumB = 0;
		while ( 1 ) {		
			if ( nn < a ) break;
			if ( A[nn] < 0 ) fb = false;
			if ( fa && A[nn] >= 0 ) sumA += A[nn];
			if ( mm < b ) break;
			if ( B[mm] < 0 ) fa = false;
			if ( fb && B[mm] >= 0 ) sumB += B[mm];
			nn--; mm--;			
		}
		if ( sumA || sumB )
			ret = min(ret, dfs(n, m, n, m, !t, 0)+sumA-sumB);
		else {		 
			ret = min(ret, dfs(n, m, n, m, !t, con+1)+sumA-sumB);
		}
	}

	return dp[n][m][a][b][t][con] = ret;	
}

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

	fill_n(*****dp, 51*51*51*51*2*3, -INF);
	cout << dfs(0, 0, 0, 0, 0, 0) << endl;	
	
	return 0;
}



Measured memory_bytes: 320236
package main

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

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var ans int

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	f := make([][]int, n)
	for i := 0; i < n; i++ {
		t := make([]int, 10)
		for j := 0; j < 10; j++ {
			t[j], _ = strconv.Atoi(stringLineScan())
		}
		f[i] = t
	}
	p := make([][]int, n)
	for i := 0; i < n; i++ {
		t := make([]int, 11)
		for j := 0; j < 11; j++ {
			t[j], _ = strconv.Atoi(stringLineScan())
		}
		p[i] = t
	}
	ans := -1000000000
	repeat := make([]int, 2)
	repeat[0], repeat[1] = 0, 1
	seed := make([]int, 0)
	ret := make([][]int, 0)
	all := allcomb(10, repeat, seed, ret)
	for _, list := range all[1:] {
		s := 0
		for i := 0; i < n; i++ {
			c := 0
			for j := 0; j < 10; j++ {
				c += list[j] * f[i][j]
			}
			s += p[i][c]
		}
		ans = larger(ans, s)
	}
	fmt.Println(ans)
}
func allcomb(n int, repeat []int, seed []int, ret [][]int) [][]int {
	if len(seed) == n {
		x := make([]int, n)
		copy(x, seed)
		ret = append(ret, x)
		return ret
	} else {
		for _, i := range repeat {
			ret = allcomb(n, repeat, append(seed, i), ret)
		}
	}
	return ret
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define LIM 1 << 28

using namespace std;

int n,k;

bool check_sub(vector<int>& w, int lim) {
	int now = 0;
	int nos = 1;
	for (int i = 0; i < n; ++i) {
		if (now+w[i] > lim) {
			++nos;
			now = w[i];
			if (nos > k) {
				return false;
			}
		}
		else {
			now += w[i];
		}
	}
	return true;
}

int main(void) {
	cin >> n >> k;
	int left = 0;
	int right = 0;
	vector<int> w(n);
	for (int i = 0; i < n; ++i) {
		cin >> w[i];
		left = max(w[i],left);
		right += w[i];
	}
	int res = 0;
	if (n > k) {
		int mid = (right+left)/2;
		int prev = -1;
		while (prev != mid) {
			if (check_sub(w,mid)) {
				right = mid; 
			}
			else {
				left = mid;
			}
			prev = mid;
			mid = (right+left)/2;
		}
		res = right;
	}
	else {
		res = left;
	}
	cout << res << endl;

	return 0;
}



Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

string revJ(string s) {
  return s[s.size()-1] + s.substr(0, s.size()-1);
}

string revC(string s) {
  return s.substr(1) + s[0];
}

string revE(string s) {
  int n = s.size();
  string ret = s.substr(n-n/2);
  if(n % 2) ret += s[n/2];
  ret += s.substr(0, n/2);
  return ret;
}

string revA(string s) {
  reverse(s.begin(), s.end());
  return s;
}

string revP(string s) {
  for(int i=0; i<s.size(); i++)
    if(isdigit(s[i])) s[i] = static_cast<char>(((s[i]-'0') + 9) % 10 + '0');
  return s;
}

string revM(string s) {
  for(int i=0; i<s.size(); i++)
    if(isdigit(s[i])) s[i] = static_cast<char>(((s[i]-'0') + 11) % 10 + '0');
  return s;
}

int main() {
  int n;
  cin >> n;
  
  while(n--) {
    string cmd, s;
    cin >> cmd >> s;
    reverse(cmd.begin(), cmd.end());
    int Ncmd = cmd.size();
    for(int i=0; i<Ncmd; i++) {
      switch(cmd[i]) {
      case 'A': s = revA(s); break;
      case 'C': s = revC(s); break;
      case 'E': s = revE(s); break;
      case 'J': s = revJ(s); break;
      case 'M': s = revM(s); break;
      case 'P': s = revP(s); break;
      }
    }
    cout << s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
vector<vector<int> > lis(10000);
vector<bool> visited(10000,false);
vector<int> prenum(10000),parent(10000),lowest(10000);
int timer,n;

void dfs(int current,int prev){
  //ノードcurrentを訪問した直後の処理
  prenum[current]=lowest[current]=timer;
  timer++;

  visited[current]=true;

  int next;

  //次のノードへ行く処理
  for(int i=0;i<lis[current].size();i++){
    next=lis[current][i];
    if(!visited[next]){
      //ノードcurrentからノードnextへ訪問する直前の処理
      parent[next]=current;

      dfs(next,current);
      //ノードnextの探索が終了した時の直後の処理
      lowest[current]=min(lowest[current],lowest[next]);
    }
    else if(next!=prev){
      //エッジcurrent-->nextがBack-edgeの場合の処理
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
  //ノードcurrentの探索が終了した直後の処理
  return;
}
void art_points(){
  timer=1;
  //lowestの計算
  dfs(0,-1); //0==root;

  set<int> ap;
  int np=0;
  //関節点をカウント
  for(int i=1;i<n;i++){
    int p=parent[i];
    if(p==0) np++;
    else if(prenum[p]<=lowest[i]) ap.insert(p);
  }
  if(np>1) ap.insert(0);

  //全列挙
  for(auto x:ap){
    cout<<x<<'\n';
  }
  return;
}
int main(){
  //関節点を求めるアルゴリズム
  int m;
  cin>>n>>m;
  //隣接リストの作成
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    lis[s].push_back(t);
    lis[t].push_back(s);
  }

  art_points();

  return(0);
}


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

int main(){
	string S;
	int i;
	int arrayAdaTidakHuruf[150];
	
	//Inisialisasi array untuk tiap huruf diset 0 artinya tidak ada
	for (i='a'; i<='z'; i++){
		arrayAdaTidakHuruf[i] = 0;
	}
	cin >> S;
	for (i=0; i<S.length(); i++){
		arrayAdaTidakHuruf[S[i]] = 1;
	}
	
	int adaHurufYangTidakAda = 0;
	for (i='a'; i<='z'; i++){
		if (arrayAdaTidakHuruf[i] == 0){
			cout << (char)i << endl;
			adaHurufYangTidakAda = 1;
			break;
		}
	}
	if (adaHurufYangTidakAda == 0)
		cout << "None" << endl;
		
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a%b == 0){
        printf("%d", a / b);
    }else{
        printf("%d", a / b + 1);
    }
    
    return 0;
}


Measured memory_bytes: 128
S=input()
N=len(S)
ans=N

stack=[]
stack.append(S[0])
for i in range(1,N):
  if len(stack)!=0 and stack[len(stack)-1]=='S' and S[i]=='T':
    ans-=2
    stack.pop()
  elif S[i]=='S':
    stack.append(S[i])

print(ans)

Measured memory_bytes: 4328
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc =new Scanner(System.in);
    
    int  S = sc.nextInt();
    
    int s = S%60;
    
    int M = S/60;
    
    int m = M%60;
    
    int H = M/60;
    
    int h = H%60;
    
    System.out.printf("%d:%d:%d\n",h,m,s);
    
    }
}




Measured memory_bytes: 26192
import java.util.*;
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String W = scanner.next();
		int count = 0;
		while(true){
			String T = scanner.next();
			if(T.equals("END_OF_TEXT"))
				break;
			T = T.toLowerCase();
			if(W.equals(T))
				count ++;
		}
		System.out.println(count);
	}
}



Measured memory_bytes: 26428
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
#define M 200005
ll a[M],res;
int n,m;
ll sum(int l,int r){
	return a[r]-a[l-1];
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n);
	int i,l,r;
	ll mn,mx;
	for (i=1;i<=n;i++){
		read(a[i]);
		a[i]+=a[i-1];
	}
	res=a[n];
	l=1; r=3;
	m=n-1;
	for (i=2;i<m;i++){
		for (;l+1<i&&abs(sum(1,l+1)-sum(l+2,i))<abs(sum(1,l)-sum(l+1,i));l++);
		for (;r+1<n&&abs(sum(i+1,r+1)-sum(r+2,n))<abs(sum(i+1,r)-sum(r+1,n));r++);
		mn=min(min(sum(1,l),sum(l+1,i)),min(sum(i+1,r),sum(r+1,n)));
		mx=max(max(sum(1,l),sum(l+1,i)),max(sum(i+1,r),sum(r+1,n)));
		Min(res,mx-mn);
	}
	printf("%lld\n",res);
	return 0;
}

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

class Food implements Comparable<Food>{
	String f;
	int w;
	int s;
	Food(String f,int w,int s){
		this.f=f;
		this.w=w;
		this.s=s;
	}
	@Override
	//あえて逆順。いわゆる重い順。
	public int compareTo(Food o) {
		// TODO 自動生成されたメソッド・スタブ
		if(this.w<w){
			return 1;
		}
		else if(this.w>w){
			return -1;
		}
		else{
			return 0;
		}
	}
}
public class Main {
	public static void main(String[] args) {
		new Main().run();
		//new AOJ0170().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0) break;

			int sum=0;
			Food food[]=new Food[n];
			for(int i=0;i<n;i++){
				food[i]=new Food(sc.next(), sc.nextInt(), sc.nextInt());
				sum+=food[i].w;
			}
			int max=-1;
			
			for(int j=0;j<n;j++){
				int k=j;
				max=-1;
				for(int i=j;i<n;i++){
					if((sum-food[i].w<=food[i].s) && (max<food[i].w)){
						max=food[i].w;
						k=i;
					}
				}
				//change
				sum-=food[k].w;
				Food temp=food[j];
				food[j]=food[k];
				food[k]=temp;
			}
			Arrays.sort(food);
			for(int i=0;i<n;i++){
				System.out.println(food[i].f);
			}
		}
	}
}

Measured memory_bytes: 20500
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long a,b,x;
    while(~scanf("%lld",&a))
    {
       if(a==1)
        printf("1\n");
       else if(a==2)
        printf("8\n");
       else if(a==3)
        printf("27\n");
        else if(a==4)
        printf("64\n");
        else if(a==5)
        printf("125\n");
        else if(a==6)
        printf("216\n");
        else if(a==7)
        printf("343\n");
        else if(a==8)
        printf("512\n");
        else if(a==9)
        printf("729\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s;
    cin>>s;
    int a,z;
    for(int i=0;i<s.length();i++){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }
    for(int i=s.length()-1;i>=0;i--){
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }
    cout<<z-a+1<<endl;
    return 0;
}


Measured memory_bytes: 720
n = int(input())
A = list(map(int, input().split()))

def f(a, ans):
    for i in range(1,n):
        b = A[i]            
        if a> 0:
            if a + b >= 0:
                ans += abs(-1-a-b)
                a = -1
            else:
                a += b
        elif a < 0:
            if a+b <= 0:
                ans += abs(1-a-b)
                a = 1
            else:
                a += b
    return ans

# A[0] の初期符号が正しいと仮定してしまっているが、そうとは限らない。
a = A[0]
q = 10**15
if a > 0:
    q = min(f(a,0), f(-1,a+1))
elif a < 0:
    q = min(f(a,0),f(1,-a+1))
else:
    q = min(f(1,1),f(-1,1))

print(q)

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

class UnionFind {
	int parent[];

	UnionFind(int N) {
		parent = new int[N];
		Arrays.fill(parent, -1);
	}

	boolean same(int x, int y) {
		return root(x) == root(y);
	}

	int root(int x) {
		if (parent[x] < 0)
			return x;
		return parent[x] = root(parent[x]);
	}

	int size(int x) {
		return -parent[root(x)];
	}

	void unite(int x, int y) {
		if (size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)
			return;
		parent[rx] += parent[ry];
		parent[ry] = rx;
	}
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt(), k = fs.nextInt();
		UnionFind uf = new UnionFind(n);
		
		//List<Integer> fr[] = new ArrayList[n];
		int frs[] = new int[n];
		List<Integer> bl[] = new ArrayList[n];
		for(int i=0;i<n;i++) bl[i] = new ArrayList<>();
		
		for(int i=0;i<m;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1;
			frs[a]++; frs[b]++;
			uf.unite(a,b);
		}
		
		for(int i=0;i<k;i++) {
			int c = fs.nextInt()-1, d = fs.nextInt()-1;
			bl[c].add(d);
			bl[d].add(c);
		}
		
		int ans[] = new int[n];
		for(int i=0;i<n;i++) {
			int t = uf.size(i);
			t -= frs[i];
			for(int s:bl[i]) {
				if(uf.same(i, s))t--;
			}
			ans[i] = t - 1;
		}
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++) {
			sb.append(ans[i] + " ");
		}
		System.out.println(sb.toString());
		
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

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

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 74888
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

void dump(vector<ll> v) {
    rep(i, v.size()) cout << v[i] << " ";
    cout << endl;
}


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

    sort(all(h));
   // dump(h);
    ll best = 1e10;
    rep(i, n - k + 1) {
        best = min(best, h[i + k - 1] - h[i]);
    }
    put(best);

    return 0;
}

Measured memory_bytes: 4008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=10005;
int n;
char s[max_n];
int main(){
    scanf("%d %s",&n,s+1);
    for(int i=1;s[i];i++){
        s[i]=(s[i]-'A'+n)%26+'A';
    }
    printf("%s\n",s+1);
    return 0;
}

Measured memory_bytes: 256