akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

string s;
int n, dp[100000][4];

int f(int k, int u)
{
    if (k == n)
        return u == 3;
    if (dp[k][u] != -1)
        return dp[k][u];

    int sol = 0;
    if (s[k] == '?')
    {
        // A
        if (u == 0)
            adds(sol, f(k + 1, 1));
        adds(sol, f(k + 1, u));

        // B
        if (u == 1)
            adds(sol, f(k + 1, 2));
        adds(sol, f(k + 1, u));

        // C
        if (u == 2)
            adds(sol, f(k + 1, 3));
        adds(sol, f(k + 1, u));
    }
    if (s[k] == 'A')
    {
        if (u == 0)
            adds(sol, f(k + 1, 1));
        adds(sol, f(k + 1, u));
    }
    if (s[k] == 'B')
    {
        if (u == 1)
            adds(sol, f(k + 1, 2));
        adds(sol, f(k + 1, u));
    }
    if (s[k] == 'C')
    {
        if (u == 2)
            adds(sol, f(k + 1, 3));
        adds(sol, f(k + 1, u));
    }

    return dp[k][u] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    n = s.size();
    memset(dp, -1, sizeof dp);
    cout << f(0, 0);
}


Measured memory_bytes: 6736
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim();
  var S = Number(inputs);
  var h = Math.floor(S / 3600);
  var m = Math.floor((S - (h * 3600)) / 60);
  var s = S % 60;
  console.log([h,m,s].join(':'));
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15516
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,PS[li];
int cev;
string s;
map<int,int> mpp;
vector<int> v;
 
main(void){
	scanf("%lld %lld",&n,&k);
	FOR{
		scanf("%lld",&a[i]);
		PS[i]=PS[i-1]+a[i];
	}
	mpp[0]++;
	FOR{
		if(i-k>=0){mpp[(PS[i-k]-(i-k))%k]--;}
		cev+=mpp[(PS[i]-i)%k];
		mpp[(PS[i]-i)%k]++;
		//~ cout<<mpp[(PS[i]-i)%k]<<endl;
	}
	printf("%lld\n",cev);
	return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int gcd(int a, int b){
  if(a%b==0)return b;
  else{
    return gcd(b,a%b);
  }
}
void solve3(){
  int n;
  cin >> n;
  vector <int> a(n);
  int res;
  int tmp;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(i>0){
      tmp = (gcd(a[i],tmp));
    }
    if(i==0){
      tmp = a[i];
    }
  }
  sort(a.begin(),a.end());
  int k=0;
  cout << tmp << endl;


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


Measured memory_bytes: 3656
#include<stdio.h>
int main (void){
  int N,M,i,MAX =0;
  scanf("%d %d",&N,&M);
  int A[M];
  for(i = 0;i<M;i++)
    scanf("%d",&A[i]);
  for(i = 0;i<M;i++)
    MAX = MAX + A[i];
  if(N>=MAX)
    printf("%d",N-MAX);
  else
    puts("-1");
}

Measured memory_bytes: 1688
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main(){
    int H, W;
    cin >> H >> W;

    vs image(H);
    string row;

    repeat (i, H) {
        cin >> row;
        image[i] = row;
    }
    repeat (i, 2 * H) {
        cout << image[i / 2] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{    
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    ll N;
    ll W;
    cin>>N>>W;
    ll a,b,s=0;
    ll w[N],v[N];
    for(ll i=0;i<N;i++){
        cin>>a>>b;
        w[i]=a;
        v[i]=b;
        s+=v[i];
    }
    ll dp[s+1];
    for(ll i=0;i<=s;i++)
        dp[i]=10000000098;
    dp[0]=0;
    s=0;
    for(ll i=0;i<N;i++) {
        s+=v[i];
        for(ll j=s;j>=v[i];j--) 
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
    for (ll i=s;i>=0;i--)
        if (dp[i]<=W){
            cout<<i;
            break;
        }
}

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;
class Main
{
  public static void main(String args[])
  {
    
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
    int x=0;
    for(int i=0;i<n;i++)
    {
        int val=sc.nextInt();
        a[i]=val;
        x^=a[i];
    }
    for(int i=0;i<n;i++)
    {
        int v=x^a[i];
        System.out.print(v+" ");
    }
  }
}

Measured memory_bytes: 61364
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
#define int long long
   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 (b<a) { a=b; return 1; } return 0; }
    const int MAX =1002;
const int MOD =1000000007;

signed main(){
  int n,a,b,x;
  cin>>n>>a;b=a;
  vector<int> v,w;
  char c;
  for(int i=1;i<n;i++){
    cin>>c>>x;
    if(c=='+'){
      a+=x;
      b+=x;continue;
    }
    v.push_back(a);
    w.push_back(b);
    a=x;b=-x;
  }
  v.push_back(a);
    w.push_back(b);
    int ans[3]={};
  for(int i=v.size()-1;i>=0;i--){
    ans[2]=w[i]+max(ans[2],ans[1]);
    ans[1]=ans[0]-v[i];
    ans[0]+=v[i];
  }
  cout<<ans[2]<<endl;
}

Measured memory_bytes: 4988
#include <stdio.h>
int main(void)
{
    int x;
    int count;
    x = 1;
    count = 0;
    while (1 <= x && x <= 10000)
    {
        scanf("%d", &x);
        if (x == 0) break;
        count = count + 1;
        {
            printf("Case %d: %d\n", count, x);
        }
    }
}


Measured memory_bytes: 2032
import scala.io.{StdIn => in}

object Main extends App {
  val s = in.readLine
  val k = in.readInt

  val ss = s.take(k)

  val res =
    for {
      i <- 0 until s.size
      end = s.size min i+k
      j <- i+1 to end
    } yield s.substring(i,j)

  val ans = res.distinct.sorted.take(k).last
  println(ans)
}

Measured memory_bytes: 32904
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
#ifdef _WIN32
    #define getchar_unlocked getchar
#endif
inline void fin(int &x){ register char c=0;x=0;while(c<33)c=getchar_unlocked();do{x=(x<<1)+(x<<3)+c-'0';c=getchar_unlocked();}while(c>33);}
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define wypisz(x) cerr << #x << " " << x << "\n";
#define ll long long
#define ld long double
#define pii pair<int,int>
#define whole(c) (c).begin(), (c).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,m,t[555][555];
vector<vector<int> > res;
vector<pii> v;
int main()
{   ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin >> t[i][j];
    for(int i=1;i<=n;i++)
    {   if(i%2==1)
            for(int j=1;j<=m;j++)
                v.push_back({i,j});
        else 
            for(int j=m;j>=1;j--)
                v.push_back({i,j});
    }
    for(int i=1;i<v.size();i++)
    {   int a = v[i-1].first, b =v[i-1].second;
        int c = v[i].first, d =v[i].second;
        if(t[a][b] % 2 == 1)
        {
            t[c][d]++;
            res.push_back({a,b,c,d});
        }
    }
    cout << res.size() << "\n";
    for(auto i : res)
        cout << i[0] << " " << i[1] << " " << i[2] << " " << i[3] << "\n";
}
// 1 1
// 1 1
//overflow??

Measured memory_bytes: 12012
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define add push_back
#define inf 2147000000

using namespace std;

int main(void){
	int yama[10];
	
	for(int i=0;i<10;i++){
		scanf("%d",&yama[i]);
	}
	
	sort(yama,yama+10);
	
	for(int i=9;i>=7;i--){
		printf("%d\n",yama[i]);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
using namespace std;

int syc(long long i,long long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	int bingo[3][3];
	int bingo_c[3][3];
	//bingo 入力
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin >> bingo[i][j];
			bingo_c[i][j]=-1;
		}
	}
	
	//bingo 初期チェック
	if(bingo[0][1]==bingo[1][1]==bingo[2][0])return 0;
	if(bingo[0][0]==bingo[1][1]==bingo[2][2])return 0;
	
	if(bingo[0][0]==bingo[0][1]==bingo[0][2])return 0;
	if(bingo[1][0]==bingo[1][1]==bingo[1][2])return 0;
	if(bingo[2][0]==bingo[2][1]==bingo[2][2])return 0;
	
	if(bingo[0][0]==bingo[1][0]==bingo[2][0])return 0;
	if(bingo[0][1]==bingo[1][1]==bingo[2][1])return 0;
	if(bingo[0][2]==bingo[1][2]==bingo[2][2])return 0;
	
	int n;
	cin >> n;
	int a[n];
	//数値入力
	for(int i=0;i<n;i++){
		cin >> a[i];
		//cout << a[i] << " ";
	}
	//cout << endl;
	
	//bingo check 入力
	for(int p=0;p<n;p++){
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(a[p]==bingo[i][j]){
					bingo_c[i][j]=777;
				}
				//cout << bingo_c[i][j] << " ";
			}
			//cout << endl;
		}
		//cout << endl;
	}
	//cout << "check   ";
	//cout << bingo_c[0][0] << "  " << bingo_c[1][1] << "  " << bingo_c[2][2] << endl;
	
	//bingo No出力
	if(bingo_c[0][2]==bingo_c[1][1] && bingo_c[1][1]==bingo_c[2][0] &&bingo_c[2][0]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[0][0]==bingo_c[1][1] && bingo_c[1][1]==bingo_c[2][2] && bingo_c[2][2]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[0][0]==bingo_c[0][1] && bingo_c[0][1]==bingo_c[0][2] && bingo_c[0][2]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[1][0]==bingo_c[1][1] && bingo_c[1][1]==bingo_c[1][2] && bingo_c[1][2]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[2][0]==bingo_c[2][1] && bingo_c[2][1]==bingo_c[2][2] && bingo_c[2][2]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[0][0]==bingo_c[1][0] && bingo_c[1][0]==bingo_c[2][0] && bingo_c[2][0]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[0][1]==bingo_c[1][1] && bingo_c[1][1]==bingo_c[2][1] && bingo_c[2][1]==777){
		cout << "Yes" << endl;
		return 0;
	}else if(bingo_c[0][2]==bingo_c[1][2] && bingo_c[1][2]==bingo_c[2][2] && bingo_c[2][2]==777){
		cout << "Yes" << endl;
		return 0;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
An = list(map(int, input().split()))
dp = [0 for x in range(N+10)]
An.insert(0, 0)
dp[1] = 1000
for i in range(2, N+1):
    stock = dp[i-1] // An[i-1]
#     print(dp[i-1], An[i-1], stock)
    money = dp[i-1]
    money -= stock * An[i-1]
    money += stock * An[i]
#     print(money)
    dp[i] = max(dp[i-1], money)
print(dp[N])








Measured memory_bytes: 9128
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;
int main() {
	int k, x;
	
	cin >> k >> x;
		
	if (500*k >= x) {
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


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

int findthedigt(int n){
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(){
    int N;
    cin >> N;
    vector<int> a(N-1);

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

    int mn  = a[0];
    for(int i = 0;i < N -1;++i){
        if(mn > a[i])mn = a[i];
    }
    
    cout << mn << endl;
} 

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

int main(){
	vector<long long int> a(5);
	long long int n, m;
	cin>>n;
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	m=min(a[0], a[1]);
	for(int i=2;i<5;i++)
		m=min(m, a[i]);
	long long int ans=ceil((double)n/m);
	ans+=4;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
graph = [dict() for _ in range(N)]

for i in range(M):
    x, y = map(int, input().split())
    graph[y - 1][x - 1] = 1

dp = [0 for _ in range(N)]


def dfs(u):
    if dp[u] != 0:
        return dp[u]
    max_dis = 0
    for f in graph[u].keys():
        if max_dis < dfs(f) + 1:
            max_dis = dfs(f) + 1

    dp[u] = max_dis
    return dp[u]


for i in range(N):
    dfs(i)
print(max(dp))


Measured memory_bytes: 125180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n; cin >> n;
    vector<int> v(n+1, 0);
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    bool ok = false;
    int nxt = 1, cnt = 0;
    while(n--){
        if(v[nxt] == 2){
            ok = true;
            cnt++;
            break;
        }
        nxt = v[nxt];
        cnt++;
    }
    cout << (ok ? cnt : -1) << endl;
}


Measured memory_bytes: 640
#!/usr/bin/python3


def calcComb(n, dnum, dc):
    return sum(dc[n][dnum - 1])

def lunNum(n, dnum, remain, dc):
    sl = len(str(n))
    if dnum == sl:
        return n

    #sl < dnum
    rd = dnum - sl
    ld = n % 10
    
    if ld > 0:
        c = calcComb(ld - 1, dnum - sl, dc)
        if remain > c:
            remain -= c
        else:
            return lunNum(n * 10 +  ld - 1, dnum, remain, dc)
        
    c = calcComb(ld, dnum - sl, dc)
    if remain > c:
        remain -= c
    else:
        return lunNum(n * 10 + ld, dnum, remain, dc)

    if ld == 9:
        print("Oops!!")
        return -1

    return lunNum(n * 10 + ld + 1, dnum, remain, dc)

k = int(input())

dc = {}

for i in range(10):
    l = [ 1 if i == j else 0 for j in range(10) ]
    dc[i] = [l]

#print(dc)
    
dnum = 1
s = 0
ps = 0
ck = 0
while True:
    out = False
    for key in range(1, 10):
        ck = key
        l = dc[key][dnum - 1]
        ps = s        
        s += sum(l)
        if k <= s:
            out = True
            break

    if out:
        break
    
    #calc next digit
    for key in dc:
        l = dc[key][dnum - 1]
        nl = [0 for i in range(10)]

        for i in range(10):
            nl[i] += l[i]
            if i > 0:
                nl[i] += l[i - 1]
            if i < 9:
                nl[i] += l[i + 1]
        dc[key].append(nl)

    dnum += 1


remain = k - ps
#print(dnum, remain, ck)
print(lunNum(ck, dnum, remain, dc))


Measured memory_bytes: 3192
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		FastScanner cin = new FastScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(FastScanner cin, PrintWriter cout) {
		assert solve(7, 5, 1) == true;
		assert solve(2, 2, 1) == false;
		assert solve(1, 100, 97) == true;
		assert solve(40, 98, 58) == true;
		assert solve(77, 42, 36) == false;
		int a = cin.nextInt();
		int b = cin.nextInt();
		int c = cin.nextInt();
		boolean ans = solve(a, b, c);
		if (ans)
			cout.println("YES");
		else
			cout.println("NO");

	}

	private static boolean solve(int a, int b, int c) {
		HashSet<Integer> set = new HashSet<>();
		int num = 0;
		int mod;
		do {
			num += a;
			mod = num % b;
			if (mod == c)
				return true;
			if (set.contains(mod))
				break;
			set.add(mod);
		} while (true);
		return false;
	}

	/**
	 * How to read input in Java — tutorial <br />
	 * By Flatfoot<br />
	 * http://codeforces.com/blog/entry/7018
	 */
	static class FastScanner {
		private BufferedReader br;
		private StringTokenizer st;

		FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			return st.nextToken();
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
			return str;
		}

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

}


Measured memory_bytes: 22868
// B - Common Raccoon vs Monster
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	rp(i,0,s)v.push_back(init);
	rp(i,s,e){cin>>x;v.push_back(x);}
	return v;
}

int H,N;
vi A;

int main(){
	cin>>H>>N;
	A = inarr<int>(0,N);
	int s = 0;
	rp(i,0,N) s += A[i];
	cout<< (s>=H? "Yes":"No") <<endl;
}

Measured memory_bytes: 892
N, K = map(int, input().split())
d = []
A = []
for _ in range(K):
    d_i = int(input())
    a = list(map(int, input().split()))
    d.append(d_i)
    A.extend(a)
set_A = set(A)
ans = N - len(set_A)
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	string S;

	cin >> S;

	cout << ((S[2] == S[3] && S[4] == S[5]) ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  char _s[200]; int k;
  while (scanf("%s%d", _s, &k) == 2) {
    string s = _s;
    int n = s.size();
    long long cnt_odd = 0;
    vector<int> cnts;
    for (int i = 0; i < n; ) {
      int j = i;
      while (j < n && s[i] == s[j]) j++;
      cnts.push_back((j - i) % 2);
      cnt_odd += cnts.back();
      i = j;
    }
    cnt_odd *= k;
    if (s[0] == s[n - 1]) {
      if (cnts.size() == 1) {
        cnt_odd = (n * 1LL * k) % 2;
      } else {
        cnt_odd -= cnts[0] * (k - 1);
        cnt_odd -= cnts.back() * (k - 1);
        cnt_odd += ((cnts[0] + cnts.back()) % 2) * (k - 1);
      }
    }
    printf("%lld\n", (n * 1LL * k - cnt_odd) / 2);
  }

  return 0;
}


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

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

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

  vector<int> nums(3);
  rep(i, 3) { cin >> nums.at(i); }

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

  cout << nums.at(2) * 10 + nums.at(1) + nums.at(0) << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        PriorityQueue<Integer> q=new PriorityQueue<>();
        
//        int n=sc.nextInt();
        long n=sc.nextLong();
        long ans=n-1;

        for (long i = 1; i*i <= n; i++) {
        	if(n%i==0) {
        		ans=min(ans,n/i+i-2);
        	}
		}


        out.println(ans);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


class P {
	int x, y, d;
	P(int  x, int y, int d) {
	  this.x=x;
	  this.y=y;
	  this.d=d;
	}
}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return p.a-a;//des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;


int main() {
    ll n;
    cin >> n;
    ll sn = int(sqrt(n));
    ll res;
    invrep(i,sn+1) {
        if (n%i==0) {
            res=n/i;
            break;
        }
    }
    int digit=0;
    while (res>0) {
        res/=10;
        ++digit;
    }
    cout << digit << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
def solve():
    n=int(input())
    d={
        'AC':0,
        'WA':0,
        'TLE':0,
        'RE':0
    }

    for i in range(n):
        si=input()
        d[si]+=1
    
    for k, v in d.items():
        print(f'{k} x {v}')


if __name__=='__main__':
    t=1
    for _ in range(t):
        solve()


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

int main(void){
    int n,m;
    cin >> n >> m;
    int x[m];
    int x_res[m-1];

    int sum = 0;
    int ans = 0;

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

    sort(x,x+m);

    for(int i = 0; i < m; i++){
        if (i==0) continue;
        else{
            x_res[i-1] = x[i]- x[i-1];
        }
    }

    sort(x_res,x_res+m-1);
    
    if(n >= m){
        ans = 0;
    }else{
        for(int i = 0; i < m - n ; i++){
            ans += x_res[i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#define fo(i,a,b) for (i=a; i<=b; i++)
using namespace std;

const int N=105;
int n, i, j, k;
char s[N], t[N];
bool flag;

int main()
{
	scanf("%s",s+1), scanf("%s",t+1), n=strlen(s+1);
	fo(i,1,n)
	{
		k=i-1;
		fo(j,1,n)
		{
			k++; if (k>n) k=1;
			if (s[k]!=t[j]) break;
		}
		if (j>n) { flag=1; break;}
	}
	if (flag) printf("Yes"); else printf("No");
}

Measured memory_bytes: 128
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define INT_MAX 2147483647
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

int max(int a,int b) {
	int max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(int a, int b) {
	int min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	rep(i, n+1) {
		int sum = 0;
		int t = i;
		while (t > 0) {
			sum += t % 10;
			t /= 10;
		}
		if (a <= sum && sum <= b) {
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vvl a(n,vl(n));
    rep(i,n)rep(j,n)cin >> a[i][j];

    bool ok = true;
    ll res = 0;
    rep(i,n)rep(j,n){
        if(a[i][j] != a[j][i])ok = false;
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(a[i][j] > a[i][k] + a[k][j]){
                    ok = false;
                }
            }
        }
    }

    rep(i,n)rep(j,n){
        bool temp = true;
        if(i <= j)continue;
        rep(k,n){
            if(i == k || j == k)continue;
            if(a[i][j] == a[i][k] + a[j][k])temp = false;
        }
        if(temp)res += a[i][j];
    }

    cout << (ok ? res : -1) << endl;


}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<17)
#define MODULO (1000000007)
#define HA1 (2420609)
#define HA2 (19260817)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <complex>
using namespace std;

namespace MRAND
{
	class MRNDS
	{
	public:
		int ngf;
		unsigned int lgf;
		MRNDS()
		{
			ngf = HA1*HA2;
			lgf = HA1 - HA2*ngf;
		}
		MRNDS(long long rgf)
		{
			lgf = rgf&((1LL << 32) - 1LL);
			ngf = (rgf >> 31);
			ngf += 2LL * lgf;
			ngf *= HA2;
			lgf += HA1;
		}
		MRNDS operator* (const MRNDS &mrs)const
		{
			MRNDS Res;
			Res.ngf += ngf*mrs.lgf;
			Res.ngf -= mrs.ngf*lgf;
			Res.ngf *= HA1;
			Res.lgf *= HA2;
			return Res;
		}
	}curl, curr;
	inline void InitRand(MRNDS &Lmrs, MRNDS &Rmrs)
	{
		curl = Lmrs;
		curr = Rmrs;
		curl = curl*curr;
		curl.ngf += HA2;
	}
	inline int GetRand()
	{
		curl = curl*curr;
		return (curl.lgf*HA1 - curr.ngf*HA2);
	}
}

int n;
char s[N];
char lst;
int cnt;

int main()
{
	scanf("%s", s);
	n = strlen(s);
	for (int i = 0;i < n;i++)
	{
		if (lst != s[i])
		{
			lst = s[i];
			cnt++;
		}
	}
	printf("%d\n", cnt - 1);
	//system("pause");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define LL long long
#define fo(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	//ios::sync_with_stdio(0);
	int n;
	cin>>n;
	LL sum=0;
	fo(i,0,n+1){
		if(i%3==0||i%5==0)continue;
		else sum+=i;
	}
	cout<<sum;
	return 0;
}

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

int main()
{
	int N = 0, i = 0, j = 0, k = 0, ans = 0;
	int x = 0, temp = 0;
	int a[100];

	//// 入力
	cin >> N >> x;
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}
	i = 0;

	//// 演算
	// 並べ替え
	while(i != N){
		for (i = 1; i < N; i++) {
			if (a[i] < a[i - 1]) {
				temp = a[i];
				a[i] = a[i - 1];
				a[i - 1] = temp;
				break;
			}
		}
	}

	// カウント
	for (i = 0; i < N; i++) {
		x -= a[i];
		if (x < 0) break;
		ans++;
	}

	if (x > 0) ans--;

	//// 出力
	cout << ans << endl;

	return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  vll ss(m), cs(m);
  rep(i, m) { cin >> ss[i] >> cs[i]; }

  ll l, r;
  if (n == 1) l = 0, r = 9;
  if (n == 2) l = 10, r = 99;
  if (n == 3) l = 100, r = 999;

  repLRE(i, l, r) {
    string s = to_string(i);
    bool ok = true;
    rep(j, m) {
      if(s[ss[j]-1] - '0' != cs[j]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int W_count = 0, E_count = 0;
    for(int i = 0; i < S.size(); i++){
        E_count += (S[i] == 'E');
    }
    int ans = 1e9;
    for(int i = 0; i < S.size(); i++){
        E_count -= (S[i] == 'E');
        ans = min(ans, W_count + E_count);
        W_count += (S[i] == 'W');
    }
    cout << ans << endl;
}





Measured memory_bytes: 900
class Node
  attr_accessor :parent, :rank, :diff_weight

  def initialize
    @parent = -1 # Positive value means its parent,and Negative value means its size.
    @rank = 0
    @diff_weight = 0
  end
end

class UnionFindTree
  
  def initialize(n)
    @nodes = (0...n).to_a.map { |i| Node.new }
  end

  def find(x)
    
    if @nodes[x].parent < 0
      x
    else
      y = find(@nodes[x].parent)
      @nodes[x].diff_weight += @nodes[@nodes[x].parent].diff_weight # 累積和をとる
      @nodes[x].parent = y
    end
  end

  def unite(a, b, w)
    
    # x と y それぞれについて、 root との重み差分を補正
    # p weight(b)
    w += weight(a)
    w -= weight(b)
    
    a = find(a)
    b = find(b)
    
    return w == diff(a, b) ? true : false if a == b

    if @nodes[a].rank < @nodes[b].rank
      @nodes[b].parent += @nodes[a].parent
      @nodes[a].parent = b
      @nodes[a].diff_weight = -w
    else
      @nodes[a].parent += @nodes[b].parent
      @nodes[b].parent = a
      @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
      @nodes[b].diff_weight = w
    end
    
    
  end
  
  # def unite(a, b)
  # 
  #   a = find(a)
  #   b = find(b)
  #   return if a == b
  # 
  #   if @nodes[a].rank < @nodes[b].rank
  #     @nodes[b].parent += @nodes[a].parent
  #     @nodes[a].parent = b
  #   else
  #     @nodes[a].parent += @nodes[b].parent
  #     @nodes[b].parent = a
  #     @nodes[a].rank += 1 if @nodes[a].rank == @nodes[b].rank
  #   end
  # end

  def same?(a, b)
    find(a) == find(b)
  end
  
  def size(a)
    -@nodes[find(a)].parent
  end
  
  def weight(x)
    find(x); # 経路圧縮
    return @nodes[x].diff_weight;
  end
  
  def diff(x, y)
    return nil unless same?(x, y) # つながってなければ距離を測れないのでnilを返すことにした(2019/03/10)
    weight(y) - weight(x)
  end
  
  # 確認用。アルゴリズムとは関係無い
  def parents 
    @nodes.map(&:parent)
  end
end

# class Bridge
#   attr_accessor :first, :second

#   def initialize
#     @first = nil
#     @second = nil
#   end
  
#   def nodes=(a)
#     a[0], a[1] = a[1], a[0] if a[0] > a[1]
#     @first = a[0]
#     @second = a[1]
#   end
  
# end

n, m = gets.split.map(&:to_i)

uft = UnionFindTree.new(n)

m.times do |i|
  
  query = gets.split.map(&:to_i)
  if true
    a, b, w = query
    a -= 1
    b -= 1
    if !uft.unite(b,a,w)
      puts "No"
      exit
    end  
    # p uft
  elsif query[0] == 1
    a, b = query[1,2]
    puts uft.diff(a, b) || ??
  else
    p "Error!"
  end
end

puts "Yes"

# bridges = (0...M).to_a.map { Bridge.new }

# M.times do |i|
#   bridge = gets.split.map(&:to_i)
#   bridge.map! { |n| n - 1 }
#   bridges[i].nodes = bridge
# end
# p bridges

# ans = Array.new(M, 0)

# inco = N * ( N - 1 ) / 2 # inconvenience

# n = N
# q = M

# uft = UnionFindTree.new(n)

# q.times do |i|
  
#   j = (M-1)-i
#   ans[j] = inco
  
#   x, y = bridges[j].first, bridges[j].second
  
#   inco -= uft.size(x) * uft.size(y) if !uft.same?(x, y)
#   break if inco == 0
  
#   uft.unite(x, y)
# end

# puts ans


Measured memory_bytes: 12180
S=input()
if S=='SUN':
    print(7)
if S=='MON':
    print(6)
if S=='TUE':
    print(5)
if S=='WED':
    print(4)
if S=='THU':
    print(3)
if S=='FRI':
    print(2)
if S=='SAT':
    print(1)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Collections;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _1_A
//{
class Program
{
    static void Main(string[] args)
    {
        int d;
        int r;
        double f;

        int[] iarray = new int[2];
        string x = Console.ReadLine();
        string[] sarray = x.Split(' ') ;
        iarray[0] = int.Parse(sarray[0]);
        iarray[1] = int.Parse(sarray[1]);

        d = iarray[0] / iarray[1];
        r = iarray[0] % iarray[1];
        f = (double)iarray[0] / (double)iarray[1];

        Console.WriteLine(d + " " + r + " " + f.ToString("f8"));

        //Console.Read();
    }
}
//}

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

int main(){
	int K;
    string S;
    cin >> K >> S;
    for(int i=0;i<min((int)S.length(), K);i++){
    	cout << S[i];
    }
    if((int)S.length() > K) cout << "..." << endl;
    cout << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n,c; cin>>n>>c;
    vector<int> s(n), t(n), C(n);
    rep(i,n) cin>>s[i]>>t[i]>>C[i];
    vector<vector<int>> p(c+1, vector<int> (1e5+5,0));
    rep(i,n){
        p[C[i]][s[i]]++;
        p[C[i]][t[i]]--;
    }
    vector<int> pp(1e5+5,0);
    rep(i,c+1){
        rep(j,1e5+4){
            if(p[i][j]==1){
                pp[j]++;
            }else if(p[i][j]==-1){
                pp[j+1]--;
            }
        }
    }
    rep(i,1e5+4){
        pp[i+1]+=pp[i];
    }
    int ans=0;
    rep(i,1e5+5){
        chmax(ans, pp[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16984
fun main(args: Array<String>) = println(run {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.drop(1) }
    (1..m).count { food -> a.all { food in it } }
})


Measured memory_bytes: 37992
import java.util.*

val MOD = 998244353L

fun main(omkar: Array<String>) {
    val jin = Scanner(System.`in`)
    val n = jin.nextInt()
    val s = jin.nextInt()
    val array = intArrayOf(0) + IntArray(n) { jin.nextInt() }
    var answer = 0L
    val dp = LongArray(s)
    for (j in 1..n) {
        if (array[j] < s) {
            answer += dp[s - array[j]] * (n - j + 1).toLong()
            answer %= MOD
            for (k in s - 1 downTo array[j]) {
                dp[k] += dp[k - array[j]]
                dp[k] %= MOD
            }
            dp[array[j]] += j.toLong()
            dp[array[j]] %= MOD
        } else if (array[j] == s) {
            answer += j.toLong() * (n - j + 1).toLong()
            answer %= MOD
        }
    }
    println(answer)
}

Measured memory_bytes: 37132
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    Sort(a);
    Reverse(a);

    int Alice = 0; int Bob = 0;
    rep(i,N) {
        if (i % 2 == 0) Alice += a[i];
        else Bob += a[i];
    }

    out(Alice - Bob);

    return 0;
}










Measured memory_bytes: 256
# AOJ 0197 Greatest Common Divisor
# Python3 2018.6.18 bal4u

def gcd(a, b):
	k = 0
	while b != 0:
		r = a % b
		a, b = b, r
		k += 1
	return [a, k]

while True:
	x, y = list(map(int, input().split()))
	if x == 0: break
	if x < y: x, y = y, x
	ans = gcd(x, y)
	print(*ans)


Measured memory_bytes: 5604
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int main() {
	string str;
	cin >> str;
	if (str[2] == str[3] && str[4] == str[5])
      cout << "Yes\n";
  	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

struct edge {
    edge() : link_to(0), cost(0) {}
    edge(int t, int c) : link_to(t), cost(c) {}
    int link_to;
    int cost;
};

void dijkstra(std::vector<std::vector<edge>>& g, std::vector<int>& d, int s) {
    priority_queue<P, std::vector<P>, greater<P>> que;
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (edge e : g[v]) {
            if (d[e.link_to] > d[v] + e.cost) {
                d[e.link_to] = d[v] + e.cost;
                que.push(make_pair(d[e.link_to], e.link_to));
            }
        }
    }
}

int main(int argc, char **argv) {
    int n, m;
    cin >> n >> m;
    std::vector<std::vector<edge>> g(n*3+1, std::vector<edge>());
    std::vector<int> d(n*3+1, int_max);

    for (int i=0; i<m; ++i) {
        int x, y;
        cin >> x >> y;
        g[x].emplace_back(y+n, 1);
        g[x + n].emplace_back(y+2*n, 1);
        g[x + 2*n].emplace_back(y, 1);
    }

    int s, t;
    cin >> s >> t;
    dijkstra(g,d,s);

    if (d[t] == int_max) {
        cout << -1 << endl;
    } else cout << d[t]/3 << endl;

    return 0;
}


Measured memory_bytes: 17792