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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string a,b; cin>>a>>b;
  if(a.size()>b.size()) cout<<"GREATER"<<endl;
  else if(a.size()<b.size()) cout<<"LESS"<<endl;
  else if(a>b) cout<<"GREATER"<<endl;
  else if(a<b) cout<<"LESS"<<endl;
  else cout<<"EQUAL"<<endl;
}

Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
bestDiff = 1e99
bestIndex = 0
H = list(map(int, input().split()))
for i in range(N):
    diff = abs(A - (T - H[i] * 0.006))
    if(bestDiff > diff):
        bestDiff = diff
        bestIndex = i + 1
print(bestIndex)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j]<<" ";cout<<endl;}};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,x;cin>>n>>x;
  vector<ll>a(n);
  for(i=0;i<n;i++)cin>>a[i];
  //p[i][j] i回変色時の色jの最小コスト
  vector<vector<ll>>p(n,vector<ll>(n,INF));
  for(i=0;i<n;i++){
    p[0][i]=a[i];
    for(j=1;j<n;j++){
      p[j][(i+j)%n]=a[i];
    }
  }
  for(i=0;i<n;i++){
    for(j=1;j<n;j++){
      chmin(p[j][i],p[j-1][i]);
    }
  }
  for(i=0;i<n;i++){
    buf=0;
    for(j=0;j<n;j++)buf+=p[i][j];
    chmin(res1,buf+i*x);
  }
  cout<<res1<<endl;
  return 0;
}

Measured memory_bytes: 31616
N = gets.to_i
V = gets.split.map(&:to_i)

f02 = Hash.new(0)
f13 = Hash.new(0)
for i in 0...(N / 2)
  f02[V[i * 2    ]] += 1
  f13[V[i * 2 + 1]] += 1
end

x = f02.to_a.max_by{|a| a[1]}
y = f13.to_a.max_by{|a| a[1]}
f13[x[0]] = 0
f02[y[0]] = 0
s02 = f02.values.max || 0
s13 = f13.values.max || 0

if x[1] > y[1]
  puts N - x[1] - s13
elsif x[1] < y[1]
  puts N - s02 - y[1]
else  
  puts N - x[1] - [s02, s13].max
end
  

Measured memory_bytes: 20244
#include <stdio.h>
int main()
{
    int H, W;
    while (1)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        else
        {
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    printf("#");
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll a, b;

int main()
{
  std::cin >> a >> b;

  ll diff = b-a, sum = 0;

  rep( i, diff )
    sum += i+1;

  std::cout << sum-b << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> a(5);
    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
    }

    int ans = 0;
    int p = 10;
    for(int i = 0; i < 5; i++)
    {
        if(a[i] % 10 != 0)
        {
            p = min(p, a[i] % 10);
            a[i] = a[i] + 10 - a[i] % 10;
        }
        ans += a[i];
    }
    cout << ans - 10 + p << endl;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int odp = 0;
    for (int i = 1; i <= k; ++i)
    {
        for (int p = 0; p <= n; ++p)
        {
            for (int s = 0; p + s <= n; ++s)
            {
                int r = i - (p + s);
                if (r < 0)
                    continue;
                vector<int> b;
                for (int j = 0; j < p; ++j)
                    b.push_back(a[j]);
                for (int j = n - s; j < n; ++j)
                    b.push_back(a[j]);
                sort(b.begin(), b.end());
                if (r > b.size())
                    continue;
                int S = 0;
                for (int j = r; j < b.size(); ++j)
                    S += b[j];
                odp = max(odp, S);
            }
        }
    }
    cout << odp;
    return 0;
}


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

int main()
{
    
	long long int n , a , sum = 0 , count = 0;
	cin >> n >> a;
	long  long int arr[a];
	for (int i = 0; i < a; i++) {
	    /* code */
	    cin >> arr[i];
	}
	for (int i = 0; i < a; i++) {
	    /* code */
	    sum = sum + arr[i];
	}
	count = n - sum;
	if(count >= 0)
	{
	    cout << count << endl;
	}
	else
	    cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main ()
{
	int n,m;
	long hi1[10001],a,cnt=0;
	cin >> n;
	for(int i=0;i<n;i++)	cin >> hi1[i];
	cin >> m;
	for(int i=0;i<m;i++)
	{
		cin >> a;
		for(int j=0;j<n;j++)
		{
			if(hi1[j]==a)
			{
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3188
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let split_on_char s c =
  Str.split (Str.regexp (String.make 1 c)) s

let () =
  let rec aux () =
    let n = scan "%d" id in
    if n <> 0 then
      begin
        let ls = scan_lines n "%s %s" tuple2 in
        let arr = Array.make (24*60*60+60*60+2) 0 in
        ListL.iter ls ~f:(fun (s0, s1) ->
            (match List.map int_of_string @@ split_on_char s0 ':' with
             | a::b::c:: _ ->arr.(60*60*a+60*b+c) <- succ arr.(60*60*a+60*b+c)
             |_ -> ());
            match List.map int_of_string @@ split_on_char s1 ':' with
            | a::b::c::_ -> arr.(60*60*a+60*b+c) <- pred arr.(60*60*a+60*b+c)
            | _ -> ());
        ListL.iter (1 ++^ (24*60*60+60*60+2)) ~f:(fun  i->
            arr.(i) <- arr.(pred i) + arr.(i));
        Array.fold_left max 0 arr |> Printf.printf "%d\n";
        aux()
      end
  in
  aux ()



Measured memory_bytes: 14424
#include <iostream>
#include <vector>

using namespace std;

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

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if (h >= K) cnt++;
  }

  cout << cnt << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define INF 100000000005
using namespace std;

typedef long long ll;


int main(){
    int N,W,V;
    ll w[105],v[105],dp[100005];
    cin>>N>>W;
    V=100005;
    int ans = 0;
    dp[0]=0;
    for(int i = 1;i < V;i++){
        dp[i]=INF;
    }
    for(int i = 0;i < N;i++){
        cin>>w[i]>>v[i];
    }

    for(int i = 0;i < N;i++){
        for(int j = V-1;j >= 0;j--){
            if(j+v[i]<V){
                dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
            }
        }
    }
    for(int i = 0;i < V;i++){
        if(dp[i]<=W){
            ans = i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100
#define INFTY 1<<21

void dijstr(void);
int n,A[N][N];

int main()
{
  int i,j,x,y,z,s;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=INFTY;}
                 }
  
  for(i=0;i<n;i++)
    {scanf("%d%d",&x,&y);
      for(j=0;j<y;j++){
	scanf("%d%d",&z,&s);
	A[x][z]=s; }
    }
  dijstr();
  return 0;
}
void dijstr()
{
  int color[N],d[N],p[N],mini;
  int i,u,v;
  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INFTY;}
  d[0]=0;
  color[0]=GRAY;

  while(1)
    {
      mini=INFTY;
      u=-1;
      for(i=0;i<n;i++){
	if(mini>d[i]&&color[i]!=BLACK){
	  u=i;
	  mini=d[i];                  }
                       }
      if(u==-1)break;
      color[u]=BLACK;
      for(v=0;v<n;v++){
	if(color[v]!=BLACK &&A[u][v]!=INFTY){
	  if(d[v]>d[u]+A[u][v]){
	    d[v]=d[u]+A[u][v];
	    color[v]=GRAY; }}
	  }
    }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define int long long
using namespace std;
char g[55][55];
int H,W;
signed main(){
  for(int i=0;i<55;i++){
    g[0][i]='.';
  }
  for(int i=0;i<55;i++){
    g[i][0]='.';
  }
  /*for(int i=0;i<55;i++){
    for(int j=0;i<55;i++){
      cout << g[j][i];
    }
    cout << endl;
  }*/
  cin >> H >> W;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin >> g[i][j];
    }
  }
  for(int i=0;i<55;i++){
    g[H+1][i]='.';
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(g[i][j]=='#'){
        if(g[i+1][j]=='#' || g[i][j+1]=='#' || g[i-1][j]=='#' || g[i][j-1]=='#');
        else{
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys


def dfs1(root, links):
    parent = [0] * n
    subtree_count = [{} for _ in range(n)]
    q = [(root, -1, 0)]  # 2番目:親  3番目:0=初, 1=全ての子巡回後
    while q:
        v, p, t = q.pop()
        if t == 0:
            parent[v] = p
            q.append((v, p, 1))
            for u in links[v]:
                if u == p:
                    continue
                q.append((u, v, 0))
        elif p != -1:
            subtree_count[p][v] = sum(subtree_count[v].values()) + 1
    return parent, subtree_count


def dfs2(root, parent, subtree_count, d2, d2s):
    ans = 0
    q = [(root, 0)]
    while q:
        v, pc = q.pop()

        if len(subtree_count[v]) == 0:
            continue

        p = parent[v]
        children, st_counts = map(list, zip(*subtree_count[v].items()))
        children.append(p)
        st_counts.append(pc)
        cl = len(st_counts)
        ct = sum(st_counts)

        for u, stc in subtree_count[v].items():
            q.append((u, ct - stc + 1))

        if cl == 1:
            continue

        tmp = 0
        for stc in st_counts:
            tmp = (tmp + d2s[ct - stc]) % MOD
        tmp = (tmp - d2s[ct] * (cl - 1)) % MOD
        ans = (ans + (1 - tmp) * d2) % MOD
    return ans


n = int(input())
links = [set() for _ in range(n)]
for line in sys.stdin:
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
root = 0
MOD = 10 ** 9 + 7
d2 = 500000004  # 2^-1 mod 10**9+7
d2s = [1]
for i in range(n):
    d2s.append(d2s[-1] * d2 % MOD)
parent, subtree_count = dfs1(root, links)
# print(parent)
# print(subtree_count)
ans = dfs2(root, parent, subtree_count, d2, d2s)
print(ans)


Measured memory_bytes: 143276
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


void solve() {
    int n;
    cin >> n;
    int q = n / 15;
    cout << 800 * n - 200 * q << endl;
    
}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
//abc047d
using System;

class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int c=0,max=-1,min=1000000001;

            input = Console.ReadLine().Split(' ');
            for(int k = 0; k < N; k++)
            {
                int Ai = int.Parse(input[k]);
                if (min > Ai) min = Ai;
                int x = Ai - min;
                if (x > max)
                {
                    max = x;
                    c = 1;
                }
                else if (x == max) c += 1;
            }

            Console.WriteLine(c);


        }
    }


Measured memory_bytes: 11736
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] x = new int[m];
        int[] y = new int[m];
        for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i = 0; i < m; i++){
        	x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            long dis = Long.MAX_VALUE;
            int ans = 0;
        	for(int j = 0; j < m; j++){
            	if((Math.abs(a[i] - x[j]) + Math.abs(b[i] - y[j])) < dis){
                	ans = j + 1;
                    dis = Math.abs(a[i] - x[j]) + Math.abs(b[i] - y[j]);
                }
            }
            System.out.println(ans);
        }
	}
}

Measured memory_bytes: 35960
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

int A[201] = {0};

int main()
{
	int N = 0, i = 0, odd_exist = 0, ans = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		if (A[i] & 1) {
			odd_exist++;
		}
	}

	if (odd_exist == 0) {
		while(1) {
			for (i = 0; i < N; i++) {
				if (A[i] & 1) {
					odd_exist++;
				} else {
					A[i] = A[i]/2;
				}
			}
			if (odd_exist != 0) {
				break;
			}
			ans++;
		}
	}
	printf("%d\n", ans);
    return 0;
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

ll comb(int n, int r) {
  vector<vector<ll>> v(n+1, vector<ll>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j-1][k-1] + v[j-1][k]);
    }
  }
  return v[n][r];
}

int main() {
  int n, m;
  cin >> n >> m;
  ll ans;
  ans = comb(n, 2);
  if (m < 2) {
    cout << ans << endl;
  } else {
    cout << ans + comb(m, 2) << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n; cin >> n;
  ll a[n]; REP(i,n) cin >> a[i];
  map<ll,ll> mp;
  vector<ll> ans;
  REP(i,n){
    mp[a[i]]++ , mp[a[n-1-i]]--;
    if(mp[a[i]]==0) mp.erase(a[i]);
    if(mp[a[n-1-i]]==0) mp.erase(a[n-1-i]);
    if(mp.empty()) ans.push_back(i+1);
  }
  for(auto v: ans){
    cout << v ;
    if(v!=ans.back()) cout << " ";
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 5324
N, A, B, C, D = map(int, raw_input().split())
mod = 10 ** 9 + 7

# 階乗 & 逆元計算
factorial = [1]
inverse = [1]
for i in xrange(1, N + 2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))


# 組み合わせ計算
def nCr(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod


# n人いたときに、k人組を、x個つくる場合の数
def f(n, k, x):
    return nCr(n, k * x) * factorial[k * x] * pow(pow(factorial[k], x, mod), mod-2, mod) * inverse[x] % mod


dp = [0] * (N + 1)
dp[0] = 1

for k in xrange(A, B + 1):  # k人からなるグループをこれから作りますよ
    for n in range(1, N + 1)[::-1]:  # すでにn人は使っちゃってますよ
        X = xrange(C, D + 1)
        for x in X:
            if n - k * x < 0:  # はみ出る段階で打ち切りますよ
                break
            dp[n] += f(n, k, x) * dp[n - k * x] % mod

print(dp[N] % mod)


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

#define debug(x) cout<<#x<<"="<<x<<endl
#define RD(x) freopen((x),"r",stdin)
#define WT(x) freopen((x),"w",stdout)
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair
const int INF=0x7fffffff;

int n,m,ans;
vector <int> g[53];
bool vis[53];
pii e[53];

bool check_union(){
	bool f=true;
	for (int i=1;i<=n;i++){
		f&=vis[i];
		vis[i]=0;
	}
	return !f;
}

void dfs(int x,int y){
	vis[x]=1;
	for (int i=0;i<g[x].size();i++){
		if (!vis[g[x][i]] && !((x==e[y].first && g[x][i]==e[y].second) || (x==e[y].second && g[x][i]==e[y].first))){
			dfs(g[x][i],y);
		}
	}
}

int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++){
		cin>>e[i].first>>e[i].second;
		g[e[i].first].pb(e[i].second);
		g[e[i].second].pb(e[i].first);
	}
	for (int i=0;i<m;i++){
		dfs(1,i);
		ans+=check_union();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N, W;
  cin >> N >> W;
  
  vector<vector<int64_t>> goods(N,vector<int64_t>(2));

  for(int i = 0; i < N; i++){
    //0行目に重さ
    cin >> goods.at(i).at(0);
    //1行目に価値
    cin >> goods.at(i).at(1);
  }
  
  //DPを宣言
  vector<vector<int64_t>> DP(N, vector<int64_t>(W+1));
  
  //aは仮の値(価値の大きさ)
  int64_t a = 0;
  //deleteは重さの差分
  int del = 0;
  //plus はDP値の更新用
  int64_t plus = 0;
  

  
  for(int i = 0; i < N; i++){
    //j = sum_w
    for(int j = 0; j <= W; j++){
      if(i == 0){
        if(j > goods.at(i).at(0) - 1){
          a = 0 + goods.at(i).at(1) ;
        }
        else{
          a = 0;
        }
      }
      else{
        //選択する場合
        del = goods.at(i).at(0);        
        if(j >= del){
          a = DP.at(i-1).at(j-del) + goods.at(i).at(1);
        }
        plus = max(plus, a);
        
        //選択しない場合
        a = DP.at(i-1).at(j);
      }        
      
      plus = max(plus, a);

      DP.at(i).at(j) = plus;
      a = 0;
      plus = 0;
    }
  }
/*
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 2; j++){
      cout << goods.at(i).at(j) << " ";
    }
    cout << endl;
  }
  cout << endl;


  for(int i = 0; i < N; i++){
    for(int j = 0; j <= W; j++){
      cout << DP.at(i).at(j) << " ";
    }
    cout << endl;
  }
*/ 
  
  cout << DP.at(N-1).at(W);
}

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

int main() {
  ll N; cin >> N;
  ll a[N][N];
  ll b[N][N];
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      cin >> a[i][j]; b[i][j] = a[i][j];
    }
  }
  for (ll k = 0; k < N; k++) {
    for (ll i = 0; i < N; i++) {
      for (ll j = 0; j < N; j++) {
        b[i][j] = min(b[i][j], b[i][k]+b[k][j]);
      }
    }
  }
  ll res = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = i+1; j < N; j++) {
      if (b[i][j] < a[i][j]) {cout << -1 << endl; return 0;}
      ll m = 1e18;
      for (ll k = 0; k < N; k++) {
        if (k == i || k == j) {continue;}
        else {
          m = min(m, b[i][k]+b[k][j]);
        }
      }
      if (m > a[i][j]) {res += a[i][j];}
    }
  }
  cout << res << endl;
}

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

int main() {
  string s; cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') a++;
    else b++;
  }
  cout << 2 * min(a, b) << endl;
  return 0;
}

Measured memory_bytes: 512
#include "stdio.h"
#define N 200000

int main()
{
  int  b, count[N] = {}, c;
  scanf("%d", &b);
  for (int i = 0; i < b - 1; i++) {
    scanf("%d", &c);
    if (c) {
      count[--c] += 1;
    }
  }
  for (int i = 0; i < b; i++) {
    printf("%d\n", count[i]);
  }
  return 0;
}


Measured memory_bytes: 2488
#include <stdio.h>

int main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b && b == c) {
        printf("No\n");
        return 0;
    }
    if (a == b) {
        printf("Yes\n");
    }
    if (a == c) {
        printf("Yes\n");
    }
    if (b == c) {
        printf("Yes\n");
    }
    if (a != b && b != c && c != a) {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int N;cin>>N;
    vector<string> data(N+1);
    REP(i,N){
      cin>>data[i];
    }
    data[N]="zzzzzzzzzzzzzzzzzzzzz";
    sort(data.begin(),data.end());
    vector<string> order(N);

    VI cou(N);
    int count=0;
    int j=0;
    for(int i=0;i<N;i++){
      if(data[i]==data[i+1]){
        count++;
      }
      else if(data[i]!=data[i+1]){
        cou[j]=count;
        order[j]=data[i];
        count=0;
        j++;
      }
    }
    int max=0;
    REP(i,j){
      if(cou[i]>=max){
        max=cou[i];
      }
    }
    REP(i,j){
      if(cou[i]==max){
        cout<<order[i]<<endl;
      }
    }
}

Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

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

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

template <class T>
inline bool chmin(T &a, T b){
    if (a > b){
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b){
    if (a < b){
        a = b;
        return true;
    }
    return false;
}

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

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll LNF = __LONG_LONG_MAX__;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

vector<ll> h;
ll n,a,b;

bool isOK(ll key){
    ll x = b*key;
    ll d = a-b;
    ll c = key;
    rep(i,0,n){
        if(h[i]<=x) continue;
        c -= (h[i]-x+d-1)/d;
    }
    if(c>=0){
        return true;
    }
    else{
        return false;
    }
}

int binary_search(){
    int ng = -1;
    int ok = 1e9+7;
    while(abs(ok-ng)>1){
        int mid = (ok+ng)/2;
        if(isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    h.resize(n);
    rep(i,0,n) cin >> h[i];
    int ans = binary_search();
    cout << ans << endl;
}

Measured memory_bytes: 1024
#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;
	cin >> N;
	while(N >= 0)
	{
		if (N % 4 == 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
		N -= 7;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
			int count = b / a;
			System.out.println((count > c) ? c : count);
		}
	}
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+5;
const int MAXN = 1e9;

ll mm=1000000000;
int main()
{

    ll s;ll x3y2;
    cin>>s;
    if(s%mm==0)x3y2=0;
    else x3y2=(mm-s%mm);

    ll x2y3=s+x3y2;
    //cout<<x2y3<<endl;
    cout<<0<<" "<<0<<" "<<x2y3/mm<<" "<<1<<" "<<x3y2<<" "<<mm;

    //cout<<"0 0 1 0 0 "<<n;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int h,w,dp[22][22][22][22];
string s[55];
int dfs(int ul,int ur,int dl,int dr){
  if(ul>dl||ur>dr)return 0;
  if(dp[ul][ur][dl][dr]!=-1)return dp[ul][ur][dl][dr];
  set<int>st;
  r(i,ul,dl+1){
    r(j,ur,dr+1){
      if(s[i][j]=='X')continue;
      int a,b,c,d;
      a=dfs(ul,ur,i-1,j-1);
      b=dfs(ul,j+1,i-1,dr);
      c=dfs(i+1,ur,dl,j-1);
      d=dfs(i+1,j+1,dl,dr);
      st.insert(a^b^c^d);
    }
  }
  int res=0;
  while(st.count(res))res++;
  return dp[ul][ur][dl][dr]=res;
}
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>h>>w;
  r(i,0,h)cin>>s[i];
  cout<<(dfs(0,0,h-1,w-1)?"First":"Second")<<endl;
}


Measured memory_bytes: 4128
#include<stdio.h>

int main(){
    int right, left, n, q, middle, i, j, S[100000], T[50000], count = 0;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    for (i = 0; i < q; i++){
        scanf("%d", &T[i]);
    }
    
    left = 0;
    right = n;
    for (i = 0; i < q; i++){
        while(right > left){
            middle = (right + left)/2;
            if(S[middle] == T[i]){
                count++;
                break;
            } else if(S[middle] > T[i]){
                right = middle;
            } else {
                left = middle + 1;
            }
        }
        left = 0;
        right = n;
    }
    
    printf("%d\n", count);
    
    return 0;
}



Measured memory_bytes: 2340
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

mat mul(mat &a,mat &b, ll mod){ //a*bなのでn*mとm*l→n*l
    mat c(a.size(),vec(b[0].size()));
    rep(i,a.size()){
        rep(k,b.size()){
            rep(j,b[0].size()){
                ll ab = (a.at(i).at(k)*b.at(k).at(j))%mod;
                (c.at(i).at(j) += ab)%=mod;
            }
        }
    }
    return c;
}

mat matpow(mat a, ll pow, ll mod){
    mat b(a.size(),vec(a.size(),0));
    rep(i,a.size()) b.at(i).at(i) = 1;
    while(pow>0){
        if(pow&1) b = mul(b,a,mod);
        a = mul(a,a,mod);
        pow >>= 1;
    }
    return b;
}
int main() {
    cin>>N>>K;
    mat a(N,vec(N));
    rep(i,N) rep(j,N) cin>>a[i][j];
    ll mod = (1e+9)+7;
    mat b = matpow(a,K,mod);
    mat c(1,vec(N,1));
    mat d = mul(c,b,mod);
    ll ans=0;
    rep(i,N) (ans += d.at(0).at(i))%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 384
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,K;
bool usable[10] = {true,true,true,true,true,true,true,true,true,true};//数iが使えるならtrue

LL ans = INF;

void generate_nums(LL n,LL digit){
	if(n>=N || digit>=1000000LL){
		if(n>=N) ans = min(ans,n);
		return;
	}
	for(int i=0;i<=9;i++){
		if(usable[i]){
			generate_nums(n+i*digit,digit*10LL);
		}
	}
}

void solve(){
	generate_nums(0,1);
}
 
int main(){
    cin >> N >> K;
    for(int i=0;i<K;i++){
    	int n;
    	cin >> n;
    	usable[n] = false;
    }
 
    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
	int i,a,b,k,p=0;
	scanf("%d %d %d",&k,&a,&b);
	if(b-a>k){p=1;}
	else{
		for(i=a;i<=b;i++){
			if(i%k==0){
				p=1;
				break;
			}
		}
	}
	if(p==1){printf("OK\n");}
	else{printf("NG\n");}
	return 0;
}
 

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

int main()
{
	int N;
	cin >> N;
	if (N >= 24) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> D(N), cnt(13);
	for (int i = 0; i < N; i++) {
		cin >> D[i];
		cnt[D[i]]++;
	}
	sort(D.begin(), D.end());
	if (N >= 12) {
		bool dis = cnt[0] == 0;
		for (auto val : cnt) {
			if (val > 2) {
				dis = false;
			}
		}
		cout << dis << endl;
		return 0;
	}
	int res = 0;
	for (int i = 0; i < (1 << N); i++) {
		vector<int> t(N + 1);
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				t[j] = D[j];
			}
			else {
				t[j] = 24 - D[j];
			}
		}
		int ans = 24;
		for (int j = 0; j < N; j++) {
			for (int k = j + 1; k <= N; k++) {
				int d = abs(t[j] - t[k]) % 24;
				ans = min(ans, min(d, 24 - d));
			}
		}
		res = max(res, ans);
	}
	cout << res << endl;
	return 0;
}


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

int main(){
  vector<int> x;
  x = {13,1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
  int a, b;
  cin >> a >> b;
  if (x[a-1] > x[b-1]){
     cout << "Alice" << endl;
  }
  else if(x[a-1]==x[b-1]){
     cout << "Draw" << endl;
  }
  else {
    cout << "Bob" << endl;
  }
}
  

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N, T = map(int, input().split())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(N-1):
        t0 = A[i]
        t1 = A[i+1]

        if t1 - t0 > T:
            ans += T
        else:
            ans += t1 - t0

    return ans + T


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 25104
#include <stdio.h>

int main() {
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a+b>c+d)
    {
        printf("Left");
    }
    if(a+b<c+d)
    {
        printf("Right");
    }
    if(a+b==c+d)
    {
        printf("Balanced");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    if (i%3 == 0 || i%5 == 0) continue;
    ans += i;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)
main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n+1],b[n+1],c[n+1],i,j;
    F(i,1,n)cin>>a[i]>>b[i]>>c[i];
    ll d[n+1][9];
    d[1][0]=a[1];d[1][1]=b[1];d[1][2]=c[1];
    F(i,2,n)
    {
        d[i][0]=a[i]+max(d[i-1][2],d[i-1][1]);
        d[i][1]=b[i]+max(d[i-1][2],d[i-1][0]);
        d[i][2]=c[i]+max(d[i-1][1],d[i-1][0]);
    }
    cout<<max(d[n][1],max(d[n][0],d[n][2]));
}


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

int main(){
	int N, Y;
	cin >> N >> Y;
	bool ans = false;
	int ans_i = -1, ans_j = -1, ans_k = -1;
	for(int i = 0; i <= N; i++)
	{
		for(int j = 0; j <= N; j++)
		{
			if (i + j > N) {
				continue;
			}

			int k = N - i - j;
			if (i * 10000 + j * 5000 + k * 1000 == Y) {
				ans = true;
				ans_i = i; ans_j = j; ans_k = k;
				break;
			}
		}
		if(ans) break;		
	}

	cout << ans_i << ' ' << ans_j << ' ' << ans_k << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main(){ 
 
  ll t1,t2; cin >> t1 >> t2;
  ll a1,b1,a2,b2; cin >> a1 >> a2 >> b1 >> b2;
  
  if( a1 < b1 ){ swap(a1,b1); swap(a2,b2);}
  
  ll d1 = (a1-b1)*t1; ll d2 = (a2-b2)*t2;
  
  if( d1+d2 > 0){ cout << 0 << endl;}
  else if( d1+d2 == 0 ){ cout <<"infinity" << endl;}
  else{
    
    ll k = ceil( (long double)d2/(d1+d2) );
    
    if( d1*k+d2*(k-1) < 0){ cout << 2*k-3 << endl;}
    else{ cout << 2*k-2 << endl;}
    
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int mod_pow(int x,int n){
    if(n==0)
        return 1;
    int res=mod_pow(x*x%mod,n/2);
    if(n%2==1)
        res=res*x%mod;
    return res;
}
int mod_fact(int n){
    return(n==0?1:mod_fact(n-1)*n%mod);
}
int mod_comb(int n,int k){
    int a1=mod_fact(n),a2=mod_fact(k),a3=mod_fact(n-k);
    return a1*mod_pow(a2*a3%mod,mod-2)%mod;
}
signed main(){
    int x,y;
    cin>>x>>y;
    if((2*x-y)%3!=0||(2*y-x)%3!=0||2*x<y||2*y<x){
        cout<<0<<endl;
        return 0;
    }
    cout<<mod_comb((x+y)/3,(2*x-y)/3)<<endl;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,A,N,M,K,S,T,X,Y,Z;
  cin >> N >> K;
  vector<int> H_i(N);
  unsigned long long count = 0;

  for(int i=0 ; i < N ; i++){
    cin >> H_i.at(i);
  }
  sort(H_i.begin(),H_i.end(),greater<int>());
  
  if(N <= K){
    cout << 0 << endl;
    return(0);
  }

  for(int j=K ; j < N ; j++){
    count += H_i.at(j);
  }
  cout << count << endl;

  return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long int N,K;
    cin >> N >> K;
 
    long int sa = N % K;

    long int result = min(abs(K-sa),min(abs(sa - K),sa));

    cout << result << endl;
  
    
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=c-a,y=d-b;
	printf("%d %d %d %d\n",c-y,d+x,a-y,b+x);
	
		
		
}
						

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

typedef long long ll;

using namespace std;

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

    int first = stoi(s.substr(0, 2));
    int second = stoi(s.substr(2, 2));

    bool fma = (1 <= first && first <= 12) ? true : false;
    bool sma = (1 <= second && second <= 12) ? true : false;

    if (fma && sma)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (fma)
    {
        cout << "MMYY" << endl;
    }
    else if (sma)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }

    return 0;
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;

typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector< vector<long long> > lmat;

typedef vector<string> svec;
typedef vector< vector<string> > smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

ll gcd(ll x, ll y){
    ll r = x%y;
    if(r == 0) return y;
    else return gcd(y, r);
} 

ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string n;
    cin >> n;
    ll cnt=0;
    int carry=0;
    lmat dp = lmat(n.size(), lvec(2));
    dp[n.size()-1][0] = n[n.size()-1]-'0';
    dp[n.size()-1][1] = 10 -(ll)(n[n.size()-1]-'0');
    for (ll i = n.size()-2; i >=0; i--)
    {
        dp[i][0] = ((int)(n[i] - '0') !=9 ) ?  min(dp[i+1][0] + (ll)(n[i]-'0'), dp[i+1][1]+(ll)(n[i]-'0')+1) : dp[i+1][0]+(ll)(n[i]-'0');
        
        dp[i][1] = min(dp[i+1][0] + 10 - (ll)(n[i]-'0'), dp[i+1][1]+ 10 - ((ll)(n[i]-'0')+1));
        
        
    }
    cout << min(dp[0][0], dp[0][1]+1) << endl;
}

Measured memory_bytes: 55964
N = input()
A = list(map(int, input().split()))
count = 0
existOdd = False
while not existOdd:
    for a in A:
        if a % 2 == 1:
            existOdd = True

    if not existOdd:
        A = list(map(lambda x: x / 2, A))
        count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
 
bool check(int n,int m,int x,int y) {
  if(x<0 || x>=n || y<0 || y>=m) return false;
  return true;
}
 
struct P {
  int xx,yy,kk;
  string cc;
};
 
 
string change(int k,string c) {//t,n,e,b,s,w
  if(k==0) {//front
    swap(c[0],c[4]);
    swap(c[0],c[1]);
    swap(c[1],c[3]);
  } else if(k==1) { //back
    swap(c[0],c[1]);
    swap(c[0],c[4]);
    swap(c[3],c[4]);
  } else if(k==2) { //right
    swap(c[0],c[2]);
    swap(c[0],c[5]);
    swap(c[3],c[5]);
  } else if(k==3) { //left
    swap(c[0],c[5]);
    swap(c[0],c[2]);
    swap(c[2],c[3]);
  }
  return c;
}
 
int main() {
  int n,m;
  while(cin >> m >> n && (n||m)) {
    string s[n],t;
    for(int i=0; i<n; i++) cin >> s[i];
    cin >> t;
    int sx,sy;
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
    if(s[i][j]=='#') {
      sx=i;sy=j;
    }
      }
    }
    queue<P> que;
    P p;
    p.xx=sx;p.yy=sy;p.kk=0;p.cc="rgbcmy";
    que.push(p);
    map<string,int> z[7][n][m];
    for(int i=0; i<7; i++) {
      for(int j=0; j<n; j++) {
    for(int k=0; k<m; k++) z[i][j][k].clear();
      }
    }
    z[0][sx][sy][p.cc]=0;
    int ans=0;
    while(!que.empty()) {
      p=que.front();que.pop();
      int nx=p.xx,ny=p.yy,k=p.kk;
      string c=p.cc;
      if(k==6) {
    ans=z[k][nx][ny][c];
    break;
      }
      for(int i=0; i<4; i++) {
    int x=nx+dx[i],y=ny+dy[i];
    if(!check(n,m,x,y) || s[x][y]=='k') continue;
    string c2=change(i,c);
    P p2;
    p2.xx=x;p2.yy=y;p2.kk=k;p2.cc=c2;
    if(c2[0]==t[k] && s[x][y]==t[k]) p2.kk++;
    if(s[x][y]!='w' && s[x][y]!='#') {
      if(t[k]!=s[x][y]) continue; 
      if(s[x][y]==t[k] && s[x][y]!=c2[0]) continue;
    }
    if(z[p2.kk][x][y][c2]!=0) continue;
    que.push(p2);
    z[p2.kk][x][y][c2]=z[k][nx][ny][c]+1;
      }
    }
    if(ans==0) cout << "unreachable" << endl;
    else cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 8664
#include<stdio.h>
int main(){
  int n,m,i,j,a,b;
  char c;
  while(scanf("%d %d",&n,&m),n||m){
    char w[101]={0};
    while(m--){
      scanf(" %c %d %d",&c,&a,&b);
      a++;
      if(c=='s'){
	for(i=0;i+b<=n;i++){
	  if(w[i])continue;
	  for(j=0;j<b;j++){
	    if(w[i+j])break;
	  }
	  if(j==b){
	    printf("%d\n",i);
	    for(j=0;j<b;j++)w[i+j]=a;
	    break;
	  }
	  i+=j-1;
	}
	if(i+b>n)printf("impossible\n");
      }
      else{
	for(i=0;w[i]-a;i++);
	for(;w[i]==a;i++)w[i]=0;
      }
    }
    printf("END\n");
  }
  return 0;
}
	  
	   

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

int main() {
  int D, N[110], K; string S;
  cin >> S >> K; D = S.size();
  if (D < K) cout << 0 << endl;
  else {
    int W = D - K + 1;
    int i, j, d, A[K+1][W+1], B[K+1][W+1];
    for (d = 0; d < D; d++) {
      N[d] = stoi(S.substr(d, 1));
    }
    for (i = 0; i <= K; i++) {
      for (j = 0; j <= W; j++) {
        A[i][j] = B[i][j] = 0;
      }
    }
    for (j = 0; j <= W; j++) A[0][j] = 1;
    i = 0; j = 1;
    for (d = 0; d < D; d++) {
      B[i][j] = 9 - N[d];
      if (N[d]) i++; else j++;
      if (i > K || j > W) break;
    }
    for (i = 1; i <= K; i++) {
      for (j = 1; j <= W; j++) {
        A[i][j] = A[i][j-1] + A[i-1][j] * 9 - B[i-1][j];
      }
    }
    cout << A[K][W] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    string a, b, c; cin >> a >> b >> c;
    out(a[0] << b[0] << c[0]);
}



Measured memory_bytes: 256
N,K=gets.chomp.split(' ').map{|n| n.to_i}

sum = 0
if(K==0)
	puts N*N
	exit(0)
end
K.upto(N){|b|
	q = N/b
	r = N-q*b-(K-1)
	r = 0 if r < 0
	dif = (b-(K))*q + r
	sum += dif
	# puts "bqr #{b}, #{q}, #{r}, sum+=#{dif}"
}
puts sum


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 7;
using namespace std;
int cnt[maxn], mod = 998244353;
int prime[maxn], tot = 0;
bool check[maxn];
ll f[maxn];
void init(int n){
    f[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!check[i]){
            prime[tot++] = i;
            f[i] = (1 - i + mod) % mod;
        }
        for(int j = 0, u; j < tot && (u = i * prime[j]) <= n; j++){
            check[u] = 1;
            if(i % prime[j] == 0){
                int x = i;
                while(x % prime[j] == 0) x /= prime[j];
                f[u] = f[x] * (1 - prime[j] + mod) % mod;
                break;
            }else{
                f[u] = f[i] * f[prime[j]] % mod;
            }
        }
    }
}
ll g(int T, int n){
    ll ans = 0;
    for(int i = 1; i <= n / T; i++){
        ans += 1ll * i * cnt[i * T] % mod;
        ans %= mod;
    }
    return ans;
}
ll qpow(ll a, ll n){
    ll ans = 1;
    for(a %= mod; n; n >>= 1){
        if(n & 1) ans = ans * a % mod;
        a = a * a % mod;
    }
    return ans;
}
ll inv(ll x){
    return qpow(x, mod - 2);
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    int n; scanf("%d", &n);
    ll sum = 0;
    for(int i = 1, t; i <= n; i++){
        scanf("%d", &t);
        cnt[t]++;
        sum = (sum + t) % mod;
    }
    init(maxn - 1);
    ll ans = 0;
    for(int i = 1; i < maxn; i++){
        ll t = g(i, maxn - 1);
        t = t * t % mod;
        ans += i * f[i] % mod * t % mod;
        ans %= mod;
    }
    ans = (ans - sum) % mod;
    ans = ans * inv(2) % mod;
    ans = (ans % mod + mod) % mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 16840
N = int(input())
D, X = map(int, input().split())
A = [int(input()) for _ in range(N)]

num = 0
for n in range(N):
    plus = A[n]
    comp = 0
    while True:
        if 1 + comp > D:
            break
        else:
            num += 1
            comp += plus

print(num + X)

Measured memory_bytes: 3060