akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text.RegularExpressions;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			BigInteger[] ABK = Console.ReadLine().Split(' ').Select(i => BigInteger.Parse(i)).ToArray();
			BigInteger A = ABK[0];
			BigInteger B = ABK[1];
			BigInteger K = ABK[2];

			if (A + B <= K)
				Console.WriteLine("0 0");
			else if(A > K)
				Console.WriteLine(A - K + " " + B);
			else
				Console.WriteLine("0 " +(B - (K - A)));

		}

		/// <summary>
		/// 回文
		/// </summary>
		/// <param name="Target"></param>
		/// <param name="len"></param>
		/// <returns></returns>
		static bool Palindrome(string Target , int len)
        {
			bool yes = true;

			for(int i = 0;i < len; i++)
            {
				if(Target[i] != Target[len - 1 - i])
                {
					yes = false;
					break;
                }
            }
			return yes;
        }

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Lcm(BigInteger a, BigInteger b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static BigInteger Gcd(BigInteger a, BigInteger b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 28528
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

    ll N, A, B;
    cin >> N >> A >> B;

    ll ans = 0;
    if (A > B) ans = 0;
    else if (A == B) ans = 1;
    else {
        if (N == 1) ans = 0;
        else {
            ll a = A * (N-1) + B;
            ll b = A + B * (N-1);
            ans = b-a+1;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    int res = 0;
    int ok = 0;
    int MIN = 1e9;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(A[i] < 0) {
            ok++;
        }
        if(abs(A[i]) < MIN) {
            MIN = abs(A[i]);
        }
        res+=abs(A[i]);
    }
    if(ok%2 == 0) {
        cout << res << endl;
    }
    else {
        cout << res-MIN*2 << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=85,low=81*81;
int a[N][N],b[N][N];
bitset<N*N*2>dp[N][N];
int mx[N][N];
int n,m;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
        scanf("%d",&b[i][j]);
    dp[1][1].set(a[1][1]-b[1][1]+low,1);
    dp[1][1].set(b[1][1]-a[1][1]+low,1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        if(i==1&&j==1) continue;
        int x=abs(a[i][j]-b[i][j]);
        dp[i][j]=(dp[i-1][j]<<x)|(dp[i-1][j]>>x)|(dp[i][j-1]<<x)|(dp[i][j-1]>>x);
    }
    int ans=1e9;
    for(int i=0;i<=low*2;i++)
        if(dp[n][m][i])
        {
            ans=min(ans,abs(i-low));
        }
    printf("%d\n",ans);
}


Measured memory_bytes: 12416
#include<stdio.h>
using namespace std;

bool used[900000];
int main() {
	int n, x; scanf("%d%d", &n, &x);
	int j = 2 * n - 1;
	if (x != 1 && x != j) {
		puts("Yes");
		if (x + j / 2 <= j) {
			for (int i = x + j / 2; i >= x; i--) { printf("%d\n", i); used[i] = true; }
			for (int i = 1; i <= j; i++) { if (!used[i])printf("%d\n", i); }
		}
		else {
			for (int i = x - j / 2; i <= x; i++) { printf("%d\n", i); used[i] = true; }
			for (int i = j; i >= 1; i--) { if (!used[i])printf("%d\n", i); }
		}
	}
	else puts("No");
}

Measured memory_bytes: 1536
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        Main m = new Main();
        m.solve(sc);
    }
    int[] gp;
    //Integer[][] aka;
    char[][] arr;
    int[][] dirs = new int[][]{{1,0},{0,1},{-1,0},{0,-1}};
    boolean[][] aka;
    void solve(Scanner sc){
        int h = sc.nextInt();
        int w = sc.nextInt();
        int r = sc.nextInt()-1;
        int c = sc.nextInt()-1;
        int er = sc.nextInt()-1;
        int ec = sc.nextInt()-1;
        arr = new char[h][w];
        for(int i=0;i<h;i++){
            arr[i] = sc.next().toCharArray();
        }
        aka = new boolean[h][w];
        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b)->(a[2]-b[2]));
        pq.add(new int[]{r,c,0});
        aka[r][c] = true;
        while(!pq.isEmpty()){
            LinkedList<int[]> nxt = new LinkedList<>();
            LinkedList<int[]> dmn = new LinkedList<>();
            while(!pq.isEmpty()){
                int[] ak = pq.poll();
                nxt.add(ak);
                if(ak[0]==er&&ak[1]==ec){
                    System.out.println(ak[2]);
                    return;
                }
                int i=ak[0],j=ak[1],v=ak[2];
                for(int[] dir :dirs){
                    int pi = i+dir[0];
                    int pj = j+dir[1];
                    if(pi<0||pj<0||pi>=h||pj>=w||aka[pi][pj]||arr[pi][pj]=='#') continue;
                    pq.add(new int[]{pi,pj,v});
                    aka[pi][pj] = true;
                }
                for(int k=Math.max(0,ak[0]-2);k<=Math.min(h-1,ak[0]+2);k++){
                    for(int p=Math.max(0,ak[1]-2);p<=Math.min(w-1,ak[1]+2);p++){
                        if(!aka[k][p]&&arr[k][p]!='#'){
                            nxt.add(new int[]{k,p,ak[2]+1});
                        }
                    }
                }
            }
            for(int[] fp:nxt){
                if(!aka[fp[0]][fp[1]]){
                    pq.add(fp);
                    aka[fp[0]][fp[1]] = true;
                }
            }
        }

        System.out.println(-1);

    }
    void dfs(int i, int j,int h, int w,PriorityQueue<int[]> pq, int v){
        for(int[] dir :dirs){
            int pi = i+dir[0];
            int pj = j+dir[1];
            if(pi<0||pj<0||pi>=h||pj>=w||aka[pi][pj]||arr[pi][pj]=='#') continue;
            pq.add(new int[]{pi,pj,v});
            aka[pi][pj] = true;
            dfs(pi,pj,h,w,pq,v);
        }
    }
    int find(int v){
        if(gp[v]<0) return v;
        //System.out.println(v);
        return gp[v] = find(gp[v]);
    }

    void g(int a, int b){
        int pa = find(a);
        int pb = find(b);
        if(pa==pb) return;
        if(gp[pa]<gp[pb]){
            gp[pa]+=gp[pb];
            gp[pb] = pa;
        }else{
            gp[pb]+=gp[pa];
            gp[pa] =pb;
        }
    }
    static long cmp(int[] a, int[] b){
        return (long)Math.abs(a[0]-b[0])+(long)Math.abs(a[1]-b[1]);
    }
}

Measured memory_bytes: 68772
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int n = sc.nextInt();
        int[] weights = new int[n];
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
            values[i] = sc.nextInt();
        }
        
        int[][] dp = new int[n + 1][W + 1];
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                dp[i][w] = 1000000000;
            }
        }
        for (int i = 0; i <= n; i++) {
            dp[i][0] = 0;
        }
        
        
        // dp[x][y] xダメージ与えられる最小のマナ
        for (int i = 0; i < n; i++) {
            for (int w = 0; w <= W; w++) {
                if (weights[i] <= w) {
                    dp[i + 1][w] = Math.min(dp[i + 1][w - weights[i]] + values[i], dp[i][w]);
                } else {
                    dp[i + 1][w] = Math.min(values[i], dp[i][w]);
                }
            }
        }
        
        System.out.println(dp[n][W]);
    }
}


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

const int K_MAX = 10, DIG = 9;

int n, k, cifN;
int dislike[DIG + 2];

bool check(int arg)
{
    while(arg)
    {
        if(dislike[arg % 10])
            return false;
        arg /= 10;
    }

    return true;
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= k; i++)
    {
        int digit;
        cin >> digit;
        dislike[digit] = true;
    }

    for(int i = n; ; i++)
        if(check(i))
        {
            cout << i << '\n';
            break;
        }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <math.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

using namespace std;

typedef long long ll;

ll x, a;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> x >> a;
    
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

string s;

int main(){
    while(cin >> s && s != "#"){
        ll y,m,d;
        bool f = false;
        cin >> y >> m >> d;
        if(y == 31){
            if(m >= 5)f = true;
        }
        else if(y > 31)f = true;
        if(f)cout << "?";
        else cout << s;
        cout << " " << y - f*(30) << " " << m << " " << d << endl;
    }
}


Measured memory_bytes: 3148
input_line = [int(i) for i in input().split()]
a = input_line[0]
b = input_line[1]
m = input_line[2]

a_list = [int(i) for i in input().split()]
b_list = [int(i) for i in input().split()]

discount = []
for i in range(m):
    input_line = [int(j) for j in input().split()]
    a_i = input_line[0] - 1
    b_i = input_line[1] - 1
    c = input_line[2]
    discount.append([a_i, b_i, c])

min_price = min(a_list) + min(b_list)
for i in discount:
    discount_price = a_list[i[0]] + b_list[i[1]] - i[2]
    if min_price > discount_price:
        min_price = discount_price
print(min_price)


Measured memory_bytes: 30708
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define RFOR(i,s,e) for(int (i) = (s);(i) >= (e);(i)--)
#define rep(i,n) FOR(i,0,n-1)

int x[105],y[105];

signed main() {
    int n,m,X,Y;cin>>n>>m>>X>>Y;
    rep(i,n)cin>>x[i];
    rep(i,m) cin>>y[i];

    int maxx = X;
    rep(i,n)maxx=max(maxx,x[i]);
    int miny = Y;
    rep(i,m)miny=min(miny,y[i]);
    

    if(maxx < miny)cout << "No War" << endl;
    else cout << "War" << endl;

}


Measured memory_bytes: 256
def myAnswer(N:int, txy:list) -> str:
   time = 0
   now = [0,0]
   ans = "Yes"
   for t,x,y in txy:
      counter = t - time
      dx = abs(x - now[0])
      dy = abs(y - now[1])
      if(counter % (dx + dy) != 0):
         ans = "No"
         break
      else:
         time = t
         now =[x,y]
   return ans


def modelAnswer():
   return
def main():
   N = int(input())
   txy = []
   for _ in range(N):
      txy.append(list(map(int,input().split())))
   print(myAnswer(N,txy[:]))
if __name__ == '__main__':
   main()

Measured memory_bytes: 28092
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD  998244353
#define REP(i,n) for(long long i = 0;i < n;++i)
vector<int> geko;
int solve(int now) {
	stack<pair<int, int>> next;
	for (int i = 1; i < geko.size(); ++i) {
		if (geko[i] > geko[i - 1]) continue;
		while (next.empty() == false && next.top().first > geko[i]) {
			next.pop();
		}
		int now_go = geko[i];
		int ok = 0;
		while (next.empty() == false && next.top().first == now_go) {
			next.top().second++;
			if (next.top().second == now) {
				next.pop();
				now_go--;
			}
			else {
				ok = 1;
				break;
			}
		}
		if (ok == 0) {
			if (now_go <= 0) return 0;
			next.push(make_pair(now_go, 1));
		}
	}
	return 1;
}
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		int a;
		cin >> a;
		geko.push_back(a);
	}
	int tmp = 1;
	for (int i = 1; i < geko.size(); ++i) {
		if (geko[i] <= geko[i - 1])tmp = 0;
	}
	if (tmp == 1) {
		cout << 1 << endl;
		return 0;
	}
	int bot = n+2;
	int top = 1;
	while (bot - top > 1) {
		int mid = (top + bot) / 2;
		if (solve(mid) == 1) {
			bot = mid;
		}
		else {
			top = mid;
		}
	}
	cout << bot << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   //freopen("input1.txt","r",stdin);
   //freopen("outputmid1.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli n,m,i,a,z;
		cin>>n>>m;
		multiset<lli> ms;
		for(i=0;i<n;i++)
		{
			cin>>z;
			ms.insert(z);
		}
		for(i=0;i<m;i++)
		{
			auto itr=ms.end();
			itr--;
			a=(*itr/2);
			ms.erase(itr);
			ms.insert(a);
		}
		lli ans=0;
		for(auto itr=ms.begin();itr!=ms.end();itr++)
		{
			ans+=*itr;
		}
		cout<<ans<<endl;
	}
}
/*
6
0 8 13 14 17 19
*/


Measured memory_bytes: 4992
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

int main(void) {
    llong A, B;
    cin >> A >> B;

    A--;
    B--;

    char ans[100][100];

    FOR(i, 50) {
        FOR(j, 100) {
            ans[i][j] = '#';
            ans[99 - i][j] = '.';
        }
    }

    for(int i = 0; i < 50; i+=2) {
        for(int j = 0; j < 100; j+=2) {
            if (A<=0) {
                i = 1000;
                j = 1000;
                break;
            }
            ans[i][j] = '.';
            A--;
        }
    }

    for(int i = 0; i < 50; i+=2) {
        for(int j = 0; j < 100; j+=2) {
            if (B<=0) {
                i = 1000;
                j = 1000;
                break;
            }
            ans[99 - i][j] = '#';
            B--;
        }
    }

    cout << "100 100" << endl;

    FOR(i, 100){
        FOR(j, 100){
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
fun max (a:Int,b:Int):Int{
    return if(a>b) a else b
}
fun min (a:Int,b:Int):Int{
    return if(a<b) a else b
}
fun main(args: Array<String>) {
    var (N,X,Y) = readLine()!!.split(" ").map { it.toInt() }
    val c = Y-X +1
    val a = X-1
    val b = N-Y

    for (i in 1 until N) {
        var result = 0
        //円の中
        if(i*2==c)result+=i
        else if(i<=c/2)result+=c
        //円の外から外
        result += max(a+b+2-i,0)
        if(i==1)result-=1
        //円の外から中
        var low=max(-(c/2),1-i)
        var up=min(-1,a-i)
        var t = max(up-low+1,0)*2
        if(c%2==0 && t>0 && c/2<i)t-=1
        if(a+1>=i && i>=2)t-=1
        result+=t

        up=min(-1,b-i)
        t = max(up-low+1,0)*2
        if(c%2==0 && t>0 && c/2<i)t-=1
        if(b+1>=i&& i>=2)t-=1
        result+=t
        println(result)
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

double n,m,d;

int main(){
  cin>>n>>m>>d;
  printf("%.10f\n",((n-d)*(m-1))/(n*n)*(d==0?1.0:2.0));
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.Iterator;

public class Main {
	public static void main(String[] args) {
		BigArray bg = new BigArray();
		bg.exec();
	}
}

class BigArray {
	static long n;
	static long k;
	static TreeMap<Long, Long> map = new TreeMap<Long, Long>();

	public BigArray() {
		Scanner cin = new Scanner(System.in);
		this.n = cin.nextLong();
		this.k = cin.nextLong();
		for (int i = 0; i < n; i++) {
			long a = cin.nextLong();
			long b = cin.nextLong();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + b);
			} else {
				map.put(a, b);
			}
		}
	}

	void exec(){
		long cur_i = 0;
		for(long key : map.keySet()) {
			cur_i += map.get(key);
			if(cur_i >= k){
				System.out.println(key);
				return;
			}
		}
	}
}


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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b;
	while (cin >> a >> b, a || b) {
		int c = max(a, b), d = min(a, b);
		int r;
		int cnt(0);
		while (d) {
			cnt++;
			r = c%d;
			c = d;
			d = r;
		}
		cout << c << " " << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> A(N), B;
	for (int i = 0; i < N - 1; i++) {
		int b; cin >> b;
		B.push_back(b);
	}

	A[0] = B[0];
	for (int i = 0; i < N - 1; i++) {
		A[i + 1] = B[i];
		A[i] = min(B[i], A[i]);
	}

	cout << accumulate(A.begin(), A.end(), 0) << endl;

	return 0;
}

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

int main() {
		int N;
		vector<int> h;

		scanf("%d", &N);
		for ( int i = 0; i < N; i++ ) {
				int x;
				scanf("%d", &x);
				h.push_back(x);
		}

		int E = 0, V = 0;

		for ( int i = 0; i < N; i++ ) V += h[i];

		for ( int i = 1; i < N; i++ ) {
				int x = 0;
				x = min(h[i-1], h[i]);
				E += x;
		}

		printf("%d\n", V - E);

		return 0;
}


Measured memory_bytes: 256
h,w,n=map(int,input().split())
import collections
tot=(h-2)*(w-2)
S=[]
append=S.append
for i in range(n):
  a,b=map(int,input().split())
  for j in range(3):
    for k in range(3):
      if 0<=a-3+j<h-2 and 0<=b-3+k<w-2:
        append((a-3+j,b-3+k))
SS=collections.Counter(collections.Counter(S).values())
print(tot-sum(SS.values()))
for i in range(1,10):
  print(0 if i not in SS.keys() else SS[i])

Measured memory_bytes: 198544
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


ll mod = 1e9+7;
int main()
{
    ll N, M; cin >> N >> M;
    vector<ll> oks(N+1, true);
    REP(i, M) {
        ll num; cin >> num;
        oks[num] = false;
    }

    vector<ll> dp(N+1);
    dp[0] = 1;
    for (ll now = 0; now < N; ++now) {
        for (ll next = now + 1; next <= min(N, now + 2); next++) {
            if (oks[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1792
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
solved=0
for _ in range(n):
    a=list(map(int,input().split()))
    point=c
    for i in range(m):
        point += a[i] * b[i]
    if 0 < point:
        solved += 1
print(solved)


Measured memory_bytes: 3060
n = int(input())
a = list(map(int,input().split()))+[10**7]
a.sort()
l = [True]*(10**6+1)

ans=0
a.sort()
for i in range(n):
    if l[a[i]]:
        for j in range(a[i],10**6+1,a[i]):
            l[j]=False
        if a[i]!=a[i+1]:
            ans+=1
print(ans)


Measured memory_bytes: 32380
#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	int key;
	struct _node **parent;
	struct _node *left;
	struct _node *right;
} node;

typedef void(*FUNCP)(node *);

node *allocNode(int key) {
	node *p = (node *)malloc(sizeof(node));
	p->key = key;
	p->parent = NULL;
	p->left = NULL;
	p->right = NULL;

	return p;
}

void terminate(node *p) {
	if (p == NULL) return;
	terminate(p->left);
	terminate(p->right);
	free(p);
}

node *insert(node *p, node *c) {
	if (p == NULL) return c;
	if (c->key < p->key) {
		p->left = insert(p->left, c);
		p->left->parent = &(p->left);
	}
	else {
		p->right = insert(p->right, c);
		p->right->parent = &(p->right);
	}
	return p;
}

node *find(node *p, int key) {
	if (p != NULL && p->key != key) {
		if (key < p->key) p = find(p->left, key);
		else p = find(p->right, key);
	}
	return p;
}

void delete(node *p) {
	node *next;
	if (p == NULL) return;
	if (p->left != NULL && p->right != NULL) {
		next = p->right;
		while (next->left != NULL) next = next->left;
		p->key = next->key;
		delete(next);
	}
	else if (p->left == NULL && p->right == NULL) {
		if (p->parent != NULL) *(p->parent) = NULL;
		free(p);
	}
	else if (p->left != NULL) {
		if (p->parent != NULL) *(p->parent) = p->left;
		p->left->parent = p->parent;
		free(p);
	}
	else {
		if (p->parent != NULL) *(p->parent) = p->right;
		p->right->parent = p->parent;
		free(p);
	}
}

void inParse(node *p) {
	if (p == NULL) return;
	inParse(p->left);
	printf(" %d", p->key);
	inParse(p->right);
}

void preParse(node *p) {
	if (p == NULL) return;
	printf(" %d", p->key);
	preParse(p->left);
	preParse(p->right);
}

void dump(node *p, FUNCP funcp) {
	(funcp)(p);
	printf("\n");
}

int main() {
	int n, i, key;
	char order[7];
	node *p, *root = NULL;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", order);
		switch (order[0])
		{
		case 'i':
			scanf("%d", &key);
			p = allocNode(key);
			root = insert(root, p);
			break;
		case 'p':
			dump(root, &inParse);
			dump(root, &preParse);
			break;
		case 'f':
			scanf("%d", &key);
			if (find(root, key) != NULL) printf("yes\n");
			else printf("no\n");
			break;
		case 'd':
			scanf("%d", &key);
			p = find(root, key);
			delete(p);
			break;
		}
	}
	terminate(root);

	return 0;
}



Measured memory_bytes: 20452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll a[200010];
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	for(ll i=1;i<n;i++){
		a[i]=a[i]+a[i-1];
	}
	map<ll,ll>b;
	for(ll i=0;i<n;i++){
		ll now=a[i];
		b[now]++;
	}
	ll ans=0;
	for(auto itr=b.begin();itr!=b.end();itr++){
		ll now=itr->first;
		ll val=itr->second;
		if(now==0){
			ans+=val*(val+1)/2;
		}
		else{
			ans+=val*(val-1)/2;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int>vec(3);
    cin >> vec.at(0)>>vec.at(1)>>vec.at(2);
    sort(vec.begin(),vec.end());
    cout <<vec.at(0) << " "<< vec.at(1)<<" "<< vec.at(2)<<endl;
}


Measured memory_bytes: 3120
import java.util.Arrays;
import java.util.Scanner;

public class Main {


    public static void main(String...args) {
        Main main= new Main();
        main.solve();
    }
    boolean[] exists;
    int[] factorials;
    void solve(){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        int[] p=new int[N];
        int[] q=new int[N];

        factorials=new int[N+1];
        factorials[0]=1;
        factorials[1]=1;
        for(int i=2;i<N;i++){
            factorials[i]=factorials[i-1]*(i);
        }
        for(int i=0;i<N;i++){
            p[i]=scanner.nextInt();
        }
        for(int i=0;i<N;i++){
            q[i]=scanner.nextInt();
        }
        exists =new boolean[N+1];
        int P=rank(p,N);
        int Q=rank(q,N);
        int result=Math.abs(P-Q);
        System.out.println(result);
    }

    int rank(int[] array,int n){
        Arrays.fill(exists,false);
        int sum=0;
        for(int i=0;i<n;i++){
            int k=0;
            for(int j=0;j<array[i];j++){
                if(!exists[j]){
                    k++;
                }
            }
            sum=sum+factorials[n-1-i]*k;
            exists[array[i]]=true;
        }
        return sum;
    }
}






Measured memory_bytes: 22484
#include<stdio.h>
#include<math.h>

void main(){
  long long int n, k, x, xmin;
  scanf("%lld %lld", &n, &k);
  
  if(n<k){
    printf("%lld", (n < llabs(n-k)) ? n : llabs(n-k) );
  }
  else{
    x = n%k;
    printf("%lld", (x < llabs(x-k)) ? x : llabs(x-k) );
  }
}

Measured memory_bytes: 1732
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    int n;
    int ans=0;
    string s;
    cin >> n;

    for(int i=1;i<=n;i++){
        s = to_string(i);
        if(s.size()%2==1){
            ans++;
        }
    }

    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N = 2e5+9;
const int mod = 998244353;

int fat[N],inv[N];

int fastexp(int b,int e){
   if(e == 0) return 1;
   int ans = fastexp(b,e/2);
   ans = (ans*ans)%mod;
   if(e%2==1) ans = (ans*b)%mod;
   return ans; 
}

int comb(int a,int b){
   int ans = fat[a];
   ans = (ans*inv[b])%mod;
   ans = (ans*inv[a-b])%mod;
   return ans; 
}

signed main(){
   IOS;
   fat[0] = fat[1] = 1;
   rep(i,2,N) fat[i] = (i*fat[i-1])%mod;
   rep(i,0,N) inv[i] = fastexp(fat[i],mod-2);
   int n,m,k; cin >> n >> m >> k;
   int ans = 0;
   rep(i,0,k+1){
      int res = m;
      res = (res*comb(n-1,n-1-i))%mod;
      res = (res*fastexp(m-1,n-1-i))%mod;
      ans = (ans+res)%mod;
   }
   cout << ans << '\n';
}

Measured memory_bytes: 6780
fun main(args: Array<String>) {
  val (N, M) = readInts()
  val SC = (1..M).map { readInts() }

  var beginNum = Math.pow(10.0, (N - 1).toDouble()).toInt()
  val endNum = beginNum * 10
  if (beginNum == 1) beginNum = 0
  for (n in beginNum until endNum) {
    val d = n.toString().map { it.toString().toInt() }
    var f = true
    for (i in 0 until M) {
      val (S, C) = SC[i]
      if (d[S - 1] != C) f = false
    }
    if (f) {
      println(n)
      return
    }
  }
  println(-1)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 37916
#include<cstdio>

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

using namespace std;

int main(){
	for(char r[5],a[5];scanf("%s%s",r,a),r[1];){
		int hit=0,blow=0;
		rep(i,4)rep(j,4)if(r[i]==a[j]){
			if(i==j)	hit++;
			else		blow++;
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int pieces = sc.nextInt();
        int m = sc.nextInt();

        if (pieces >= m) System.out.println(0);
        else {
            int[] arr = new int[m];
            for (int i = 0; i < m; i++) {
                arr[i] = sc.nextInt();
            }
            Arrays.sort(arr);

            int[] diffs = new int[m-1];
            for (int i = 1; i < m; i++) {
                diffs[i-1] = Math.abs(arr[i] - arr[i-1]);
            }
            Arrays.sort(diffs);
            
            int res = 0;
            for (int i = 0; i < m - pieces; i++) {
                res += diffs[i];
            }
            System.out.println(res);
        }
    }
}

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

using namespace std;

const int M = 1e6;
vector<pair<int, int>> negg, tot;
pair<int, int> seg[4 * M];
int small = -1e9;

pair<int, int> build(int l, int r, int i) {
    if (l == r)
        seg[i] = tot[l];
    else
        seg[i] = max(build(l, (l + r) / 2, i * 2 + 1), build((l + r) / 2 + 1, r, i * 2 + 2));
    return seg[i];
}
pair<int, int> update(int l, int r, int i, int x) {
    if (x < l || x > r)
        return seg[i];
    if (l == r)
        seg[i] = tot[l];
    else
        seg[i] = max(update(l, (l + r) / 2, i * 2 + 1, x), update((l + r) / 2 + 1, r, i * 2 + 2, x));
    return seg[i];
}
pair<int, int> get(int l, int r, int L, int R, int i) {
    if (R < l || L > r)
        return make_pair(small, small);
    if (L >= l && R <= r)
        return seg[i];
    return max(get(l, r, L, (L + R) / 2, i * 2 + 1), get(l, r, (L + R) / 2 + 1, R, i * 2 + 2));
}

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

    int n, pos = 0, neg = 0;
    cin >> n;

    while (n--) {
        string s;
        cin >> s;
        stack<char> st;
        int curPos = 0, curNeg = 0;

        for (char c : s)
            if (!st.empty() && st.top() == '(' && c == ')')
                st.pop();
            else
                st.push(c);

        while (!st.empty())
            st.top() == '(' ? curPos++ : curNeg--, st.pop();
        if (curPos && curNeg)
            negg.push_back(make_pair(-curNeg, curPos + curNeg));
        else
            pos += curPos, neg += curNeg;
    }

    if (!negg.empty()) {
        sort(negg.begin(), negg.end());
        for (int i = 0; i < negg.size(); i++)
            tot.push_back(make_pair(negg[i].second, i));
        build(0, tot.size() - 1, 0);

        for (int i = 0; i < negg.size(); i++) {
            int last = upper_bound(negg.begin(), negg.end(), make_pair(pos, -small)) - negg.begin() - 1;
            if (last == -1)
                return cout << "No\n", 0;

            pair<int, int> cur = get(0, last, 0, tot.size() - 1, 0);
            pos += cur.first;
            tot[cur.second] = make_pair(small, cur.second);
            update(0, tot.size() - 1, 0, cur.second);
        }
    }

    cout << (pos + neg == 0 ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 10564
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	int size=s.size();
	for(int i=0;i<size;i++)
	cout<<"x"; 
		
	
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

judge = False
if 0 in c and c[0] == n:
  judge = True
if n % 3 == 0:
  judge1, judge2 = False, 0
  num = 0
  value = 0
  for k, v in c.items():
    num += 1
    if v == n // 3:
      if k == 0:
        judge1 = True
      judge2 += 1
    value ^= k
  if judge1 and num == 2:
    judge = True
  if judge2 == num == 3 and value == 0:
    judge = True

print("Yes" if judge else "No")
  

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

int main(){
	int s[60]={0};int n=0,cnt=0;
	while(cin>>s[n++]);n--;
	for(int i=0;i<n;i++){
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int c=0;c<10;c++){
					if(s[i]-a-b-c>-1&&s[i]-a-b-c<10)cnt++;
				}
			}
		}
		cout<<cnt<<endl;cnt=0;
	}
	return 0;
}

Measured memory_bytes: 3072
/*我是萌新*/
#include<bits/stdc++.h> 
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
using namespace std;
#define INS(x) x.begin(),x.end()
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s;
    cin >> s;

    int z = 0; //0正1反
    string s1, s2;
    int q;
    cin >> q;
    while (q--)
    {
        int t, f;
        string x;
        cin >> t;

        if (t == 1)
        {
            z = !z;
        }
        else
        {
            cin >> f >> x;
            if (f == 1)
            {
                if (z)
                {
                    s2 += x;
                }
                else s1 += x;
            }
            else
            {
                if (z)
                {
                    s1 += x;
                }
                else s2 += x;
            }
        }
    }

    reverse(INS(s1));
    s = s1 + s + s2;
    if (z)
    {
        for (int i = s.size() - 1; i >= 0; i--)
            cout << s[i];
    }
    else
        for (auto i : s)
            cout << i;

    
} 

Measured memory_bytes: 1200
use proconio::{input, fastout};
use itertools::Itertools;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n-1],
    }

    let mut sn = vec![0; n];

    for &sub in a.iter() {
        sn[sub-1] += 1;
    }

    println!("{}", sn.iter().join("\n"));
}


Measured memory_bytes: 6152
import java.util.*;
public class Main{
	public static void main(String args[]){
		ArrayList[] a;
		//a=new ArrayList[10];
		///a[1]=new ArrayList<Integer>();
		//a[1].add(3);
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				System.out.printf("%dx%d=%d\n",i,j,i*j);
			}
		}
		
	}
}

Measured memory_bytes: 17964
// Same Integers
#include <cmath>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int t = 0;
    while (!(A == B && B == C && C == A)) {
        int mx = max(A, max(B, C));
        int mn = min(A, min(B, C));
        int mi = A + B + C - mx - mn;

        if (mi - mn >= 2) {
            if (A == mn) A += 2;
            else if (B == mn) B += 2;
            else  C += 2;
        } else {
            if (A == mn) A++;
            else if (B == mn) B++;
            else C++;

            if (A == mi) A++;
            else if (B == mi) B++;
            else C++;
        }
        t++;
        // cout << A << B << C << endl;
    }
    cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<double> a(n);
  double sum = 0;
  rep(i,n){
    cin >> a[i];
    sum += a[i];
  }
  sum /= (double)n;
  double minDiff = 1e10;
  int ans = 0;
  rep(i,n){
    double diff = abs(sum - a[i]);
    if(minDiff > diff) {
      minDiff = diff;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N=input()
#print(N[-1])
if N[-1]=="2" or N[-1]=="4" or N[-1]=="5" or N[-1]=="7" or N[-1]=="9":
  print("hon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
  print("pon")
else:
  print("bon")

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else if (a + b < c + d) {
    cout << "Right" << endl;
  }
  else {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a,c=[],[]
for _ in range(m):
  a.append(list(map(int,input().split()))[0])
  bit=0
  for i in input().split():
    bit|=(1<<(int(i)-1))
  c.append(bit)
inf=float("inf")
dp=[[inf]*(1<<n) for i in range(m+1)]
dp[0][0]=0
for i in range(m):
  for j in range(1<<n):
    dp[i+1][j]=min(dp[i+1][j],dp[i][j])
    next_bit=j|c[i]
    dp[i+1][next_bit]=min(dp[i+1][next_bit],dp[i][j]+a[i])
print(dp[-1][-1] if dp[-1][-1]!=inf else -1)

Measured memory_bytes: 137560
//答えによって、頂点集合を2分割するイメージ。
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, k;
vector<int> et[200];
int cnt[200];
	
void game() {
	int v = 0;
	string s;
	
	while (true) {
		cout << v + 1 << endl;
		cin >> s;
		if (s == "Yes") return;
		if (s == "Near") v += 1;
		if (s == "No") v += cnt[v] / 2 + 1;
	}
}

int main() {
	int i, j;
	
	cin >> n >> k;
	
	cnt[0] = n;
	
	rep(i, n) {
		int h = cnt[i] / 2;
		rep(j, h) {
			et[i].push_back(i + 1 + j);
			cnt[i + 1 + j] = h;
		}
		rep(j, cnt[i] - 1 - h) {
			et[i + 1].push_back(i + h + 1 + j);
			cnt[i + h + 1 + j] = cnt[i] - 1 - h;
		}
	}
	
	int m = 0;
	rep(i, n) m += et[i].size();
	
	cout << m << endl;
	rep(i, n) {
		rep(j, et[i].size()) {
			cout << i + 1 << " " << et[i][j] + 1 << endl;
		}
	}
	
	//K回ゲームをする
	rep(i, k) {
		game();
	}
	return 0;
}


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

Measured memory_bytes: 1740
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;




int main(){
    int n;
    cin>>n;
    vec(a,n,0);
    map<int,int> mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
    int cnt=0;
    for(auto itr:mp){
        if(itr.second%2)cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 5760
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


s=int(input())
ans=0
wakeru=0
while s>0:
    s=s-3
    ans=ans+cmb(s+wakeru,wakeru,p)
    wakeru+=1
print(ans%(10**9+7))


Measured memory_bytes: 87196
import java.util.*;

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

	int i;

	for(i=1;i<10001;i++){
	int a = sc.nextInt();

	  if(a == 0) break;

	  System.out.println("Case "+i+": "+a);
	}

  }
}

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

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  vector<int> s(N);
  int total = 0;
  for (int i = 0; i < N; ++i) {
    cin >> s[i];
    total += s[i];
  }

  if ((total % 10) != 0) {
    cout << total << endl;
    return 0;
  }

  sort(s.begin(), s.end());
  for (int i = 0; i < N; ++i) {
    if ((total - s[i]) % 10 != 0) {
      cout << total - s[i] << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int H,W;
  cin>>H>>W;
  vector<vector<int>> A(10,vector<int>(10)),B(H,vector<int>(W));
  vector<int> C={0,1,2,3,4,5,6,7,8,9},D(10,1000000000);
  for(vector<int> &v:A)
    for(int &i:v)
      cin>>i;
  D[1]=0;
  do{
    if(C[0]==1)
      continue;
    int cnt=0;
    for(int i=0;i<10;i++){
      cnt+=A[C[i]][C[i+1]];
      if(C[i+1]==1)
        break;
    }
    D[C[0]]=min(D[C[0]],cnt);
  }while(next_permutation(C.begin(),C.end()));
  int ans=0;
  for(vector<int> &v:B)
    for(int &i:v){
      cin>>i;
      if(i!=-1)
        ans+=D[i];
    }
  cout<<ans<<endl;
}

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

int main(){
  int n, e=0, ans;
  string s;
  cin >> n >> s;
  for (int i=1; i<n; i++)
    if(s[i] == 'E') e++;
  ans = e;
  for (int i=1; i<n; i++){
    if(s[i-1] == 'W') e++;
    if(s[i] == 'E') e--;
    if(ans > e) ans = e;
  }
  cout << ans << endl;
}


Measured memory_bytes: 900
#include<cstdio>

int main(){
	int n, m, l;
	scanf("%d %d %d", &n, &m, &l);
	int a[n][m];
	int b[m][l];
	long c[n][l];
	for(int i = 0; i < n ; i++){
		for(int j = 0; j < m; j++){
			scanf("%d", &a[i][j]);
		}
	}

	for(int i = 0; i < m ; i++){
		for(int j = 0; j < l; j++){
			scanf("%d", &b[i][j]);
		}
	}

	for(int i = 0; i < n ;i++){
		for(int j = 0; j < l; j++){
			c[i][j] = 0;
			for(int k = 0; k < m ; k++){
				c[i][j] += a[i][k] * b[k][j];
			}
			if(j){
				printf(" ");
			}
			printf("%ld", c[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1188
N = int(input())
A = [int(i) for i in input().split()] + [(1 << 21) - 1]

ret = 0
j = 1
cur = A[0]
for i in range(N) :
    while j < N and cur & A[j] == 0 :
        cur ^= A[j]
        j += 1
    ret += j - i
    if j - i == 1 :
        cur = A[j]
        j += 1
    else :
        cur ^= A[i]
    
print(ret)

Measured memory_bytes: 79564
n,h=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(reverse=True,key=lambda x:x[1])

a_max=0
for a,b in ab:
  a_max=max(a,a_max)

cnt=0
damage=0
for a,b in ab:
  if damage>=h:
    print(cnt)
    exit()
  if b<=a_max:
    break

  cnt+=1
  damage+=b

zan=h-damage
cnt+=(zan+a_max-1)//a_max
print(cnt)

Measured memory_bytes: 28912
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : 
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (ll i=a;i<=(ll)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
multiset<ll> cw, ccw, cw2, ccw2;
ll n, c, x[N], y[N], ry[N], rx[N], r, l;
inline bool counter(ll cost, bool w) {
	return (w ? cw : ccw).lower_bound(cost) != (w ? cw : ccw).end();
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	cin >> n >> c;
	lp(i,1,n)
	{
		cin >> x[i] >> y[i];
		rx[i] = x[i];
		ry[i] = y[i];
		r += y[i];
		y[i] += y[i - 1];
		cw.insert(y[i] - x[i]);
	}
	reverse(ry + 1, ry + n + 1);
	reverse(rx + 1, rx + n + 1);
	lp(i,1,n)
	{
		rx[i] = c - rx[i];
		ry[i] += ry[i - 1];
		ccw.insert(ry[i] - rx[i]);
	}
	ccw2 = ccw;
	cw2 = cw;
	ll ans = 0;
	while (l <= r) {
		ll cost = (l + r) >> 1;
		bool is = counter(cost, 1) | counter(cost, 0);
		lp(i,1,n)
		{
			if (is)
				break;
			ll l = cost - y[i] + x[i];
			ccw.erase(ccw.find(ry[n - i + 1] - rx[n - i + 1]));
			is |= counter(l + x[i], 0);
		}
		ccw = ccw2;
		lp(i,1,n)
		{
			if (is)
				break;
			ll rr = cost - ry[i] + rx[i];
			cw.erase(cw.find(y[n - i + 1] - x[n - i + 1]));
			is |= counter(rr + rx[i], 1);
		}
		cw = cw2;
		if (!is)
			r = cost - 1;
		else {
			l = cost + 1;
			ans = cost;
		}
	}
	f(ans);
	return 0;
}

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

#define int long long 

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, c, d; cin >> a >> b >> c >> d;
	cout << max({a * c, a * d, b * c, b * d}) << endl;
}

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

int main()
{
    int n;
    cin>>n;
    set<string>s;
    string prev_word,word;
    cin>>word;
    s.insert(word);
    --n;
    bool ans = true;
    while(n--)
    {
        prev_word = word;
        cin>>word;
        if(s.count(word)!=0)
            ans = false;
        if(prev_word[prev_word.size()-1]!=word[0])
            ans = false;
        s.insert(word);
    }
    if(ans)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3620