akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]
# T = [int(input()) for i in range(d)]
c = 26
# m = int(input())
# Q = [list(map(int,input().split())) for i in range(m)]

ans = 0
L = [[-1] * c for i in range(d)]
T = [-1] * d  # この中には0-25を入れる
K = [[] for i in range(d)]  # この中は0-indexed
pp = 6

for i in range(d):
    ANS = [0] * c
    L[i] = L[i-1][:]
    for k in range(c):
        ANS[k] = S[i][k] + C[k] * (i - L[i][k])
    ANSS = [[ANS[j], j] for j in range(c)]
    ANSS.sort(reverse=True)
    for j in range(pp):
        K[i].append(ANSS[j][1])
    ind = ANSS[0][1]
    ans += S[i][ind]
    L[i][ind] = i
    for j in range(c):
        ans -= C[j] * (i - L[i][j])
    # print(ans)
    # print(ind + 1)
    T[i] = ind

fans = ans
# print("fans",fans)
# print(L)
# print(T)



# cp = 3
# dp = 3

# CC = [[C[i], i] for i in range(c)]
# CC.sort(reverse=True)
# for i in range(d):
#     for k in range(cp):
#         K[i].append(CC[k][1])

# for i in range(d):
#     DD = [[S[i][j], j] for j in range(c)]
#     DD.sort(reverse=True)
#     for k in range(dp):
#         K[i].append(DD[k][1])

# print("K",K)
    
from random import randint

m = 5*10**5

Q = [[0] * 2 for i in range(m)]
for i in range(m):
    dd = randint(0, d-1)
    # print("dd",dd)
    # print(dd-1,randint(0, len(K[dd-1])-1))
    q = K[dd][randint(0, len(K[dd])-1)]
    Q[i][0] = dd
    Q[i][1] = q

# print(Q)

for i in range(m):
    # print(*T)
    # print(Q)
    dd = Q[i][0]
    q = Q[i][1]
    nans = ans
    # print("dd",dd)
    nans -= S[dd][T[dd]]
    nans += S[dd][q]
    for j in range(dd, d):
        # print("j",j)
        if T[j] == q:
            # print("break")
            break
        nans += C[q] * (j - L[j][q])
        nans -= C[q] * (j - dd)
        L[j][q] = dd
    
    old = T[dd]
    T[dd] = q

    for j in range(dd, d):
        # print("j",j)
        if T[j] == old:
            # print("break")
            break
        oldl = L[j-1][old] if j > 0 else -1
        nans += C[old] * (j - dd)
        nans -= C[old] * (j - oldl)
        L[j][old] = oldl

    # print(nans, ans)

    if nans < ans:
        if i != m-1:
            Q[i+1] = [dd, old]
        else:
            T[dd] = old
    
    ans = nans

# print(max(ans,fans))
for i in T:
    print(i+1)


Measured memory_bytes: 151448
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long

int main()
{
  long long int n,m;
  cin>>n>>m;
  n*=m;
  cout<<n;
}

Measured memory_bytes: 3616
class Array
  def lcm
    self.inject do |a, b|
      a*b/self.gcd
    end
  end

  def gcd
    self.inject do |a, b|
      a, b = b, a if a < b
      return a if b == 0
      arr = b, a%b
      arr.gcd
    end
  end
end

while str = gets
  a = str.split(' ').map(&:to_i)
  puts "#{a.gcd} #{a.lcm}"
end

Measured memory_bytes: 6104
// https://beta.atcoder.jp/contests/abc114

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int>> factorize(int x) {
    vector<pair<int, int>> factors;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i != 0) continue;
        int n = 0;
        while (x % i == 0) { n++; x /= i; }
        factors.emplace_back(i, n);
    }
    if (x != 1) factors.emplace_back(x, 1);
    return move(factors);
}

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(100
)");
#endif
    // <factor, n_factors>
    map<int, int> factor_count;

    uint64_t x;
    in >> x;

    if (x == 1) {
        cout << 0 << endl;
        exit(0);
    }

    for (int i = 2; i <= x; ++i) {
        auto v = factorize(i);
        for (auto p : v) factor_count[p.first] += p.second;
    }

    queue<int> q;
    q.push(1);
    for (auto e : factor_count) {
        queue<int> next_q;
        while (!q.empty()) {
            auto v = q.front();
            q.pop();

            auto n_factors = e.second + 1;
            if (75 <= n_factors) next_q.push(v * 75);
            if (25 <= n_factors) next_q.push(v * 25);
            if (15 <= n_factors) next_q.push(v * 15);
            if (5 <= n_factors) next_q.push(v * 5);
            if (3 <= n_factors) next_q.push(v * 3);
            next_q.push(v * 1);
        }
        q = next_q;
    }

    auto ans = 0;
    while (!q.empty()) {
        auto v = q.front();
        q.pop();
        if (v == 75) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 77332
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000003;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    if(n==3){
        cout<<2<<" "<<5<<" "<<63<<endl;
        return 0;
    }
    if(n==4){
         cout<<2<<" "<<5<<" "<<20<<" "<<63<<endl;
         return 0;
   }
   if(n==5){
       cout<<2<<" "<<5<<" "<<20<<" "<<30<<" "<<63<<endl;
         return 0;
   }
   set<int> s;
   ll sum=0;
   for(int i=0;i<n/4;i++){
       s.insert(6*i+2);
       s.insert(6*i+3);
       s.insert(6*i+4);
       s.insert(6*i+6);
       sum+=15;
   }
   int t=n/4;
       if(n%4==1){s.insert(6*t+2);sum+=2;}
       if(n%4==2){s.insert(6*t+2);s.insert(6*t+3);sum+=5;}
       if(n%4==3){s.insert(6*t+2);s.insert(6*t+3);s.insert(6*t+4);sum+=9;}
       if(sum%6==2){s.erase(8);s.insert(6*t+6);}
       if(sum%6==3){s.erase(9);s.insert(6*t+6);}
       if(sum%6==5){s.erase(9);s.insert(6*t+4);}
  for(auto ite=s.begin();ite!=s.end();ite++){
      cout<<*ite<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1408
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
    int n = scan!int;
    int a = n / 500;
    int b = (n - 500 * a) / 5;
    int ans = a * 1000 + b * 5;
    ans.writeln;
}



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

int main() {
	int i,count=0;
	char S[11], T[12];
	scanf("%s", S);
	scanf("%s", T);
	for (i = 0; i < strlen(T); i++) {
		count = count + 1;
	}
	if (strlen(S) + 1 == strlen(T)) {
		T[count-1] = '\0';
		if (strcmp(S, T) == 0) {
			printf("Yes");
		}
		else {
			printf("No");
		}
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
//#define int int64_t
#define pcnt __builtin_popcount
#define pb push_back
#define ALL(x) (x).begin(),(x).end()
#define vec vector<int>
#define mat vector<vector<int>> //mat データ名(縦,vec(横));
int64_t INF = 1000000000000000001; //10^18+1
int MOD = 1000000007; //10^9+7
//cout << fixed << setprecision(15); (小数点以下表示)


void next(vec &A,int M,int i){
  if(A[i]>=M){
    next(A,M,i-1);
    int siz=A.size();
    for(int j=i;j<siz;j++){
      if(j>0){
        A[j]=A[j-1];
      }else{
        A[0]++;
      }
    }
  }else{
    A[i]++;
  }
}

signed main () {
  int N,M,Q,score=0,ans=0;
  cin >> N >> M >> Q;
  vec A(N,1),a(Q),b(Q),c(Q),d(Q);
  for(int i=0;i<Q;i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  for(int i=0;i<INF;i++){
    if(i!=0)next(A,M,N-1);
    score=0;
    for(int j=0;j<Q;j++){
      if(A[b[j]-1]-A[a[j]-1]==c[j])score+=d[j];
    }
    ans=max(ans,score);
    if(A[0]==M)break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
h, w = map(int, input().split())
src = [input() for i in range(h)]

ans = []
for row in src:
        ans.append(list(row))

dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for x in range(h):
        for y in range(w):
                if src[x][y] == ".":
                        continue
                if src[x][y] == "#":
                        flag = 0
                        for dx, dy in dxy:
                                if x + dx < 0 or x + dx > h -1 or y + dy < 0 or y + dy > w - 1:
                                        continue
                                if src[x + dx][y + dy] == "#":
                                        flag = 1
                                        break
                        if flag == 0:
                                print("No")
                                exit()

print("Yes")

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

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

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  RSORT(a);
  ll ans = a[0];
  FOR(i, 1, n - 2) {
    ans += a[(i + 1) / 2];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


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

int main() {
  long long n=0;
  cin>>n;
  for(long long i=0;i<n;i++){
    long long test=n-i*100;
    if(0<=test&&test<=5*i){
      cout<<"1"<< endl;
      return 0;
    }
  }
  cout<<"0"<< endl;
}

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  bool ans=false;
  
  for (int i=1;i<=b;i++) {
    if (a*i%b==c) ans=true;
  }
  
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 m,k;
    cin >> m >> k;
    if(k >= (1 << m)){
        ANS(-1);
        return 0;
    }
    if(m == 0){
        if(k == 0)
            ANS("0 0");
        return 0;
    }
    if(m == 1){
        if(k == 0){
            ANS("0 0 1 1");
        }else{
            ANS(-1);
        }
        return 0;
    }
    REP(i,1<<m){
        if(i == k)continue;
        cout << i << " ";
    }
    cout << k << " ";
    FORR(i,(1<<m)-1,0){
        if(i == k)continue;
        cout << i << " ";
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static class Team implements Comparable<Team> {
		int c,t,i;
		public Team(int c, int t, int i) {
			this.c = c;
			this.t = t;
			this.i = i;
		}
		public int compareTo(Team o) {
			if (this.c - o.c == 0) {
				if (this.t - o.t == 0) {
					if (o.i - this.i > 0)
						return Integer.MAX_VALUE;
					else
						return Integer.MIN_VALUE;
				}
				else
					return this.t - o.t;
			}
			else
				return o.c - this.c;
		}
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = Integer.parseInt(sc.next());
			int t = Integer.parseInt(sc.next());
			int p = Integer.parseInt(sc.next());
			int r = Integer.parseInt(sc.next());
			if (m == 0 && t == 0 && p == 0 && r == 0) break;
			Team[] T = new Team[t];
			int[][] miss = new int[t][p];
			for (int i = 0; i < t; i++)
				T[i] = new Team(0, 0, i + 1);
			for (int i = 0; i < r; i++) {
				int mt = Integer.parseInt(sc.next());
				int tt = Integer.parseInt(sc.next()) - 1;
				int pt = Integer.parseInt(sc.next()) - 1;
				int jt = Integer.parseInt(sc.next());
				if (jt != 0)
					miss[tt][pt]++;
				if (jt != 0 || mt > m) continue;
				T[tt].c++;
				T[tt].t += mt + 20 * miss[tt][pt];
			}
			Arrays.sort(T);
			for (int i = 0; i < t; i++) {
				System.out.print(T[i].i);
				if (i != t - 1 && T[i].compareTo(T[i + 1]) == Integer.MIN_VALUE) {
					System.out.print("=");
				}
				else if (i != t - 1)
					System.out.print(",");
				else
					System.out.println();
			}
		}
	}
}


Measured memory_bytes: 53064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main(){
  int N, K;
  cin >> N >> K;
  int rem = (N-1)*(N-2)/2, M = 0;
  if(K > rem) {
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> to(N);
  for(int i=1; i<N; i++) {
    to[0].push_back(i);
    M++;
  }
  for(int i=1; i<N-1; i++) {
    bool flag = false;
    for(int j=i+1; j<N; j++) {
      if(rem == K) {
        flag = true;
        break;
      }
      to[i].push_back(j);
      rem--;
      M++;
    }
    if(flag)
      break;
  }
  cout << M << endl;
  rep(i, N) {
    for(auto e : to[i]) {
      cout << i+1 << ' ' << e+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
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; }
using namespace std;

class UnionFindS{
private:
    vector<int> par;
public:
    UnionFindS(int n){
        par=vector<int>(n,-1);
    }
    int find(int x){
        if(par.at(x)<0) return x;
        else return par.at(x)=find(par.at(x));
    }
    int size(int x){
        return -par.at(find(x));
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par.at(x)+=par.at(y);
        par.at(y)=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<P> x(n),y(n);
    rep(i,n){
        cin>>x.at(i).F>>y.at(i).F;
        x.at(i).S=i; y.at(i).S=i;
    }
    sort(all(x));
    sort(all(y));
    vector<pair<int,P>> dif(n*2-2);
    rep(i,n-1){
        dif.at(i).F=x.at(i+1).F-x.at(i).F;
        dif.at(i).S.F=x.at(i).S;
        dif.at(i).S.S=x.at(i+1).S;
        dif.at(n-1+i).F=y.at(i+1).F-y.at(i).F;
        dif.at(n-1+i).S.F=y.at(i).S;
        dif.at(n-1+i).S.S=y.at(i+1).S;
    }
    sort(all(dif));
    UnionFindS uni(n);
    int ans=0;
    rep(i,n*2-2){
        int v=dif.at(i).S.F,u=dif.at(i).S.S;
        if(!uni.same(v,u)){
            uni.unite(v,u);
            ans+=dif.at(i).F;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B; cin>>A>>B;
  int ans=1;
  if(A>B)
    swap(A,B);
  if(A==1&&B==2)
    ans=3;
  else if(A==1&&B==3)
    ans=2;
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
        int K = in.nextInt();
       
        System.out.println(K / 2 * (K / 2 + K % 2));
    }
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int64_t n;
  cin >> n;
  for(int m=sqrt(n);m>0;m--) {
    if(n % m == 0) {
      cout << n/m + m - 2;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#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;
typedef vector<string> Vs;

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=300+19;

int A[N][N],cnt[N],Q[N],B[N];
int n,m,res,l,r,f,w;

bool check(int x){
	memset(cnt,0,sizeof(cnt));
	For(i,1,n+1){
		cnt[A[i][1]]++;
		B[i]=1;
	}
	f=0,w=0;
	For(i,1,m+1) if (cnt[i]>x) Q[++f]=i;
	while (f>w){
		int c=Q[++w];
		For(i,1,n+1){
			if (cnt[A[i][B[i]]]<=x) continue;
			while (B[i]<=m&&cnt[A[i][B[i]]]>x) B[i]++;
			if (B[i]>m) return 0;
			if (++cnt[A[i][B[i]]]>x) Q[++f]=A[i][B[i]];
		}
	}
	return 1;
}

int main(){
	n=IN(),m=IN();
	For(i,1,n+1) For(j,1,m+1) A[i][j]=IN();
	l=1,r=n;
	while (l<=r){
		int mid=(l+r)/2;
		if (check(mid)) res=mid,r=mid-1;else l=mid+1;
	}
	printf("%d\n",res);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    string s;
    cin >> s;
    if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) out("Yes");
    else out("No");
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int a, b, c, d, l, r;

int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	l = a + b;
	r = c + d;
	if(l > r) printf("Left\n");
	else if(l < r) printf("Right\n");
	else printf("Balanced\n");
	return 0;
}

Measured memory_bytes: 128
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a = inp()
print(a^1)

Measured memory_bytes: 10444
from heapq import heappush, heappop

infi = 10 ** 20
n, m, s = map(int, input().split())

s = min(s, 2500)

edges = [[] for _ in range(51 * 2501 + 1)]
# edge:1-50, max silver=0-2500

for _ in range(m):
    u, v, a, b = map(int, input().split())
    for i in range(a, 2501):
        edges[v + 50 * i].append((b, u + 50 * (i - a)))
        edges[u + 50 * i].append((b, v + 50 * (i - a)))


for edge_num in range(1, n + 1):
    c, d = map(int, input().split())
    # c枚, d分
    for i in range(2501):
        # 点edge_num+ i * 50のところに
        if edge_num + (i + c) * 50 <= 51 * 2501:
            edges[edge_num + i * 50].append((d, edge_num + min((i + c), 2500) * 50))
start = 1 + 50 * s


def dijkstra(edges, start):
    time = [infi] * (51 * 2501 + 1)
    used = [False] * (51 * 2501 + 1)
    # time[i][j] 頂点i, 銀貨jのときの時間
    time[start] = 0
    edgelist = []
    heappush(edgelist, (0, start))
    while edgelist:
        nowtime, nowedge = heappop(edgelist)
        if used[nowedge] is True:
            continue
        used[nowedge] = True
        time[nowedge] = nowtime
        for vt, v in edges[nowedge]:
            if used[v] is True:
                continue
            newtime = nowtime + vt
            heappush(edgelist, (newtime, v))
    return time


time = dijkstra(edges, start)

ans = [infi] * (51)
for i in range(1, 51 * 2501 + 1):
    temp = time[i]
    a = i % 50
    if a == 0:
        a += 50
    ans[a] = min(temp, ans[a])

print(*ans[2 : (n + 1)], sep="\n")


Measured memory_bytes: 106060
#include<bits/stdc++.h>
using namespace std;
using pii = std::pair<int,int>;
auto addp(pii a, pii b){ return make_pair(a.first + b.first, a.second + b.second);}
signed main(){
    int N;
    cin >> N;
    std::vector<pii>v(N);
    map<pii,int>mp;
    for(auto & p : v)
        std:: cin >> p.first >> p.second;
    sort(v.begin(),v.end());
    for(auto p : v)mp[p]++;
    int ans = N;
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < N; ++j){
            if(i == j)continue;
            auto t = mp;
            auto mt = t;
            int x_dif = v[i].first - v[j].first;
            int y_dif = v[i].second - v[j].second;
            for(int k = 0; k < N; ++k){
                if(k == i or k == j) continue;
                auto pp = addp(v[k],make_pair(x_dif,y_dif));
                auto np = addp(v[k],make_pair(-1*x_dif, -1*y_dif));
                if(t[pp] > 0) t[v[k]]--;
                if(mt[np] > 0) mt[v[k]]--;
            }
            int tans = -1, mtans = -1;
            for(auto itr :t) tans += itr.second;
            for(auto itr : mt) mtans += itr.second;
            ans = min({ans,tans,mtans});
            
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main extends App {
  def read(e:Double,n:Double,angle:Double):(Double,Double) = {
    val Array(x,y) = readLine.split(",").map(_.toDouble)
    if(x==0 && y==0) (e,n)
    else read(e+x*Math.cos(Math.toRadians(angle)),n+x*Math.sin(Math.toRadians(angle)),angle-y)
  }
  val (e,n) = read(0,0,90)
  println(e.toInt)
  println(n.toInt)
}

Measured memory_bytes: 43980
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;
bool vis[100005];
int a[100005],ans,n,idx=1;
int main(){
	in(n);L(i,1,n+1)in(a[i]);
	while(idx!=2){
		if(vis[idx]){
			cout << -1 <<endl;
			return 0;
		}
		vis[idx]=1;
		idx=a[idx];
		ans++;
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            String S = in.next();
            String T = in.next();

            StringBuilder res = new StringBuilder();
            for (int i = 0; i < N; i++) {
                res.append(S.charAt(i));
                res.append(T.charAt(i));
            }

            System.out.println(res.toString());
        }
    }
}

Measured memory_bytes: 27060
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main()
{
  int A[3];
  REP(i,3)
    cin >> A[i];
  sort(A,A+3);
  if(A[0] == A[1])
    cout << A[2] << endl;
  else
    cout << A[0] << endl;
  
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        if(N==0){
            System.out.println(0);
            System.exit(0);
        }
        StringBuilder sb = new StringBuilder();
        int flag = 1;
        int pos = 0;
        while(N!=0){
            long cur = 1;
            for(int i=0;i<=pos;i++){
                cur *= 2;
            }
            if(N%cur!=0){
                sb.append(1);
                N -= flag*(cur/2);
            }
            else{
                sb.append(0);
            }
            pos++;
            flag *= -1;
        }
        System.out.println(sb.reverse().toString());
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
 
using namespace std;
 
int v[105]; 
 
int main(){
  int n,i,j;
  
  cin>>n;
  
  for(i=1;i<=9;i++) 
    for(j=i;j<=9;j++) 
      v[i*j]=1; 
  
  if(v[n])
    cout<<"Yes"; 
  else
    cout<<"No";
  
  return 0;
  }

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc146/tasks/abc146_d

/*

đồ thị duyệt (check visited) theo cạnh, nhưng bỏ vào & lấy ra queue là 1 pair gồm đỉnh và màu của cạnh đi từ u tới cạnh đang xét đó (vì đây là tree, nên giữa 2 đỉnh chỉ lun có 1 cạnh)
    0 là chưa visit

problem 1 : trùng cạnh
từ đỉnh v, đánh số các cạnh kề nó từ 1 trở lên, nhưng check thêm nếu nó trùng với cạnh u-v thì tăng lên 1 đơn vị

problem 2 : dùng số (đánh)

Note : Do bài này là cây nên BFS dùng đc

*/

#include <iostream>
#include <vector>

using namespace std;

#define MAX 100001

vector<pair<int, int> > graph[MAX];
int visited[MAX+1];

int ans = 0;

void DFS(int s, int old_color)
{
	int color = 0;
	for(int i = 0; i < graph[s].size(); i++)
	{
		pair<int, int> v = graph[s][i];
		if(visited[v.second] == 0)
		{
			color++;
			if(color == old_color)
				visited[v.second] = ++color;
			else
				visited[v.second] = color;
			DFS(v.first, color);
		}
	}

	ans = max(ans, color);
}

int main()
{
	int N;

	cin >> N;

	for(int i = 1; i <= N-1; i++)
	{
		int u, v;
		cin >> u >> v;

		graph[v].push_back(pair<int, int>(u, i));
		graph[u].push_back(pair<int, int>(v, i));
	}

	for(int i = 1; i <= N-1; i++)
	{
		visited[i] = 0;
	}

	DFS(1, 0);

	cout << ans << endl;
	for(int i = 1; i <= N-1; i++)
	{
		cout << visited[i] << endl;
	}

	return 0;
}

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

int main() {
    cout<< fixed << setprecision(100);
    while(true) {
        double n, a;
        cin >> n;
        if (n == 0) break;
        vector<double> scores(n);
        double sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a;
            sum += a;
            scores[i] = a;
        }
        double average = sum / n;
        double dispersion = 0;
        for (double j : scores) dispersion += (j - average) * (j - average);
        cout << sqrt(dispersion / n) << endl;
    }
}



Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>

using namespace std;


int main(){

  int n;
  cin >> n;
  int m[n + 1][n + 1], p[n + 1];

  for(int i = 0; i < n; i++){
    cin >> p[i] >> p[i + 1];
    m[i][i] = 0;
  }
  m[n][n] = 0;

  for(int l = 2; l <= n; l++){
    for(int i = 1; i <= n - l + 1; i++){
      int j = i + l - 1;
      m[i][j] = 1000000;
      for(int k = i; k < j; k++){
        m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1]*p[k]*p[j]);
      }
    }
  }

  cout << m[1][n] << endl;

  return 0;
}



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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
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;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ll MAX_V = 2e5 + 5;
vector<vector<ll>> G(MAX_V);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(MAX_V);//訪問したかどうか
vector<ll>a(MAX_V);
bool judgebuf=true;
ll dfs(ll k){
  t[k]=1;
  if(G[k].size()==1)return a[k];
  ll sumbuf=0;
  ll maxbuf=0;
  for(ll i=0;i<G[k].size();i++){
    if(t[G[k][i]]==0){
      auto p=dfs(G[k][i]);
      chmax(maxbuf,p);
      sumbuf+=p;
    }
  }
  ll x=sumbuf-a[k];
  if(x<0||x>a[k])judgebuf=false;
  ll limit=sumbuf-maxbuf;
  if(x>limit)judgebuf=false;
  //cout<<k spa a[k]-x<<endl;
  return a[k]-x;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  rep(i,0,n)cin>>a[i];
  for(ll i=0;i<n-1;i++){
    ll p,q;
    cin>>p>>q;
    G[p-1].push_back(q-1);
    G[q-1].push_back(p-1);
  }
  ll idx=-1;
  rep(i,0,n){
    if(G[i].size()>=2)idx=i;
  }
  if(n==2){
    ans2(a[0]==a[1]);
  }
  else{
    if(dfs(idx)!=0)judgebuf=false;
    ans2(judgebuf);
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	vector<ll> a(4, 0);
	int n;
	cin >> n;
	forn(i, 0, n - 1){
		ll x, y, z;
		cin >> x >> y >> z;
		vector<ll> at(4, 0);
		at[0] = max(a[1], a[2]) + x;
		at[1] = max(a[0], a[2]) + y;
		at[2] = max(a[0], a[1]) + z;
		a = at;
	}
	cout << max(a[0], max(a[1], a[2])) << "\n";
	return 0;
}

Measured memory_bytes: 256
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<stdlib.h>
#include	<string.h>
#include	<ctype.h>

#define		MXW		10+5
#define		MXT		1000+5

int		main(void)
{
	int		i;

	int		rst;
	char	W[MXW]={0};
	char	WU[MXW]={0};
	char	T[MXT]={0};
	char	TU[MXT]={0};


	//printf("%s\n",WU);

	rst = 0;
	scanf("%s",W);
	for( i=0; i<MXW; i++ )
	{
		WU[i] = toupper(W[i]);
	}
	/*
	printf("%d\n",strlen(W));
	printf("%d\n",strlen(WU));
	printf("%s\n",WU);
	*/

	while(1)
	{
		scanf("%s",T);
		if( strcmp("END_OF_TEXT",T) == 0 )
			break;

		for( i=0; i<MXT; i++ )
		{
			TU[i] = toupper(T[i]);
		}

		if( strcmp(WU, TU) == 0 )
		{
			rst+=1;
		}
	}

	printf("%d\n",rst);

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
    vi a(3);
    rep(i,3) cin >> a[i];
  	sort(all(a));
  	cout << a[2]-a[0] << endl;
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
<?php
$n = intval(trim(fgets(STDIN)));
fscanf(STDIN, "%d %d", $d, $x);
$a = [];
$ans = 0;
for ($tmp = 0; $tmp < $n; $tmp++){
    array_push($a, intval(trim(fgets(STDIN))));
}
for ($tmp = 0; $tmp < $n; $tmp++){
    $factor = 0;
    while ($factor*$a[$tmp]+1 <= $d){
        $ans++;
        $factor++;
    }
}
$ans += $x;
print("$ans\n");
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    string a,b,c,ans;
    cin >> a >> b >> c;
    a = a[0]-32;
    b = b[0]-32;
    c = c[0]-32;
    cout << a << b << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

#define r 6378.1

int main(){
  double a,b,c,d;

  while(true){
    scanf("%lf %lf %lf %lf" ,&a ,&b ,&c ,&d);
    if(a == -1 && b == -1 && c == -1 && d == -1){
      break;
    }

    a = a * M_PI / 180;
    b = b * M_PI / 180;
    c = c * M_PI / 180;
    d = d * M_PI / 180;

    double e = cos(a)*cos(b);
    double f = sin(b)*cos(a);
    double g = sin(a);
    double h = cos(c)*cos(d);
    double i = sin(d)*cos(c);
    double j = sin(c);

    double dist = acos(e*h + f*i + g*j);  

    printf("%d\n" ,(int)(r*dist+0.5));
  }

  return 0;
}

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

int main(){
    int n;cin>>n;
    string w[100];
    for(int i=0;i<n;i++){
        cin>>w[i];
    }

    string ans="Yes";
    for(int i=1;i<n;i++){
        if(w[i-1][w[i-1].size()-1]!=w[i][0]){
            ans="No";
            break;
        }
    }

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            if(w[i]==w[j]){
                ans="No";
                break;
            }
        }
    }

    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int N, Q, ans;
	
	cin >> N >> Q;
	
	string S;
	
	cin >> S;
	
	vector<int> l(Q), r(Q);
	
	for (int i = 0; i < Q; i++) {
		cin >> l[i] >> r[i];
	}
	
	vector<int> t(N, 0);
	
	for (int i = 0; i < N; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			t[i + 1] += t[i] + 1;
		}
		else {
			t[i + 1] = t[i];
		}
	}
	
	for (int i = 0; i < Q; i++) {
		cout << t[r[i] - 1] - t[l[i] - 1] << endl;
	}
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>A(N);
  vector<int>count(200001);
  set<int>r;
  for(int i=0;i<N;i++){
    cin>>A[i];
    count[A[i]]++;
    r.insert(A[i]);
  }

  int sum=0;
  int cnt=r.size()-K;
  if(cnt<=0){cout<<0<<endl;return 0;}
  sort(count.begin(),count.end());
 
  for(int i=0;i<200001;i++){
    if(cnt>0&&count[i]>0){sum+=count[i];cnt--;}
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 13892
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int d, g, ans = 100000;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d)cin >> p[i] >> c[i];
    for(int bit = 0; bit < (1<<d); bit++){
        int cnt = 0, now = 0, a[d];
        fill(a, a+d, 0);
        rep(i, d){
            if(bit & (1<<i))a[i]=1;
            else a[i]=0;
            if(a[i]){
                now += (i+1)*100*p[i]+c[i];   
                cnt += p[i];
            }
        }
        if(now >= g)ans = min(ans, cnt);
        else{
            int ma = 0;
            for(int i = d-1; i >= 0; i--){
                if(!a[i])ma = max(ma, i+1);
            }
            if(now+p[ma-1]*ma*100 < g);
            else {
                cnt += (g-now+ma*100-1)/(ma*100);
                ans = min(ans, cnt);
            }
        }
    }
    cout << ans << endl;
}


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

import sys
import os
from collections import defaultdict

n = int(input())
m = int(input())

# Map
M = defaultdict(list)

for i in range(m):
    a, b, c, d = list(map(int, input().split(',')))
    a -= 1
    b -= 1
    M[a].append((b, c))
    M[b].append((a, d))

s, g, V, P = list(map(int, input().split(',')))
s -= 1
g -= 1

def min_dist(Q, dists):
    min_v = float('inf')
    min_i = None

    for i in Q:
        if dists[i] < min_v:
            min_v = dists[i]
            min_i = i
    return min_v, min_i

def dijkstra(i, j, M):
    """return cost from i to j"""

    n = len(M)
    dists = [float('inf')] * n
    dists[i] = 0

    Q = [i for i in range(n)]
    while Q:
        min_dist_index = min_dist(Q, dists)[1]
        Q.remove(min_dist_index)

        for idx, cost in M[min_dist_index]:
            if dists[idx] > dists[min_dist_index] + cost:
                dists[idx] = dists[min_dist_index] + cost
    return dists[j]

res0 = dijkstra(s, g, M)
res1 = dijkstra(g, s, M)

print(V - P - res0 - res1)

Measured memory_bytes: 7956
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#define upzero(n) if (n < 0) n = 0
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
	int n;
	cin >> n;
	map<ll int, int> mp;
	for (int x = 1;x <= 100;x++) {
		for (int y = 1;y <= 100;y++) {
			for (int z = 1;z <= 100;z++) {
				ll int ans = (x * x) + (y * y) + (z * z) + (x * y) + (x * z) + (y * z);
				if (ans <= n) {
					mp[ans]++;
				}
			}
		}
	}
	for (int i = 1;i <= n;i++) cout << mp[i] << endl;
}

Measured memory_bytes: 4116
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a>=13) printf("%d\n", b);
    else if(a>=6) printf("%d\n", b/2);
    else printf("%d\n", 0);
    
    return 0;
}


Measured memory_bytes: 128
# include <bits/stdc++.h>
# define ll long long int
# define pb push_back
# define pf push_front
# define mpi make_pair
# define pi pair<ll,ll>
# define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
# define mod 1000000007
# define endl "\n"
using namespace std;
int main()
{
  fast
  priority_queue <double, vector<double>, greater<double> > pq;
  double n,a,b;
  cin>>n;
  for(ll i=0;i<n;i++)
  {
    ll x;
    cin>>x;
    pq.push(x);
  }
  while(pq.size()!=1)
  {
    a=pq.top();
    pq.pop();
    b=pq.top();
    pq.pop();
    pq.push((a+b)/2);
  }
  cout<<setprecision(6)<<pq.top();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define sum(a) accumulate(a.begin(),a.end(),0LL)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    //ll n = 1e5; vector<ll> a(1e5,1e9);
    
    ll suma = 0;
    for(long long i = 0; i < n; i++){
        suma += a[i];
        suma %= ll(1e9+7);
    }

    
    ll ans = 0;
    for(long long j = 0; j < n-1; j++){
        suma -= a[j];
        if(suma < 0) suma += 1e9+7;
        ans += (suma * a[j]);
        ans %= ll(1e9+7);
    }
    put(ans);
}

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    for (int i = 0;i < m;i++){
        cin >> a.at(i);
    }
    int cnt_up = 0;
    for (int i = x;i < n;i++){
        for (int j = 0;j < m;j++){
            if (i == a.at(j)){
                cnt_up++;
            }
        }
    }
    int cnt_down = 0;
    for (int i = x;i >= 0;i--){
        for (int j = 0;j < m;j++){
            if (i == a.at(j)){
                cnt_down++;
            }
        }
    }

    cout << min(cnt_up,cnt_down) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
using namespace std;

int main()
{
int r,g,b; cin>>r>>g>>b;
if((r*100+g*10+b)%4==0)
    cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> AC(N),WA(N);
  for(int i=0;i<M;i++){
    int p;
    string s;
    cin>>p>>s;
    p--;
    if(AC.at(p)){
      continue;
    }
    if(s=="AC"){
      AC.at(p)=1;
    }
    else{
      WA.at(p)++;
    }
  }
  int ACcount = 0;
  int WAcount = 0;
  for(int i=0;i<N;i++){
    ACcount+=AC.at(i);
    if(AC.at(i)){
      WAcount+=WA.at(i);
    }
  }
  cout<<ACcount<<" "<<WAcount<<endl;
  return 0;
}
  
      

Measured memory_bytes: 1024
N = int(input())
h = [int(_) for _ in input().split()]
dp = [0,abs(h[1]-h[0])]
for i in range(2,N):
    dp.append(min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2])))
print(dp[-1])

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

int main(void) {
	using namespace std;
	int N;
	cin >> N;
	map<int, int> m;
	for(int i = 0; i < N; ++i) {
		long long A;
		cin >> A;
		if(m.count(A) == 0) {
			m.insert(make_pair(A, 1));
		} else {
			++m.at(A);
		}
	}
	int res = 0;
	for(auto it = m.begin(); it != m.end(); ++it) {
		if(it->second % 2 != 0) ++res;
	}
	cout << res << '\n';
	return 0;
}



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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n, k;
  cin >> n >> k;
  vll a(n);
  rep(i, n) cin >> a[i];

  map<ll, ll> m;
  for (auto i : a) {
    m[i]++;
  }

  vll v;
  for (auto [a, b] : m) {
    v.push_back(b);
  }
  sort(all(v));

  if (v.size() <= k) {
    cout << 0 << endl;
  } else {
    cout << accumulate(v.begin(), v.begin() + (v.size() - k), 0ll) << endl;
  }

  return 0;
}


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

int main(){
    long int N,M,K; 
    cin >> N >> M >> K;
    vector<ll> A(N),B(M),S_A(N+1),S_B(M+1);
    for(int i=0;i<N;i++)cin >> A[i];
    for(int i=0;i<M;i++)cin >> B[i];
    for(int i=0;i<N;i++)S_A[i+1] = S_A[i]+A[i];
    for(int i=0;i<M;i++)S_B[i+1] = S_B[i]+B[i];
    S_B.push_back(1000000010);
    int ans = 0;
    for(int i=0;i<N+1;i++){
        ll rest = K-S_A[i];
        if(rest >= 0){
            int l=0,r=M+1,m;
            while(r-l>1){
                m = (l+r)/2;
                if(S_B[m]>rest)r = m;
                else l = m;
            }
            ans = max(ans,i+l);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 11140