akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

static const int MAX = 10000;

using namespace std;
int V,E;
vector<int> G[MAX];
vector<int> ans;
bool used[MAX]; //訪問済みかどうか
int indeg[MAX]; //各点の入次数

void bfs(int s){
    queue<int> q;
    q.push(s);
    used[s]=true;
    while(!q.empty())
    {
        int u=q.front(); q.pop();
        ans.push_back(u);
        for(int i=0;i<G[u].size();i++)
        {
            int k = G[u][i];
            indeg[k]--;
            if(indeg[k]==0 && !used[k])
            {
                used[k]=true;
                q.push(k);
            }
        }
    }
}

void topological()
{
    for(int u=0;u<V;u++)
    {
        if(indeg[u]==0 && !used[u])
        {
            bfs(u);
        }
    }
}

int main(){
    cin>>V>>E;
    fill(indeg,indeg+MAX,0);
    fill(used,used+MAX,0); //訪問済み=true
    for(int i=0;i<E;i++){
        int s,t;
        cin>>s>>t;
        G[s].push_back(t);
        indeg[t]++;
    }
    topological();
    for(int i=0;i<V;i++)
    {
        cout<<ans[i]<<"\n";
    }

}



Measured memory_bytes: 3896
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define int long long int
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int j;
	int n;
	cin>>n;
	int arr[n],answer=0;
	for(j=0;j<n;j++)
	{
		cin>>arr[j];
	}
	int maxval=0;
	for(j=0;j<n;j++)
	{
		if(arr[j]<maxval)
		{
			answer+=(maxval-arr[j]);
		}
		else
		{
			maxval=arr[j];
		}
	}
	cout<<answer<<endl;
}


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

int main() {
  int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
int b[100005];
for(int i=0;i<100005;i++) b[i]=0;

int ans=0;
for(int i=0;i<n;i++){
  if(a[i]>100000) ans++;
  else{
    b[a[i]]++;
  }
}

for(int i=0;i<=100000;i++){
  //cout<<b[i]<<endl;
if(b[i]>i){
  ans+= b[i]-i;
}
else if(b[i]<i){
  ans+= b[i];
}
}
cout<<ans<<endl;

}


Measured memory_bytes: 1024
M,D=map(int,input().split())

ans=0
for m in range(1,M+1):
  for d in range(1,D+1):
    d1=d//10
    d2=d%10
    if d1>1 and d2>1 and m==d1*d2:
      ans+=1
        
print(ans)



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

typedef long long ll;
using namespace std;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;

  if(a[a.length()-1]==b[0]&&b[b.length()-1]==c[0]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    string s;
    cin >> s;
    s+='a';
    int f = 0;
    int p = 0;
    //s += "aaaaaaaaaa";
    for(int i = 0; i < s.size()-1; i += 2) {
        if(s[i] == 'h' && s[i+1] == 'i') {
            f = 1;
        }
        else {
            f = 0;
        }
    }
    if(f == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, ans = 1, c, b[N];
string a;
int main()
{
	ll i;
	cin >> n >> a;
	if (a[0] == 'W') {puts("0"); return 0;}
	b[0] = 1;
	for (i = 1; i < n * 2; i++) {
        if (a[i] != a[i - 1]) b[i] = b[i - 1];
        else b[i] -= b[i - 1];
	}
	for (i = 0; i < n * 2; i++) {
		if (b[i] < 0) ans = ans * c % M;
		c += b[i];
		if (c < 0) {puts("0"); return 0;}
	}
	if (c != 0) {puts("0"); return 0;}
	for (i = 1; i <= n; i++) ans = ans * i % M;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int sum = 0;
		for(int i=0; i<M; i++) {
			sum += sc.nextInt();
		}

		int ans = N - sum;

		if(ans < 0)
			ans = -1;

		System.out.println(ans);

	}

}


Measured memory_bytes: 46184
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,n;
  cin>>n;
  ll s=0;
  int c=86400,d=10800;
  vi t(c+1,0);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    s=(s+a)%c;
    t[s]++;
    s=(s+b)%c;
  }
  rep(i,c)t[i+1]+=t[i];
  int ans=t[d];
  loop(i,1,c-d)ans=max(ans,t[i+d]-t[i-1]);
  loop(i,0,d)ans=max(ans,t[i]+t[c]-t[i+c-d-1]);
  cout<<ans<<endl;
}


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

long long MOD = 1000000007;
vector<long long> F, RF, R;

void init(long long N) {
	F.resize(N + 1), RF.resize(N + 1), R.resize(N + 1);
	F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
		RF[i] = (RF[i - 1] * R[i]) % MOD;
	}
}

long long Comb(long long A, long long B) {
	if (B < 0 || A < B) return 0;
	return (F[A] * ((RF[A - B] * RF[B]) % MOD)) % MOD;
}

int main() {
	long long N, K, ANS = 0;
	cin >> N >> K;
	init(N);
	for (long long X = 0; X <= N && X <= K; X++) {
		long long COUNT = Comb(N, X);
		COUNT *= Comb(N - 1, X);
		COUNT %= MOD;
		ANS = (ANS + COUNT) % MOD;
	}
	cout << ANS << endl;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<pair<int, int> > vp;
	if (N % 2 == 0) {
		for (int i = 0; i < M; i++) {
			if (4 * (i + 1) - 2 >= N) {
				vp.emplace_back(i + 2, N - i);
			} else {
				vp.emplace_back(i + 1, N - i);
			}
		}
	} else {
		for (int i = 0; i < M; i++) {
			vp.emplace_back(i + 1, N - i);
		}
	}
	for (int i = 0; i < vp.size(); i++) {
		cout << vp[i].first << " " << vp[i].second << endl;
	}
}

Measured memory_bytes: 5268
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n,m;
    string s;
    cin>>n>>m>>s;
    vector<int>road;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i] == '0' ) road.push_back(i);
    }
    
    vector<int>ans;
    //逆から貪欲に考える
    int i=0;
    int pre=n;
    road.push_back(INF);
    //show(road);
    while(1)
    {
        //6
        ans.push_back(pre-*lower_bound(ALL(road),n-i-m));
        //cerr<<*lower_bound(ALL(road),n-i-m)<<endl;
        //cerr<<ans.back()<<endl;
        if((ans.back()==0 && ans.back()!=n)|| ans.back()>m){
            cout<<-1<<endl;
            return 0;
        }
        pre = *lower_bound(ALL(road),n-i-m);
        i = n-*lower_bound(ALL(road),n-i-m);
        //cerr<<i<<endl;
        if(*lower_bound(ALL(road),n-i-m)==0) {
            
            if(pre>0)ans.push_back(pre);
            break;
        }
    }
    reverse(ALL(ans));

    for( int &u : ans) cout<<u<<" ";
    cout<<endl;
   
   
    return 0;
}

Measured memory_bytes: 2676
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<pair<ll, ll>> vec(n);
	rep(i, 0, n - 1)
	{
		ll a, b; cin >> a >> b;
		vec[i] = { b,a };
	}
	sort(all(vec));
	ll now = 0;
	rep(i, 0, n - 1)
	{
		now += vec[i].second;
		if (vec[i].first < now)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()

    if 1 <= int(S[:2]) <= 12:
        is_MMYY = True
    else:
        is_MMYY = False

    if 1 <= int(S[2:]) <= 12:
        is_YYMM = True
    else:
        is_YYMM = False

    if is_MMYY and is_YYMM:
        ans = "AMBIGUOUS"
    elif is_MMYY:
        ans = "MMYY"
    elif is_YYMM:
        ans = "YYMM"
    else:
        ans = "NA"

    print(ans)


if __name__ == "__main__":
    main()


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

void print(int A[], int n) {
  int i, x;
  for (i = 0; i < n; i++) {
    x = i + 1;
    cout << "node " << x << ": ";
    cout << "key = " << A[i] << ", ";

    if (i != 0) {
      cout << "parent key = " << A[x / 2 - 1] << ", ";
    }

    if (x * 2 <= n) {
      cout << "left key = " << A[x * 2 - 1] << ", ";
    }

    if (x * 2 + 1 <= n) {
      cout << "right key = " << A[x * 2] << ", ";
    }

    cout << "\n";
  }
}

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

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

  print(H, n);

  return 0;
}



Measured memory_bytes: 3092
#include <stdio.h>
#include <string.h>

int main(void){
    int i;
    char day[10];
    char week[7][10] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};
    
    scanf("%s",day);
    for(i = 0;i < 7;i++){
        if(!strcmp(day,week[i]))break;
    }
    printf("%d\n",i + 1);
    return 0;
}

Measured memory_bytes: 128
import sys,fractions,math
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

def prime_division(x):
    q = int(math.sqrt(x))
    a = []
    for i in range(2,q+1):
        ex = 0
        while x%i == 0:
            ex += 1
            x //= i
        if ex>0:
            a.append([i,ex])
    if x>q:
        a.append([x,1])
    return a

a,b = inm()
g = fractions.gcd(a,b)
p = prime_division(g)
print(len(p)+1)


Measured memory_bytes: 5076
import java.util.Scanner;

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

        String S = sc.next();

        System.out.println(solve(S));

        sc.close();
    }

    static int solve(String S) {
        int result = 0;
        int count = 0;
        for (char ch : S.toCharArray()) {
            if ("ATCG".indexOf(ch) >= 0) {
                ++count;
                result = Math.max(result, count);
            } else {
                count = 0;
            }
        }

        return result;
    }
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    int s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    float valid=(float)s/(4*m);
    int k=0;
    for(int i=0;i<n;i++)
{
    if(a[i]>=valid)
    k++;
}
  if(k>=m)
  cout<<"Yes";
  else
  cout<<"No";
}

Measured memory_bytes: 256
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(int argc, const char * argv[]) {
    
    ll N,K;
    cin >> N >> K;
    
    
    
    ll sum=0;
    for(ll i=K;i<=N+1;i++){
        ll min_value = i*(i-1)/2;
        ll max_value = N*i - i*(i-1)/2;
        ll combi_num = max_value - min_value + 1;
        sum += combi_num % MOD;
    }
    
    cout << sum % MOD << endl;
 
    return 0;
    
}




Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n;
vector<i64> a;
int main() {
  cin >> n;
  read_n(a, n);
  i64 s = 0, c = 0, b = 1e15;
  for (i64 x : a) {
    s += abs(x);
    b = min(b, abs(x));
    if (x < 0) {
      c++;
    }
  }
  if (c % 2 == 1) s -= 2 * b;
  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

typedef pair<int, int> P;

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

    map<P, int> mp;
    for (int i = 1; i <= n; i++) {
        int last = i % 10;  // 末尾
        int num = i;
        while (num >= 10) {
            num /= 10;
        }
        int first = num;  // 先頭
        mp[P(first, last)]++;
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int last = i % 10;  // 末尾
        int num = i;
        while (num >= 10) {
            num /= 10;
        }
        int first = num;  // 先頭
        ans += mp[P(last, first)];
    }
    cout << ans << endl;
    return 0;
}

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

const ll mod = 998244353;

int main(){
  int n, s;
  cin >> n >> s;
  vector<ll> A(n);
  for (int i=0; i<n; i++) cin >> A[i];

  ll ans = 0;
  vector<ll> sum(s+1);
  for (int i=0; i<n; i++){
    sum[0]++;
    ll a = A[i];
    for (int k=s-a; k>=0; k--){
      sum[k+a] += sum[k];
      sum[k+a] %= mod;
    }
    ans += sum[s];
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;
const int Nmax = 1e5 + 100;

int n, a[Nmax], cnt[10];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
        if (a[i]%4 == 0) ++cnt[4];
        else if (a[i]%2 == 0) ++cnt[2];
        else ++cnt[3];
    }
    if (cnt[3] > cnt[4] + 1) printf("No");
    else if (cnt[3] == cnt[4] + 1 && cnt[2]) printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define puts(x) cout << x << "\n"
using namespace std;
long long t1, t2, a1, a2, b1, b2;
int main() {
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	a1 = (a1 - b1) * t1;
	a2 = (a2 - b2) * t2;
	if (a1 + a2 == 0)puts("infinity");
	else if (a1/abs(a1) * a2 > 0 || abs(a1) > abs(a2))puts(0);
	else {
		long long ans = (abs(a2) / abs(a1 + a2)) * 2 - 1;
		if (abs(a2) % abs(a1 + a2) == 0)ans--;
		puts(ans);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include <queue>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
    ll N,sum=0,c;
    std::vector<std::string> S;
      string saw;
    string as="",ans="";
    int m[30];
    int yui[30];
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        string s;

        cin>>s;
        for(auto x:s){
            yui[(int)x-(int)'a']++;
                DEB((int)x-(int)'a') DEB(yui[(int)x-(int)'a']) END
        }
        REP(j,(int)'z'-(int)'a'+1){
            if(i==0){
                m[j]=yui[j];
            }else{
                DEB(j)DEB(m[j])DEB(yui[j])END
                m[j]=min(yui[j],m[j]);
            }
        }
        REP(k,30)yui[k]=0;
    }
    REP(i,(int)'z'-(int)'a'+1){
        REP(j,m[i]){
            cout<<(char)(i+(int)'a');
        }
    }
    cout<<endl;
    //cout<<ans;
    return 0;
}


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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;

	int n,k,x,y;
	cin >> n >> k >> x >> y;
	
	int f = min(n,k);
	int r = max(0LL,n-k);
	cout << f*x + r*y;

}







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

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

int main(){
    int N,M;
    int A;
    int i;
    int sum;
    cin >> N >> M;
    sum = 0;
    for(i=0;i<M;i++){
        cin >> A;
        sum += A;
    }
    if( sum > N){
        cout << -1 << endl;
    }else{
        cout << N - sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 1010;
//char str[maxn][maxn];

struct node{
    char head;
    string str;

}Node[maxn];

int cmp(node a,node b)
{
    return a.str < b.str;

}

int main()
{
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
        cin>>Node[i].str;
        Node[i].head = Node[i].str[0];
    }
    sort(Node,Node+n,cmp);
    for(int i=0;i<n;i++)
        cout<<Node[i].str;
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h, w;
    cin >> h >> w;
    if ((h % 3 == 0) || (w % 3 == 0)) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = min(h, w);
    reps(i, 1, h) {
        vector<ll> area(3);
        area[0] = i * w;
        area[1] = (h - i) * (w / 2);
        area[2] = (h - i) * ((w + 1) / 2);
        sort(all(area));
        ans = min(ans, area[2] - area[0]);
    }
    reps(i, 1, w) {
        vector<ll> area(3);
        area[0] = i * h;
        area[1] = (w - i) * (h / 2);
        area[2] = (w - i) * ((h + 1) / 2);
        sort(all(area));
        ans = min(ans, area[2] - area[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y = [int(i) for i in input().split()]
Sum = 0
if A+B<=2*C:
    Sum = A*X+B*Y
else:
    Min = min([X,Y])
    Sum+=Min*(2*C)
    Y-=Min;X-=Min
    if A*X+B*Y<=2*C*(X+Y):
        Sum+=A*X+B*Y
    else:
        Sum+=2*C*(X+Y)
print(Sum)

Measured memory_bytes: 3064
/**
 * coding: utf-8
 * Copyright (C) 2020 Matsuda.Hironobu. All Rights Reserved.
 * Code for 'AtCoder Beginner Contest 101-B'
 * 2020/07/14
 */
import java.util.Scanner;

/**
 * @author Matsuda.Hironobu
 */
public class Main{
	/**
	 * @param args 起動時引数(なにも渡さない)
	 */
	public static void main(String[] args) {
		// 標準入力からのデータを関数に渡す
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		s.close();
		
		System.out.println(digitSums(n));
	}

	// 入力からのデータintを受け取り、結果をStringとして返す
	public static String digitSums(int n) {
		String si = Integer.toString(n);
		
		int s = 0;
		for(int i = 0; i < si.length(); i++) {
			s += Integer.parseInt(si.substring(i, i + 1));
		}
		
		if( n % s == 0) {
			return "Yes";
		} else {
			return "No";
		}
	}
}


Measured memory_bytes: 35544
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;
P it[100];
int dp[101];
int min(int a,int b){return a<b?a:b;}
int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int i,j;
	for(i=0;i<m;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		it[i]=P(a,b);
	}
	sort(it,it+m);
	for(i=0;i<=n;i++)dp[i]=1000;
	dp[0]=0;
	for(i=0;i<m;i++){
		int a=it[i].first;
		int b=it[i].second;
		for(j=a-1;j<=b-1;j++)dp[b]=min(dp[b],dp[j]+1);
	}
	if(dp[n]==1000)printf("Impossible\n");
	else printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i=1;
    int x;

    while(i<=N){
      x=i;
      if(x%3==0) System.out.printf(" %d",i);
      else{
        while(x!=0){
          if(x%10==3){
            System.out.printf(" %d",i);
            break;
          }
          x/=10;
        }
      }
      i++;
    }
    System.out.printf("\n");
  }
}

Measured memory_bytes: 33952
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(signed i=0;i<n;++i)
#define repi(n) rep(i,n)
#define int long long
#define str string
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define yn(b) cout<<((b)?"Yes":"No")<<endl
#define YN(b) cout<<((b)?"YES":"NO")<<endl
#define call(a) for(auto t:a)cout<<t<<" ";cout<<endl
#define ENDL printf("\n");
#define debg(a) cout<<#a<<":"<<a<<endl;
#define SORT(a) sort(all(a));
#define INF 1LL<<60
#define inf INF
#define out(i) cout<<i<<endl;
int min(int a,int b){if(a>b)return b;return a;}
int max(int a,int b){if(a>b)return a;return b;}

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  a-=c;
  b-=d;
  out(a*b);
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a*=b;
    c*=d;
    cout<<max(a,c);


}






Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(a >0 && b >0){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if(a <=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ul unsigned long long int
using namespace std;
bool bo(string t)
{
 for(char c:t)
  if(c=='7')
   return 1;
 return 0;
}
void solve(string s)
{
  cout<<(bo(s)?"Yes":"No")<<"\n";
}
int main()
{
 ul x;
 cin>>x;
 solve(to_string(x));
 return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

typedef long long ll;

const int MAX = 40;
const int MAXS = 410;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1e15;
const ll INFL = 1e30;
const int MOD = 1000000007;

ll dp[64][MAXS][MAXS], as[MAX], bs[MAX], cs[MAX];

void solve(void){
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    rep(N, i) scanf("%lld %lld %lld\n", &as[i], &bs[i], &cs[i]);
    rep(N+1, n) rep(MAXS, a) rep(MAXS, b) dp[n][a][b] = INF;
    dp[0][0][0] = 0;
    rep(N, n) rep(MAXS, a) rep(MAXS, b) {
        dp[n+1][a][b] = min(dp[n+1][a][b], dp[n][a][b]);
        dp[n+1][a+as[n]][b+bs[n]] = min(dp[n][a][b]+cs[n], dp[n][a+as[n]][b+bs[n]]);
    }
    ll ans = INF;
    int k = 1;
    while (Ma*k < MAXS && Mb*k < MAXS) {
        ans = min(ans, dp[N][Ma*k][Mb*k]);
        k++;
    }
    cout <<(ans==INF?-1:ans) << '\n';
}

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


Measured memory_bytes: 55552
import heapq
INF = 10**18
def dijkstra(s, edge, n):
    d = [INF] * n
    used = [True] * n #True: not used
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v],e[1]))
    return d
 
n, m, s, t = map(int, input().split())
s -= 1
t -= 1
graph_a = [[] for _ in range(n)]
graph_b = [[] for _ in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    graph_a[u].append((a, v))
    graph_a[v].append((a, u))
    graph_b[u].append((b, v))
    graph_b[v].append((b, u))
 
yen = dijkstra(s, graph_a, n)
snu = dijkstra(t, graph_b, n)

cost = [0] * n
for i in range(n):
    cost[i] = (yen[i] + snu[i],i)

heapq.heapify(cost)
c = -1
aaa = 10 ** 15
for i in range(n):
    if c < i:
        while cost:
            nn, t = heapq.heappop(cost)
            if t >= i:
                c = t
                break
    print(aaa - nn)


Measured memory_bytes: 90184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  if(N%2==0)
    cout<<0.50000000000<<endl;
  else{
    int K=(N+1)/2;
    cout<<fixed<<setprecision(12);
    cout<<K/(double)N<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	char alpha;
	cin >> alpha;
	if (alpha >= 'a' && alpha <= 'z')
		cout << "a";
	else
		cout << "A";
	return 0;
}

Measured memory_bytes: 3592
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int k, x;

	cin >> k >> x;

	if (500 * k >= x) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ON			1										// 汎用フラグ - ON
#define D_OFF			0										// 汎用フラグ - OFF
#define D_ARRAY_MAX		100005									// 最大配列数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_ARRAY_MAX];								// 文字列
static int siLen;												// 文字列長

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// 削除可否 - 取得
int
fGetDel(
	int piNo					// <I> 位置
	, int piPCnt				// <I> 前方向 1～
	, int piNCnt				// <I> 後方向 1～
)
{
	int i;

	// 前方向
	int liPNo = piNo;
	for (i = 0; i < piPCnt; i++) {
		if (liPNo == 0) {
			return -1;
		}
		else {
			liPNo--;
		}
	}

	// 後方向
	int liNNo = piNo;
	for (i = 0; i < piNCnt; i++) {
		if (liNNo == siLen - 1) {
			return -1;
		}
		else {
			liNNo++;
		}
	}

	// 文字比較
	if (sc1Str[liPNo] == sc1Str[liNNo]) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, liRet;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);
	siLen = fCutCrLf(sc1Str);

	// 削除可能数 - 取得
	int liDCnt = 0;
	for (i = 0; i < siLen; i++) {
		liRet = fGetDel(i, 1, 1);
		if (liRet == 0) {
			liDCnt++;
		}
	}
	if (liDCnt == 0) {
		return -1;
	}

	// １文字削除で、削除不可となるかチェック
	if (liDCnt <= 3) {
		for (i = 0; i < siLen; i++) {

			// 削除可
			liRet = fGetDel(i, 1, 1);
			if (liRet == 0) {

				// 削除後の前側の削除可否 - 取得
				liRet = fGetDel(i - 1, 1, 2);
				if (liRet != 0) {

					// 削除後の後側の削除可否 - 取得
					liRet = fGetDel(i + 1, 2, 1);
					if (liRet != 0) {
						return 0;
					}
				}
			}
		}
	}

	// 削除可能数
	if (sc1Str[0] == sc1Str[siLen - 1]) {
		liDCnt = siLen - 3;
	}
	else {
		liDCnt = siLen - 2;
	}

	return !(liDCnt % 2);
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	if (liRet == 0) {
		sprintf(lc1Buf, "First\n");
	}
	else {
		sprintf(lc1Buf, "Second\n");
	}
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    ll N; cin >> N;
    for(ll h=1; h<=3500; h++){
        for(ll n=1; n<=3500; n++){
            if(4*h*n-N*n-N*h != 0 && N*h*n%(4*h*n-N*n-N*h) == 0 && N*h*n/(4*h*n-N*n-N*h) > 0){
                cout <<  N*h*n/(4*h*n-N*n-N*h) << " " << h << " " << n << endl;
                return 0;
            } 
        }
    }
}

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

int main() {
  
  int N;
  cin >> N;
  
  long long M = 0;
  
  for(int i=1;i<=N;i++){
    if(i%3!=0 && i%5!=0){
      M += i;
    }
  }
  
  cout << M <<endl;
  
  
  
}



Measured memory_bytes: 3552
/*
      author : Nishikawa
      created: 06.08.2020 14:38:16
*/

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


int main(){
    char c;
    cin >> c;
    if(c>='a' && c<='z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3624
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int count = std.nextInt();
        List<Integer> xs = IntStream.range(0, count)
                .map(it -> std.nextInt()).boxed().collect(Collectors.toList());

        List<Integer> state = new ArrayList<>();

        IntStream.range(0, xs.size()).forEach(it -> {
            if (it == xs.size() - 1) {
                return;
            }

            int left = xs.get(it);
            int right = xs.get(it + 1);
            if (left >= right) {
                state.add(1);
            } else {
                state.add(0);
            }
        });

        String value = state.stream().map(String::valueOf).collect(Collectors.joining());
        Optional<Integer> result = Arrays.stream(value.split("0")).map(String::length).max((l, r) -> l - r);
        System.out.println(result.orElse(0));
    }
}

Measured memory_bytes: 64488
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		StringBuilder T = new StringBuilder(sc.next());
		HashMap<Integer, Integer> score = new HashMap<>();
		score.put((int)'s', R);
		score.put((int)'r', P);
		score.put((int)'p', S);
		long ans = 0;
		for(int i = 0; i < K; i++) {
			ans += score.get((int)T.charAt(i));
			for(int j = i+K; j < N; j+=K) {
				if(T.charAt(j) != T.charAt(j-K))
					ans += score.get((int)T.charAt(j));
				else
					T.setCharAt(j, 'x');
			}
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 28028
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int x, y, z;
    cin >> x >> y >> z;
    x -= z;
    int num = x / (z + y);
    cout << num << endl;
} 


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s == "SUN") {
    cout << 7 << endl;
  }
  if (s == "MON") {
    cout << 6 << endl;
  }
  if (s == "TUE") {
    cout << 5 << endl;
  }
  if (s == "WED") {
    cout << 4 << endl;
  }
  if (s == "THU") {
    cout << 3 << endl;
  }
  if (s == "FRI") {
    cout << 2 << endl;
  }
  if (s == "SAT") {
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int x = Integer.parseInt(line);
        System.out.println(x * x * x);;
    }
}

Measured memory_bytes: 16864
N = gets.to_i
SP = N.times.map { |i| gets.split + [i+1] }

SP.group_by { |sp| sp[0] }.sort_by { |sp| sp[0] }.each do |name, sp|
  sp.sort_by { |sp| -sp[1].to_i }.each do |sp|
    puts sp[2]
  end
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#include <stdlib.h>
int asc(const void *a, const void *b) {
   return *(int *)a - *(int *)b;
}
#define MIN(a,b) ((a)<(b)?(a):(b))
int main(void) {
   int N, K;
   int ans = 1000000010;
   int L[1000000];
   cin >> N;
   cin >> K;
   for (int i = 0; i < N; i++) {
      cin >> L[i];
   }
   qsort(L,N,sizeof (int), asc);
   for (int i = 0; i < N - K + 1; i++) {
      ans = MIN(ans, L[i+K-1] - L[i]);
   }
   cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2812
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
t = [na() for _ in range(n)]
zahyo = [0,0]
pre = 0
flag = 1
for i in range(n):
    time = t[i][0] - pre
    dis = (t[i][1]+t[i][2]) - sum(zahyo)
    dis = abs(dis)
    if time >= dis and time%2 == dis%2:
        zahyo = [t[i][1], t[i][2]]
        pre = t[i][0]
    else:
        flag = 0
        break
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String N = sc.nextLine();
		String Array[] = N.split("");

		int total1 = 0,total2 = 0;

		if(1 == Array.length) {
			System.out.println(0);
			System.exit(0);
		}

		//先頭(偶数)を0にする
		for (int i = 0; i < Array.length; i++) {
			//先頭
			if(i % 2 == 0) {
				if(Array[i].equals("1")) {
					total1++;
				}
			}else {
				if(Array[i].equals("0")) {
					total1++;
				}
			}
		}

		//先頭(偶数)を1にする
		for (int i = 0; i < Array.length; i++) {
			//先頭
			if(i % 2 == 0) {
				if(Array[i].equals("0")) {
					total2++;
				}
			}else {
				if(Array[i].equals("1")) {
					total2++;
				}
			}
		}
		
		
		
		if(total1 < total2) {
			System.out.println(total1);
		}else {
			System.out.println(total2);
		}
	}

}

Measured memory_bytes: 34008
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

int MOD = 1000000007;

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

  vector<uint32_t> A(60,0);

  for (int n=0; n<N; ++n) {
    uint64_t a;
    cin >> a;
    for (int idx = 0; a; ++idx, a/=2) {
      if (a&1)
	++A[idx];
    }
  }

  uint64_t sum = 0;
  for (int idx=0; idx<60; ++idx) {
    if (A[idx] == 0 || A[idx] == N)
      continue;
    sum += ((uint64_t(A[idx])*(N-A[idx]))%MOD * uint64_t((uint64_t(1)<<idx)%MOD))%MOD;
    sum %= MOD;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
	public static void main(String[] aargs) {
		Scanner sc = new Scanner(System.in);
		Map<String,Integer>A=new HashMap<>();
		int a=sc.nextInt();
		int q,x;
        String key;
		for(int i=0;i<a;i++) {
			q=sc.nextInt();
		if(q==0){
            key = sc.next();
                A.remove(key);
                 x = sc.nextInt();
            	A.put(key,x);
           
		}else if(q==1){
            key = sc.next();
            if(A.get(key)==null){
                System.out.println("0");
        }else{
                 System.out.println(A.get(key));
        }
		
	}else if(q==2){
             key = sc.next();
            A.remove(key);
}
        }
    }
}


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

int main() {
  int A, B;
  std::cin >> A >> B;

  int res_1 = A + B;
  int res_2 = A - B;
  int res_3 = A * B;

  int res_max = std::max(std::max(res_1, res_2), res_3);
  std::cout << res_max << "\n";
}


Measured memory_bytes: 384
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;
double PI=asin(1)*2;
double H=PI*20/2-20.0;
double Q=PI*20/4-20.0;

istream & operator >> (istream &I,pll &A){I>>A.F>>A.S; return I;}


int main(){
    cout<<fixed<<setprecision(12);
    pll s,g;
    cin>>s>>g;
    if(s>g){swap(s,g);}
    ll k=1;
    if(s.S>g.S){s.S*=-1; g.S*=-1; k*=-1;}
    ll n;
    cin>>n;
    vector<pll> A(n);
    for(auto &I:A){cin>>I; I.S*=k;}
    sort(A.begin(),A.end());
    k=0;
    map<ll,ll> M;
    M[s.S]=0;
    for(pll &I:A){
        if(I.F<s.F || I.F>g.F || I.S<s.S || I.S>g.S){continue;}
        auto it=M.upper_bound(I.S);
        it--;
        M[I.S]=it->second+1;
        it=M.find(I.S);
        it++;
        while(it!=M.end() && it->second<=M[I.S]){it=M.erase(it);}
    }
    auto it=M.end(); it--;
    if(it->second==min(g.S-s.S,g.F-s.F)+1){cout<<(double)(g.S-s.S+g.F-s.F)*100+Q*(it->second-1)+H<<endl;}
    else{cout<<(double)(g.S-s.S+g.F-s.F)*100+Q*it->second<<endl;}
    
    
    return 0;
}


Measured memory_bytes: 15872
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    if b[i]-a[i]>=0:
        cnt+=a[i]
        b[i]-=a[i]
    else:
        cnt+=b[i]
        b[i]=0
    if b[i]>0:
        if b[i]-a[i+1]>=0:
            cnt+=a[i+1]
            a[i+1]=0
        else:
            cnt+=b[i]
            a[i+1]-=b[i]
print(cnt)

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

using namespace std;

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

	int total = 0;
	for (char s : N) {
		int n = (s - '0');
		total += n;
	}

	if (total % 9 == 0) {
		cout << "Yes" << endl;
	}

	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  char ans = '1';
  if(k>100){
    rep(i,sz(s)){
      if(s[i]!='1'){
        ans = s[i];
        break;
      }
    }
  }
  else{
  rep(i,k){
    if(s[i]!='1'){
      ans = s[i];
      break;
    }
    else{
      continue;
    }
  }
  }
  print(ans);
}

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

using namespace std;

int N;
int A[505];
long long int K;

long long int total;

int B[505];

int POSSIBLE(long long int k) {

	long long int sum = 0;
	for (int i = 1; i <= N; i++) {
		B[i] = A[i] % k;
		sum += B[i];
	}

	if (sum%k != 0) { return -1; }

	vector<int> V;

	for (int i = 1; i <= N; i++) {
		V.push_back(B[i]);
	}

	sort(V.begin(), V.end());

	long long int q = sum / k;

	long long int tmp = 0;

	for (int i = 0; i <(int)( N - q); i++) {
		tmp += V[i];
	}
	//cout << "tmp= " << tmp << endl;
	if (tmp <= K) { return 1; }
	return -1;
}

int main(void) {

	cin >> N >> K;

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		total += A[i];
	}

	long long  int ans = 0;


	for (int k = 1; k*k <= total; k++) {
		if (total%k == 0) {
			//cout << k << " " << total / k << endl;
			if (POSSIBLE(k) == 1) { ans = max(ans, (long long int) k); }
			if (POSSIBLE(total/ k) == 1) { ans = max(ans, total/k); }
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384