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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(a, b);
	inn(h, m);
	double rh = 30 * h + 0.5 * m;
	double rm = 6 * m;
	double r = (rh > rm ? rh - rm : rm - rh);
	if (r > 180) r = 360 - r;

	double x2 = pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(rad(r));
	cout << fixed << setprecision(12) << sqrt(x2) << endl;
	return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) for(ll i=1;i<=(n);i++)
#define MOD 1000000007
#define int long long
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9;

ll T;   //合計T[g]の砂
int K;  //砂時計をひっくり返す回数
int Q;  //クエリ数

signed main()
{
    cin >> T;
    cin >> K;
    set<P> events;
    REP(i,K) {
        int t;  //ひっくり返す時刻。元から昇順で並んでいる
        cin >> t;
        events.insert(P(t, -1));    //reverse query
    }
    cin >> Q;
    REP(i,Q) {
        ll t;   //時刻
        ll f;   //始めのAの砂の量
        cin >> t >> f;
        events.insert(P(t, f));
    }

    bool inc = false;   //A,Bどちらが上か。Aが上のときfalse
    ll pt = 0;
    ll a = 0;
    ll b = T;
    ll c = 0;
    for (P e : events) {
        ll t = e.first;     //ひっくり返す、もしくはクエリの時刻
        ll x = e.second;    //-1ならreverse query

        if (inc) {  //Bが上
            ll d = t - pt;
            c += d;
            if (b + c > T) b = T - c;
            if (a > b) a = b;
        } else {    //Aが上
            ll d = t - pt;
            c -= d;
            if (a + c < 0) a = -c;
            if (a > b) b = a;
        }
        if (x == -1) {  //reverse
            inc = !inc;
        } else {
            cout << max(a, min(b, x)) + c << endl;
        }
        pt = t;
    }
}


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

typedef long long ll;

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}

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

int main() {
	ll a, b; cin >> a >> b;
	cout << lcm(a, b) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			final long K = sc.nextLong();
			
			int[] as = new int[N];
			for(int i = 0; i < N; i++) {
				as[i] = sc.nextInt() - 1;
			}
			
			long[] depth = new long[N];
			Arrays.fill(depth, -1);
			
			{
				int curr_node = 0, curr_depth = 0;
				while(depth[curr_node] < 0) {
					depth[curr_node] = curr_depth++;
					curr_node = as[curr_node];
				}
				
				//System.out.println(curr_depth + " " + depth[curr_node]);				
				final long loop_length = curr_depth - depth[curr_node];
				final long start = K - depth[curr_node];
				if(start < 0) {
					int answer = 0;
					for(int i = 0; i < K; i++) {
						answer = as[answer];
					}
					
					System.out.println(answer + 1);
				}else {
					final long mod = start % loop_length;
				
					int answer = curr_node;
					for(int i = 0; i < mod; i++) {
						answer = as[answer];
					}
					
					System.out.println(answer + 1);
				}
			}
			
			
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 54344
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e4 +7;
const ll mod = 1e9 +7;
ll a[N];
int main()
{
    ll n,k;
    scanf("%lld%lld",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    ll ans=0;
    ll cnt;
    for(int i=0;i<n;i++){
        cnt = 0;
        for(int j=0;j<i;j++){
            if(a[j] > a[i])
                cnt++;
        }
        ans = (ans + cnt * k) % mod;
        cnt = 0;
        for(int j=0;j<n;j++){
            if(a[j] > a[i])
                cnt++;
        }
        ans = (ans + k * (k-1) / 2 % mod * cnt %mod) % mod;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifdef LOCAL
#include "prabh.hpp"
#endif

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

int n, m, k;
vector<list<int>> adjList(N);
vector<list<int>> bad(N);
vector<int> col(N, -1), sz;
vector<int> ans(N);
int cur = 0;

int dfs(int nd) {
	col[nd] = cur;

	int ans = 1;
	for (int i : adjList[nd]) {
		if (col[i] == -1)
			ans += dfs(i);
	}

	return ans;
}

void solve() {
	cin >> n >> m >> k;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		adjList[a].pb(b);
		adjList[b].pb(a);
	}

	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		bad[a].pb(b);
		bad[b].pb(a);
	}

	for (int i = 1; i <= n; i++) {
		if (col[i] == -1) {
			sz.pb(dfs(i));
			cur++;
		}
	}


	for (int i = 1; i <= n; i++) {
		ans[i] = sz[col[i]] - adjList[i].size() - 1;
		for (int padosi : bad[i])
			if (col[padosi] == col[i]) ans[i]--;
	}

	for (int i = 1; i <= n; i++)
		cout << ans[i] << " ";
}

// you should probably see down .. believe me it would help
int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//       cin >> t_c;
	while (t_c--)
		solve();
}

// COME ON DUDE .... GIVING UP NOT GONNA HELP
// JUST GET YOUR ASS TO WORK ALREADY ..
// AND FOR FUCKING SAKE ... DONT PANIC !!


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

int main(){
int N, K;
cin >> N >> K;
cout << N-K+1 << endl;
}


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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> vec(N+1);
    for(int i=0; i<M; i++){
        int c;
        cin >> c;
        vec[c] = 1;
    }

    int x=0;
    for(int i=0; i<=X; i++){
        x += vec[i];
    }

    int y=0; 
    for(int i=X; i<=N; i++){
        y += vec[i];
    }

    cout << min(x, y) << endl;
}


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

int n;
int k[1001];
string str[1001];
vector<int> G[1001];

void dfs(int v,int d){
	for(int i=0;i<d;i++){
		printf(".");
	}
	cout << str[v] << endl;
	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i],d+1);
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&k[i]);
		G[k[i]].push_back(i);
		cin >> str[i];
	}
	dfs(1,0);
	return 0;
}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K; cin >> N >> K;
    int one = -1;
    int A[N]; rep(i, N){cin >> A[i]; if(A[i] == 1) one = i;}
    //右に(N-1)-one個,左にone個
    int pos = 0;
    int ans = 0;
    while(pos < N-1){
        pos += K-1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

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

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

const int cap = 1e5 + 1;
int N;
int H[cap], dp[cap];

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; ++i)
        scanf(" %d", &H[i]);
    dp[1] = 0;
    dp[2] = abs(H[1] - H[2]);
    for (int i = 3; i <= N; ++i) {
        dp[i] = min(dp[i - 2] + abs(H[i] - H[i - 2]), dp[i - 1] + abs(H[i] - H[i - 1]));
    }
    printf("%d\n", dp[N]);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int n,count = 0;
  	cin >> n;
  	vector<int>a(n);
  	for(int i = 0; i < n;i++)
      	cin >> a[i];
  	sort(a.begin(),a.end());
  	for(int i = 0; i< n-1;i++)
  		count += a[i];
  	count +=a[n-1]/2;
  	cout << count << endl;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << '\n';
  } else {
    cout << "Impossible" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <cstdlib>
#include <string.h>
using namespace std;
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 long long INF = 1LL << 60;
 
int N;
long long h[100010];
 
long long dp[100010];
 
int main() {
  int N; cin >> N;
  for (int i = 0; i < N; ++i) cin >> h[i];
  
  for (int i = 0; i < 100010; ++i) dp[i] = INF;
  
  dp[0] = 0;
  
  for (int i = 1; i < N; ++i) {
    chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
    if ( i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[int(_) for _ in input().split()]
    sumA=sum(A)
    sumB=sum(B)
    if sumA<sumB:
        print(-1)
        sys.exit()
    D=[0]*n
    sum_plus=0
    sum_minus=0
    ans=0
    for i in range(n):
        diff=A[i]-B[i]
        if diff>0:
            D.append(diff)
        elif diff<0:
            sum_minus-=diff
            ans+=1
    D.sort(reverse=True)
    if sum_minus==0:
        print(0)
        sys.exit()
    for d in D:
        ans+=1
        if sum_minus<=d:
            print(ans)
            break
        sum_minus-=d


if __name__=='__main__':
    main()

Measured memory_bytes: 18356
#!/usr/bin/ruby

def travel(t, x, y, x_now, y_now)
  if t < (x - x_now).abs + (y - y_now).abs then
    return false
  elsif t == (x - x_now).abs + (y - y_now).abs then
    return true
  else
    return travel(t-2, x, y, x_now, y_now)
  end
end


t = [0]
x = [0]
y = [0]
i = 0

n = STDIN.gets.to_i

ret = true

while line = gets
  input = line.split(" ")
  t << input[0].to_i
  x << input[1].to_i
  y << input[2].to_i

  i += 1
  if i == n then
    break
  end
end

for i in 1..n do
  if !(travel(t[i]-t[i-1], x[i], y[i], x[i-1], y[i-1])) then
    ret = false
    break
  end
end

if ret then
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 4252
#include <iostream>

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

  for (int i = 1; i < 10; ++i) {
    if (n % i == 0 && n / i < 10) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }
  std::cout << "No" << std::endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] C1 = new int[3];
        int[] C2 = new int[3];
        int[] C3 = new int[3];
        for (int i = 0; i < 3; ++i) {
            C1[i] = sc.nextInt();
            C2[i] = sc.nextInt();
            C3[i] = sc.nextInt();
        }
        if (sol(C1) != sol(C2) || sol(C2) != sol(C3)) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }

    private static int sol(int[] C) {
        Arrays.sort(C);
        int sum = 0;
        for (int n : C) {
            sum += n;
        }
        return sum - C[0] * C.length;
    }
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


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

class Dice
{
public:
  vint pos;


  Dice();
  void roll(char d);
  ll face();
};

Dice::Dice(){
  pos.resize(6);
  rep(i,6) pos[i] = i;
}

void Dice::roll(char d){
  vint tmp_pos = pos;

  if(d == 'E'){
    pos[2] = tmp_pos[0];
    pos[0] = tmp_pos[3];
    pos[3] = tmp_pos[5];
    pos[5] = tmp_pos[2];
  }else if(d == 'N'){
    pos[0] = tmp_pos[1];
    pos[1] = tmp_pos[5];
    pos[5] = tmp_pos[4];
    pos[4] = tmp_pos[0];
  }else if(d == 'S'){
    pos[0] = tmp_pos[4];
    pos[4] = tmp_pos[5];
    pos[5] = tmp_pos[1];
    pos[1] = tmp_pos[0];
  }else if(d == 'W'){
    pos[0] = tmp_pos[2];
    pos[2] = tmp_pos[5];
    pos[5] = tmp_pos[3];
    pos[3] = tmp_pos[0];
  }else{
    assert(false);
  }
  // rep(i,6) cout<<pos[i]<<" ";
  // cout<<endl;

}

ll Dice::face(){
  return pos[0];
}


int main() {


  cout<<fixed<<setprecision(10);

  vint v(6);
  rep(i,6)cin>>v[i];

  Dice d = Dice();

  string order;
  cin>>order;
  rep(i, order.size()){
    d.roll(order[i]);
  }

  cout<<v[d.face()]<<endl;
}





//









Measured memory_bytes: 3196
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var d = int.Parse(Console.ReadLine());
            var diff = 25 - d;
            var answer = "Christmas";
            for (var i = 0; i < diff; i++)
            {
                answer += " Eve";
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11092
X,N = map(int, input().split())


if N > 0:
    p = list(map(int,input().split()))
    
    for i in range(1000):
        if X-i not in p:
            print(X-i)
            break
        elif X+i not in p:
            print(X+i)
            break
    
    #y = [abs(i - X) for i in p]
    
else:
    input()
    print(X)

Measured memory_bytes: 9184
import java.util.*;
import java.awt.Point;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Integer dx[] = {0, 1, 0, -1};
        Integer dy[] = {1, 0, -1, 0};
        int INF = Integer.MAX_VALUE;
        Queue<Point> queue = new ArrayDeque<>();
        int h = sc.nextInt();
        int w = sc.nextInt();
        char[][] map = new char[h][w];
        int a[][] = new int[h][w];
        for(int[] n : a){
            Arrays.fill(n,INF);
        }
        for(int i=0; i<h; i++){
            map[i] = sc.next().toCharArray();
            for(int j=0; j<w; j++){
                if(map[i][j]=='#'){
                    queue.add(new Point(i,j));
                    a[i][j] = 0;
                }
            }
        }
        int memo = 0;
        while(!queue.isEmpty()){
            Point p = queue.poll();
            for(int k=0; k<4; k++){
                int X = p.x + dx[k];
                int Y = p.y + dy[k];
                if(X>=0 && X<h && Y>=0 && Y<w && a[X][Y]==INF){
                    a[X][Y] =  a[p.x][p.y] + 1;
                    queue.add(new Point(X,Y));
                    memo = a[X][Y];
                }
            }
        }
        System.out.println(memo);
    }
}

Measured memory_bytes: 66028
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll a,b;
  cin >> a >> b;
  if (a >= 13) {
    cout << b << endl;
  }
  else if (6 <= a && a <= 12) {
    cout << b/2 << endl;
  }
  else {

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


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{char A, B, C, D; cin >> A >> B >> C >> D;
 
 int a,b,c,d;
 a = A - '0';
 b = B - '0';
 c = C - '0';
 d = D - '0';
 
 int x, y; x = 10*a + b; y = 10*c + d;
 
 //xが上二桁の整数、yが下２桁の整数をそれぞれ表す
 
 if( 1 <= x && 1 <= y && x <= 12 && y <= 12){cout << "AMBIGUOUS"; return 0;}
 else if( 1 <= x && x <= 12 && 0 <= y && y <= 99){cout << "MMYY"; return 0;}
 else if( 0 <= x && x <= 99 && 1 <= y && y <= 12){cout << "YYMM"; return 0;}
 else { cout << "NA"; return 0;}
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
using namespace std;

int main() {
	string S; cin >> S;
	if (S == "SUN")cout << 7 << endl;
	if (S == "MON")cout << 6 << endl;
	if (S == "TUE")cout << 5 << endl;
	if (S == "WED")cout << 4 << endl;
	if (S == "THU")cout << 3 << endl;
	if (S == "FRI")cout << 2 << endl;
	if (S == "SAT")cout << 1 << endl;
}

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

using ll = long long;
static const ll MOD = 998244353;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, q;
  cin >> n >> q;
  
  vector<vector<ll>> dp(10, vector<ll>(n + 1));
  for (ll i = 1; i < 10; i++) {
    ll now = 0;
    for (int j = 1; j <= n; j++) {
      now = (now * 10 + i) % MOD;
      dp[i][j] = now;
    }
  }
  
  set<vector<ll>> s;
  s.insert({1, n, 1});
  s.insert({-1, -1, 0});
  s.insert({n + 1, n + 10000, 0});
  ll ans = dp[1][n];
  
  while (q--) {
    ll l, r, d;
    cin >> l >> r >> d;
    auto it = s.upper_bound({l, n + 1, 0});
    it--;
    vector<ll> x = *it;
    ll l2 = n - l + 1, r2 = n - r + 1;
    if (x[0] < l && r < x[1]) {
      ans -= dp[x[2]][l2] - dp[x[2]][r2 - 1];
      ans += dp[d][l2] - dp[d][r2 - 1];
      s.erase(it);
      s.insert({x[0], l - 1, x[2]});
      s.insert({r + 1, x[1], x[2]});
      s.insert({l, r, d});
      ans = (ans + MOD * MOD) % MOD;
      cout << ans << '\n';
      continue;
    }
    
    if (x[0] < l) {
      ans -= dp[x[2]][l2] - dp[x[2]][n - x[1] + 1 - 1];
      it = s.erase(it);
      s.insert({x[0], l - 1, x[2]});
    }
    while (true) {
      x = *it;
      if (r < x[1]) break;
      ans -= dp[x[2]][n - x[0] + 1] - dp[x[2]][n - x[1] + 1 - 1];
      it = s.erase(it);
    }
    if (x[2] > 0) {
      ans -= dp[x[2]][n - x[0] + 1] - dp[x[2]][r2 - 1];
      it = s.erase(it);
      s.insert({r + 1, x[1], x[2]});
    }
    ans += dp[d][l2] - dp[d][r2 - 1];
    s.insert({l, r, d});
    
    ans = (ans + MOD * MOD) % MOD;
    cout << ans << '\n';
  }
}

Measured memory_bytes: 37740
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int p = 1;
	for (int i = 0; i < m; i++) {
		p *= 2;
	}
	int ans = ((n - m) * 100 +1900 * m) * p;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define N 305
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define LL long long
using namespace std;

char str[2][60];
int num[60];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s%s",str[0],str[1]);
	LL ans=3;
	for(int i=1;i<n;i++)
	{
		if(str[0][i]==str[1][i])
		{
			if(str[0][i-1]!=str[1][i-1])
			{
				continue;
			}
			else 
			{
				ans*=2;
				ans%=MOD;
			}
		}
		else
		{
			if(i==1) ans*=2;
			else if(str[0][i-1]==str[1][i-1])
			{
				ans*=2;
				ans%=MOD;
			}
			else
			{
				if(i-2>=0&&str[0][i-2]!=str[1][i-2])
				{
					ans*=3;
					ans%=MOD;
				}
			}
			i++; 
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
n = int(input())

def make753(s):
    count = 0
    if int(s) > n:
        return 0
    if all(s.count(i) > 0 for i in '753'):
        count += 1
    for i in '753':
        count += make753(s + i)
    return count

print(make753('0'))

Measured memory_bytes: 2940
#include<iostream>
#include<queue>
using namespace std;
int n,k;
vector<int>adj[2001];
int u[2001],v[2001];
int d[2001];
int q[2001];
int st,en;
int ans=0;
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i=1; i<n ;i++){
		cin >> u[i] >> v[i];
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	if(k%2==1){
		for(int i=1; i<n ;i++){
			for(int j=1; j<=n ;j++) d[j]=1e9;
			d[u[i]]=d[v[i]]=0;
			int cnt=0;
			st=1,en=2;
			q[1]=u[i],q[2]=v[i];
			while(st<=en){
				int cur=q[st++];
				for(auto newi:adj[cur]){
					if(d[newi]>d[cur]+1){
						d[newi]=d[cur]+1;
						q[++en]=newi;
					}
				}
			}
			for(int j=1; j<=n ;j++) cnt+=(d[j]<=k/2);
			ans=max(ans,cnt);
		}
	}
	else{
		for(int i=1; i<=n ;i++){
			for(int j=1; j<=n ;j++) d[j]=1e9;
			d[i]=0;
			int cnt=0;
			st=1,en=1;
			q[1]=i;
			while(st<=en){
				int cur=q[st++];
				for(auto newi:adj[cur]){
					if(d[newi]>d[cur]+1){
						d[newi]=d[cur]+1;
						q[++en]=newi;
					}
				}
			}
			for(int j=1; j<=n ;j++) cnt+=(d[j]<=k/2);
			ans=max(ans,cnt);
		}
	}
	cout << n-ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
int main()
{
      int  n,m;
      LL sum_even,sum_odd,mul;
      while(cin>>n>>m)
      {
           sum_even=sum_odd=0;
           for(int i=1;i<=2*n;++i)
           {
                mul=(LL) i*m;
                if(mul%2==1)continue;
                if(mul/2>n)break;
                if(mul/2%m==0)++sum_even;
                else ++sum_odd;
           }
           cout<<sum_odd*sum_odd*sum_odd+sum_even*sum_even*sum_even<<endl;
      }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		H = H - a;
	}

	if (H <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main(){
  int64_t N, K;
  cin >> N >> K;
  vector<int> vec(2*N);
  rep(i, N){
    cin >> vec.at(i);
    vec.at(N + i) = vec.at(i);
  }
  
  int64_t ans1 = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i + 1; j < N; j++){
      if(vec.at(i) > vec.at(j)) ans1++;
    }
  }
  
  int64_t ans2 = 0;
  for(int i = 0; i < N; i++){
    for(int j = N; j < 2*N; j++){
      if(vec.at(i) > vec.at(j)) ans2++;
    }
  }
  
  ans1 = ans1 * K % INF;
  int64_t rep = (K * (K - 1) / 2) % INF;
  ans2 = ans2 * rep % INF;
  cout << (ans1 + ans2) % INF << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int sz;
    sz = s.size();
    int cnt=0;
    for(int i=0; i<sz; i++){
        if(s[i]!=t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}




Measured memory_bytes: 3856
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	rep(i,7){
		int a,b;
		cin>>a>>b;
		cout<<a-b<<endl;
	}
}

Measured memory_bytes: 1164
using System;

namespace AtCoder {
    class Program {

        static void Main(string[] args) {

            var N = int.Parse(Console.ReadLine());

            var diff = N % 111;
            var result = 0;
            if(diff == 0) {

                result = N;
            } else {

                result = N + 111 - diff;
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
#define N 3010
using namespace std;
ll po(ll x,ll y,ll mo){ll z=1;while (y){if (y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll ans,n,mo,f[N][N],c[N][N],p[N*N];
int main(){
	cin>>n>>mo;
	f[0][0]=c[0][0]=1;
	p[0]=1;for (int i=1;i<=n*n;i++)p[i]=p[i-1]*2%mo;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=i;j++){
			f[i][j]=f[i-1][j]*(1+j)%mo;c[i][j]=c[i-1][j];
			if (j)f[i][j]=(f[i][j]+f[i-1][j-1])%mo,c[i][j]=(c[i][j]+c[i-1][j-1])%mo;
		}
	for (int i=0;i<=n;i++){
		ll su=0;
		for (int j=0;j<=i;j++)su=(su+p[(n-i)*j]*f[i][j])%mo;
		ans=(ans+((po(mo-1,i,mo)*po(2,po(2,n-i,mo-1),mo)%mo)*su%mo)*c[n][i])%mo;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 212352
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
  cin >> n;
  string str;
  cin >> str;
  if (str.size() > n){
  	for (int i=0;i<n;++i)
      	cout << str[i];
    cout << "..." << endl;
  }
  else
    cout << str << endl;;
}

Measured memory_bytes: 3580
K = int(input())
def euclid(a, b):
    if b == 0:
        return a
    return euclid(b, a%b)

ans = 0
for i in range(1, K + 1):
    for j in range(1, i + 1):
        for k in range(1, j + 1):
            tmp = euclid(i, j)
            if k < tmp:
                gcd = euclid(tmp, k)
            else:
                gcd = euclid(k, tmp)
            if i == j == k:
                ans += gcd
            elif i == j or j == k or k == i:
                ans += gcd * 3
            else:
                ans += gcd * 6

print(ans)

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

int main() {
  int A,B;
  cin >> A >> B;
 
  vector<vector<int>> data(1000, vector<int>(3,0));
 
  for (int i = 0; i < 1000; i++) {
    for (int j = 0; j < 3; j++) {
      if (j == 0){
        data.at(i).at(j) = i+1;
      }
      else if (j == 1){
        data.at(i).at(j) = (i+1)*8/100;
      }
      else {
        data.at(i).at(j) = (i+1)/10;
      }
    }
  }
  
  for (int i = 0; i < 1000; i++) {
    if (A == data.at(i).at(1) && B == data.at(i).at(2)){
      cout << i + 1 << endl;
      break;
    }
    else if (i == 999){
      cout << -1 << endl;
    }
  }
}



Measured memory_bytes: 256
#include<stdio.h>

int n, k;
long long int T[100000];

int check(long long P)
{
	int i = 0, j;
	for(j = 0; j < k; j++)
	{
		long long int s = 0;
		while(s + T[i] <= P)
		{
			s += T[i];
			i++;
			if(i == n)
			{
				return n;
			}
		}
	}
	return i;
}

int solve()
{
	long long int left = 0;
	long long int right = 100000 * 10000;
	long long int mid;
	while(right - left > 1)
	{
		mid = (left + right) / 2;
		int v = check(mid);
		if(v >= n)
		{
			right = mid;
		}
		else
		{
			left = mid;
		}
	}
	return right;
}

int main(void)
{
	int i;
	scanf("%d %d", &n, &k);
	for(i = 0; i < n; i++)
	{
		scanf("%lld", &T[i]);
	}
	long long int c = solve();
	printf("%lld\n", c);
	
	return 0;
}


Measured memory_bytes: 2620
#include<stdio.h>

int main(void){
  int n,d=0;
  scanf("%d",&n);
  for(int a=1;a<n;a++){
    for(int b=1;b<(double)n/a;b++){
        if(n-(a*b)>0){
          d++;
        }
    }
  }
  printf("%d",d);
  return 0;
}


Measured memory_bytes: 1732
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b, c) = readListOfInt()
    println(if(a <= c && b >= c) "Yes" else "No")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


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

int N, M;
int a[50];
int b[50];
bool tree[50][50];
bool visited[50];

void dfs (int c) {

  // 訪れたことを記録する
  visited[c] = true;

  for (int i = 0; i < N; i++) {

    // 繋がっていない場合は次へ
    if (!tree[c][i]) {
      continue;
    }

    // すでに訪問済みの場合は次へ
    if (visited[i]) {
      continue;
    }

    // 次の頂点を調べる
    dfs(i);

  }

}

int main() {

  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    tree[a[i]][b[i]] = true;
    tree[b[i]][a[i]] = true;
  }

  int ans = 0;

  for (int i = 0; i < M; i++) {
    
    // 頂点を繋がっていないと仮定する
    tree[a[i]][b[i]] = false;
    tree[b[i]][a[i]] = false;

    // 訪問済みチェックをリセットする
    for (int j = 0; j < N; j++) {
      visited[j] = false;
    }

    dfs(0);

    bool flg = false;

    // 全部繋がっている（すべて訪問済み）かをチェックする
    for (int j = 0; j < N; j++) {
      if(visited[j] == false) {
        flg = true;
        break;
      }
    }

    // 繋がっていない点がある場合
    if (flg) {
      ans++;
    }

    // 仮定を戻す
    tree[a[i]][b[i]] = true;
    tree[b[i]][a[i]] = true;

  }

  cout << ans << endl;
  return 0;

}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d; cout<<max(a*b,c*d)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a,b,c,d,e,aa[100]={};
signed main()
{
	cin>>a>>b;
	rep(i,a){
		cin>>c;
		rep(j,c){
			cin>>d;
			aa[d-1]++;
		}
	}
	rep(i,b){
		if(aa[i]==a){
			e++;
		}
	}
	cout<<e;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s; 
int k;
vector<string> v;
vector<string> vec;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>s>>k;
	for(int i=1;i<=min(5,(int)s.size());i++){
		v.clear();
		for(int j=0;j<=s.size()-i;j++){
			v.push_back(s.substr(j,i));
		}
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		for(int j=0;j<v.size();j++)
			vec.push_back(v[j]);
	}
	sort(vec.begin(),vec.end());
	cout<<vec[k-1]<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a,p;
int main()
{
    while(~scanf("%d%d",&a,&p))
    {
        int x=a*3+p;
        int y=x/2;
        printf("%d\n",y);
    }
}


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

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N - 1; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = it->second;
				--it;
			}
			else {
				bubblenum = (--it)->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

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

int main() {
  int N, sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;


int main() {
	int n, a, b, sum, dig, num, sum2 = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) {
		num = i;
		sum = 0;
		while (num) {
			dig = num % 10;
			sum = sum + dig;
			num = num / 10;
		}
		if (sum >= a && sum <= b) {
			sum2 += i;
		}
	}
	cout << sum2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
	int N,D;
	scanf("%d%d",&N,&D);
	int x[N][D],count=0;
	double ans;
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			scanf("%d",&x[i][j]);
		}
	}

	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			ans=0;
			for(int k=0;k<D;k++){
				ans+=pow(x[i][k]-x[j][k],2);
			}
			//printf("ans=%lf\n",ans);
			if(sqrt(ans)-(int)sqrt(ans)==0){
				count++;
			}
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
x,y,z,K=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)
ans=[]
for i in range(x):
    for j in range(y):
        if (i+1)*(j+1)>K:
            break
        for k in range(z):
            if (i+1)*(j+1)*(k+1)>K:
                break
            ans.append(a[i]+b[j]+c[k])
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 8708
A,B,C=map(int,input().split())
cnt=0
if(A==B==C):
    if A%2!=0:
        print(0)
    else:
        print(-1)
    exit()
while(A%2==B%2==C%2==0):
    a,b,c=A,B,C
    A=b//2+c//2;B=a//2+c//2;C=a//2+b//2
    cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m ; cin >> n >> m ;
	ll sum = 0;
	for(int i = 0; i < m; i++){
		ll x;cin >> x ;
		sum+=x;
	}
	if(sum > n){
		cout << "-1" ;
	}
	else cout << n-sum;
 	return 0;
}

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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!
std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
//

void solve(long long X) {
  auto p = Eratosthenes(X+100);
  //dump(p);
  auto it = lower_bound(all(p), X);
  cout << *it << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define mp make_pair

int main()
{
	ll n,k; cin >> n >> k;
	vector <ll> v;
	// make_heap hp;
	forn(i,0,n)
	{
		ll a; cin >> a;
		v.push_back(a);
	}

	ll l = 1; ll r = 1000000005;
	ll mid;
	ll count = 0;

	while(l < r)
	{
		// ll ans = mid;
		mid = l + (r-l)/2;
		count = 0;

		for(ll i : v)
		{
			count += (i-1)/mid;
		}

		if(count > k)
			l = mid + 1;
		else
			r = mid;

		// ll ans = mid;
	}
	
	cout << l << endl;
}

Measured memory_bytes: 5304
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8

static const double PI=6*asin(0.5);
typedef complex<double> P;
typedef long long ll;

string s;
string app="apple",pea="peach";

void apple(){
	int it;
	vector <int> a;
	bool f=true,update=false;
	while(it=s.find("apple"),it!=-1){
		//cout<<"it = "<<it<<endl;
		if(it!=-1){
			a.PB(it);
			rep(i,5){
				s[it+i]=pea[i];
			}
		}
	}
	//cout<<s<<endl;
	it=-1;
	while(it=s.find("peach",it+1),it!=-1){
		//cout<<it<<endl;
		f=true;
		rep(i,a.size()){
			if(a[i]==it){
				f=false;
				break;
			}
		}
		if(f){
			rep(i,5){
			s[it+i]=app[i];
			}
		}
	}
	return;
}

int main(){
	cin>>s;
	apple();
	cout<<s;
	while(cin>>s){
		apple();
		cout<<" "<<s;
	}
	cout<<endl;
	return 0;
}

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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

const int mod = 1e9+7;

int N;
auto dp = vectors(111, 9, 9, 9, 0);

bool isAGC(vector<int> C) {
  return C[0] == 0 and C[1] == 1 and C[2] == 2;
}


signed main() {
  cin >> N;
  int M = 4;

  // 初期化
  dp[0][3][3][3] = 1;
  // for (int i = 0; i < 5; i++) {
  //   dp[0][i][i][i] = 1;
  // }

  for (int i = 0; i < N; i++) {
    for (int c3 = 0; c3 < M; c3++) { // iの3文字前
      for (int c2 = 0; c2 < M; c2++) { // iの2文字前
        for (int c1 = 0; c1 < M; c1++) { // iの1文字前
          for (int now = 0; now < M; now++) { // 新しく選ぶ文字
            // AGC文字列になるかどうかの判定
            bool ok = true;
            vector<int> t = {c3, c2, c1, now};
            if (isAGC({c3, c2, c1}) or isAGC({c2, c1, now})) ok = false;

            for (int j = 0; j < t.size()-1; j++) {
              vector<int> tt = t;
              swap(tt[j], tt[j+1]);
              if (isAGC({tt[0], tt[1], tt[2]}) or isAGC({tt[1], tt[2], tt[3]})) ok = false;
            }

            // AGC文字列にならないなら遷移させる
            if (ok) {
              Add(dp[i+1][c2][c1][now], dp[i][c3][c2][c1]);
            }
          }
        }
      }
    }
  }

  int ans = 0;
  for (int c3 = 0; c3 < M; c3++) {
    for (int c2 = 0; c2 < M; c2++) {
      for (int c1 = 0; c1 < M; c1++) {
        Add(ans, 1LL*dp[N][c3][c2][c1]); // これはNでできる。
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
import java.util.*;

class Main{
   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      long    N    = scan.nextLong();
      long    M    = scan.nextLong();
      long    Time = 0;

      Time = (long)Math.pow(2, M) * (N - M) * 100 + 1900 * M * (long)Math.pow(2, M);
      System.out.println(Time);
   }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define abdelrahman001 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define pb push_back
#define pf push_front
#define Pb pop_back
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define Pf pop_front
#define sz size
#define MP make_pair
#define Pc __builtin_popcount
#define pi 2*acos(0)
#define BiEdge(v,a,b) (v)[(a)].pb(b),(v)[(b)].pb((a))
#define mod 1000000007
#define point complex<ld>
#define X real()
#define Y imag()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define cross(a,b)(conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define rectangle pair<coordinate,coordinate>
#define line tuple<ll,ll,ll>
#define EPS 1e-7
#define polygon vector<point>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int const N = 1e5+5,M = 105;

using namespace std;

int main()
{
	abdelrahman001
	ll n,x,a,ans=0;
	cin >> n >> x;
	for(int i = 0;i<n;i++)
		cin >> a,ans = __gcd(ans,abs(a-x));
	cout << ans;
	return 0;
}


Measured memory_bytes: 256