akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int best(vector<int> as) {
    vector<int> ds;
    for (int i = 1; i * i <= as[0]; ++i) {
        if (as[0] % i == 0) {
            ds.push_back(i);
            if (i != as[0]/i) {
                ds.push_back(as[0]/i);
            }
        }
    }
    sort(ds.begin(), ds.end(), [](int i, int j) { return i > j; });
    for (int d : ds) {
        int count_wrong = 0;
        for (int a : as) {
            count_wrong += a % d != 0;
        }
        if (count_wrong <= 1) {
            return d;
        }
    }
    return 1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> as(n);
    for (int& a : as) {
        cin >> a;
    }
    int res_1 = best(as);
    swap(as[0], as[1]);
    int res_2 = best(as);
    cout << max(res_1, res_2) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=2000005,INF=1<<30;

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

void make(){
    
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    
    for(int i=2;i<MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll)i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
    
}

ll comb(ll a,ll b){
    if(a<b) return 0;
    return fac[a]*(finv[b]*finv[a-b]%mod)%mod;
}

int main(){
    
    make();
    
    int N,M;cin>>N>>M;
    
    ll sum=0;
    
    for(int i=M;i>=0;i-=2){
        if(i>N) continue;
        ll rem=(3*M-i)/2;
        sum+=comb(rem+N-1,N-1)*comb(N,i);
        sum%=mod;
    }
    
    for(int i=M;i>=0;i-=2){
        if(i>N) continue;
        ll rem=(M-i)/2;
        sum+=N*(mod-comb(rem+N-1,N-1))%mod*comb(N,i);
        sum%=mod;
    }
    
    for(int i=M;i>=0;i-=2){
        if(i>N) continue;
        ll rem=(M-i)/2;
        sum+=N*(comb(rem+N-2,N-2))%mod*comb(N-1,i);
        sum%=mod;
    }
    
    cout<<sum<<endl;
    
}


Measured memory_bytes: 47104
#include <cmath>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n-1);i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) (v).begin(), (v).end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,a,b; cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll int a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    x=ceil(c/(double(b)));
    y=ceil(a/(double(d)));
    if(y>=x)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }
ll mod = 1e9+7;
signed main() {
    ll n,a; cin>>n;
    vl b(n);
    rep(i,n){
        cin>>a;
        b[a-1]=i+1;
    }
    rep(i,n){
        cout<<b[i];
        if(i<n-1)cout<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 1664
def solve(n, xs):
    ss = [0] + [abs(a - b) for (a, b) in zip(xs + [0], [0] + xs)]
    for i in range(1, n + 1):
        ss[i + 1] += ss[i]
    cost2 = [abs(a - b) for (a, b) in zip(xs[1:] + [0], [0] + xs[:n - 1])]
    for k in range(n):
        yield ss[n + 1] - ss[k + 2] + ss[k] + cost2[k]

if __name__ == "__main__":
    n = int(input())
    xs = [int(s) for s in input().split()]
    for ans in solve(n, xs):
        print(ans)


Measured memory_bytes: 18348
import math
(n,k) = input().split(" ")
n=int(n)
k=int(k)
arr = input().split(" ")

idx = arr.index("1")
if idx < k or n-idx-1 < k:
    num=math.ceil((n-k)/(k-1))+1
else:
    num1 = math.ceil((idx+1)/k)
    idx1=k+(k-1)*(num1-1)-1
    num = num1+math.ceil((n-idx1-k)/(k-1))+1
print(num)

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

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define X first
#define Y second

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	string s; cin >> s;
	s.reserve();
	string a = "dream", b = "dreamer", c = "erase", d = "eraser";
	string e = a + c, f = a + d;
	a.reserve(); b.reserve(); c.reserve(); d.reserve(); e.reserve(); f.reserve();
	vector<string> v{ a,b,c,d,e,f };
	sort(all(v), [](string& s1, string& s2) {return s1.size() > s2.size(); });
	int idx = 0;
	while (idx < s.size()) {
		bool ok = false;
		for (string& x : v) {
			if (x == s.substr(idx, x.size())) {
				idx += x.size();
				ok = true;
				break;
			}
		}
		if (!ok) idx = s.size() + 1;
	}
	cout << (idx == s.size() ? "YES" : "NO") << endl;
	system("pause");
}

Measured memory_bytes: 756
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

#define all(x) (x).begin(),(x).end()
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define y1 Emilia
#define forit(s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)


#define N 400400
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n, k;
int main(){
    dracarys
    cin >> n >> k;
    if(k == 1){
        cout << 0 << "\n";
    } else {
        cout << n - k << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while(b) {
    swap(a, b);
    b %= a;
  }
  return a;
}
long long lo(long long a, long long b) {
  return a * b / gcd(a, b);
}
int main () {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long K = lo(C, D);
  //cout << K << endl;
  long long p = B / C - (A - 1) / C;
  long long q = B / D - (A - 1) / D;
  long long r = B / K - (A - 1) / K;
  long long s = (B - A + 1) - (p + q - r);
  cout << s << endl;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int w = in.nextInt();
        int wt[] = new int[n];
        int val[] = new int[n];
        for(int i=0;i<n;i++){
            wt[i] = in.nextInt();
            val[i] = in.nextInt();
        }
        long K[][] = new long[n+1][w+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=w;j++){
                if(i==0 || j==0) K[i][j]=0;
                else if(wt[i-1]<=j) K[i][j] = Math.max( K[i-1][j], val[i-1] + K[i-1][j - wt[i-1]] );
                else K[i][j] = K[i-1][j];
            }
        }
        out.println(K[n][w]);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int n, v[100001], k;
const int INF = 1e9 + 5;
int main() {
    cin >> n >> k;
    vector<int> dp(n+1, INF);
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    dp[1] = 0;
    for(int i = 1; i <= n; i++) {
       for(int j = i + 1; j <= i + k && j <= n; j++) {
           dp[j] = min(dp[j], dp[i] + abs(v[i] - v[j]));
       }
    }
    cout << dp[n];
}

Measured memory_bytes: 1024
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    if n >= r:
        return int(factorial(n) // (factorial(r) * factorial(n - r)))
    else:
        return 0

for i in range(1, K+1):
    print(combination(N-K+1, i) * combination(K-1, i-1)%mod)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()

bool is_valid_warp(vector<string> &S, vector<int> &cost, int ci, int cj, vector<int> &to) {
    for (int i = -2; i <= 2; i++) {
        for (int j = -2; j <= 2; j++) {
            if (i == 0 && j == 0) continue;
            int H = S.size();
            int W = S[0].size();
            int ni = ci + i, nj = cj + j;
            if (ni < 0 || ni > H - 1 || nj < 0 || nj > W - 1) continue;
            if (S[ni][nj] == '#') continue;

            int id = ni * W + nj;
            if (cost[id] == -1) {
                to.push_back(id);
            }
        }
    }
    if (!to.empty()) return true;
    else return false;
}

int main() {
    int H, W;
    cin >> H >> W;
    int Ch, Cw, Dh, Dw;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;
    Ch--; Cw--;
    Dh--; Dw--;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    Graph G(H * W);
    vector<vector<int>> gid(H, vector<int>(W, -1));
    map<int, pair<int, int>> tocood;
    rep(i, H) rep(j, W) {
        int id = i * W + j;
        gid[i][j] = id;
        tocood[id] = make_pair(i, j);
        if (S[i][j] == '#') continue;
        if (count(ALL(G[id]), id - W) == 0 && i - 1 > 0 && S[i - 1][j] == '.') {
            G[id].push_back(id - W);
            G[id - W].push_back(id);
        }
        if (count(ALL(G[id]), id + 1) == 0 && j + 1 < W && S[i][j + 1] == '.') {
            G[id].push_back(id + 1);
            G[id + 1].push_back(id);
        }
        if (count(ALL(G[id]), id + W) == 0 && i + 1 < H && S[i + 1][j] == '.') {
            G[id].push_back(id + W);
            G[id + W].push_back(id);
        }
        if (count(ALL(G[id]), id - 1) == 0 && j - 1 > 0 && S[i][j - 1] == '.') {
            G[id].push_back(id - 1);
            G[id - 1].push_back(id);
        }
    }

    vector<int> cost(H * W, -1);
    vector<int> visited;
    queue<int> que;

    int cid = gid[Ch][Cw];
    int did = gid[Dh][Dw];
    cost[cid] = 0;
    que.push(cid);

    while (!que.empty()) {
        // Move A
        while (!que.empty()) {
            int v = que.front(); que.pop();
            visited.push_back(v);
            for (auto nv : G[v]) {
                if (cost[nv] != -1) continue;
                cost[nv] = cost[v];
                que.push(nv);
            }
        }
        if (cost[did] != -1) break;

        // Move B
        for (auto v : visited) {
            int i, j;
            vector<int> to;
            tie(i, j) = tocood[v];
            if (is_valid_warp(S, cost, i, j, to)) {
                for (auto nv : to) {
                    if (cost[nv] != -1) continue;
                    cost[nv] = cost[v] + 1;
                    que.push(nv);
                }
            }
        }
        visited.clear();
    }

    cout << cost[did] << endl;
    
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string S;
    cin >> S;
    vector<ll> dp(13, 0);
    vector<ll> dp2(13, 0);
    dp[8] = 1;
    int d = 1;
    for(int i=S.size()-1; i>=0; i--){
        if(S[i] == '?'){
            for(int k=0; k<10; k++){
                auto n = (k * d) % 13;
                for(int j=0; j<13; j++){
                    dp2[(j+n)%13] += dp[j];
                }
            }
        }else{
            int n = S[i] - '0';
            n = (n * d) % 13;
            for(int j=0; j<13; j++){
                dp2[(j+n)%13] += dp[j];
            }
        }
        for(int j=0; j<13; j++){
            dp[j] = dp2[j] % 1000000007;
            dp2[j] = 0;
        }

        d = (10 * d) % 13;
    }
    cout << dp[0] << endl;

    return 0;
}

Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Round One
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int a, b;
  scanf("%d%d", &a, &b);

  if (a > b) swap(a, b);

  if (a == 1 && b == 2) puts("3");
  else if (a == 2 && b == 3) puts("1");
  else puts("2");
  return 0;
}


Measured memory_bytes: 256
// Problem : C - Boxes and Candies
// Contest : AtCoder - AtCoder Beginner Contest 048
// URL : https://atcoder.jp/contests/abc048/tasks/arc064_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long n, x, t = 0, c;
	cin >> n >> x;
	vector<int> v(n);
	for(auto &it:v) cin >> it;
	for(int i = 1; i < n; i++){
	    if(v[i-1]+v[i] > x){
	        c = v[i-1] + v[i] -x;
	        if(v[i]>c){
	            v[i]-=c;
	        }
	        else{
	            v[i] = 0;
	            v[i-1]-=c-v[i];
	        }
	        t+=c;
	    }
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			if(n==0)
				return;
			int f=in.nextInt();
			char[] ch=in.next().toCharArray();
			int ans=0;
			int re=0;
			for(int i=0;i<f-2;i++)
			{
				if(ch[i]=='I')
				{
					if(ch[i+1]=='O'&&ch[i+2]=='I')
						re++;
					else
						re=0;
					if(re>=n)
						ans++;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 18000
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a))
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define co() cout.precision(10);
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n";
#define nec cout<<'\n';continue;
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif
//memset(arr, 0, sizeof arr);
typedef long long li;
typedef long double ld;

const li mod = 1000000007;

int main() 
{
    io();
    li d,t,s;
    cin>>d>>t>>s;
    li x=ceil((double)d/s);
    if(x<=t)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 3716
#include <iostream> // cin, cout
#include <algorithm> // sort
#include <vector> // vector
#include <cstdio> // printf
#include <cmath> // M_PI
#include <numeric> // accumulate
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

int		main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)
		cin >> a.at(i);
	reverse(a.begin(), a.end());
	rep(i, n - 1)
		cout << a.at(i) << " ";
	cout << a.at(n - 1) << endl;
	return (0);
}



Measured memory_bytes: 3096
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 2e6+10;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n,m;
ll val[maxn],b[maxn],c[maxn];
ll ans;

void solve()
{
	ans=0;
	scanf("%d%d",&n,&m);
	repp(i,1,n)
	{
		scanf("%lld",&val[i]);
	}
	repp(i,2,n)
	{
		if(val[i-1]<val[i])
		{
			ans+=val[i]-val[i-1];
			
			b[val[i-1]+1]+=val[i-1]+1;
			b[val[i]+1]-=val[i-1]+1;
			++c[val[i-1]+1];
			--c[val[i]+1];
		}
		else
		{
			ans += m+val[i]-val[i-1];

			b[1]-=m-val[i-1]-1;
			b[val[i]+1]+=m-val[i-1]-1;
			b[val[i-1]+1]+=val[i-1]+1;

			c[1]++;
			c[val[i]+1]--;
			c[val[i-1]+1]++;
		}
	}
	for(int i=1;i<=m;i++)
	{
		b[i]+=b[i-1];
		c[i]+=c[i-1];
	}
	ll cnt=0;
	for(int i=1;i<=m;i++)
	{
		cnt=max(cnt,1LL*i*c[i]-b[i]);

	}
	//DE(cnt)

	printf("%lld\n", ans-cnt);
}

int main()
{

	solve();
	//system("pause");
	return 0;
}







Measured memory_bytes: 7168
#include<iostream>
#include<cstdio>
using namespace std;
int n,g,ans,dp[2001000],p[101000],c[101000],t[2001000],V;
int main()
{
	cin>>n>>g;
	g=g/100;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i],&c[i]);
		c[i]=c[i]/100;
		V+=p[i]*i+c[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=V;j>=p[i];j--)	t[j]=dp[j-p[i]]+p[i]*i+c[i];
		for(int k=1;k<=p[i];k++)
		for(int j=V;j>=1;j--)
		dp[j]=max(dp[j],dp[j-1]+i);
		for(int j=V;j>=p[i];j--)	dp[j]=max(dp[j],t[j]);
	}
	for(int i=1;i<=V;i++)
	{
		if(dp[i]>=g)
		{
			ans=i;	break;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <locale>
#include <stdio.h>
#include <ctype.h>
#include <cstring>
#include <cctype>
using namespace std;

int main()
{   char s[20];
    cin>>s;
    int n=0;
    while(true){
        
        char p[20];

        cin>>p;
        
        
        if(strcmp(p,"END_OF_TEXT")==0){
            break;
        }else{
            for (int i=0;i<strlen(p);i++){
            p[i]=tolower(p[i]);}
           
            if(strcmp(p,s)==0){
                n+=1;
            }
        }
    }
    
    cout << n<<endl;
return 0;
}


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

bool is_ACGT(char s);

int main() {
    string S;
    cin >> S;
    int count, max = 0;
    for (int i = 0; i < S.length(); i++) {
        if (is_ACGT(S[i])) {
            count++;
            if (count > max) {
                max = count;
            }
            else {}
        }
        else {
            if (count > max) {
                max = count;
            }
            else {}
            count = 0;
        }
    }
    cout << max << endl;
    return 0;
}

bool is_ACGT(char s) {
    if (s == 'A' || s == 'C' || s == 'G' || s == 'T') {
        return true;
    }
    else {
        return false;
    }
}


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

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

    vector<long long int> color(3);
    for(int i=0; i<n; i++){
        if(s[i] == 'R') color[0] += 1;
        if(s[i] == 'G') color[1] += 1;
        if(s[i] == 'B') color[2] += 1;
    }

    long long int ans = color[0] * color[1] * color[2];
    for(int d=1; d<=n/2; d++){
        for(int i=0; i+2*d<n; i++){
            if(s[i]   != s[i+d]
            && s[i]   != s[i+2*d]
            && s[i+d] != s[i+2*d]) ans -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int,input().split()))
tmp = []
for i in range(N):
  tmp.append(A[i] - (i+1))
tmp.sort()
mid = tmp[int(N/2)]
ans = 0
for i in range(N):
  ans += abs(tmp[i] - mid)
print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 1e9;;
    for (auto &d : a) {
        cin >> d;
        int res = 0;
        while (d % 2 == 0) {
            res++;
            d /= 2;
        }
        ans = min(ans, res);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
int a[30],e[30],c[30],d[30],i,ii,b,f,r,v,x,y=0,z=10;
cin >> x;
for(i=0;i<30;i++)
{a[i]=0;}
for(i=0;i<30;i++)
{e[i]=0;}
for(i=0;i<30;i++)
{c[i]=0;}
for(i=0;i<30;i++)
{d[i]=0;}
for(i=1;i<=x;i++)
{
    cin >> b >> f >> r >> v;
    if(b==1)
    {
        a[(f-1)*10+r-1]=a[(f-1)*10+r-1]+v;
    }
    else if(b==2)
    {
        e[(f-1)*10+r-1]=e[(f-1)*10+r-1]+v;
    }
    else if(b==3)
    {
        c[(f-1)*10+r-1]=c[(f-1)*10+r-1]+v;
    }
    else
    {
        d[(f-1)*10+r-1]=d[(f-1)*10+r-1]+v;
    }
}
for(ii=1;ii<=3;ii++)
{
for(i=y;i<z;i++)
{
    cout << " " << a[i];
}
y=y+10;
z=z+10;
cout << endl;
}
y=0;
z=10;
for(i=1;i<=20;i++)
{
    cout << "#";
}
cout << endl;
for(ii=1;ii<=3;ii++)
{
for(i=y;i<z;i++)
{
    cout << " " << e[i];
}
y=y+10;
z=z+10;
cout << endl;
}
y=0;
z=10;
for(i=1;i<=20;i++)
{
    cout << "#";
}
cout << endl;
for(ii=1;ii<=3;ii++)
{
for(i=y;i<z;i++)
{
    cout << " " << c[i];
}
y=y+10;
z=z+10;
cout << endl;
}
y=0;
z=10;
for(i=1;i<=20;i++)
{
    cout << "#";
}
cout << endl;
for(ii=1;ii<=3;ii++)
{
for(i=y;i<z;i++)
{
    cout << " " << d[i];
}
y=y+10;
z=z+10;
cout << endl;
}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const int MAX = 100000;
static const int NIL = -1;
using namespace std;


int main() {

    ll n,a[5]; cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    sort(a,a+5);
    ll ans = 0;

    if(n%a[0] != 0) ans ++;
    ans += n/a[0] + 4;
    cout << ans;


    return 0;
}


Measured memory_bytes: 3596
N,M = map(int, input().split())
ab = []
c = []
for _ in range(M):
    a,b = map(int, input().split())
    ab.append((a,b))
    tmp = tuple(map(int, input().split()))
    bit_c = 0
    # c[i]で開けられる宝箱はbitの１が立っている部分
    for i in tmp:
        bit_c = bit_c | (1 << (i - 1))

    c.append(bit_c)

INF = 10**9
# m番目の鍵をつかって、開けた宝箱がbitの状態になったときの、最小コスト
dp = [INF] * (1 << N)
dp[0] = 0


for bit in range(1 << N):
    for i in range(M):
        dp[bit | c[i]] = min(dp[bit | c[i]], dp[bit] + ab[i][0])

print(dp[-1] if dp[-1] < INF else -1)

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

int main()
{
	int a, b, c;
	int min1, min2, min3;

	cin >> a;

	min1 = a;

	cin >> b;

	if (min1 > b) {
		min2 = min1;
		min1 = b;
	} else {
		min2 = b;
	}

	cin >> c;

	if (min1 > c) {
		min3 = min2;
		min2 = min1;
		min1 = c;
	} else if (min2 > c) {
		min3 = min2;
		min2 = c;
	} else {
		min3 = c;
	}

	cout << min1 << " " << min2 << " " << min3 << endl;

	return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

void get_intint(char *line, int size, int *a1, int *a2) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d", a1, a2);
}

#define BUF_SIZE 20


struct problem {
  int point;
  int bonus;
  int cnt;
  int sum;
};

int solve(struct problem* probs, int grades, int goal, int cnt) {
  int i, j;
  int success = 0;
  for(i = 0; i < (1<<grades); i++) {
    int sum = 0;
    int tmpcnt = 0;
    // get bonus
    for(j = 0; j < grades; j++) {
      int flag = !!(i & (1<<j));
      tmpcnt += probs[j].cnt*flag;
      sum += probs[j].sum*flag;
    }
    if(tmpcnt > cnt) continue; // skip
    if(sum >= goal) {
      success = 1;
      break;
    }
    // append reminder
    for(j = 0; j < grades; j++) {
      int flag = !!(i & (1<<j));
      if(flag) continue; // it would get bonus twice
      int rem = cnt - tmpcnt;
      if(rem >= probs[j].cnt) continue;
      if(sum + rem * probs[j].point >= goal) {
        success = 1;
        goto fin;
      }
    }
  }
fin:
  return success;
}

int main(void) {
  int grade, total_score;
  char line[BUF_SIZE];
  get_intint(line, BUF_SIZE, &grade, &total_score);

  struct problem probs[10];

  int i, j;
  int max_cnt = 0;
  for(i = 0; i < grade; i++) {
    int cnt, bonus;
    get_intint(line, BUF_SIZE, &cnt, &bonus);
    probs[i].cnt = cnt;
    probs[i].bonus = bonus;
    probs[i].point = (i+1)*100;
    probs[i].sum = probs[i].point * probs[i].cnt + bonus;
    max_cnt += probs[i].cnt;
  }

  int low = -1;
  int high = max_cnt+1;
  while(low + 1 < high) {
    int middle = (low+high)/2;
    int success = solve(probs, grade, total_score, middle);
    if(success) {
      high = middle;
    } else {
      low = middle;
    }
  }
  printf("%d\n", high);
}

Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	ll tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int imos[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), D = getint(), A = getint();
	ll XH[200001];
	rep(i, N) {
		int x = getint();
		XH[i] = (ll(getint()) << 32) + x;
	}
	pakuri_sort(N, XH);
	XH[N] = (1ll << 62) - 1;

	int ima = 0;
	const ll m = (1ll << 32) - 1;
	ll kotae = 0;
	int k = 0;
	int d = min(1000000000, 2 * D);
	rep(i, N) {
		ima += imos[i];
		int nokori = (XH[i] >> 32) - ima;
		if (nokori > 0) {
			int kaisuu = (nokori + A - 1) / A;
			while ((XH[i] & m) + d >= (XH[k] & m)) k++;
			ima += kaisuu * A;
			imos[k] -= kaisuu * A;
			kotae += kaisuu;
		}
	}

	printf("%lld", kotae);

	Would you please return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var output = 0;
            var p = ' ';
            foreach (var s in S)
            {
                if (s == p)
                {
                    output++;
                    p = s == '0' ? '1' : '0';
                }
                else
                {
                    p = s;
                }
            }

            Console.Write(output);
        }
    }
}


Measured memory_bytes: 13144
class Pque < Array
  def push(x)

    # 自分のノードの番号
    i = size
    while i > 0
      # 親のノードの番号
      p = (i - 1) / 2 #i = p*2 + 1
      # もう逆転してないなら抜け
      unless self[p].nil?
        break if self[p] >= x # ヒープの不等号で順序が逆に
      end
      # 親のノードの数字を下ろして、自分は上に
      self[i] = self[p]
      i = p
    end
    self[i] = x
  end

  def pop
    # 最大（小）値
    ret = self[0]
    #根に持ってくる値
    x = self[-1]
    # 根から下ろしていく
    i = 0
    while i * 2 + 1 < size - 1
      # 子同士を比較
      child1 = i * 2 + 1; child2 = i * 2 + 2
      child1 = child2 if child2 < self.size &&
        self[child2] > self[child1]# ヒープの不等号で順序が逆に
      # もう逆転してないなら終わり
      break if self[child1] <= x
      # この数字を持ち上げる
      self[i] = self[child1]
      i = child1
    end
    self[i] = x
    self.delete_at(-1)
    ret
  end

end # class Pque


MAX_V = 50 # 制約の最大値。
MAX_S = MAX_V * 50 + 5
INF   = Float::INFINITY

#　頂点
Edge = Struct.new(:to, :a, :b)
#　両替所
Exchange = Struct.new(:v, :s, :x) do
  include Comparable
  def <=>(other)
    other.x <=> self.x
  end
end

g    = Array.new(MAX_V) { Array.new { Edge.new } }
dist = Array.new(MAX_V) { Array.new(MAX_S + 5) { INF } }

def input
  gets.split.map &:to_i;
end

# メイン
n, m, s = input
#　都市の入力
m.times do
  u, v, a, b = input
  u          = u.pred
  v          = v.pred
  g[u] << Edge.new(v, a, b)
  g[v] << Edge.new(u, a, b)
end

# プライオリティキューのライブラリを利用
# require 'pqueue'
# 銀貨は最大でもMAX_S
s = [s, MAX_S].min
# プライオリティーキュー
q = Pque.new
# 入力用ラムダ
push = lambda { |v, s, x|
  return if s < 0
  return if dist[v][s] <= x

  dist[v][s] = x
  q.push(Exchange.new(v, s, x))
}

c = []
d = []
n.times do |i|
  cc, dd = input
  c[i]   = cc
  d[i]   = dd
end
push.call(0, s, 0)
until q.empty?
  hoge = q.pop
  v    = hoge.v; s = hoge.s; x = hoge.x
  next if dist[v][s] != x

  ns = [s + c[v], MAX_S].min
  push.call(v, ns, x + d[v])

  g[v].each do |e|
    push.call(e.to, s - e.a, x + e.b)
  end
end


(1 ... n).each do |i|
  ans = INF
  (0 ... (MAX_S + 5)).each do |j|
    ans = [ans, dist[i][j]].min
  end
  puts ans
end

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

int main(){
    string n;
    cin >> n;
    for(int i = 0;i < 3;i++){
        if(n[i] == '1'){
            n[i] = '9';
        }else if(n[i] == '9'){
            n[i] = '1';
        }
    }
    cout << n << endl;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f
using namespace std;
#define mod 1000000007
ll a[200005],sum[200005];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        ans+=(a[i]%mod)*((sum[n]-sum[i])%mod);
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6756
# グー:1,チョキ:2,パー:3
# 勝ち:1,負け:2,あいこ:3
datas = [0] * 5
while(1):
    try:
        lens = [0] * 3
        status = [0] * 3
        for i in range(0,5):
            datas[i] = int(input())
            lens[datas[i] - 1] += 1
        # あいこ
        if (lens[0] > 0 and lens[1] > 0 and lens[2] > 0) or (lens[0] == 5 or lens[1] == 5 or lens[2] == 5):
            for i in range(0,5):
                print(3)
        else:
            # グー
            if lens[0] > 0:
                status[1] = 2
                status[2] = 1
            # チョキ
            if lens[1] > 0:
                status[0] = 1
                status[2] = 2
            # パー
            if lens[2] > 0:
                status[0] = 2
                status[1] = 1
            for i in range(0,5):
                print(status[datas[i] - 1])
    except:
        break


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

int main() {

    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;

    if (S == U)
        cout << --A << " " << B;
    else
        cout << A << " " << --B;

    cout << endl;

    return 0;
}

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

int main() {
  int h,n,inf = 1e9;
  cin >> h >> n;
  vector<P>data(n);
  vector<int>dp(h+1,inf);
  dp[0] = 0;
  rep(i,0,n) cin >> data[i].first >> data[i].second;
  rep(i,0,h){
    rep(j,0,n){
      int pos = min(h,i+data[j].first);
      dp[pos] = min(dp[pos],dp[i]+data[j].second);
    }
  }
  cout << dp[h] << endl;
}

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

int main() {
	vector<int> o(3);
	cin >> o[0] >> o[1] >> o[2];
	sort(o.begin(), o.end());
	cout << o[0] + o[1] + 10 * o[2] << endl;
}

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

int binarySearch(int a[],int n,int key){
    int left = 0;
    int right = n;
    
    while (left<right){
        int mid = (left+right) /2;
        if (a[mid] > key) right = mid;
        else if(a[mid] < key) left = mid+1;
        else return mid;
    }
    return -1;
}

int n,q;

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

    int count = 0;
    for (int i=0;i<q;i++){
        if (binarySearch(a,n,b[i]) != -1) count ++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(n) n.begin(),n.end()
#define yn(x) cout << (x ? "Yes":"No") << endl;

int main() {
  string s;
  cin >> s;
  rep(i,3) cout << s[i];
  cout << endl;
  return 0;
}


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

int main(){
  long long N;
  cin >> N;
  vector<long long> A(N+1),Vmax(N+1),Vmin(N+1);
  for(int i=0;i<=N;i++) cin >> A[i];
  
  Vmax[N] = A[N];
  Vmin[N] = A[N];
  for(int i=N-1;i>=0;i--){
    Vmax[i] = Vmax[i+1] + A[i];
    Vmin[i] = (Vmin[i+1]+1)/2 + A[i];
  }
  
  vector<long long> V(N+1);
  if(Vmin[0]>1){
    cout << -1 << endl;
    return 0;
  }
  V[0] = 1;
  for(int i=1;i<=N;i++){
    long long x = (V[i-1]-A[i-1])*2;
    if(Vmin[i] > x){
      cout << -1 << endl;
      return 0;
    }
    else if(Vmax[i] > x) V[i] = x;
    else V[i] = Vmax[i];
  }
  
  long long ans=0;
  for(int i=0;i<=N;i++) ans += V[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
 
struct UnionFind{
  vector<long long> par;
 
  UnionFind(int n){
    par.assign(n,-1);
  }
 
  void unite(long long x, long long y){
    x=root(x);y=root(y);
    if(x==y) return;
 
    if(par[x]>par[y]){
      swap(x,y);
    }
    par[x]+=par[y];
    par[y]=x;
  }
 
  long long root(long long x){
    if(par[x]<0){
      return x;
    }else{
      return par[x]=root(par[x]);
    }
  }
 
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
};

int main(){
  int n,m,k,l;
  cin >> n >> m;
  vector<int> vec[m];
  for(int i=0;i<n;i++){
    cin >> k;
    for(int j=0;j<k;j++){
      cin >> l;
      vec[l-1].push_back(i);
    }
  }
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    for(int j=0;j<vec[i].size();j++){
      uf.unite(vec[i][0], vec[i][j]);
    }
  }
  for(int i=1;i<n;i++){
    if(!uf.same(i-1, i)){
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}

Measured memory_bytes: 4608
// abc107_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[] = {1, 0, -1, 0};
bool check(vector<int> vec, int num) {
  for(int x : vec) {
    if(x==num){
      return true;
    }
  }
  return false;
}
int main(int argc, char *argv[])
{
  int h,w;
  string s;
  bool flag;
  vector<int> checkH,checkW;
  cin>>h>>w;
  char a[100][100];
  rep(i,h){
    cin>>s;
    rep(j,w){
      a[i][j]=s[j];
    }
  }
  rep(i,h) {
    flag=true;
    rep(j,w) {
      if(a[i][j]=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      checkH.push_back(i);
    }
  }
  rep(i,w) {
    flag=true;
    rep(j,h) {
      if(a[j][i]=='#'){
        flag=false;
        break;
      }
    }
    if(flag){
      checkW.push_back(i);
    }
  }
  rep(i,h) {
    flag=false;
    rep(j,w){
      // cout<<i<<":"<<j<<":"<<!check(checkH, i)<<"::"<<!check(checkW, j)<<endl;
      if (!check(checkH, i) && !check(checkW, j)) {
        cout<<a[i][j];
        flag=true;
      }
    }
    if (flag){
      cout<<endl;
    }
  }

  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++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N * (N - 1) + M * (M - 1)) / 2 << endl;
}


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

int N=5e5;
int main(int argc, char* argv[])
{
  int64_t m,n,s=0,d=1;
  int c=getchar();
  while (d) {
    for(m=0;c=='<';m++,c=getchar());
    for(n=0;c=='>';n++,c=getchar());
    s += (d = (m>n?m:n) + m*(m-1)/2 + n*(n-1)/2);
  }
  printf("%ld\n",s);
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 100005;
vector<int> graph[MAX_N];
bool passed[MAX_N];

int main(){
  int N,M;
  cin >> N >> M;
  rep(i,M){
    int a,b;
    scanf("%d%d",&a,&b);
    graph[a-1].pb(b-1);
    graph[b-1].pb(a-1);
  }
  deque<int> deq;
  deq.push_back(0);
  deq.push_back(graph[0][0]);
  while(true){
    bool ok = true;
    int s = deq.front();
    int e = deq.back();
    passed[s] = passed[e] = true;
    bool update = false;
    for(auto u:graph[s]){
      if(!passed[u]){
        deq.push_front(u);
        update = true;
        break;
      }
    }
    if(update) continue;
    for(auto u:graph[e]){
      if(!passed[u]){
        deq.push_back(u);
        update = true;
        break;
      }
    }
    if(update) continue;
    break;
  }
  cout << deq.size() << endl;
  for(auto u:deq) cout << u+1 << " ";
  cout << "" << endl;
  return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  int ans = 0;
  ans = n*(n-1)/2+m*(m-1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int tate,yoko;
    for(int a=0;a<=100;a++){
        cin>>tate>>yoko;
        if(tate==0||yoko==0)
        break;
    for(int i=1;i<=tate;i++){
        for(int j=1;j<=yoko;j++){
            if((i+j)%2==0){
                cout<<"#";
            }else{
                cout<<".";
            }
        }cout<<endl;
    }cout<<endl;
    }
}



Measured memory_bytes: 3116
import math

N, M = map(int, input().split())
dp = [math.inf] * pow(2, N)  # (どの宝箱をあけたかのbit)=>現時点の最小値
dp[0] = 0
for _ in range(M):
    a, b = map(int, input().split())
    c = sum([pow(2, int(i)-1) for i in input().split()])
    for i in range(pow(2, N)):
        dp[i | c] = min(dp[i | c], dp[i] + a)
print(dp[-1] if dp[-1]!=math.inf else -1)


Measured memory_bytes: 74784
import sys
from collections import deque
input = sys.stdin.readline

n,m = map(int,input().split())
edge = [[] for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

res = [0]*(n-1)
used = [False]*n

tank = deque([0])
while tank:
    q = tank.popleft()
    if used[q]:
        continue
    used[q] = True

    for go in edge[q]:
        if go == 0 or res[go-1] != 0:
            continue
        res[go-1] = q+1
        tank.append(go)
print("Yes")
print(*res,sep='\n')
        

Measured memory_bytes: 93440
#include <stdio.h>

#define N 8
#define FREE 0
#define N_FREE -1

int row[N];
int col[N];
int dpos[N * 2];
int dneg[N * 2];
int in[N];

void put(int);

int main() {
	int i, j, r, c;
	for (i = 0; i < N; i++) in[i] = N_FREE;
	scanf("%d", &j);
	for (i = 0; i < j; i++) {
		scanf("%d %d", &r, &c);
		/*row[r] = c;
		col[c] = N_FREE;
		dpos[r + c] = N_FREE;
		dneg[r - c + N - 1] = N_FREE;*/
		in[r] = c;
	}
	put(0);
	/*for (i = 0; i < N; i++) {
		for (j = 0; j < N; j++) {
			if (row[i] == j) printf("Q");
			else printf(".");
		}
		printf("\n");
	}*/
	return 0;
}

void put(int i) {
	int j,a,b,flag;
	static int count = 0;
	//sprintf("DEBUG:%d i=%d\n", count++,i);
	if (i == N) {
		//PRINT
		flag = 0;
		for (j = 0; j < N; j++) {
			if (in[j] != row[j] && in[j]!=-1) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			for (a = 0; a < N; a++) {
				for (b = 0; b < N; b++) {
					if (row[a] == b) printf("Q");
					else printf(".");
				}
				printf("\n");
			}
		}
		//printf("DEBUG OK\n");
		return;
	}
	for (j = 0; j < N; j++) {
		if (col[j] == N_FREE ||
			dpos[i + j] == N_FREE ||
			dneg[i - j + N - 1] == N_FREE) {

		}else {
				row[i] = j;
				col[j] = dpos[i + j] = dneg[i - j + N - 1] = N_FREE;
				put(i + 1);
				col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
		}
	}
}


Measured memory_bytes: 2104
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

int A, v, B, w, T;
int main(){
	read(A); read(v);
	read(B); read(w);
	read(T);
	if (v <= w || (abs(A - B) / (v - w) + (abs(A - B) % (v - w) != 0) > T)){
		puts("NO");
	}
	else puts("YES");
    return 0;
}


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

const int N = (int) 2e6 + 5 ;
const int inf = (int) 2e9 ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    int month , day ; scanf("%d %d" , &month , &day ) ;
    int ans = 0 ;
    for( int m = 1 ; m < month ; m++ ) {
        for( int d = 1 ; d <= 31 ; d++ ) {
            ans += ( m == d ) ;
        }
    }
    for( int d = 1 ; d <= day ; d++ ) {
        ans += ( d == month ) ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 256
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int a,b,c; cin>>a>>b>>c;
	int ans = a + b + c - max({a,b,c});
	ote(ans);
}


Measured memory_bytes: 256
#include <iostream>
#define MAXK 100100
using namespace std;

int dp[MAXK];
int A[110];

int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=k;i++)dp[i]=-1;
	
	for(int i=0;i<n;i++)cin>>A[i];
	
	dp[0]=1;
	
	for(int i=0;i<n;i++){
		dp[A[i]]=0;
	}

	for(int i=1;i<=k;i++){
		if(dp[i]==-1){
			dp[i]=1;
			for(int j=0;j<n;j++){
				if(i+A[j]<=k){
				dp[i+A[j]]=0;
                }
                }
		}
	}
	if(dp[k]==1){
		cout<<"Second\n";
	}else cout<<"First\n";
	
}

Measured memory_bytes: 3964