akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N, Q;
    cin >> N >> Q;
    VVL G(N);
    rep(i, 0, N-1){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    VL cnt(N, 0);
    rep(i, 0, Q){
        ll p, x;
        cin >> p >> x;
        p--;
        cnt[p] += x;
    }

    queue<ll> que;
    VB seen(N, false);
    que.push(0);
    seen[0] = true;
    while(!que.empty()){
        auto q = que.front();
        que.pop();
        for(auto g : G[q]){
            if(seen[g]) continue;
            seen[g] = true;
            cnt[g] += cnt[q];
            que.push(g);
        }
    }

    rep(i, 0, N) cout << cnt[i] << " ";
    cout << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "yes" << endl;}
void no(){ cout << "no" << endl;}

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

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

  ll a, b;
  cin >> a >> b;
  ll d = a/b;
  ll r = a%b;
  ld f = (ld)a / (ld)b;
  cout << d << " " << r <<" " << f <<endl;



  return 0;
}






Measured memory_bytes: 3292
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
import java.io.InputStream;
import java.io.IOException;


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

    int N = sc.nextInt();
    int W = sc.nextInt();
    long[][] dp = new long[N + 1][W + 1];
    int[] weights = new int[N + 1];
    int[] values  = new int[N + 1];
    for (int i = 1; i <= N; i++) {
        weights[i] = sc.nextInt();
        values[i]  = sc.nextInt();
    }
    for (int j = 1; j <= W; j++) {
        dp[0][j] = 0;
    }
    for (int i = 1; i <= N; i++) {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= W; j++) {
            if (weights[i] <= j) {
                dp[i][j] = Math.max(values[i] + dp[i - 1][j - weights[i]], dp[i - 1][j]);
            } else {
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    System.out.println(dp[N][W]);
  }
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }

      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }

      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }

      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }

      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 132436
def dfs(v):
    visited[v]=1
    for i in range(n):
        if connect[v][i]==0:#接続していない
            continue
        if visited[i]==1:#既に訪問済み
            continue
        dfs(i)
n,m=map(int,input().split())
edge=[[int(i)for i in input().split()]for i in range(m)]
connect=[[0 for i in range(n)]for i in range(n)]
for i in range(m):
    connect[edge[i][0]-1][edge[i][1]-1]=1#接続状況を格納する配列
    connect[edge[i][1]-1][edge[i][0]-1]=1
visited=[0]*n#既にその頂点を訪問したか管理する配列
ans=0
for i in range(m):
    connect[edge[i][0]-1][edge[i][1]-1]=0
    connect[edge[i][1]-1][edge[i][0]-1]=0
    for j in range(n):
        visited[j]=0
    dfs(0)
    brdge=False
    for j in range(n):
        if visited[j]==0:
            brdge=True
    if brdge:
        ans+=1
    connect[edge[i][0]-1][edge[i][1]-1]=1
    connect[edge[i][1]-1][edge[i][0]-1]=1
print(ans)



Measured memory_bytes: 3188
A=int(input())+1
B=int(input())+1
C=int(input())+1
X=int(input())
ans=0
for i in range(0,A):
  for j in range(0,B):
    for k in range(0,C):
      tmp=i*500+j*100+k*50
      if(tmp==X):
        ans=ans+1
print(ans)

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

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  for(int i=1;i<=n;i++){
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define ll           long long
#define all(v)       (v).begin() , (v).end()
#define vi           vector <ll>
#define vii          vector <pair<ll,ll>>
#define ii           pair<ll,ll>
#define sz(v)	     ((int)((v).size()))
#define lp(i,a,b)    for(int i=a;i<b;i++)
#define pb           push_back
#define pf           push_front
#define F            first
#define S            second
#define endl         "\n"
#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const double PI = 3.14159265358979323846;
const ll inf=2e9,MOD=1e9+7,MAX=1e5+2;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    IOS;
    int n;
    cin>>n;
    string s=to_string(n);
    lp(i,0,sz(s)){
        if(s[i]=='1')
            s[i]='9';
        else if(s[i]=='9')
            s[i]='1';
    }
    cout<<s;
}


Measured memory_bytes: 3648
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto s = readln.chomp.to!(char[]);
    auto K = readln.chomp.to!int;
    foreach (ref c; s) {
        if (c == 'a') continue;
        int i = c-'a';
        if (K < 26-i) continue;
        c = 'a';
        K -= 26-i;
    }
    if (K) {
        s[$-1] = ('a' + ((s[$-1] - 'a').to!int + K) % 26).to!char;
    }
    writeln(s);
}

Measured memory_bytes: 2584
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n, k = map(int, input().split())
    c = list(map(int, input().split()))

    ans = 10 ** 15
    for i in range(n-k+1):
        if c[i+k-1] <= 0:
            t = abs(c[i])
        elif c[i] < 0 < c[i+k-1]:
            t = min(abs(c[i]), abs(c[i+k-1])) + abs(c[i+k-1]-c[i])
        else:
            t = c[i+k-1]

        ans = min(ans, t)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14252
X,Y,A,B,C = map(int,input().split())
R = list(map(int,input().split()))
G = list(map(int,input().split()))
T = list(map(int,input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
R = R[:X]
G = G[:Y]
A = T+R+G
A.sort(reverse=True)
print(sum(A[:X+Y]))

Measured memory_bytes: 22560
x, y = map(int, raw_input().strip().split())

if x * y > 0:
	if x <= y:
		print abs(y - x)
	else:
		print abs(y - x) + 2
elif x * y == 0:
	if x <= y:
		print abs(y - x)
	else:
		print abs(y - x) + 1
else:
	print abs(x + y) + 1


Measured memory_bytes: 2568
n,k = map(int,input().split()) #入力
a = list(map(int,input().split())) #使用不可の数字
b = {0,1,2,3,4,5,6,7,8,9}-set(a) #使用可能な数字の集合
while set([int(i) for i in list(str(n))])-b !=set() : # 使用可能な数字のみでなければ
    n += 1
print(n)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int n,a[59],j,sum=0;
	cin>>n;
	cin>>a[0];
	for(int i=1;i<n;i++)
	{
		cin>>a[i];
		for(j=0;j<i;j++)
		{
			sum=sum+a[i]*a[j];
		}
	}
	cout<<sum;
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define AC(x,t) accumulate(ALL(x),t)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{   int a, b;
    cin >> a >> b;
    cout << ( a % 3 == 0 || b % 3 == 0 || ( a + b ) % 3 == 0 ? "Possible" : "Impossible" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

long gcd[201][201];
int main()
{
  long K;
  cin >> K;

   long i;
   long result;
   long a,b,c;

   for (a=1;a<=K;a++) {
    gcd[a][1] = 1;
    gcd[a][0] = a;
    gcd[1][a] = 1;
    gcd[0][a] = a;
   }
   for (a=1;a<=K;a++) {
     gcd[a][a] = a;
     for (b=1;b<a;b++) {
       gcd[a][b] = gcd[b][a-b];
       gcd[b][a] = gcd[a][b];
     }
  }


   result = 0;
   for (a=1;a<=K;a++)
    for (b=1;b<=K;b++)
      for (c=1;c<=K;c++)
        result += gcd[a][gcd[b][c]];
   cout << result << endl;
  return 0;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  vector<ll> left(n+1,0), right(n+1,0);
  REP(i,n){
    left[i+1] = max(left[i],a[i]);
    right[i+1] = max(right[i],a[n-1-i]);
  }
  REP(i,n){
    cout << max(left[i],right[n-1-i]) << endl;
  }
}



Measured memory_bytes: 6272
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;
 
double heronsMethod(double a, double b, double c){
    double s = (a + b + c) / 2;
    return sqrt(s * (s - a) * (s - b) * (s - c));
}
 
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        double x1, x2, x3, y1, y2, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        double a = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        double b = sqrt((x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3));
        double c = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
        double s = heronsMethod(a, b, c);
        double x = (a*a * (b*b + c*c - a*a) *x3 + b*b * (c*c + a*a - b*b) *x1 + c*c *(a*a + b*b - c*c) *x2) / (16 * s * s);
        double y = (a*a * (b*b + c*c - a*a) *y3 + b*b * (c*c + a*a - b*b) *y1 + c*c *(a*a + b*b - c*c) *y2) / (16 * s * s);
        double r = (a * b * c) / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
        printf("%.3f %.3f %.3f\n", x, y, r);
    }
}

Measured memory_bytes: 1232
import java.util.*;
import java.lang.*;

public class Main{
    
    static int n;
    static int X;
    static int[] x;
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        X = sc.nextInt();
        x = new int[n + 1];
        int[] interval = new int[n];
        
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        x[n] = X;
        
        Arrays.sort(x);
        
        int imin = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            interval[i] = x[i + 1] - x[i];
            if (interval[i] < imin) {
                imin = interval[i];
            }
        }
        
        int j = 0;
        boolean isgcd = false;
        while(j <= imin - 1) {
            for (int i = 0; i < n; i++) {
                if (interval[i] % (imin - j) != 0) {
                    break;
                }
                if (i == n - 1) {
                    isgcd = true;
                }
            }
            if (isgcd) break;
            j++;
        }
        System.out.println(imin - j);
    }
}

Measured memory_bytes: 59656
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    bool check(int v) {
        for (int i = 0; i * i <= v; ++i) {
            if (i * i == v)
                return true;
        }
        return false;
    }


    void solve() {
        input();
        int N, D;
        cin >> N >> D;
        vector<vector<int>> vv(N, vector<int>(D));
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < D; ++j) {
                cin >> vv[i][j];
            }
        }

        int ans = 0;
        for (int i = 0; i < N; ++i) {
            for (int j = i + 1; j < N; ++j) {
                int tmp = 0;
                for (int k = 0; k < D; ++k) {
                    tmp += abs(vv[i][k] - vv[j][k]) * abs(vv[i][k] - vv[j][k]);
                }
                if (tmp > 0 && check(tmp))
                    ans++;
            }
        }
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define int long long
using namespace std;
int a, b, c, d, e, f;

signed main()
{
	cin >> a >> b >> c;
	int mind = min(b - 1, c);
	cout << a * mind / b;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define T 3.305785
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int a, b;
	cin >> a >> b;
	printf("%6lf\n", a*b/T);

	return 0;
}

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

int main(){
  int n;
  cin >> n;
  if(n < 1000) puts("ABC");
  else puts("ABD");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define DEBUG
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
constexpr ll MOD = 1e9 + 7;
constexpr int mxH = 1e5;
constexpr int mxW = 1e5;
constexpr int mxCh = mxH + mxW;
int h, w, a ,b;

ll facto_mod[mxCh + 1];
ll inverse_facto_mod[mxCh + 1];
int first_half, second_half;

template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}
ll pow_mod(ll a , ll p, ll MOD){
    if( p < 2){
        ll ans = 1;
        while(p--){
            ans =  (ans * a) % MOD;
        }
        return ans;
    }else{
        if( p % 2){
            ll ans = pow_mod(a, p / 2, MOD);
            ans = (ans * ans) % MOD;
            ans = (a * ans) % MOD;
            return ans;
        }else{
            ll ans = pow_mod(a , p /2, MOD);
            ans = (ans * ans) % MOD;
            return ans;
        }
    }
}
void cal_facto_mod(){
    facto_mod[0] = 1;
    ll ans = facto_mod[0];
    for(int i = 1 ; i < mxCh + 1; i++){
        ans = ans * i ;
        if( ans >= MOD){
            ans = ans % MOD;
        }
        facto_mod[i] = ans;
    }
}

void cal_inverse_facto_mod(){
    ll last_factor = pow_mod(facto_mod[mxCh], MOD - 2, MOD );
    inverse_facto_mod[mxCh] = last_factor;
    for(int i = mxCh -1 ; i >= 0; i--){
        last_factor = last_factor * ( i + 1);
        if( last_factor >= MOD){
            last_factor = last_factor % MOD;
        }
        inverse_facto_mod[i] = last_factor;
    }
}

ll combination(ll n,ll r){
    ll ans = facto_mod[n] * inverse_facto_mod[r];
    if( ans >= MOD){
        ans = ans % MOD;
    }
    ans = ans * inverse_facto_mod[n - r];
    if(ans >= MOD){
        ans = ans % MOD;
    }
    return ans;
}

void solve(){
    cin >> h >> w >> a >> b;
    first_half = h - 1 - a;
    second_half = a - 1; 
    cal_facto_mod();
    cal_inverse_facto_mod();
    ll ans = 0;
    for( int i = b ; i < w ; i++){
        ans = ans + combination( first_half + i, first_half) * combination( second_half + w - 1 -i, second_half);
        if(ans >= MOD){
            ans = ans % MOD;
        }
    }
    cout << ans << endl;
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

// MY CP mistakes :
// Have some resistance working with inverse mod
// Don't have much experience with nCr
// Messed up with when include and exclude boundary


Measured memory_bytes: 6676
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int y[3];
    cin>>y[0]>>y[1]>>y[2];
    sort(y,y+3);
    cout<<y[0]+y[1]<<endl;
    return 0;
}


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

const int MAX_X = 1e3 + 10;
const ll INF = 1e14;

int main(){
    ll X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y) , C(Z);
    rep(i, X) cin >> A[i];
    rep(i, Y) cin >> B[i];
    rep(i, Z) cin >> C[i];

    vector<ll> D;
    priority_queue<ll> PQ;
    rep(i, X) rep(j, Y) D.push_back(A[i] + B[j]);
    sort(D.begin(), D.end(), greater<ll>());
    D.resize(min(X * Y, K));
    ll W = D.size();
    rep(i, W) rep(j, Z) PQ.push(D[i] + C[j]);

    rep(i, K){
        ll ans = PQ.top(); PQ.pop();
        cout << ans << endl;
    }

}


Measured memory_bytes: 43240
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,c,d;
  long long int prod1,prod2,prod3,prod4;
  long long int max1,max2;
  cin>>a>>b>>c>>d;
  prod1 = a*c;
  prod2 = b*c;
  prod3 = a*d;
  prod4 = b*d;
  max1 = max(prod1,prod2);
  max2 = max(prod3,prod4);
  cout<<max(max1,max2);
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
  int i, j, hit, blow;
  char r[4], a[4];

  while(1) {
    hit = 0;
    blow = 0;
    scanf("%s %s", r, a);

    if(r[0] == '0' && a[0] == '0') break;

    for(i = 0; i < 4; i++) {
      for(j = 0; j < 4; j++) {
	if(r[i] == a[j]) {
	  if(i == j) hit++;
	  else blow++;
	}
      }
    }

    printf("%d %d\n", hit, blow);
  }

  return 0;
}

Measured memory_bytes: 536
#include<bits/stdc++.h>
using namespace std;
long long int n;
int main(){
	char c[50];
	scanf("%lld",&n);
	long long int a,b,i,j,k,l,sum=0,re=26,cnt=1;
	while(n){
		a=n%re;
		if(a==0)a=re;
		b=a/(re/26);
		c[cnt++]=b+'a'-1;
		n-=a;
		re*=26;
	}
	cnt--;
	for(i=cnt;i>0;i--)cout<<c[i];
}

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

int main() {
	int n;
	int i = 1;
	int x = 1;
	int mark = 0;

	cin >> n;
		do {
			if(mark == 0)
				x = i;
			if (x % 3 == 0 && mark == 0) {
				cout << " " << i;
				continue;
			}
			else
			{
				do {
					if (x % 10 == 3)
					{
						cout << " " << i;
						mark = 0;
						break;
					}
					x /= 10;
				} while (x);
			}
		} while (++i <= n);


	cout << endl;

	return 0;
}

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

int digit(int n, int j){
    int N[10];
    int i=1;
    while(n>0){
        N[i]= n%10;
        n /= 10;
        i++;
    }
    return N[j];
}

int main(){
    int A, B, N, count=0;
    cin >> A >> B;
    for(N=A; N<=B; N++){
        if(digit(N, 1)==digit(N, 5) && digit(N, 2)==digit(N, 4)){
            //cout << N << " aaa" << endl;
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  

  int32_t main()
  {         
    

      IOS

      
      int x,y;
      cin>>x>>y;
      if(x<=8 and y<=8)
      {
        cout<<"Yay!";
      }      
      else
      {
        cout<<":(";
      }


  }           

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
		int c_ac=0, c_wa=0, c_tle=0, c_re=0;
	int t;
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		
		if(s =="AC") c_ac++;
		if(s== "WA") c_wa++;
		if(s=="TLE" ) c_tle++;
		if(s== "RE") c_re++;
	}
	cout<<"AC x "<<c_ac<<endl;
		cout<<"WA x "<<c_wa<<endl;
			cout<<"TLE x "<<c_tle<<endl;
				cout<<"RE x "<<c_re<<endl;
	return 0;

}



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

const int N = 100010;

int n, k;
int f[N], a[N];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 2; i <= n; ++i) {
		f[i] = 0x3f3f3f3f;
		if(i >= 2) f[i] = min(f[i], f[i - 1] + abs(a[i] - a[i - 1]));
		if(i >= 3) f[i] = min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
	}
	printf("%d\n", f[n]);
}

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

typedef long long ll;
const int mod = 1e9 + 7;
string S;

ll N;
vector<ll> A;

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];

    ll abs_min = 1e10;
    ll minus_cnt = 0;
    ll zero_cnt = 0;

    ll ans = 0;
    rep(i, N) {
        if (A[i] < 0) {
            ans += -A[i];
            minus_cnt++;
        } else if (A[i] > 0) {
            ans += A[i];
        } else {
            zero_cnt++;
        }

        abs_min = min(abs(A[i]), abs_min);
    }
    if (minus_cnt % 2 == 1 && zero_cnt < 1) {
        ans -= 2 * abs_min;
    }
    // cout << minus_cnt << endl;
    // cout << minus_max << endl;
    // cout << zero_cnt << endl;

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) (a<<b)
#define Rshift(a,b) (a>>b)
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;

int in[10001];


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    int i, sum(0);
    rep(i, n) {
        cin >> in[i];
        sum += in[i];
    }
    sort(in, in+i);
    int choosed = in[n - m];
    if (choosed * 4 * m < sum) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(int)
n = int(input())
s = [input() for _ in range(n)]

for tmp in s:
    tmp =sorted(tmp)
    tmp = "".join(tmp)
    d[tmp] += 1

result = 0
for c in d.values():
    result += c*(c-1) // 2

print(result)

Measured memory_bytes: 25332
from collections import Counter

N = int(input())
A = Counter(list(map(int, input().split())))

nums = [0, 0]

for key, value in A.items():
    if value < 2:
        continue
    if nums[0] < key:
        nums[0] = key
        value -= 2

    if value >= 2 and nums[1] < key:
        nums[1] = key

    nums.sort()
print(nums[0]*nums[1])

Measured memory_bytes: 18600
import os, sys, re, math

N = int(input())
(T, A) = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

best_diff = 1000
best_index = 0

for i in range(N):
    t = T - H[i] * 0.006
    diff = abs(t - A)
    if diff < best_diff:
        best_index = i
        best_diff = diff

print (best_index + 1)   


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ls  (n<<1)
#define rs  (ls|1)
using namespace std;

const int N=100010;
struct edge{int s,t,n;}e[2*N],E[N];
int n,h[N],f[N],g[N],siz[N],hs[N],dfn[N],dep[N],t1[4*N],t2[4*N],tag[4*N];
set <int> S[4*N];

void dfs(int x,int fa)
{
	f[x]=fa,siz[x]=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=fa)
			{
				dfs(y,x),siz[x]+=siz[y];
				if (siz[y]>siz[hs[x]])  hs[x]=y;
			}
}

void dfs2(int x,int gf)
{
	g[x]=gf,dfn[x]=++dfn[0],dep[x]=dep[f[gf]]+1;
	if (hs[x])  dfs2(hs[x],gf);
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if ((y!=f[x])&&(y!=hs[x]))  dfs2(y,y);
}

void merge(int n)
{
	if (t1[ls]<t1[rs])  t1[n]=t1[ls],t2[n]=min(t2[ls],t1[rs]);
	else  if (t1[ls]>t1[rs])  t1[n]=t1[rs],t2[n]=min(t2[rs],t1[ls]);
	else  t1[n]=t1[ls],t2[n]=min(t2[ls],t2[rs]);
	t1[n]+=tag[n],t2[n]+=tag[n];
}

void modify(int n,int l,int r,int L,int R,int k)
{
	if ((L<=l)&&(r<=R))
		{
			if (k>0)  S[n].insert(k),t1[n]++,t2[n]++,tag[n]++;
			else  S[n].erase(-k),t1[n]--,t2[n]--,tag[n]--;
		}else
		{
			int mid=(l+r)>>1;
			if (L<=mid)  modify(ls,l,mid,L,R,k);
			if (mid<R)  modify(rs,mid+1,r,L,R,k);
			merge(n);
		}
}

int find(int n,int l,int r)
{
	if (S[n].size())  return *S[n].begin();
	int mid=(l+r)>>1;
	return (t1[ls]==1)||(t2[ls]==1)?find(ls,l,mid):find(rs,mid+1,r);
}

void modify(int x,int y,int k)
{
	while (g[x]!=g[y])
		{
			if (dep[x]<dep[y])  swap(x,y);
			modify(1,1,n,dfn[g[x]],dfn[x],k),x=f[g[x]];
		}
	if (dfn[x]>dfn[y])  swap(x,y);
	if (x!=y)  modify(1,1,n,dfn[x]+1,dfn[y],k);
}

void work()
{
	scanf("%d",&n);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	for (int i=1; i<n; i++)  scanf("%d %d",&E[i].s,&E[i].t);
	dfs(1,0),dfs2(1,1),memset(t2,127,sizeof(t2));
	for (int i=1; i<n; i++)  modify(E[i].s,E[i].t,i);
	for (int i=1,j; i<n; i++)
		if (t2[1]==1)  j=find(1,1,n),modify(E[j].s,E[j].t,-j);
		else  puts("NO"),exit(0);
	puts("YES");
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 132608
(defvar *n* (read))
(defvar *m* (read))
(defvar *x* (read))
(defvar *y* (read))

(defun set-lst (n)
  (let ((lst (list nil)))
    (dotimes (x n)
      (let ((tmp (read)))
        (push tmp lst)))
    (cdr (reverse lst))))

(defvar *x-n* (nth 0 (sort (set-lst *n*) #'>)))
(defvar *y-m* (nth 0 (sort (set-lst *m*) #'<)))

(defun calc (x y z)
  (cond ((and (< x z) (>= y z) (< *x* z) (>= *y* z))
         t)
        ((> z *y*)
         nil)
        (t (calc x y (1+ z)))))


(if (calc *x-n* *y-m* (1+ *x*))
    (princ "No War")
    (princ "War"))

Measured memory_bytes: 4196
#include <iostream>
#include <unordered_set>

int main() {
  int N, temp;
  std::cin >> N;
  
  std::unordered_set<int> set;
    
  while (std::cin >> temp) {
    if (set.count(temp)) {
      std::cout << "NO\n";
      return 0;
    }
    set.insert(temp);
  }
  std::cout << "YES\n";
}

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

int main(){
   int a;
  cin >> a;
  vector<string> x(a);
  for(int i = 0;i < a;i++){
    cin >> x.at(i);
  }
  map<string, int> z;
  for(int i = 0;i < a;i++){
    string g = x.at(i);
    if (z.count(g)) {
      z[g]++;
        }
    else{z[g] = 1;}
  }
  set<string> d;
    int c = 0;
  for(int i = 0;i < a;i++){
    string g = x.at(i);
    if(z[g] > c){
      c = z[g];
    }
  }
  for(int i = 0;i < a;i++){
    string g = x.at(i);
    if(z[g] == c){
      d.insert(g);
    }
  }

    for (auto value : d) {
  cout << value << endl;
}   
}

Measured memory_bytes: 36096
import itertools
N = int(input())
d = {'M':0 ,'A':0 ,'R':0 ,'C':0 ,'H':0}
for i in range(N):
    S = input()
    if S[0] in d:
        d[S[0]] += 1

ans = 0
for i, j, k in itertools.combinations(d.keys(), 3):
    ans += d[i] * d[j] * d[k]

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  for (int i=0; i<N; i++) {
    if (a[a[i]-1]==i+1) ans++;
  }
  cout << ans/2 << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
typedef long long ll;
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
#define MOD 1000000007
#define EPS 10e-8

void preorder_tree_walk(ll root[40][3],ll parent[],ll i){
    cout <<" "<< i;
    if(root[i][0]!=-1){
        preorder_tree_walk(root,parent,root[i][0]);
    }
    if(root[i][1]!=-1){
        preorder_tree_walk(root,parent,root[i][1]);
    }
}

void inorder_tree_walk(ll root[40][3],ll parent[],ll i){
    if(root[i][0]!=-1){
        inorder_tree_walk(root,parent,root[i][0]);
    }
    cout <<" "<< i;
    if(root[i][1]!=-1){
        inorder_tree_walk(root,parent,root[i][1]);
    }
}

void postorder_tree_walk(ll root[40][3],ll parent[],ll i){
    if(root[i][0]!=-1){
        postorder_tree_walk(root,parent,root[i][0]);
    }
    if(root[i][1]!=-1){
        postorder_tree_walk(root,parent,root[i][1]);
    }
    cout <<" "<< i;
}


int main(){
    ll N,t,x,parent[40];
    rep(i,40){
        parent[i]=-1;
    }
    cin >> N;
    ll root[40][3];
    // 各点に親と子の情報のみ持たせる
    rep(i,N){
        cin >> x;
        rep(j,2){
            cin >> t;
            if(t!=-1){
                parent[t] = x;
            }
            root[x][j]=t;
        }
    }

    rep(i,N){
        if(parent[i]==-1){
            cout << "Preorder" <<endl;
            preorder_tree_walk(root,parent,i);
            cout << endl;
            cout << "Inorder" <<endl;
            inorder_tree_walk(root,parent,i);
            cout << endl;
            cout << "Postorder" <<endl;
            postorder_tree_walk(root,parent,i);
            cout << endl;
        }
    }
}


Measured memory_bytes: 3100
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = LI()
    a = [0]*(n+1)
    a[p[0]] += 1
    a[p[1]] += 1
    a[p[2]] += 1
    ans = 0
    if sum(a[:p[1]]) == 1:
        ans += 1
    for i in range(2,n-1):
        a[p[i-2]] -= 1
        a[p[i+1]] += 1
        if sum(a[:p[i]]) == 1:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define mt make_tuple
using namespace std;

const int N = 100005;

int n;
vector<int> graph[N];
int leaf[N];

int dfs(int v = 0, int f = 0) {
	int lcnt = 0;
	for (int to : graph[v]) if (to != f) {
		int res = dfs(to, v);
		if (res == 2) return 2;
		if (res == 1) lcnt++;
	}
	if (lcnt == 0) return 1;
	if (lcnt > 1) return 2;
	return 0;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i + 1 < n; i++) {
		int a, b; scanf("%d%d", &a, &b); a--, b--;
		graph[a].eb(b);
		graph[b].eb(a);
	}
	int ans = dfs();
	if (ans) puts("First");
	else puts("Second");
	return 0;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P{ P(int x, int y) : x(x), y(y) {} double x, y; };

void rec(vector<vint>& f, P p)
{
	f[p.y][p.x] = 0;

	for(int i = -3; i <= 3; i++)
	{
		if(0 <= p.y + i && p.y + i < 8 && f[p.y + i][p.x]) rec(f, P(p.x, p.y + i));
		if(0 <= p.x + i && p.x + i < 8 && f[p.y][p.x + i]) rec(f, P(p.x + i, p.y));
	}
}


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

	rep(i, n)
	{
		vector<vint> f(8, vint(8));

		rep(i, 8)
		{
			string line;
			cin >> line;

			rep(j, 8)
				f[i][j] = line[j] - '0';
		}

		P p(0, 0);
		cin >> p.x >> p.y; p.x--, p.y--;

		rec(f, p);

		cout << "Data " << i + 1 << ":" << endl;
		rep(i, 8)
		{
			rep(j, 8)
				cout << f[i][j];
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

bool sosuu(int i, vector<int> &prime){
    if(prime.at(i)!=-1) return(prime.at(i));
    bool k=false;
    for(int j=2;j*j<=i;j++){
        if(i%j==0){k=true; break;}
    }
    if(k){prime.at(i)=0; return(false);}
    prime.at(i)=1; return(true);
}

bool like(int i, vector<int> &prime){
    if(i%2==0) return(false);
    if(sosuu(i,prime) && sosuu((i+1)/2,prime)) return(true);
    return(false);
}

int main(){
    int p=100005;
    vector<int> memo(p+1);
    vector<int> prime(p+1,-1);
    prime.at(1)=0;
    rep(i,p){
        memo.at(i+1)=memo.at(i);
        if(like(i+1,prime)) memo.at(i+1)++;
    }
    int q;
    cin>>q;
    rep(i,q){
        int l,r;
        cin>>l>>r;
        cout<<memo.at(r)-memo.at(l-1)<<endl;
    }
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdlib>
#include<utility>
#include<tuple>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<queue>
#include<deque>
#include<bitset>
#include<cmath>
#include<map>
using namespace std;
using ll = long long int;
const ll mod = 1e9 + 7;

int main() {

	string s;

	cin >> s;

	if (s == "SUN") cout << 7 << endl;
	else if (s == "MON") cout << 6 << endl;
	else if (s == "TUE")cout << 5 << endl;
	else if (s == "WED") cout << 4 << endl;
	else if (s == "THU")cout << 3 << endl;
	else if (s == "FRI")cout << 2 << endl;
	else if (s == "SAT")cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 200010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e18 + 7;


int main (){
    ios_base::sync_with_stdio(false);
    ll n, ta, aoki, a, t;

    cin >> n;
    cin >> ta >> aoki;

    for (int i=0; i<n-1; i++){
        cin >> t >> a;
        ll div = max((ta-1)/t + 1, (aoki - 1)/a + 1);
        ta = t*div;
        aoki = a*div;
    }

    cout << ta + aoki << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
#include <time.h>
#include <functional>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int N_ = 100500;

int N;
int A[N_]; ll S[N_];
char op[N_];

ll ans;

int main() {
  scanf("%d", &N);
  for(int i = 1; i <= N-1; i++) {
    char s[2];
    scanf("%d%s", &A[i], s);
    S[i] = S[i-1] + A[i];
    op[i] = *s;
  }
  scanf("%d", &A[N]);
  S[N] = S[N-1] + A[N];

  int j = N;
  for(int i = N-1; i > 0; i--) {
    if(op[i] == '+') {
      ans += A[i+1];
    }else {
      ans = max(ans, S[N] + S[i+1] - 2 * S[j]) - A[i+1];
      j = i;
    }
  }

  ans += A[1];
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    unsigned long long  n,m;
    cin >> n >> m;
    if(m <= n*2){
        cout << m/2 << endl;
    }else{
        cout << n + (m-n*2)/4 << endl;
    } 
    return 0;
}

Measured memory_bytes: 256
from itertools import product 

T = input()

for pm in product(["+", "-"], repeat = 3):
  if eval(T[0]+pm[0]+T[1]+pm[1]+T[2]+pm[2]+T[3]) == 7:
    print(T[0]+pm[0]+T[1]+pm[1]+T[2]+pm[2]+T[3]+"=7")
    exit()


Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int n, i;

    cin >> n >> i;

    cout << (n - i) + 1 << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;

int main(void)
{
    //string a,b;
    int a,b,c,d;
    int i=0;
    //char a,b='.';
    cin>>a>>b;
    if(a%500>b) cout<<"No";
    else cout<<"Yes";
    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll p[11], c[11];
ll all[11];
bool comp[11];

int main()
{
	ll D, G;
	cin >> D >> G;
	for (int i = 0; i < D; i++) {
		cin >> p[i] >> c[i];
		all[i] = 100 * (i + 1) * p[i] + c[i];
	}
	int ans = mod;
	for (int i = 0; i < (1 << D); i++) {
		int num = 0;
		ll score = 0;
		int bit = i;
		for (int j = 0; j < D; j++) {
			comp[j] = false;
		}
		for (int j = 0; j < D; j++) {
			if (bit % 2 == 1) {
				comp[j] = true;
				score += all[j];
				num += p[j];
			}
			bit /= 2;
		}
		//cout << score << endl;
		if (score < G) {
			ll diff = G - score;
			for (int j = D - 1; j >= 0; j--) {
				if (!comp[j]) {
					ll get = (j + 1) * 100;
					if (get * p[j] >= diff) {
						num += (diff + (get - 1)) / get;
					}
					else {
						num = mod;
					}
					break;
				}
			}
		}
		ans = min(ans, num);
		//cout << num << endl;
	}
	cout << ans << endl;
}


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

using namespace std;

const int N = 1e5 + 7;

int n, a[N], dem;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    a[0] = 1023123;
    for (int i = 1; i <= n; i++){
        if (a[i] == i){
            dem++;
            if (a[i - 1] == i - 1){
                dem--;
                swap(a[i], a[i - 1]);
            }
        }
    }
    cout << dem;
}


Measured memory_bytes: 640
import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    private static Scanner sc = new Scanner(new BufferedInputStream(System.in));

    public static void main(String[] args) {
        String s1 = sc.nextLine();
        String s2 = sc.nextLine();
        if (s1.length() + 1 == s2.length() && s1.equals(s2.substring(0, s1.length()))) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int t[40000],u[40000],v[40000];
#define B 200

class UnionFind {
	vector<int>par, sz;
public:
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};

multiset<int>E[40000];
int d[40000];

int main(){
	int n,k;scanf("%d%d",&n,&k);
	rep(i,k){
		scanf("%d%d%d",&t[i],&u[i],&v[i]);
	}
	set<P>se;
	for(int i=0;i<k;i+=B){
		set<P>s2,s3;
		for(int j=i;j<k&&j-i<B;j++){
			if(t[j]==2){
				if(se.count(P(u[j],v[j]))){
					se.erase(P(u[j],v[j]));
					s3.insert(P(u[j],v[j]));
				}
			}
		}
		UnionFind uf(n);
		for(auto p:se)uf.unite(p.first,p.second);
		rep(j,n)E[j].clear();
		for(auto p:s3){
			E[uf.find(p.first)].insert(uf.find(p.second));
			E[uf.find(p.second)].insert(uf.find(p.first));
		}
		for(int j=i;j<k&&j-i<B;j++){
			if(t[j]==1){
				s2.insert(P(u[j],v[j]));
				u[j]=uf.find(u[j]);v[j]=uf.find(v[j]);
				E[u[j]].insert(v[j]);
				E[v[j]].insert(u[j]);
			}
			else if(t[j]==2){
				s2.erase(P(u[j],v[j]));
				u[j]=uf.find(u[j]);v[j]=uf.find(v[j]);
				E[u[j]].erase(E[u[j]].find(v[j]));
				E[v[j]].erase(E[v[j]].find(u[j]));
			}
			else{
				memset(d,0,sizeof(d));
				queue<int>que;
				d[uf.find(u[j])]=1;
				que.push(uf.find(u[j]));
				while(!que.empty()){
					int p=que.front();que.pop();
					for(int v:E[p]){
						if(d[v]==0){
							d[v]=1;que.push(v);
						}
					}
				}
				if(d[uf.find(v[j])]==1)puts("YES");
				else puts("NO");
			}
		}
		for(auto p:s2)se.insert(p);
	}
}

Measured memory_bytes: 7344
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

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

    vector<int> odd;
    vector<int> even;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(i % 2 == 0){
            even.push_back(x);
        }else{
            odd.push_back(x);
        }
    }

    if((n - 1) % 2 == 0){
        for(int i = even.size() - 1; i >= 0; i--){
            cout << even[i] << " ";
        }
        for(int i = 0; i < odd.size(); i++){
            cout << odd[i] << " ";
        }
    }else{
        for(int i = odd.size() - 1; i >= 0; i--){
            cout << odd[i] << " ";
        }
        for(int i = 0; i < even.size(); i++){
            cout << even[i] << " ";
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 3316