akhauriyash/Code-Regression huggingface dataset:
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))

s=input()
N=len(s)
K=intput()
ans=[]
for i in range(N-1):
    if (26-ston(s[i]))%26<=K:
        ans.append('a')
        K-=(26-ston(s[i]))%26
    else:
        ans.append(s[i])
ans.append(ntos((ston(s[N-1])+K)%26))
lprint(ans,'')

Measured memory_bytes: 83980
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1, k, n;
        n = sc.nextInt();
        while(i <= n){
            if(i % 3 == 0){
                System.out.print(" " + i);
            }else{
                k = i;
                while(k != 0){
                    if(k % 10 == 3){
                        System.out.print(" " + i);
                        break;
                    }else{
                        k /= 10;
                    }
                }
            }
            i++;
        }
        System.out.println();
    }
}



Measured memory_bytes: 28836
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  long long int a,b;
  while(cin>>a>>b){
    cout<<__gcd(a,b)<<" "<<a*(b/__gcd(a,b))<<endl;
  }


}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	int a,b;cin>>a>>b;
	b -= a-1;
	rep(i,a*2-1){
		cout << b << " ";
		b++;
	}
	cout << endl;
}



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

using namespace std;


#define int long long
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)


using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

signed main() {
    int n, m, c = 0;
    cin >> n >> m;
    rep(i, m) {
        int x;
        cin >> x;
        c |= 1 << x;
    }
    rep(b, (1 << n)) {
        if ((b & c) != c) continue;
        cout << b << ":";
        rep(i, n) {
            if (b & (1 << i)) {
                cout << " " << i;
            }
        }
        cout << endl;
    }
    cout << flush;
    return 0;
}


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

int main() {
    int x,a,b;
    cin >> x >> a >> b;
    if(a >= b){
        cout << "delicious";
    } else if(x < (b-a)){
        cout << "dangerous";
    } else {
        cout << "safe";
    }
}


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

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=2e5+19;

int A[N];
int n;
ll ans;

int main(){
	n=IN();
	For(i,1,n+1) A[i]=IN();
	if (A[1]!=0){
		puts("-1");
		return 0;
	}
	For(i,2,n+1) if (A[i]>A[i-1]+1){
		puts("-1");
		return 0;
	}
	For(i,2,n+1) if (A[i]==A[i-1]+1){
		ans+=1;
	} else{
		ans+=A[i];
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    vector<ll> cp(ALL(a));
    sort(ALL(cp));
    reverse(ALL(cp));
    REP(i, n) {
        if (a[i] == cp[0]) cout << cp[1] << endl;
        else cout << cp[0] << endl;
    }
    return 0;
}

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

int main(){
  string s;
  int a,b,c,f,e;
 cin>>s;
a=s.size();
  e=0;
  for(int i=0;i<a;i++){
  if(i%2==0){
    cout<<s[i];
  }
  }
  cout<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<vector<LL>> a(512,vector<LL>(512));
  REP(i,9) {
    vector<LL> l,r;
    REP(q,512) {
      if(q&(1<<i)) l.push_back(q);
      else r.push_back(q);
    }
    for(LL x:l) for(LL y:r) {
        a[x][y] = i;
        a[y][x] = i;
      }
  }
  REP(i,n-1) {
    FOR(j,i+1,n) {
      cout << a[i][j]+1;
      if(j+1 == n) cout << endl;
      else cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 2560
def solve(N, Q, S, L_R):
    memo = [None] * N
    cumsum = 0
    for i in range(len(S) - 1):
        memo[i] = cumsum
        if S[i] == "A" and S[i + 1] == "C":
            cumsum += 1
    memo[N - 1] = cumsum
    for l, r in L_R:
        print(memo[r - 1] - memo[l - 1])


N, Q = map(int, input().split())
S = input()
L_R = [tuple(map(int, input().split())) for _ in range(Q)]
solve(N, Q, S, L_R)

Measured memory_bytes: 21736
def main():
  N = int(input())
  ABC = [[int(i) for i in input().split()]for _ in range(N)]

  dp = [[0]*3 for _ in range(N+1)]
  for i in range(N):
    for j in range(3):
      for k in range(3):
        if j == k:
          continue
        dp[i+1][k] = max(dp[i+1][k], dp[i][j]+ABC[i][k])
  print(max(dp[N]))

if __name__ == "__main__":
  main()

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

typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll v[n];
    ll c=0;
    for(int i=1;i<=n;i++)
    {
        c=c+i;
    }
    cout<<c;
    return 0;
}





Measured memory_bytes: 3616
x1, y1, x2, y2 = gets.split.map(&:to_i)

dx, dy = x2 - x1, y2 - y1
x3, y3 = x2 - dy, y2 + dx
x4, y4 = x3 - dx, y3 - dy
printf "%d %d %d %d\n", x3, y3, x4, y4

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , m , i , j ;
    cin >> n >> m ;
    char c[n][m] ;
    for(i=0 ; i<n ; i++){
        for(j=0 ; j<m ; j++){
             cin >> c[i][j] ;
        }
    }
    ll dp[n][m] ;
    if(c[0][0] == '#' || c[n-1][m-1]=='#'){
         cout << "0" ;  return 0 ;
    }
    bool flag=1 ;
    for(i=0 ; i<n ; i++){
        if(c[i][0]=='#')flag=0 ;
        if(flag)dp[i][0] = 1 ;
        else dp[i][0] = 0 ;
    }
    flag=1 ;
    for(i=0 ; i<m ; i++){
        if(c[0][i]=='#')flag=0 ;
        if(flag)dp[0][i] = 1 ;
        else dp[0][i] = 0 ;
    }

    for(i=1 ; i<n ; i++){
        for(j=1 ; j<m ; j++){
              if(c[i][j]=='#')continue ;
              dp[i][j] = 0 ;
              if(c[i-1][j]=='.')dp[i][j] =( dp[i][j] + dp[i-1][j] )%M ;
              if(c[i][j-1]=='.')dp[i][j] =( dp[i][j] + dp[i][j-1] )%M ;
              //cout << i+1 << " " << j+1 << " " << dp[i][j] << endl ;
        }
    }

    cout << dp[n-1][m-1] ;

    return 0 ;
}

Measured memory_bytes: 9088
S=list(input())
lenS=len(S)
ans=0

if lenS%2==0:
  for l in range(lenS//2-1):
    check=0
    for k in range(l+1):
      if S[k]==S[k+l+1]:
        check+=1
    if check==l+1:
      ans=check*2
  print(ans)

else:
  for l in range(lenS//2):
    check=0
    for k in range(l+1):
      if S[k]==S[k+l+1]:
        check+=1
    if check==l+1:
      ans=check*2
  print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,k;
  cin >> n >> k;
  long double ans=0;
  long double o=n;
  rep(i,n){
    int y=i+1;
    long double c=1/o;
    //cout << c << endl;
    while(y<k){
      c/=2;
      y*=2;
    }
    ans+=c;
  }
  cout << fixed << setprecision(15);
  cout << ans << endl;
}  


Measured memory_bytes: 256
#include<iostream>
#define N 101
#define INF 1<<21
using namespace std;

int A[N][N];
int n;
int visited[N];
int d[N];
int p[N];

void dijkstra(int b){
    d[b]=0;
    p[b]=-1;
    int node=-1;
    int minval=INF;
    while(1){
        node=-1;
        minval=INF;
        for(int i=0;i<n;i++){
            if(visited[i]==true) continue;
            if(d[i]<minval){
                node=i;
                minval=d[i];
            }
        }
        if(node==-1) break;
        visited[node]=true;
        for(int e=0;e<n;e++){
            if(A[node][e]==INF || visited[e]==true) continue;
            if(d[e]>d[node]+A[node][e]){
                d[e]=d[node]+A[node][e];
            }
        }
    }
}

void init(){
    int k;
    int b,e,val;
    cin>>n;
    for(int i=0;i<n;i++){
        visited[i]=false;
        d[i]=INF;
        p[i]=-1;
        for(int j=0;j<n;j++){
            A[i][j]=INF;
        }
    }
    for(int i=0;i<n;i++){
        cin>>b>>k;
        for(int j=0;j<k;j++){
            cin>>e>>val;
            A[b][e]=val;
        }
    }
}

int main(){
    init();

    dijkstra(0);

    for(int i=0;i<n;i++){
        cout<<i<<' '<<d[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long x,y;
    cin >> x >> y;
    long long ans = 1LL<<60;
    
    //(x,y)=(10,20)
    //(x,y)=(10,5)
    //(x,y)=(10,-5)
    //(x,y)=(10,-20)
    //(x,y)=(10,0)
    //(x,y)=(-10,20)
    //(x,y)=(-10,5)
    //(x,y)=(-10,-5)
    //(x,y)=(-10,-20)
    //(x,y)=(-10,0)
    //(x,y)=(0,10)
    //(x,y)=(0,-10)
    //(x,y)=(0,0)
    
    if(x > 0){
        if(y > 0){
            //cout << ans << endl;
            if(x <= y) ans = y - x;
            else ans = x - y + 2;
        }else if(y < 0){
            ans = x - y;
            if(x >= -y) ans = min(ans, x + y + 1);
            else ans = min(ans , - y - x + 1);
        }else if(y == 0){
            ans = x + 1;
        }
    }else if(x < 0){
        if(y > 0){
            ans = - x + y;
            if(-x <= y) ans = min(ans, y + x + 1);
            else ans = min(ans, - x - y + 1);
        }else if(y < 0){
            if(-x >= -y) ans = - x + y;
            else ans = x - y + 2;
        }else if(y == 0){
            ans = -x;
        }
    }else if(x == 0){
        if(y > 0)ans = abs(y);
        else if(y < 0) ans = abs(y) + 1;
        else if(y == 0)ans = 0;
    }
    
    cout << ans << endl;
}


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

int main() {
  int n;
  std::cin >> n;
  std::vector<std::string> s(n);
  for (int i = 0; i < n; ++i)
    std::cin >> s[i];

  std::map<std::string, int> mp;
  for (int i = 0; i < n; ++i)
    mp[s[i]] += 1;

  int res = 0;
  for (auto &kv: mp)
    res += 1;

  std::cout << res << std::endl;
}


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

int main(){
    string s;
    cin>>s;
    int ans=1e9;
    for(int i=0;i<s.size()-2;i++){
        int tmp = (s[i]-'0')*100 + (s[i+1]-'0')*10 +(s[i+2]-'0');
        if (ans> abs(753-tmp)) ans = abs(753-tmp);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = gets.to_i

data = gets.split.map(&:to_i)

swap_cnt = 0

for i in 0..N-1
(N-1).downto(i+1)do|j|
if data[j] < data[j-1]
work = data[j]
data[j] = data[j-1]
data[j-1] = work
swap_cnt +=1

end

end

end
puts data.join(" ")
p swap_cnt

Measured memory_bytes: 8664
#include<cstdio>

long long Solve(long long a,long long b){
    if(b%a==0)
        return b/a*a*2-a;
    return b/a*a*2+Solve(b%a,a);
}

int main(){
    long long N,X;
    scanf("%lld%lld",&N,&X);
    printf("%lld",N+Solve(X,N-X));
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = 0;

		int[] d = new int[n];
		for (int i = 0; i < d.length; i++) {
			d[i] = sc.nextInt();
		}

		Arrays.sort(d);

//		for (int i = 0; i < d.length; i++) {
//			int j = d[i];
//			System.out.println(j);
//		}

		int div = n / 2;
		int a = d[div - 1];
		int b = d[div];

//		System.out.println(a + " " + b);
		if ( a != b) {
			k = b - a;
		}



		System.out.println(k);

	}

}


Measured memory_bytes: 50416
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; long long k;
  cin >> n >> k;
  vector<long long> a(n); for(auto & i : a) cin >> i;
  long long v = 0, ans = 0;
  for(int i = 60; i >= 0; i--){
    long long v1 = v + (1ll<<i);
    if(v1 <= k){
      int pc = 0;
      for(int j = 0; j < n; j++) if(a[j]&(1ll<<i)) pc++;
      pc = n - pc;
      if(pc > n / 2){
		v = v1;
      }
    } 
  }
  for(auto & i : a) ans += (i ^ v);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
from bisect import bisect
INF = float('inf')
A,B,Q = map(int,input().split())
S = [int(input()) for _ in range(A)]
T = [int(input()) for _ in range(B)]
X = [int(input()) for _ in range(Q)]

for x in X:
    ans = INF
    i = bisect(S,x)
    for j in {min(i,A-1),max(i-1,0)}:
        s = S[j]
        k = bisect(T,s)
        for l in {min(k,B-1),max(k-1,0)}:
            t = T[l]
            ans = min(ans,abs(x-s)+abs(s-t))
    i = bisect(T,x)
    for j in {min(i,B-1),max(i-1,0)}:
        t = T[j]
        k = bisect(S,t)
        for l in {min(k,A-1),max(k-1,0)}:
            s = S[l]
            ans = min(ans,abs(x-t)+abs(s-t))
    print(ans)

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

int main(){
    int N,W;cin>>N>>W;
    vector<int> v(N),w(N),m(N);
    vector<int> dp(W+1);
    for(int i = 0 ; i < N ; i++){
        cin >> v[i] >> w[i] >> m[i];
    }
    dp[0] = 0;
    for(int i = 0 ; i < N ; i++){
        int num = m[i];
        for(int k = 1; num > 0 ; k<<=1){
            int mul = min(num,k);
            for(int j = W; j >= w[i]*mul ; j--){
                dp[j] = max(dp[j],dp[j-w[i]*mul]+v[i]*mul);
            }
            num -= mul;
        }
    }
    cout << dp[W] << endl;
    return 0;
}


Measured memory_bytes: 3136
import numpy as np

n = int(input())
arr = list(map(int,input().split()))
d1 = {}
d2 = {}

for i in range(n//2):
    if arr[i*2] in d1:
        d1[arr[i*2]]+=1
    else:
        d1[arr[i*2]] = 1
    if arr[i*2+1] in d2:
        d2[arr[i*2+1]]+=1
    else:
        d2[arr[i*2+1]] = 1

a1 = [[-1,0]]
a2 = [[-1,0]]

for key in d1.keys():
    a1.append([key,d1[key]])
for key in d2.keys():
    a2.append([key,d2[key]])

a1.sort(key = lambda x:x[1])
a2.sort(key = lambda x:x[1])

if a1[-1][0] == a2[-1][0]:
    temp1 = n-a1[-1][1]-a2[-2][1]
    temp2 = n-a1[-2][1]-a2[-1][1]
    print(min(temp1,temp2))
else:
    print(n-a1[-1][1]-a2[-1][1])






Measured memory_bytes: 32976
n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(key=lambda x: -x[1])
# print(a)
# print(bc)

count = 0
idx = -1
end = False
for b, c in bc:
  if idx + b <= n-1 and a[idx+b] < c:
    count += b * c
    idx += b
  else:
    for i in range(idx+1, idx+1+b):
      if i >= n or end:
        break
      else:
        if a[i] < c:
          count += c
          idx += 1
        else:
          end = True
  # print((idx, count))
  if end:
    break

if idx <= n-2:
  count += sum(a[idx+1:])

print(count)


Measured memory_bytes: 80108
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    string a;
    cin >> a;
  
  string en = "Z";
  string st = "A";

    // 出力
  if( (a <= en) && (st <= a) ) {
    cout << "A";
  } else {
    cout << "a";
  }

    return 0;
}


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

using namespace std;

const int N = 100010;

vector < pair <int, long long> > g[N];
bool used[N];
long long d[N];

long long mx;

void dfs(int x) {
  used[x] = 1;
  for (auto &e : g[x]) {
    int to = e.first;
    int dist = e.second;
    if (used[to] && d[to] != d[x] + dist) {
      puts("No");
      exit(0);
    } else if (!used[to]) {
      d[to] = d[x] + dist;
      mx = max(mx, d[to]);
      dfs(to);
    }
  }
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int st = 0;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    g[x].push_back({y, z});
    g[y].push_back({x, -z});
    st = x;
  }
  mx = -1;
  for (int i = 1; i <= n; ++i) {
    if (!used[i]) {
      ++mx;
      dfs(i);
    }
  }
  puts("Yes");
	return 0;
}

Measured memory_bytes: 15616
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b && b == c {
		fmt.Println(1)
	} else if a == b || b == c || c == a {
		fmt.Println(2)
	} else {
		fmt.Println(3)
	}
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-


def lcm(x: int, y: int):
    '''
    See:
    https://note.nkmk.me/python-gcd-lcm/
    '''
    from fractions import gcd
    return (x * y) // gcd(x, y)


def main():
    n, m = map(int, input().split())
    s = input()
    t = input()
    size = lcm(n, m)
    part_s = [s[i] for i in range(0, n, size // m)]
    part_t = [t[j] for j in range(0, m, size // n)]

    for si, ti in zip(part_s, part_t):
        if si != ti:
            print(-1)
            exit()

    print(size)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 1000005
#define MOD 1000000007
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
int prime[MAX+1];
void sieve()
{
    int i,j;
    for(i=2; i*i<=MAX; i++)
    {
        if(prime[i]) continue;
        for(j=i; j*i<=MAX; j++)
        {
            if(prime[i*j]==0) prime[i*j]=i;
        }
    }
}
bool exists[MAX+1];
bool divide(int n)
{
    int p;
    while(n>1)
    {
        if(prime[n]) p=prime[n];
        else p=n;
        if(exists[p]) return false;
        exists[p]=true;
        while(n%p==0) n=n/p;
    }
    return true;
}
int A[MAX];
int gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
    sieve();
    int n,i;
    bool ppos=true;
    scanf("%d",&n);
    int g=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
        g=gcd(g,A[i]);
        ppos=(ppos&&divide(A[i]));
    }
    if(ppos)
    {
        printf("pairwise coprime");
    }
    else if(g==1)
    {
        printf("setwise coprime");
    }
    else
    {
        printf("not coprime");
    }
    return 0;
}


Measured memory_bytes: 11460
#include<cstdio>
#include<cstring>
#define inf 1000000000
using namespace std;
typedef long long ll;
const int N=2e3+100;
struct edge{
	int x,y,c1,c2,next;
}a[20*N];int len,last[N];
int st,ed,maxn;
void ins(int x,int y,int c1,int c2){
	a[++len].x=x;a[len].y=y;a[len].c1=c1;a[len].c2=c2;
	a[len].next=last[x];last[x]=len;
	a[++len].x=y;a[len].y=x;a[len].c1=0;a[len].c2=-c2;
	a[len].next=last[y];last[y]=len;
}
int dx[4]={-1,1,-1,1};
int dy[4]={1,1,-1,-1};
int list[N],head,tail,fa[N],Min[N];bool v[N];ll dis[N];
int mymin(int x,int y) {return x<y?x:y;}
int main()
{
	int n;scanf("%d",&n);
	maxn=2*n+6;st=maxn-1;ed=maxn;
	len=1;memset(last,0,sizeof(last));
	for(int i=1;i<=n;i++){
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		ins(st,i,c,0);
		for(int j=0;j<=3;j++){
			int xx=dx[j]*x,yy=dy[j]*y;
			ins(i,2*n+j+1,inf,xx+yy);
		}
	}
	for(int i=1;i<=n;i++){
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		ins(i+n,ed,c,0);
		for(int j=0;j<=3;j++){
			int xx=-dx[j]*x,yy=-dy[j]*y;
			ins(2*n+j+1,i+n,inf,xx+yy);
		}
	}
	ll ans=0;
	while(1){
		Min[st]=inf;
		memset(dis,-60,sizeof(dis));dis[st]=0;
		memset(v,true,sizeof(v));v[st]=false;
		list[1]=st;head=1;tail=2;if(tail==maxn+1) tail=1;
		while(head!=tail){
			int x=list[head];
			for(int k=last[x];k;k=a[k].next){
				int y=a[k].y;
				if(a[k].c1&&dis[y]<dis[x]+a[k].c2){
					fa[y]=k;
					dis[y]=dis[x]+a[k].c2;
					Min[y]=mymin(Min[x],a[k].c1);
					if(v[y]){
						v[y]=false;
						list[tail]=y;
						tail++;if(tail==maxn+1) tail=1;
					}
				}
			}
			head++;if(head==maxn+1) head=1;
			v[x]=true;
		}
		if(dis[ed]<0) break;
		ans=ans+dis[ed]*Min[ed];
		int t=ed;
		while(t!=st) a[fa[t]].c1-=Min[ed],a[fa[t]^1].c1+=Min[ed],t=a[fa[t]].x;
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int con0[30] = {};
	int con1[30] = {};
	
	string s;
	
	cin>>s;
	
	for(int i = 0; i < s.size(); i += 2){
		con0[s[i] - 'A']++;
	}
	for(int i = 1; i < s.size(); i += 2){
		con1[s[i] - 'A']++;
	}
	
	// cout<<con0['R'-'A']<<" "<<con0['R'-'A']<<endl;
	if(con1['R'-'A'] == 0 && con0['L'-'A'] == 0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define p 3.14159265358979323846L

using namespace std;

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

    long double a,b,h,m,deg,res;
    cin>>a>>b>>h>>m;

    deg=2*p*(h/12+(m/60)/12 -m/60);
    res=a*a+b*b-2*a*b*cosl(deg);

    printf("%20.20Lf",sqrt(res));

    return 0;
}


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

int p(int k){
	int ans = 1;
	for(int i = 0;i < k;i++)ans *= 10;
	return ans;
}

int main(){
	string str, x, y = "", z = "";
	int xn, yn = 0, zn = 0, f = 0;
	cin >> str;
	for(int i = 0;i < str.size();i++){
		if(str[i] == '.'){
			x = str.substr(0, i);
			xn = x.size();
		}
		if((i == str.size()-1 && !f) || (i+1 < str.size() && str[i+1] == '(')){
			y = str.substr(xn+1, i-xn);
			yn = y.size();
			f = 1;
		}
		if(str[i] == ')'){
			z = str.substr(xn+yn+2, i-xn-yn-2);
			zn = z.size();
		}
	}
	int a = p(zn+yn)-p(yn);
	int b = atoi(x.c_str())*p(yn+zn)+atoi(y.c_str())*p(zn)+atoi(z.c_str());
	b = b-b/p(zn);
	if(zn == 0){
		a = p(yn);
		b = atoi(x.c_str())*p(yn)+atoi(y.c_str());
	}
	int g = __gcd(a, b);
	a /= g;b /= g;
	printf("%d/%d\n", b, a);
	return 0;
}


Measured memory_bytes: 3340
N = gets.to_i
a = N.times.map{gets.split.map(&:to_i)}

WHITE = 0
GRAY  = 1
BLACK = 2

@color = []
@d = []
@f = []
@tt = 0
@m = Array.new(N){Array.new(N){0}}

def dfs_visit(u)
  @color[u] = GRAY
  @d[u] = @tt += 1

  (0...N).each do |v|
    if @m[u][v] == 0
      next
    end

    if @color[v] == WHITE
      dfs_visit(v)
    end
  end

  @color[u] = BLACK
  @f[u] = @tt += 1
end

def dfs
  (0...N).each do |u|
    @color[u] = WHITE
  end

  (0...N).each do |u|
    if @color[u] == WHITE
      dfs_visit(u)
    end
  end

  (0...N).each do |u|
    puts "#{u + 1} #{@d[u]} #{@f[u]}"
  end
end

(0...N).each do |i|
  u, k = a[i][0], a[i][1]
  u -= 1

  (0...k).each do |j|
    v = a[i][j + 2]
    v -= 1

    @m[u][v] = 1
  end
end
dfs


Measured memory_bytes: 8956
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define ll long long

//edpc_a
ll N,h[100010];
ll dp[100100];

ll min(ll a, ll b){
    if(a<b)return a;
    else return b;
}

int main(void){
    scanf("%lld",&N);
    for(ll i=0;i<N;i++){
        scanf("%lld",&h[i]);
    }

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

    printf("%lld\n",dp[N-1]);
    return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];

  ll maxbuf=0,minbuf=0,maxn=0,minn=0;
  for(i=0;i<n;i++){
    if(maxbuf<a[i]){
      maxbuf=a[i];
      maxn=i;
    }
    if(minbuf>a[i]){
      minbuf=a[i];
      minn=i;
    }
  }
  vector<pair<ll,ll>> r;//最後r+1で取り出し
  if(abs(maxbuf)>=abs(minbuf)){
    for(i=0;i<n;i++){
      if(i!=maxn){
        r.push_back({maxn,i});
      }
    }
    for(i=0;i<n-1;i++){
      r.push_back({i,i+1});
    }
  }
  else if(abs(maxbuf)<abs(minbuf)){
    for(i=0;i<n;i++){
      if(i!=minn){
        r.push_back({minn,i});
      }
    }
    for(i=n-1;i>0;i--){
      r.push_back({i,i-1});
    }
  }

  cout<<r.size()<<endl;
  for(i=0;i<r.size();i++){
    cout<<r[i].first+1 spa r[i].second+1<<endl;
  }



  return 0;
}

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

int main(){

    string str_input;
    cin >> str_input;

    if(str_input.size() == 1) {
        cout << str_input << endl;
        return 0;
    }

    long long result_sum = 0;
    for(int bit = 0; bit < (1 << (str_input.size()-1)); bit++){

        vector <bool> add_opp(str_input.size()-1, false);
        for(unsigned int i = 0; i < add_opp.size(); i++){
            if(bit & (1 << i)) {
                add_opp[i] = true;
            }
        }

        unsigned int start_digit = 0;
        unsigned int digit_len   = 1;
        for(unsigned int k = 0; k < add_opp.size(); k++) {
            if(k == add_opp.size() - 1) {
                if(add_opp[k] == true) {
                    result_sum += atoll(str_input.substr(start_digit, digit_len).c_str());
                    start_digit = k+1;
                }
                result_sum += atoll(str_input.substr(start_digit).c_str());
                continue;
            }
            if(add_opp[k] == false) {
                digit_len++;
                continue;
            }

            result_sum += atoll(str_input.substr(start_digit, digit_len).c_str());
            start_digit = k+1;
            digit_len = 1;
        }
    }

    cout << result_sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
    	Scanner sn = new Scanner(System.in);
      	int n = sn.nextInt();
      	int x = sn.nextInt();
      	int t = sn.nextInt();
      	int res = n / x;
      	int mod = n % x;
      	if(mod != 0) {
        	res++;
        }
      	res = res * t; 
        System.out.println(res);
    }
}

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;

  string num;
  int cnt = 0;
  int digit_sum;
  int sum = 0;
  string tmp;
  for (int i = 1; i <= N; i++)
  {
    num = to_string(i);
    digit_sum =0;
    for (int j = 0; j < num.size(); j++)
    {
      tmp = {num.at(j)};
      digit_sum += stoi(tmp);
    }

    //cout << digit_sum << endl;
    if (digit_sum >= A && digit_sum <= B){
      sum += i;
      
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3660
def main():
    A, B, C = map(int, input().split())

    if A == B and A != C:
        print("Yes")
    elif B == C and B != A:
        print("Yes")
    elif C == A and C != B:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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


int main(){
  string s;
  cin >> s;
  int n= s.length();
  ll sum=0;
  rep(i,0,n){
    sum+=int(s[i])-48;
  }
//  cout << sum << endl;
  if(sum%9==0) cout <<"Yes" << endl;
  else cout <<"No"<<endl;
//  cout << 0%9 << endl;
  return 0;

}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005;
int n,a[Maxn];
bool check(int lim){
    map<int,int>Map;
    for(int i=2;i<=n;i++){
        if(a[i]<=a[i-1]){
            Map.erase(Map.lower_bound(a[i]+1),Map.end());
            for(int j=a[i];;j--){
                if(!j)return false;
                if(Map[j]==lim-1)Map.erase(j);
                else{
                    Map[j]++;
                    break;
                }
            }
        }
    }
    return true;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    bool succ=true;
    for(int i=1;i<n;i++)
        if(a[i]>=a[i+1])
            succ=false;
    if(succ){
        cout<<"1\n";
        return 0;
    }
    int l=2,r=n;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid))r=mid-1;
        else l=mid+1;
    }
    cout<<l<<"\n";
    return 0;
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;
  A--; B--; C--; D--;

  string s;
  cin >> s;

  bool f = true;
  for ( int i = A+1; i <= C; i++ ) {
    if ( s[i] == '#' && s[i-1] == '#' ) {
      f = false;
      break;
    }
  }
  for ( int i = B+1; i <= D; i++ ) {
    if ( s[i] == '#' && s[i-1] == '#' ) {
      f = false;
      break;
    }
  }

  bool f2 = false;
  if ( C > D ) {
    for ( int i = B+1; i <= min(N-1,D+1); i++ ) {      
      if ( s[i] == '.' && s[i-1] == '.' && s[i-2] == '.' ) {
	f2 = true;
	break;
      }
    }
    if ( f && f2 ) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if ( f ) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
using namespace std;
char a[53][54];
int main(){
  int h,w,num=0;
  cin>>h>>w;
  for (int i=0;i<h;i++)
    for (int j=0;j<w;j++)
      cin>>a[i][j];
  for (int i=0;i<h;i++)
    for (int j=0;j<w;j++){
      if (a[i][j]=='#'){
        if ((i != 0) and (a[i-1][j]=='#')) num++;
        if ((i != h-1) and (a[i+1][j]=='#')) num++;
        if ((j != 0) and (a[i][j-1]=='#')) num++;
        if ((j != w-1) and (a[i][j+1]=='#')) num++;
        if (num == 0){
		  cout<<"No";
		  return 0;
	    }
	    num=0;
       }
    }
  cout<<"Yes";
  return 0;
}

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

string s;
bool a[30];

int main(){
	cin >> s;
	if(s == "zyxwvutsrqponmlkjihgfedcba") printf("-1\n");
	else{
		for(int i=0; i<s.size(); ++i)
			a[s[i]-'a'] = true;
		bool f = false;
		for(int i=0; i<26; ++i)
			if(!a[i]){
				cout << s << (char)('a' + i) << endl;
				f = true;
				break;
			}
		if(!f){
			a[s[s.size()-1]-'a'] = false;
			int t = s.size()-1;
			while(s[t-1] > s[t]){
				--t;
				a[s[t]-'a'] = false;
			}
			char c;
			for(int i=s[t-1]-'a'; i<26; ++i)
				if(!a[i]){
					c = 'a' + i;
					break;
				}
			cout << s.substr(0, t-1) << c <<  endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int N, Q;
string S;
char t[202020], d[202020];

int f(int x) {
    if (x < 0 && x >= N)
        return x;
    FOR(Q) {
        if (S[x] == t[i]) {
            x += d[i];
        }
        if (x < 0 && x >= N)
            return x;
    }
    return x;
}
bool checkL(int x) {
    return f(x) >= 0;
}
bool checkR(int x) {
    return f(x) < N;
}

void solve() {
    int L, R;
    {
        int ok = N;
        int ng = -1;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (checkL(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        L = ok;
    }
    {
        int ok = -1;
        int ng = N;
        while (abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;
            if (checkR(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        R = ok;
    }
    cout << max(R - L + 1, 0ll) << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> Q >> S;
    FOR(Q) {
        cin >> t[i] >> d[i];
        if (d[i] == 'L')
            d[i] = -1;
        else
            d[i] = 1;
    }

    solve();
    return 0;
}


Measured memory_bytes: 976
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    string a, s, c;
    cin >> a >> s >> c;

    cout << a.front() << s.front() << c.front() << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
int a,b,k;
    cin >> a >> b >> k;
    for(int i=a;i<b+1;++i)
     {
        if(i < a+k || b-k < i) cout << i << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(10);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */

struct UnionFind{
  vector<long long> data;
  UnionFind(long long N) :data(vector<long long>(N,-1)){}
  void boot(long long n){
    for(long long i = 0;i < n;i++)data.push_back(-1);
    return;
  }
  long long root(long long x){
    if(data[x] < 0)return x;
    else return data[x] = root(data[x]);
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y){
    if(!same(x,y)){
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
      }
      else{
        data[y] += data[x];
        data[x] = y;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
};

/* main */

signed main(){
    ll N,K,L;
    cin >> N >> K >> L;
    UnionFind train(N);
    UnionFind road(N);
    FOR(i,0,K){
        ll p,q;
        cin >> p >> q;
        road.unite(p-1,q-1);
    }
    FOR(i,0,L){
        ll r,s;
        cin >> r >> s;
        train.unite(r-1,s-1);
    }
    map<pl,ll> m;
    FOR(i,0,N)m[make_pair(road.root(i),train.root(i))]++;
    FOR(i,0,N){
        cout << m[make_pair(road.root(i),train.root(i))] << ' ';
    }
}


Measured memory_bytes: 15104
// https://atcoder.jp/contests/abc169/tasks/abc169_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

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

  ll ans = 1;
  REP(i, N) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0;
      return 0;
    }
    if (ans > ll(1e18) / a) {
      ans = 2e18;
    } else
      ans *= a;
  }
  if (ans > ll(1e18)) {
    cout << -1;
    return 0;
  }
  cout << ans;
}


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

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for(int i = b; i<=c;i++){
            if(i%a==0){
               count++;
               break;
            }
            else{
                continue;
            }
        }
        if(count>0) System.out.println("OK");
        else System.out.println("NG");
    }
}


Measured memory_bytes: 35672
#include<bits/stdc++.h>
using namespace std;
	int main()
{
	int W,H;
	cin>>W>>H;
	int x,y,r;
	cin>>x>>y>>r;

	if(x-r>=0 && x+r<=W && y-r >=0 && y+r<=H) 
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890


int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll p[n];
    for(i=0;i<n;i++) cin>>p[i];
    vector<P> v;
    for(i=0;i<n;i++){
        v.pb(P(p[i],i));
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    set<ll> s;
    s.insert(n);
    s.insert(-1);
    s.insert(n+1);
    s.insert(-2);
    ll ans=0;

    for(i=0;i<n;i++){
        if(i>=1){
            auto it=s.upper_bound(v[i].se);
            ll x1=*it - v[i].se;
            ll x2=*(++it)-v[i].se;
            if(x2==n+1-v[i].se) x2=n-v[i].se;
            it--;
            it--;
            ll y1=*it-v[i].se;
            ll y2=*(--it)-v[i].se;
            if(y2==-2-v[i].se) y2=-1-v[i].se;

            ans+=(y1-y2)*x1*v[i].fi;
            ans+=(x2-x1)*(-y1)*v[i].fi;
        }
        s.insert(v[i].se);
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 7280
function Main(input) {
  input.trim();
  var ans = 0
switch(input){
  case "SUN\n" :
  ans++;
  case "MON\n" :
  ans++;
  case "TUE\n" :
  ans++;
  case "WED\n" :
  ans++;
  case "THU\n" :
  ans++;
  case "FRI\n" :
  ans++;
  case "SAT\n" :
  ans++;
 }
 console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;++i){
    int c=0;
    for(int j=i;j<k;j*=2)c++;
    double m=1;
    for(int l=0;l<c;++l)m*=1.0/2.0;
    ans+=(1.0/double(n))*m;
  }
  printf("%.10lf",ans);
}

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

using namespace std;

typedef long long ll;

ll counter[10000001] = {0};

void setCounter()
{
    for(ll i = 2; i <= 10000000; i++)
    {
        for(int j = 2 * i; j <= 10000000; j += i)
        {
            counter[j]++;
        }

        counter[i] += 2;
    }

    counter[1] = 1;
}

int main()
{
    setCounter();

    //cout << "ready" << endl;

    /*for(ll i = 1; i <= 10000000; i++)
    {
        cout << counter[i] << endl;
    }*/

    ll n;

    cin >> n;

    ll sum = 0;

    for(ll i = 1; i <= n; i++)
    {
        sum += i * counter[i];
    }

    cout << sum << endl;

    return 0;
}


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

public class Main {

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

        final int A = Integer.parseInt(sc.next());
        final int B = Integer.parseInt(sc.next());
        final int C = Integer.parseInt(sc.next());
        out.println(A + B >= C ? "Yes" : "No");

        out.flush();
    }
}

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

bool comp(pair<long long int,long long int> a, pair<long long int,long long int> b)
{
  if(a.first != b.first)
  {
    return a.first < b.first;
  }
  else
  {
    return a.second > b.second;
  }
}

int main()
{
  int n;
  cin >> n;
  vector<pair<long long int,long long int> > v;
  for(int i = 0;i < n;i++)
  {
    long long int a,b;
    cin >> a >> b;
    v.push_back(make_pair(b,a));
  }
  sort(v.begin(),v.end(),comp);
  long long int work_sum = 0;
  for(int i = 0;i < n;i++)
  {
    work_sum = work_sum + v[i].second;
    if(v[i].first < work_sum)
    {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 5616