akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 110
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238462643383279502884L
#define elif else if
#define lld long double
#define r0 return 0
#define EPS 1e-7
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

const int inf = 1e9 + 1;
const ll modw = 1e9 + 9;
  
using namespace std;
using namespace __gnu_pbds;

int gcd(int a_a, int b_b)
{
	return b_b?gcd(b_b,a_a%b_b):a_a;
}



int main()
{
    barnarnar
	forn1(i, 5)
	{
		int t;
		cin >> t;
		if(t == 0)	cout << i, exit(0);
	}
    return 0;
}
/*
1
1
FMMMMFFFFFMM 1
*/



Measured memory_bytes: 3504
#include <cstdio>
#include <string>
#include <iostream>
#define INT long long
using namespace std;
INT p = 1, n, a[100010], ans;
int main()
{
    cin>>n;
    for(int i = 0 ; i < n ; i++ )
        cin>>a[i];
    for(int i = 0 ; i < n ; i++ )
    {
        if( a[i] < p ) continue;
        if( a[i] == p ) p++;
        else
        {
            ans += (a[i]-1)/p;
            if( a[i]%p == p || p == 1 ) p++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int ans=0;
    int tmp=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            ++tmp;
            ans=max(ans,tmp);
        }else tmp=0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC123C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = ReadLong;

            long[] limit = new long[5];
            for (int i = 0; i < 5; i++)
            {
                limit[i] = ReadLong;
            }

            long min = limit.Min();
            if (min >= N)
            {
                Console.WriteLine(5);
                return;
            }
            else
            {
                long ans = (long)Math.Ceiling((double)N / min) + 4;
                Console.WriteLine(ans);
            }

        }
        

    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <sstream>
using namespace std;

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

int calc(string exp,int &idx){
	int count = 0, val[2];
	char op;

	for(;idx<exp.length();idx++){
		if(count == 2) break;
		if(exp[idx] == '('){
			idx++;
			val[count++] = calc(exp,idx);
		}
		else if(exp[idx] == ')'){
			idx++;
			break;
		}
		else if('1' <= exp[idx] && exp[idx] <= '9'){
			val[count++] = exp[idx] - '0';
		}
		else op = exp[idx];
	}

	if(op == '+') return val[0] + val[1];
	if(op == '-') return val[0] - val[1];
	if(op == '*') return val[0] * val[1];
}

int main(void){
	char op[4] = "+-*";
	int pos[6][4] = {
		{-5,-3,0,0},
		{-7,4,-3,0},
		{-5,-5,2,0},
		{-7,-5,2,2},
		{-7,4,-3,0},
		{-7,-7,4,2}
	};

	while(1){
		vector<int> v;
		bool ansFlg = false;

		rep(i,4){
			int x;
			cin>>x;
			if(x == 0) return 0;
			v.push_back(x);
		}

		sort(v.begin(),v.end());
		do{
			rep(i,3)rep(j,3)rep(k,3)rep(l,6){
				stringstream ss;
				ss<<v[0]<<op[i];
				ss<<v[1]<<op[j];
				ss<<v[2]<<op[k];
				ss<<v[3];

				string exp = ss.str();
				rep(m,4){
					exp.insert(abs(pos[l][m]), (pos[l][m]>=0 ? "(" : ")"));
				}
				int idx = 0;
				int res = calc(exp,idx);
				if(res == 10){
					cout<<exp<<endl;
					ansFlg = true;
					i = j = k = 3;
					l = 6;
				}
			}
		}while(!ansFlg && next_permutation(v.begin(),v.end()));

		if(!ansFlg) cout<<"0\n";
	}

	return 0;
}

Measured memory_bytes: 940
import numpy as np
N = int(input())
A = np.array([int(i) for i in input().split()])
# 操作を行う回数
num = 0
# 奇数があるか否か
oddexist = 0
while True:
    for x in range(N):
        # １つでも奇数があればoddexistを1にする
        if A[x] % 2 != 0:
            oddexist = 1
    # oddexistが1なら操作回数を出力して終了
    if (oddexist == 1):
        print("{}".format(num))
        break
    A = A / 2
    num += 1


Measured memory_bytes: 12496
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>

using namespace std;
typedef long long lint;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> mp;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        mp[A[i]]++;
    }
    int ans = 0;
    for (const auto p : mp) {
        if (p.first > p.second) {
            ans += p.second;
        } else {
            ans += p.second - p.first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        String line = buffer.readLine();
        int x = Integer.parseInt(line);

        System.out.println(lucas(x));
    }

    public static long lucas(int x) {
      long l0 = 2;
      long l1 = 1;
      long lx = 0;

      if (x == 0){
        return l0;
      } else if (x == 1){
        return l1;
      } else {
        for (int i = 2; i <= x; i++){
          lx = l0 + l1;
          l0 = l1;
          l1 = lx;
        }

        return lx;
      }
    }

}


Measured memory_bytes: 22612
def ban():
    n = int(input())
    a = list(map(int, input().split()))
    d = {}
    total = 0

    for i in a:
        if i not in d:
            d[i] = 1
        else:
            total += d[i]
            d[i] += 1

    ans = [total - (d[i] - 1) for i in a]
    return "\n".join(map(str, ans))

print(ban())

Measured memory_bytes: 38972
#include <iostream>
using namespace std;
int h,w,t[2000][2000],p,u[2000][2000];
char a;
string s[2000];
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a;
            s[i]+=a;
        }
    }
    for(int i=0;i<h;i++){
        p=0;
        for(int j=0;j<w;j++){
            if(s[i][j]=='.')p+=1;
            else p=0;
            t[i][j]=p;
        }
        p=0;
        for(int j=w-1;j>=0;j--){
            if(t[i][j]>0){
                p=max(p,t[i][j]);
                t[i][j]=p;
            }
            else p=0;
            
        }
    }
    for(int i=0;i<w;i++){
        p=0;
        for(int j=0;j<h;j++){
            if(s[j][i]=='.')p+=1;
            else p=0;
            u[j][i]=p;
        }
        p=0;
        for(int j=h-1;j>=0;j--){
            if(u[j][i]>0){
                p=max(p,u[j][i]);
                u[j][i]=p;
            }
            else p=0;
        }
    }
    int ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            ans=max(ans,t[i][j]+u[i][j]-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 35584
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());

            for(var i = x; i <= 999; i++){
                var s = Convert.ToString(i);

                if(s[0] == s[1] && s[0] == s[2]){
                    Console.WriteLine(i);
                    break;
                }
            }
        }
    }
}


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

int main(void){
    int a,b; cin>>a>>b;
    int aho [1000];
    aho[1] = 1;
    for(int i=1;i<=999;i++){
        aho[i] = aho[i-1]+i;
    }
    //int tmp = b-a;
    for(int i=1;i<=999;i++){
        if(aho[i]-aho[i-1] ==  b-a){
            cout<<aho[i]-b<<endl;
            break;
        }
    }
    //cout<<aho[b] - b << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

ll memo[4001];
ll solve(int n, int r = 4) {
    if (n < 0) return 0;
    if (r == 1) return (0 <= n && n <= 1000) ? 1 : 0;
    if (r == 2 && memo[n] >= 0) return memo[n];
    ll ret = 0;
    for (int i = 0; i <= 1000; i++) {
        if (n - i < 0) break;
        ret += solve(n - i, r - 1);
    }
    if (r == 2) memo[n] = ret;
    return ret;
}

int main() {
    int n;
    memset(memo, -1, sizeof(memo));
    while (cin >> n) {
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b & (1LL << i)) != 0) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long fact[1 << 20], factinv[1 << 20];
long long mod = 1000000007;

void init() {
	fact[0] = 1;
	for (int i = 1; i < (1 << 20); i++) fact[i] = (1LL * fact[i - 1] * i) % mod;
	for (int i = 0; i < (1 << 20); i++) factinv[i] = modpow(fact[i], mod - 2, mod);
}

long long ncr(long long n, long long r) {
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

long long X, Y;

int main() {
	cin >> X >> Y;
	init();

	if ((X + Y) % 3 != 0) {
		cout << "0" << endl;
	}
	else {
		long long S = (X + Y) / 3;
		long long T = X - S;
		if (T<0 || T>S) cout << "0" << endl;
		else cout << ncr(S, T) << endl;
	}
	return 0;
}

Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)cout<<1<<endl;
	else if(a==b||a==c||b==c)cout<<2<<endl;
	else cout<<3<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int dice_front[3] = {};
    int n, total = 0, temp;
    while(cin >> n && n != 0) {
        dice_front[0] = 1; dice_front[1] = 2; dice_front[2] = 3;
        total = dice_front[0];
        string s;
        for(int i = 0; i < n; i++) {
            cin >> s;
            if(s == "North") {
                temp = dice_front[1];
                dice_front[1] = 7 - dice_front[0];
                dice_front[0] = temp;
            } else if (s == "East") {
                temp = dice_front[0];
                dice_front[0] = 7 - dice_front[2];
                dice_front[2] = temp;
            } else if (s == "West") {
                temp = dice_front[2];
                dice_front[2] = 7 - dice_front[0];
                dice_front[0] = temp;
            } else if (s == "South") {
                temp = dice_front[0];
                dice_front[0] = 7 - dice_front[1];
                dice_front[1] = temp;
            } else if (s == "Right") {
                temp = dice_front[2];
                dice_front[2] = 7 - dice_front[1];
                dice_front[1] = temp;
            } else if (s == "Left") {
                temp = dice_front[1];
                dice_front[1] = 7 - dice_front[2];
                dice_front[2] = temp;
            }
            
            total += dice_front[0];
        }
        
        cout << total << endl;
    }
}



Measured memory_bytes: 3112
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
typedef long long int ll;
typedef unsigned long long int ull;

int main(){
    int n;scanf("%d",&n);
    int t[200];
    char s[200][200];for(int i=0;i<n;i++)scanf("%s %d",s[i],&t[i]);
    char x[200];scanf("%s",x);

    int flg=0;
    int sum=0;
    for(int i=0;i<n;i++){
        if(!strcmp(s[i],x)){
            flg=1;
            continue;
        }
        if(flg){
            sum+=t[i];
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		String joi=sc.next();
		int n=joi.length();
		int num[]=new int[n];
		char str[]=new char[n];
		str[0]=joi.charAt(0);
		int cnt=0;
		for(int i=1;i<n;i++){
			char tmp=joi.charAt(i);
			if(tmp==joi.charAt(i-1)){
				num[cnt]++;
			}else{
				cnt++;
				str[cnt]=tmp;
			}
		}
		int ans=0;
		//for(int i=0;i<=cnt;i++)System.out.println(str[i]+" "+num[i]);
		for(int i=0;i<n-2;i++){
			//System.out.println(str[i]+" "+num[i]+" "+str[i+1]+" "+num[i+1]+" "+str[i+2]+" "+num[i+2]);
			if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I')
				if(num[i]>=num[i+1]&&num[i+2]>=num[i+1])
					ans = Math.max(ans, (num[i+1]+1));					
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36388
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>

using namespace std;

vector<int> res;
int r;
bool rej;

void func(vector<int> vec, string str, int t, int s)
{
	if(str.size() == 0){
		if(s > t){
			return ;
		} else if(r == s){
			rej = true;
		} else if(r < s){
			rej = false;
			r = s;
			res = vec;
		}
	} else {
		string s1 = "", s2;
		for(int i = 0; i < str.size(); i++){
			s1 += str[i];
			if(i+1 < str.size()){
				s2 = str.substr(i+1);
			} else {
				s2 = "";
			}
			int v = atoi(s1.c_str());
			vector<int> v2 = vec;
			v2.push_back(v);
			func(v2, s2, t, s+v);
		}
	}
	
	return ;
}

int main()
{
	int t;
	string str;
	
	while(cin>>t>>str && !(t == 0 && str == "0")){
		vector<int> vec;
		rej = false;
		r = -1;
		func(vec, str, t, 0);
		if(res.size() == 0){
			cout << "error" << endl;
		} else {
			if(rej){
				cout << "rejected" << endl;
			} else {
				cout << r;
				for(int i = 0; i < res.size(); i++){
					cout << " " << res[i];
				}
				cout << endl;
			}
		}
		
		res.clear();
	}
	
	return 0;
}

Measured memory_bytes: 0
<?php
    fscanf(STDIN,'%d %d',$n,$m);
    $tmp_array = explode(' ',trim(fgets(STDIN)));
    for($index=0;$index < $n;++$index){
        $towr[$index+1] = $tmp_array[$index];
    }
    $road = array_fill(1,$n,[]);
    for($index=0;$index<$m;++$index){
        fscanf(STDIN, '%d %d', $a, $b);
        $road[$a][] = $b;
        $road[$b][] = $a;
    }
    
    $ans = 0;

    foreach($road as $key => $values){
        if(!is_array($values)){
            ++$ans;
            continue;
        }
        $flag = 1;
        foreach($values as $value){
            if($towr[$key] <= $towr[$value]){
                $flag = 0;
                break;
            }
        }
        if($flag === 1){
            ++$ans;
        }
    }
    echo $ans.PHP_EOL;
?>

Measured memory_bytes: 61488
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;

vi v;
int n, m;

bool check(int mid){
	int w = 0, h = 0;
	for(int i = 0; i < v.size(); i++){
		if(v[i] > mid) return false;
		if(w + v[i] > mid){
			h++;
			w = v[i];
		}
		else{
			w += v[i];
		}
	}
	return h < m;
}

int main(){
	while(1){
		m = in.nextInt(); n = in.nextInt();
		if(m == 0 && n == 0) break;
		v.resize(n);
		rep(i, n) v[i] = in.nextInt();
		int l = 0, r = 1e9;
		rep(i, 100){
			int mid = (l + r) / 2;
			if(check(mid)){
				r = mid;
			}
			else{
				l = mid;
			}
		}
		printf("%d\n", r);
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
pair<ll,ll> A[1000000];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, 1<<N) cin >> A[i].first;
    
    rep(i, N){
        ll bi = 1 << i;
        rep(bit, 1<<N){
            if(bit & bi){
                ll pit = bit ^ bi;
                if(A[bit].first<=A[pit].first){
                    A[bit].second = max(A[bit].first, A[pit].second);
                    A[bit].first = A[pit].first;
                }
                else{
                    chmax(A[bit].second, A[pit].first);
                }
            }
        }
    }

    ll ans = 0;
    repe(i, 1, 1 << N){
        chmax(ans, A[i].first + A[i].second);
        cout << ans << '\n';
    }
}

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

void swap (int *, int *);
void print_a (int *, int);

int main (void) {
    int n, count=0;
    int *a;

    scanf ("%d", &n);
    a = (int *) malloc (sizeof(int) * n);
    for (int i=0; i<n; i++) scanf ("%d", a+i);

    for (int i=0; i<n; i++) {
        for (int j=n-1; j>i; j--) {
            if (a[j]<a[j-1]) {
                swap (a+j, a+j-1);
                count++;
            }
        }
    }

    print_a (a, n);
    printf ("%d\n", count);

    free(a);
    return 0;
}

void swap (int *a, int *b) {
    int t;
    t = *a;
    *a = *b;
    *b = t;
}

void print_a (int *a, int n) {
    for (int j=0; j<n; j++) {
        if (j==n-1) printf ("%d\n", a[j]);
        else printf ("%d ", a[j]);
    }
}


Measured memory_bytes: 2080
#include<stdio.h>

int main() {
  int N;
  int T; 
  int min;
  scanf("%d %d", &N, &T);
  int c[N];
  int t[N];
  for(int i = 0; i < N; i++) {
    scanf("%d %d", &c[i], &t[i]);
  }
  min = 1001;
  for(int i = 0; i < N; i++) {
    if(c[i] < min && t[i] <= T) {
      min = c[i];
    }
  }
  
  if(min == 1001) {
    printf("TLE\n");
  } else {
    printf("%d\n", min);
  }
}


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

using namespace std;

const int MAXN = 15, INF = 1e9;
int dist[MAXN][MAXN];
int main()
{
  int h, w;
  cin >> h >> w;
  for (int i = 0; i <= 9; i++)
  {
    for (int j = 0; j <= 9; j++)
    {
      cin >> dist[i][j];
    }
  }


  for (int k = 0; k <= 9; k++)
  {
    for (int i = 0; i <= 9; i++)
    {
      for (int j = 0; j <= 9; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
  }

  long long res = 0;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      int v;
      cin >> v;
      if (v >= 0) res += dist[v][1];

    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		String result = " ";

		if (A == 5 && B == 7 && C == 5 ) {
			result = "YES" ;
		} else if (A == 5 && B == 5 && C == 7) {
			result = "YES" ;
		}else if (A == 7 && B == 5 && C == 5) {
			result = "YES" ;
		}else {
			result = "NO" ;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 21204
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;
const double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<pair<int, int>>v(N);
	for (auto &i : v)cin >> i.second >> i.first;
	sort(v.begin(), v.end());
	int cnt = 0;
	for (auto i : v) {
		if (i.second + cnt > i.first) {
			cout << "No\n";
			return 0;
		}
		cnt += i.second;
	}
	cout << "Yes\n";
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define f(p,n) for(ll i=p;i<n;i++)
ll exp(ll a,ll b,ll m);

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

	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<(a[0]*a[1])/2<<endl;
	
return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}



Measured memory_bytes: 256
from collections import defaultdict

M = 998244353
B = pow(10, 18, M)
N = int(input())

def geometric_mod(a, r, m, n):
  x = a
  for i in range(n):
    yield x
    x = (x*r)%m

BB = list(geometric_mod(1, B, M, N+2))

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in set(e[i])})
    if m:
      g[i] = m
      sum_g[g[i]] = (sum_g[g[i]] + BB[i]) % M
      sum_g[0]  = (sum_g[0] - BB[i]) % M

  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret = (ret + sx*sy*sz) % M
  return ret


edge = [read_edge() for i in range(3)]

print(solve(N, edge))

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

int W[22];
int K[22];

int main()
{
  rep(i, 10) cin >> W[i];
  rep(i, 10) cin >> K[i];

  sort(W, W + 10, greater<int>());
  sort(K, K + 10, greater<int>());

  cout << W[0] + W[1] + W[2] << ' ' << K[0] + K[1] + K[2] << endl;

  return 0;
}

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

int main(void){
	int N;
	int *A;
	int count;
	int i;
	int odd_flag;

	scanf("%d", &N);
	if (!(A = (int *)malloc(sizeof(int) * N))){
		printf("malloc error\n");
		return (0);
	}
	i = 0;
	while (i < N){
		scanf("%d", &A[i]);
		i++;
	}
	count = 0;
	while (1){
		odd_flag = 0;
		i = 0;
		while(i < N){
			if (A[i] % 2 != 0){
				odd_flag = 1;
			}
			i++;
		}
		if (odd_flag){
			break;
		}
		i = 0;
		while (i < N){
			A[i] = A[i] / 2;
			i++;
		}
		count++;
	}
	printf("%d\n", count);
	return (0);

}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double D;
const ll mod=1e9+7;
const ll inf=(1ll<<62);
ll POW(ll x,ll y){
    if(y==0)return 1;
    if(y==1)return x;
    ll ans=POW(x,y/2)%mod;
    ans*=ans;
    ans%=mod;
    if(y%2)ans*=x;
    return ans%mod;
}
const int MX=3e5+9;
int n,a[MX];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    for(int i=n-1,j=0;i>=0;i--,j++){
        if(j%2==0)sum+=a[i];
        else sum-=a[i];
    }
    cout<<sum<<endl;
}


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

int arr[200'001];

int main()
{
	int N, K;
	long long ans = 0;
	std::cin >> N >> K;
	for (int i = 0; i < N; ++i)
		std::cin >> arr[i];
	std::sort(arr, arr + N);
	for (int i = 0; i < N - K; ++i)
		ans += arr[i];
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


ll h,w,n;
vector<Pi> ab;
ll ans[10]={};
int main(){
	cin>>h>>w>>n;
	REP(i,n){
		int a,b;
		cin>>a>>b;
		a--,b--;
		ab.push_back(Pi(a,b));
	}
	sort(ab.begin(),ab.end());
	ll ty=-1;
	REP(i,n){
		ll a=ab[i].first,b=ab[i].second;
		for(int i=-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				ll a1=a+i;
				ll b1=b+j;
				if(a1>0&&a1<h-1&&b1>0&&b1<w-1){
					ll cou=0;
					for(int k=-1;k<=1;k++){
						for(int l=-1;l<=1;l++){
							auto itr=lower_bound(ab.begin(),ab.end(),Pi(a1+k,b1+l));
							if(itr!=ab.end()&&*itr==Pi(a1+k,b1+l)){
								//cout<<a1+k<<" "<<b1+l<<endl;
								cou++;
							}
						}
					}
					if(cou!=0)ans[cou]++;
				}
			}
		}
	}
	int sum=0;
	for(int i=1;i<10;i++){
		ans[i]/=i;
		sum+=ans[i];
	}
	cout<<(h-2)*(w-2)-sum<<endl;
	for(int i=1;i<10;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

#ifdef GCC
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#define log(x) cout << (x) << "\n"
#define loop(i, begin, end)for(__typeof(end) i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define rep(i, n) loop(i, 0, n)

using ll = long long;

int main() {
    int n;
    cin >> n;
    ll sm=0, cnt=0, x, mn=numeric_limits<ll>::max();
    rep (i, n) {
        cin >> x;
        if (x < 0) sm += -x, cnt += 1;
        else sm += x;
        mn = min(abs(x), mn);
    }
    if (cnt&1) sm -= 2*mn;
    log(sm);
}



Measured memory_bytes: 256
#include "iostream"
#include "cmath"
using namespace std;
int main()
{
	int n, a, b;
	cin >> n;
	if (n == 1)
	{
		cout << "Hello World";
	}
	if (n == 2)
	{
		cin >> a >> b;
		cout << a + b;
	}
	cout << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int>data(N);
  for(int i;i<N;i++){
    char a;
    cin >> a;
    if(a=='W') data.at(i)=0;
    else data.at(i)=1;
  }
  vector<int>result(N);
  int one=0;
  for(int i=1;i<N;i++){
    one+=data.at(i);
  }
  result.at(0)=one;
  for(int i=1;i<N;i++){
    int a=0;
    if(data.at(i)==1) a--;
    if(data.at(i-1)==0) a++;
    result.at(i)=result.at(i-1)+a;
  }
  sort(result.begin(),result.end());
  
  cout << result.at(0) << endl;
}


Measured memory_bytes: 5632
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
x = int(input())

a = 0
b = 0
comp = 0
# print('{:.2f}'.format(pow(3125,1/5)))
while comp == 0 :
    aa = a**5
    tmp = aa - x
    if tmp < 0:
        b = -(pow(-tmp,1/5))
        b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
    elif tmp == 0:
        b = 0
    else:
        b = pow(tmp,1/5)
        b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
    b = float(b)
    if b.is_integer():
        b = int(b)
        comp = 1
    else:
        aa = (-a)**5
        tmp = aa - x
        if tmp < 0:
            b = -(pow(-tmp,1/5))
            b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
        elif tmp == 0:
            b = 0
        else:
            b = pow(tmp,1/5)
            b = Decimal(str(b)).quantize(Decimal('0.00000001'), rounding=ROUND_HALF_UP)
        b = float(b)
        if b.is_integer():
            b = int(b)
            a = -a
            comp = 1
        else:
            a += 1
print(a,b)

Measured memory_bytes: 10192
# 文字列を入力
number = list(input())
# カウントの設置
count = 0
# 各桁の判定
if number[0] == '1':
    count += 1
if number[1] == '1':
    count += 1
if number[2] == '1':
    count += 1
# 出力
print(count)


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
import numpy as np

def main():
    n, W = map(int, input().split())
    dp = np.zeros(W + 1, dtype = np.int64)
    for i in range(n):
        w,v=map(int,input().split())
        dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
    print(max(dp))

if __name__ == '__main__':
    main()

Measured memory_bytes: 15500
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
const int N=1e5+5;
int a[N];

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    cout<<min(n%k,k-(n%k));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    char g[h][w] = {};
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> g[i][j];
        }
    }
    int ans[h][w] = {};
    int index = 1;
    rep(i, 0, h) {
        int start = 0;
        rep(j, 0, w) {
            if (g[i][j] == '#') {
                int end = j;
                if (j < w - 1) {
                    while (g[i][end + 1] != '#') {
                        end++;
                        if (end >= w - 1) break;
                    }
                }
                rep(k, start, end + 1) {
                    ans[i][k] = index;
                }
                start = end + 1;
                index++;
            }
        }
    }
    int tmp = 0;
    rep(i, 1, h) {
        if (ans[i][0] != 0 && ans[i - 1][0] == 0) {
            int tmp = i - 1;
            while (tmp >= 0 && (ans[tmp][0] == 0)) {
                rep(j, 0, w) {
                    ans[tmp][j] = ans[i][j];
                }
                tmp--;
            }
        }
    }
    if (ans[h - 1][0] == 0) {
        for (int i = h - 1; i >= 0; i--) {
            if (ans[i][0] != 0 && ans[i + 1][0] == 0) {
                rep(j, i + 1, h) {
                    rep(k, 0, w) {
                        ans[j][k] = ans[i][k];
                    }
                }
            }
        }
    }

    rep(i, 0, h) {
        rep(j, 0, w) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1152
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b = sc.next()
  val n = s"$a$b".toInt
  var i = 1
  while (i * i <= n) {
    i += 1
  }
  i -= 1
  println(if (i*i == n) "Yes" else "No")
}


Measured memory_bytes: 55016
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	ll a,b,k;
	cin >>a  >> b >> k;
	ll ans1;
	ll ans2;
	if(a - k >= 0){
		cout << a - k << " " << b;
	}
	else if(a - k < 0){
		cout << 0 << " ";
		k -= a;
		if(b - k < 0){
			cout << 0;
		}
		else cout << b-  k;
	}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#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 FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string a, b;
/**********************************************/

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

    if(a.size() < b.size()){
        cout << "LESS" << endl;
        return 0;
    }else if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }else{
        REP(i, a.size()){
            if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }else if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
        }
    }

    cout << "EQUAL" << endl;
}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
const int MOD = 1000000007;

#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()
#define s_exists(elem, s) s.find(elem)!=s.end()
#define mod_mul(x, y) x*y%MOD
#define mod_add(x, y) (x+y)%MOD
#define mod_sub(x, y) (x-y)%MOD

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

long lcm( long m, long n ){
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m / gcd(m, n)) * n);
}


long nCr(long n, long r){
    if(n==r || r==0){
        return 1;
    } else {
        return mod_add(nCr(n-1,r),nCr(n-1,r-1));
    }
}

std::vector<pair<int, int>> v;

int main(){
    int N,M; cin >> N >> M;
    for (int i = 0; i < M; ++i){
        int a,b; cin >> a >> b;
        v.push_back(make_pair(a-1, b-1));
    }

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


    int left = v[0].first;
    int right = v[0].second;
    int cnt = 0;
    for(int i=1; i<v.size(); i++){
        if(right <= v[i].first){
            cnt ++;
            left = v[i].first; right = v[i].second;
        } else {
            left = max(v[i].first, left);
            right = min(v[i].second, right);
        }
    }

    cout << cnt+1 << endl;


    return 0;

}


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

void insertionSort(int *A, int N);

int main(void){
	int n;
	int *num;
	scanf("%d",&n);
	num=(int *)malloc(sizeof(int)*n);
	if(num==NULL){
		printf("failure\n");
		exit(1);
	}

	int i;
	for(i=0;i<n;i++){
		scanf("%d",(num+i));
	}
	for(i=0;i<n-1;i++){
		printf("%d ",*(num+i));
	}
	printf("%d\n",*(num+n-1));
	insertionSort(num,n);
	/*
	for(i=0;i<n;i++){
		printf("%d",*(num+i));
	}
	*/

	free(num);
	return 0;
}

void insertionSort(int *num, int n){
	int i,j,k,v;
	for(i=1;i<n;i++){
		v=num[i];
		j=i-1;
		while(j>=0&&num[j]>v){
			num[j+1]=num[j];
			j--;
		}
		num[j+1]=v;
		for(k=0;k<n-1;k++){
			printf("%d ",*(num+k));
		}
		printf("%d\n",*(num+n-1));
	}
}

Measured memory_bytes: 1832
import bisect

LI = lambda: list(map(int, input().split()))

N = int(input())
XD = [LI() for _ in range(N)]

MOD = 998244353


class BIT:

    def __init__(self, n):
        self.n = n
        self.dat = [i - 1 for i in range(self.n + 1)]

    def change(self, i, x):
        i += 1
        while i <= self.n:
            self.dat[i] = max(self.dat[i], x)
            i += i & -i

    def max_num(self, i):
        if i == 0:
            return -1
        return max(self.dat[i], self.max_num(i - (i & -i)))


def main():
    XD.sort()
    x = [None] * N
    d = [None] * N
    for i in range(N):
        x[i], d[i] = XD[i]
    
    bit = BIT(N)
    w = [None] * N
    for i in range(N - 1, -1, -1):
        v = x[i] + d[i]
        j = bit.max_num(bisect.bisect_left(x, v))
        w[i] = j - i
        bit.change(i, j)
    
    dp = [None] * (N + 1)
    dp[-1] = 1
    for i in range(N - 1, -1, -1):
        dp[i] = (dp[i + 1] + dp[i + w[i] + 1]) % MOD
    
    ans = dp[0]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 132512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  int bangou = 1;
  for (int i = 0; i < N; i++) {
    if (2 * bangou > bangou + K) {
      bangou += K;
    }
    else {
      bangou = 2 * bangou;
    }
  }
  cout << bangou << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
using ll=long long;

string ans;

void ps(int n,char a){
    for(int i=0;i<n;i++) ans+=a;
    return;
}

int main(){
    int a,b;cin>>a>>b;
    int ans=0;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        bool flag=true;
        for(int j=0;j<s.size();j++)if(s[j]!=s[s.size()-1-j]){
            flag=false;
            break;
        }
        if(flag) ans++;
    }
    cout<<ans<<endl;
}    

Measured memory_bytes: 632
import java.util.*;

class Main{
	public static void main(String args[]){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int argInt[] ={a,b,c};
     
      int fiveCount = 0;
      int sevenCount = 0;
       
      for(int arg: argInt){
      	if(arg == 5){
          fiveCount++;
        }
        if( arg == 7){
          sevenCount++;
        }
      }
      
      if(fiveCount == 2 || sevenCount == 1){
        System.out.print("YES");
      }else{
        System.out.print("NO");
      }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main () {
  long H, W, K;
  cin >> H >> W >> K;
  if(W == 1){
    cout << 1 << endl;
    return 0;
  }
  long a, flag = 0;
  string sub;
  vector<string> data;
  for(int i = 0; i < pow(2, W - 1); i++){
    a = i;
    sub = "";
    flag = 0;
    for(int j = 0; j < W - 1; j++){
      if(flag == 1){
        if(a % 2 == 1){
          flag = 0;
          break;
        } else flag = 0;
      } else {
        if(a % 2 == 1)flag = 1;
      }
      sub += a % 2 + '0';
      a /= 2;
      if(j == W - 2)flag = 1;
    }
    if(flag == 1){
      data.push_back(sub);
    }
  }
  vector<long> path(W - 1);
  for(int i = 0; i < data.size(); i++){
    for(int j = 0; j < W - 1; j++){
      path.at(j) += data.at(i).at(j) - '0';
    }
  }
  vector<vector<long>> dp(H + 1, vector<long>(W + 1));
  dp.at(0).at(1) = 1;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < path.size(); j++){
      dp.at(i + 1).at(j + 2) += dp.at(i).at(j + 1) * path.at(j);
      dp.at(i + 1).at(j + 1) += dp.at(i).at(j + 2) * path.at(j);
      dp.at(i + 1).at(j + 2) %= 1000000007;
      dp.at(i + 1).at(j + 1) %= 1000000007;
    }
    for(int j = 1; j < W + 1; j++){
      if(j == 1)dp.at(i + 1).at(j) += dp.at(i).at(j) * (data.size() - path.at(j - 1));
      else if(j == W)dp.at(i + 1).at(j) += dp.at(i).at(j) * (data.size() - path.at(j - 2));
      else dp.at(i + 1).at(j) += dp.at(i).at(j) * (data.size() - path.at(j - 1) - path.at(j - 2));
      dp.at(i + 1).at(j) %= 1000000007;
    }
  }
  cout << dp.at(H).at(K) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int a[100000];
  int main()
  {
      int k,s;
      cin>>k>>s;
      for(int i=0;i<=k;i++)
      {
         for(int j=0;j<=k;j++)
         {
             a[5000+i+j]++;
         }
     }
     int sum=0;
     for(int i=0;i<=k;i++)
     {
         int pos=s-i;
         if(pos<0)
         {
             continue;
         }
         sum+=a[5000+pos];
     }
     cout<<sum<<endl;
     return 0;
 }

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

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

  int c[101] = {};
  int ans = 0;

  for (int i = 0; i < 3; ++i) {
    int a;
    cin >> a;

    ++c[a];
  }

  for (auto e : c) if (e) ++ans;

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3556
N,K,*X = `dd`.split.map &:to_i
x = 0
f = 0
(0..40).reverse_each{ |k|
  b = 1 << k
  ad = X.map{ |x| (x & b) }
  if x + b > K
    f += ad.reduce(0){ |a,x| a + x }
    next
  end
  a1 = ad.reduce(0){ |a,x| a + (x ^ b) }
  a0 = ad.reduce(0){ |a,x| a + x }
  if a1 > a0
    x += b
    f += a1
  else
    f += a0
  end
}
p f

Measured memory_bytes: 29676
#include<cstdio>
long long n,f[1000001],sum;
int main()
{
	scanf("%lld",&n);
	f[1]=n;f[2]=n*n;
	for(int i=3;i<=n;++i){
		f[i]=(f[i-1]+(n-i+2)*f[1]+sum)%1000000007;
		sum=(sum+f[i-2]+n-1)%1000000007;
	}
	printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 7936
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define hurr cout<<"Road_Clear"<<endl;
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        int n,k; cin >> n >> k;
        ll res = k* pow((k-1),n-1);
        cout<<res<<endl;

return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

vector<ll> divisor(ll n){
	vector<ll> res;
	for(ll i=1; i*i<=n; i++){
		if(n%i==0){
			res.push_back(i);
			if(i*i!=n) res.push_back(n/i);
		}
	}
	sort(res.begin(),res.end());
	return res;
}

int main(void) {
	ll n,m; cin >> n >> m;
	vll d = divisor(m);
	ll ans = 1;
	for(auto l: d){		
		if(m<l*n) break;			
		ans = l;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc073.contest.atcoder.jp/tasks/arc073_a>
問題文============================================================
 とある銭湯には、スイッチを押すと T 秒間お湯が出るシャワーがあります。
 
 なお、お湯が出ているときにスイッチを押すと、そのタイミングから T 秒間お湯が出つづけます。
 お湯の出る時間が T 秒間延長されるわけではないことに注意してください。
 
 このシャワーの前を、N 人の人がスイッチを押して通り過ぎていきます。
 i 人目の人は、1 人目の人がスイッチを押した ti 秒後にスイッチを押します。
 
 お湯が出る時間の総和は何秒かを求めてください。
 
=================================================================

解説=============================================================
手前から順番にシミュレーションすれば良い
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N, T; cin >> N >> T;
    ll res = 0,pre_t = 0;
    for(int i = 0; i  <N;i++){
        ll t; cin >> t;
        if(i == 0){
            pre_t = t; continue;
        }else{
            res += min(t- pre_t,T); pre_t = t;
        }
    }
    res += T;
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256