akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
void insert(int);
void heapIncreaseKey(int,int);
int extract();
void maxHeapify(int);

int B,A[MAX+1];

int main(){
  int key;
  string com;
  while(1){
    cin >> com;
    if(com[0] == 'e' && com[1] == 'n'){
      break;
    }
    if(com[0] == 'i'){
      cin >> key;
      insert(key);
    }
    else{
      cout << extract() << endl;
    }
  }
  return 0;
}//end of main func


void insert(int key){
  B++;
  A[B] = -INFTY;
  heapIncreaseKey(B,key);
}

void heapIncreaseKey(int i,int key){
  int tmp;
  if(key < A[i]){
    return;
  }
  A[i] = key;
  while(i>1 && A[i/2] < A[i]){
   //tmp = A[i];
   //A[i] = A[i/2];
   //A[i/2] = tmp;
    swap(A[i],A[i/2]);
    i = i / 2;
  }
}//end of insert func


int extract(){
  int maxV;
  if(B < 1){
    return -INFTY;
  }
  maxV = A[1];
  A[1] = A[B--];
  maxHeapify(1);
  return maxV;
}//end of


void maxHeapify(int i){
  int right,left,largest;
  left = 2*i;
  right = (2*i)+1;
  if(left <= B && A[left] > A[i]){
    largest = left;
  }
  else{
    largest = i;
  }
  if(right <= B && A[right] > A[largest]){
    largest = right;
  }
  if(largest != i){
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}

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

int main()
{
    long long N, M;
    cin >> N >> M;
    long long ans = 0LL;
    if (N * 2LL <= M)
    {
        ans += N;
        M -= N * 2LL;
        ans += M / 4LL;
    }
    else
    {
        ans += M / 2LL;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int64_t> V(N+1, 0);
  
  for (int i = 0; i <= N; i++) {
    if (i==0) {
      V.at(i) = 2;
    }
    else if (i==1) {
      V.at(i) = 1;
    }
    else {
      V.at(i) = V.at(i-1) + V.at(i-2);
    }
    //cout << V.at(i) << endl;
  }
  cout << V.at(N) << endl;
}


Measured memory_bytes: 3600
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
void merge(T)(T left, T right, T ary, ref int count)
{
    T left2 = left.dup;
    T right2 = right.dup;
    ptrdiff_t i = 0;
    ptrdiff_t j = 0;
    for (ptrdiff_t k = 0; k < ary.length; k++)
    {
        count++;
        if (left2.length > i && (right2.length <= j || left2[i] <= right2[j]))
        {
            ary[k] = left2[i];
            i++;
        }
        else if (right2.length > j)
        {
            ary[k] = right2[j];
            j++;
        }
    }
}
void merge_sort(T)(T ary, ref int count)
{
    if (ary.length == 1)
        return;
    T left = ary[0..$ / 2];
    T right = ary[$ / 2..$];
    merge_sort(left, count);
    merge_sort(right, count);
    merge(left, right, ary, count);
}
void main()
{
    int count;
    readln();
    int[] a = readln().strip.split(' ').map!(x => x.to!int).array;
    merge_sort(a, count);
    writeln(a.map!(x => x.to!string).join(' '));
    writeln(count);
}



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

#define ll long long int
#define mp make_pair
#define pb push_back
using namespace std;

int main() {
    string s;
    cin>>s;
    ll n;
    cin>>n;
    if(s.length() == 1 && s[0] == '1'){
        printf("1");
        return 0;
    }
    else if(s[0] == '1'){
        int i ;
        int c= 0 ;
        for ( i = 0; i < s.length(); ++i) {
            if(s[i] == '1') {
                c++;
                continue;
            }
            else{
                break;
            }
        }
        if(n <= c){
            printf("1");
            return 0;
        }
        else{
            printf("%d",s[i] - '0');
            return 0;
        }
        /*if(n == 1){
            printf("1");
            return 0;
        }*/
        /*else{
            printf("%d",s[1] - '0');
            return 0;
        }*/
    }
    else{
        printf("%d",s[0] - '0');
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int ans = 0 ;
		for(int i = 0;i<s.length(); i++) {
			if(s.charAt(i) == '1') ans++; 
		}
		System.out.println(ans); 
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int a[100005],b[100005];
int main()
{
	int n,f=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	if(a[0]>=a[1])
		a[0]--;
	for(int i=0;i<n-1;i++){
		if(a[i+1]>a[i]){
			a[i+1]--;
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i]>a[i+1]){
			f=1;
			break;
		}
	}
	if(f==1)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
 } 

Measured memory_bytes: 640
#153 Fennec vs Monster
n,k = map(int,input().split())
tairyoku = list(map(int,input().split()))
tairyoku.sort(reverse=True)

if k == 0:
    print(sum(tairyoku))
    
else:
    del tairyoku[:k]
    print(sum(tairyoku))


Measured memory_bytes: 26764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int 			long long int
#define pll 			pair<ll , ll>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

ll mod_pow(ll a,ll b) {
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
    
    int n;
    
    cin >> n;
    
    int a[n];
    
    for(int i = 0; i < n; ++i) {
    	cin >> a[i];
    }
    
    sort(a , a+n);
    
    int cur = n-1;
    
    int ans = 0;
    
    for(int i = n-2; i >= 0; --i) {
    	if(cur <= 0) {
    		break;
    	}
    	
    	if(i == n-2) {
    		cur--;
    		ans += a[i+1];
    	}
    	else {
    		if(cur > 0) {
    			ans += a[i+1];
    			cur--;
    		}
    		if(cur > 0) {
    			ans += a[i+1];
    			cur--;
    		}
    	}
    }
    
    cout << ans ;
}       

signed main() {
    fast;
    
    int t = 1;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 5196
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a = int(input())
if a % 2 == 0:
    print(int(a/2*a/2))
else:
    print(int(a/2)*(int(a/2)+1))


Measured memory_bytes: 2940
d, g = map(int, input().split())
dp = [0 for i in range(1001)]
dp[0] = 0
num = 0
for i in range(1, d + 1):
    p, c = map(int, input().split())
    for j in range(num, -1, -1):
        for k in range(1, p + 1):
            if k != p:
                dp[j + k] = max(dp[j + k], dp[j] + 100 * i * k)
            else:
                dp[j + k] = max(dp[j + k], dp[j] + 100 * i * k + c)
    num += p
for i in range(1001):
    if dp[i] >= g:
        print(i)
        break

Measured memory_bytes: 9084
<?php

    $data = explode(" ", trim(fgets(STDIN)));
    $n = $data[0];
    $c = $data[1];
    $k = $data[2];
    
    for($i=0;$i<$n;$i++){
        $t[$i] = trim(fgets(STDIN));
    }
    sort($t);
    
    $x = $t[0];
    $y = 0;
    $ans = 1;
    for($i=0;$i<$n;$i++){
        if($y >= $c || $t[$i] > $x + $k){
            $x = $t[$i];
            $y = 1;
            $ans++;
        } else $y++;
    }
    
    echo $ans;
 
?>

Measured memory_bytes: 12792
#include <iostream>
#include <queue>

using namespace std;

int main() {
    int N;
    int A;
    priority_queue<int> pq;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        cin >> A;
        pq.push(A);
    }
    int found = 0;
    long long int L,R;
    while(pq.size() > 1 and found < 2) {
        int a = pq.top();
        pq.pop();
        if(pq.top() == a) {
            pq.pop();
            if(found == 0) {
                L = a;
            } else {
                R = a;
            }
            ++found;
        }
    }
    if(found == 2)
        cout << L*R << endl;
    else
        cout << 0 << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int res = (h2 - h1) * 60 + (m2 - m1) - k;
	pv(res)
	return(0);
}

Measured memory_bytes: 3636
while True:
    a, op, b = list(input().split())
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        ans = a+b
        print(ans)
    elif op == '*':
        ans = a*b
        print(ans)
    elif op == '/':
        ans = a//b
        print(ans)
    else:
        ans = a-b
        print(ans)


    
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
 
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
const int INF = 1e9 + 7;
 
int main(void)
{
	FAST
	
	int x, n; cin >> x >> n;
	
	vector<int> ref(103);
	iota(ref.begin(), ref.end(), -1);
	
	int ans = INF;
	int num = INF;

	for(int i = 0; i < n; i++)
	{
		int y; cin >> y;
		
		ref[y+1] = INF;
	}

	for(int i : ref)
	{
		int diff = abs(x-i);

		if(diff < ans)
		{
			ans = diff;
			num = i;
		}
		if(diff == ans) num = min(num, i);
	}
	cout << num << '\n';

	return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a%2 == 1)&&(b%2 == 1)) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#define MAX 100
using namespace std;
typedef long long ll;
ll n,c[MAX]; 
ll getGCD(ll a,ll b)
{  
    ll temp;  
    if(a < b)
	{  
      temp = a;  
      a = b;  
      b = temp;  
    }    
    if(a%b == 0)
	{  
        return b;    
    }
	else
	{    
        return getGCD(b,a%b);    
    }    
}    
ll doLCM(ll* array,ll size)
{    
    ll x,y,num=array[0],i,gcd;  
    for(i=0;(i+1)<size;i++)
	{  
        x=num;    
        y=array[i+1];   
        gcd = getGCD(x,y);    
    	num = x/gcd * y/gcd * gcd;  
    }  
    return num;    
}  
int main()
{
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&c[i]);
	}
	printf("%lld",doLCM(c,n));
	return 0;
}



Measured memory_bytes: 256
import heapq

N,M = map(int, input().split())
A = list(map(lambda n:-1*int(n), input().split()))
heapq.heapify(A)

for _ in range(M):
    v = heapq.heappop(A)
    if v == 0:
        break
    v = -(-v // 2)
    heapq.heappush(A, v)

print(-1*sum(A))


Measured memory_bytes: 14180
##入力は以下の形式で標準入力から与えられる。
##N
##d1
##:
##dN
n = gets.chomp.to_i
a_d = []
n.times do
  a_d << gets.chomp.to_i
end

##X段重ねの鏡餅 (X ≥ 1)とは、X枚の円形の餅を縦に積み重ねたものであって、
##どの餅もその真下の餅より直径が小さい（一番下の餅を除く）もののことです。

##例えば、直径 10、8、6センチメートルの餅をこの順に下から積み重ねると 
##3段重ねの鏡餅になり、餅を一枚だけ置くと 1段重ねの鏡餅になります。

##N枚の円形の餅を持っていて、そのうち i枚目の餅の直径は diセンチメートルです。
##これらの餅のうち一部または全部を使って鏡餅を作るとき、
##最大で何段重ねの鏡餅を作ることができるでしょうか。
a_d.sort!

sum, check = 0, 0
a_d.each do |v|
  if check < v
    check = v
    sum +=1
  end
end

##制約
##1 ≤ N ≤ 100
##1 ≤ di ≤ 100
##入力値はすべて整数である。

##作ることのできる鏡餅の最大の段数を出力せよ。
# p a_d
p sum

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

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++){
    int A;
    cin >> A;
    N -= A;
  }
  if (N < 0){
    cout << -1 << endl;
  }
  else {
    cout << N << endl;
  }
}


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

int main(){
    int a,b;
    char op;
    
    
    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;
        
        if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
        
    }
    return 0;
}


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

void main_()
{
    string s;
    cin >> s;
    ll K;
    cin >> K;

    set<string> res;

    for (char ch = 'a'; ch <= 'z' && (ll)res.size() < K; ch++) {
        vector<ll> chpos_vec;
        for (ll i = 0; i < (ll)s.size(); ++i) {
            if (s[i] == ch) {
                chpos_vec.push_back(i);
            }
        }

        if (!chpos_vec.empty()) {
            res.emplace(1, ch);
        }
        for (auto pos : chpos_vec) {
            for (ll i = 2; i <= K; ++i) {
                res.insert(s.substr(pos, i));
            }
        }
    }

    cout << *next(begin(res), K - 1) << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public 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 k = sc.nextInt();
    
    int ans = 0;
    ans += Math.min(a,k);
    k -= a;
    k -= b;
    if(k > 0){
      ans -= Math.min(c,k);
    }
    System.out.println(ans);
  }
}

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

typedef long long ll;
typedef pair<ll, ll> pll;
const ll mod=1000000007;
const char nl='\n';

void solve(){
    ll i,j,k,l,m,n,u,v,x,y;
    string s,t;
    cin>>s>>t;
    ll ss=(ll)s.size(), tt=(ll)t.size();
    ll ans=1000000;
    for(i=0;i<=ss-tt;i++){
        ll c=0;
        for(j=i;j<i+tt;j++){
            if(s[j]!=t[j-i]) c++;
        }
        ans=min(ans,c);
    }
    cout<<ans<<nl;
}

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int t = 1,i=1;
//    cin >> t;
	while (t--)
	{
//	    cout<<"Case #"<< i++ <<": ";
		solve();
	}
	return 0;
}



Measured memory_bytes: 3616
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Y;
    cin >> N >> Y;

    REP(x, N + 1) {
        REP(y, N + 1) {
            int z = N - x - y;
            if (z >= 0) {
                int sum = 10000 * x + 5000 * y + 1000 * z;
                if (sum == Y) {
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int main() {
    int n, k;
    scanf("%d", &n);
    ll m = INF;
    k = 0;
    ll sum = 0;
    for (int  i = 0, x; i<n; ++i) {
        scanf("%d", &x);
        if (x < 0) {
            k++;
            sum-=x;
            if (-x < m) m = -x;
        } else {
            sum+=x;
            if (x < m) m = x;
        }

    }
    printf("%lld\n", k&1 ? sum-2LL*m : sum);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int flg = 0;
  for(int i=min(A,B); i>0; --i){
    if(A%i==0&&B%i==0) ++flg;
    if(flg==K){
      cout << i << endl;
      return 0;
    }
  }
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

//////////////////////////////////////////////

const int N = 1e5;

int par[N + 5];
int deg[N + 5], sz[N + 5];

int find(int x){
	if(par[x] == x) return x;
	return par[x] = find(par[x]);
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	REP(i,1,N) par[i] = i;
	int n,m,k; cin >> n >> m >> k;
	FOR(i,m) {
		int u,v; cin >> u >> v;
		int pu = find(u);
		int pv = find(v);
		par[pu] = pv;
		deg[u]++;
		deg[v]++;
	}
	REP(i,1,n) {
		sz[find(i)]++;
	}
	FOR(i,k) {
		int u,v; cin >> u >> v;
		int pu = find(u);
		int pv = find(v);
		if(pu == pv) {
			deg[u]++;
			deg[v]++;
		}
	}
	REP(i,1,n) {
		if(i > 1) cout << " ";
		cout << sz[find(i)] - deg[i] - 1;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ

//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

int main(){
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    int ans = 0;
    rep(i, h) cin >> s[i];
    rep(is, 1<<h){ //行情報。2のh乗している
        rep(js, 1<<w){ //列情報。2のh乗している
            int cnt = 0;
            rep(i, h){
                rep(j, w){
                    if(is>>i&1) continue; //行が消されているならコンテニュー
                    if(js>>j&1) continue; //列が消されているならコンテニュー
                    if(s[i][j]=='#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
#define intmax 2147483647
#define intmin –2147483648
#define llmax 9223372036854775807
#define llmin -9223372036854775808
using namespace std;

int n,cnt,s[100];



int main(){
	cnt = 0;
	cin >> n;
	int z = 0;
	lp(n) {
		cin >> s[z];
		if (s[z] % 10 == 0)cnt += s[z];
		else z++;
	}
	if (z == 0) {
		cout << 0 << endl;
		return 0;
	}
	sort(s, s + z - 1);
	lp(z)
		cnt += s[i];
	if (cnt % 10 == 0)cnt -= s[0];
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  #define ll  long long int
  #define N 51
  #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
  #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
  #define po pop_back
  #define pb push_back
  #define lb lower_bound
  #define fi first
  #define se second
  #define debug(x) cout << #x << " = " << x << endl
  #define ub upper_bound
  #define ibs ios_base::sync_with_stdio(false)
  #define cti cin.tie(0)
  #define all(x) x.begin(),x.end()
  #define PI 3.14159265
  #define cot cout.tie(0)
  using namespace std;
    /**
      * @author :: Sawlani
      *
      */
      int main()
      {

          char ch;
          cin >> ch;
          ch++;
          cout << ch << endl;
      }


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let sx: i64 = itr.next().unwrap().parse().unwrap();
    let sy: i64 = itr.next().unwrap().parse().unwrap();
    let tx: i64 = itr.next().unwrap().parse().unwrap();
    let ty: i64 = itr.next().unwrap().parse().unwrap();

    let dx = tx - sx;
    let dy = ty - sy;
    let mut ans = Vec::new();
    for _ in 0..dx {
        ans.push('R');
    }
    for _ in 0..dy {
        ans.push('U');
    }
    for _ in 0..dx {
        ans.push('L');
    }
    for _ in 0..dy {
        ans.push('D');
    }

    ans.push('D');
    for _ in 0..dx + 1 {
        ans.push('R');
    }
    for _ in 0..dy + 1 {
        ans.push('U');
    }
    ans.push('L');
    ans.push('U');
    for _ in 0..dx + 1 {
        ans.push('L');
    }
    for _ in 0..dy + 1 {
        ans.push('D');
    }
    ans.push('R');

    let s: String = ans.into_iter().collect();
    println!("{}", s);
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

int n;
vector<ll> a;

struct Data {
  int i;
  ll v;
  bool operator < ( const Data & d ) const {
    if( v != d.v ) return v < d.v;
    return i < d.i;
  }
};

ll bf() {
  vector<Data> vec;
  rep(i,n) vec.pb((Data){i,a[i]});
  sort(ALL(vec));
  ll maxi = 0;
  do {
    ll score = 0;
    rep(i,(int)vec.size()) {
      score += (ll)( llabs(vec[i].i - i) * vec[i].v  );
    }
    maxi = max(maxi,score);
    /*
    rep(i,(int)vec.size()) {
      cout << "(" << vec[i].i << ", " << vec[i].v << ") ";
    } puts("");
    */
  } while( next_permutation(ALL(vec)) );

  sort(ALL(vec));
  do {
    ll score = 0;
    rep(i,(int)vec.size()) {
      score += (ll)( llabs(vec[i].i - i) * vec[i].v  );
    }
    if( maxi == score ) {
      rep(i,(int)vec.size()) {
	cout << "(i:" << vec[i].i << ", v:" << vec[i].v << ") ";
      } puts("");
    }

  } while( next_permutation(ALL(vec)) );

  
  return maxi;
}

const bool debug = 0;
#define MAX 2001
ll dp[MAX][MAX];
void solve() {
  if( debug ) {
    cout << "Answer: " << bf() << endl;
  }
  vector<Data> vec;
  rep(i,n) {
    vec.pb((Data){i,a[i]});
  }
  sort(ALL(vec));
  reverse(ALL(vec));
  ll maxi = 0;
  rep(i,n) {
    Data d = vec[i];
    rep(use_in_L,i+1) {
      int L = use_in_L;
      int rem = i - use_in_L;
      int R = n - 1 - rem;
      if( debug ) {
	cout << "*" << i << "-th: d = (i:" << d.i << ", v:" << d.v << ")"<< endl;
	cout << "  L = " << L << ", R = " << R << " dp["<<L<<"]["<<R<<"] = " << dp[L][R] << endl;
      }
      if( !( L <= R ) ) continue;
      // put L
      dp[L+1][R] = max(dp[L+1][R],dp[L][R]+llabs(d.i-L)*d.v);
      maxi = max(maxi,dp[L+1][R]);
      if( debug ) {
	cout << "  dp[" << L+1 << "][" << R << "] = " << dp[L+1][R] << " :: "
	     << dp[L][R] << " + " << "llabs(" << d.i << "-" << L << ") * " << d.v << endl;
      }
      
      // put R
      dp[L][R-1] = max(dp[L][R-1],dp[L][R]+llabs(d.i-R)*d.v);
      if(debug) {
	cout << "  dp[" << L << "][" << R-1 << "] = " << dp[L][R-1] << " :: "
	     << dp[L][R] << " + " << "llabs(" << d.i << "-" << R << ") * " << d.v << endl;

      }
      maxi = max(maxi,dp[L][R-1]);
    }
  }
  cout << maxi << endl;
}

int main() {
  cin >> n;
  a.resize(n);
  rep(i,n) cin >> a[i];
  solve();
  return 0;
}


Measured memory_bytes: 26304
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
const double PI = 3.14159265358979323846;
int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance(vec.begin(), itr);
  if (index != vec.size()) {  // 発見できたとき
    return 1;
  } else {  // 発見できなかったとき
    return 0;
  }
}
int main() {
  int n;
  cin >> n;
  /*vector<int> a;
  int d;
  for (int i = 0; i < n; i++) {
    cin >> d;
    a.push_back(d);
  }*/
  if (400 <= n && n <= 599) cout << 8;
  if (600 <= n && n <= 799) cout << 7;
  if (800 <= n && n <= 999) cout << 6;
  if (1000 <= n && n <= 1199) cout << 5;
  if (1200 <= n && n <= 1399) cout << 4;
  if (1400 <= n && n <= 1599) cout << 3;
  if (1600 <= n && n <= 1799) cout << 2;
  if (1800 <= n && n <= 1999) cout << 1;

  return 0;
}

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

int mod=1e18+7;
D w,h,v,t,X,Y,x,y,r,w1,h1,w2,h2;
D dx[2],dy[2];

D get_h(double a){
  return r*r-a*a;
}

int UP(D h){
  D ny=abs(y-Y);
  int idx=1;
  if(y<=Y)ny=dy[1]-(Y-y),idx=0;
  int l=0,r=1e6;
  while(l<r){
    int mid=(l+r)/2;
    bool flag=0;
    if(!mid)flag=1;
    else if(mid==1)flag=(ny<=h);
    else{
      D NY=ny;
      NY+=dy[0]*((mid-1)/2);
      NY+=dy[1]*((mid-1)/2);
      if((mid-1)%2) NY+=dy[idx];
      if(NY<=h)flag=1;
      else flag=0;
    }
    if(!flag)r=mid;
    else l=mid+1;
  }
  return l-1;
}

int DOWN(D h){
  D ny=-abs(Y-y);
  int idx=0;
  if(y>=Y)ny=-dy[0]+(y-Y),idx=1;
  int l=0,r=1e6;
  while(l<r){
    int mid=(l+r)/2;
    bool flag=0;
    if(!mid)flag=1;
    else if(mid==1)flag=(abs(ny)<=h);
    else{
      D NY=ny;
      NY-=dy[0]*((mid-1)/2);
      NY-=dy[1]*((mid-1)/2);
      if((mid-1)%2) NY-=dy[idx];
      if(abs(NY)<=h)flag=1;
      else flag=0;
    }
    if(!flag)r=mid;
    else l=mid+1;
  }
  return l-1;
}
int Binary_search(D h){
  int s1=UP(h);
  int s2=DOWN(h);
  if(y==Y)s1++;
  return (s1+s2)%mod;
}

int LEFT(){
  D nx=x;
  int idx=0,ans=0;
  if(X<=x)nx=x-dx[0],idx=1;
  while(1){
    D h=get_h(abs(nx-X));
    if(h<0)break;
    h=sqrt(h);
    ans+=Binary_search(h);
    ans%=mod;
    nx-=dx[idx++];
    idx%=2;
  }
  return ans;
}

int RIGHT(){
  D nx=x;
  int idx=1,ans=0;
  if(X>=x)nx=x+dx[1],idx=0;
  while(1){
    D h=get_h(abs(nx-X));
    if(h<0)break;
    h=sqrt(h);
    ans+=Binary_search(h);
    ans%=mod;
    nx+=dx[idx++];
    idx%=2;
  }
  return ans;
}

int EQUAL(){
  if(X!=x)return 0;
  return Binary_search(r);
}

signed main(){
  cin>>w>>h>>v>>t>>X>>Y>>x>>y;
  r=v*t;
  w1=x;w2=w-x;
  h1=y;h2=h-y;
  dx[0]=w1*2;
  dx[1]=w2*2;
  dy[0]=h1*2;
  dy[1]=h2*2;
  int s1=LEFT();
  int s2=RIGHT();
  int s3=EQUAL();
  cout<<(s1+s2+s3)%mod<<endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n, 0);
    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            int d = min(j - i, abs(y - j) + abs(x - i) + 1);
            ++ans[d];
        }
    }
    for (int i = 1; i <= n - 1; ++i) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

ll lcm(ll a, ll b){
    return a*b/__gcd(a, b);
}
int main(){
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;

}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc080/tasks/abc080_c

# 各店の各曜日の各営業時間で営業するかどうか全探索


N = int(input())    # 店の数
F_list = []
for _ in range(N):
    f = list(map(int, input().split()))
    F_list.append(f)

P_list = []
for _ in range(N):
    p = list(map(int, input().split()))
    P_list.append(p)

# # 各曜日時間帯の最低限の店の開店数（おねーちゃんの店を考慮しない）
# min_open_list = []
# for i in range(10):
#     count_open = 0
#     for j in range(N):
#         if F_list[j][i] == 1:
#             count_open += 1
#     min_open_list.append(count_open)

# c個の店が営業中の時の、店iの利益
def benefit(i, c):
    return P_list[i][c]

is_joisino_shop_open_list = [False] * 10
benefit_joisino_list = []

def dfs(j):
    if j >= 10:

        # 1つ以上の時間帯でお店を営業していること
        if True in is_joisino_shop_open_list:
            # joisinoおねえちゃんのお店の利益を計算
            benefit_joisino = 0
            for n in range(N):
                # 各お店ごとのjoisinoお姉ちゃんの利益を計算
                count_n_open = 0                
                shop_n_list = F_list[n]

                for i in range(10):    
                    if shop_n_list[i] == 1 and is_joisino_shop_open_list[i] == True:
                        count_n_open += 1

                benefit_n_joisino = P_list[n][count_n_open]
                benefit_joisino += benefit_n_joisino

            benefit_joisino_list.append(benefit_joisino)

        return

    # joisinoお姉ちゃんのお店をあけるかあけないか全パターン試す
    # j番目の日時にjoisinoお姉ちゃんのお店をあけるとき
    is_joisino_shop_open_list[j] = True
    dfs(j+1)

    # j番目の日時にjoisinoお姉ちゃんのお店をあけないとき
    is_joisino_shop_open_list[j] = False
    dfs(j+1)


dfs(0)
max_benefit_joisino = max(benefit_joisino_list)
print(max_benefit_joisino)


Measured memory_bytes: 3188
using System;
using System.Linq;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                string s = Console.ReadLine().Trim('\n');
                if(s == "0 0") break;
                int[] i = s.Split(' ')
                           .Select(e => int.Parse(e))
                           .ToArray();
                int a = i[0];
                int b = i[1];
                for(int j = 0; j < a; j++)
                {
                    if(j == 0 || j == a - 1)
                    {
                        Console.WriteLine(new string('#', b));
                    }
                    else
                    {
                        string _t = new string('.', b - 2);
                        Console.WriteLine("#" + _t + "#");
                    }
                }      
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9440
p=[0,2,5,3]
q=[0,1,5,4]
r=[1,2,4,3]

dice1=map(int,raw_input().split())
dice2=map(int,raw_input().split())
for i in range(4):
    dice1[p[0]],dice1[p[1]],dice1[p[2]],dice1[p[3]]=dice1[p[1]],dice1[p[2]],dice1[p[3]],dice1[p[0]]
    for j in range(4):
        dice1[q[0]],dice1[q[1]],dice1[q[2]],dice1[q[3]]=dice1[q[1]],dice1[q[2]],dice1[q[3]],dice1[q[0]]
        for k in range(4):
            dice1[r[0]],dice1[r[1]],dice1[r[2]],dice1[r[3]]=dice1[r[1]],dice1[r[2]],dice1[r[3]],dice1[r[0]]
            if dice1==dice2:
                print 'Yes'
                exit()
print 'No'

Measured memory_bytes: 4288
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
//#define         ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         UNIQUE(v)                   v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define         mod                         1000000007
#define         INF                         2e18
#define         EPS                         1e-15
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;
//int dx[]={0,0,1,-1,1,1,-1,-1};
//int dy[]={1,-1,0,0,1,-1,1,-1};

#define lim 200005

ll a[lim],cums[lim];

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n;
    sfl(n);
    for(ll i=1;i<=n;i++){
        sfl(a[i]);
    }
    for(ll i=1;i<n;i++) cums[i+1] += a[i];
    for(ll i=1;i<=n;i++) cums[i] += cums[i-1];
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        cums[i] %= mod;
        a[i] %= mod;
        ans += (cums[i]*a[i])%mod;
        ans%=mod;
    } 
    pfl(ans);
    return 0;
}

Measured memory_bytes: 6948
n=int(input())
r,l,u,d=[[] for _ in range(4)]
cx_max,cx_min,cy_max,cy_min=[None for _ in range(4)]

for i in range(n):
    x,y,s=input().split()
    x,y=int(x),int(y)
    if s=='R':
        r.append(x)
        if cy_max==None or cy_min==None:
            cy_max,cy_min=y,y
        cy_max,cy_min=max(cy_max,y),min(cy_min,y)
    if s=='L':
        l.append(x)
        if cy_max==None or cy_min==None:
            cy_max,cy_min=y,y
        cy_max,cy_min=max(cy_max,y),min(cy_min,y)

    if s=='U':
        u.append(y)
        if cx_max==None or cx_min==None:
            cx_max,cx_min=x,x
        cx_max,cx_min=max(cx_max,x),min(cx_min,x)
    if s=='D':
        d.append(y)
        if cx_max==None or cx_min==None:
            cx_max,cx_min=x,x
        cx_max,cx_min=max(cx_max,x),min(cx_min,x)
        
r.sort()
l.sort()
u.sort()
d.sort()

T=[0,10**9]
for j in r+l:
    if cx_max!=None:
        T.append(abs(j-cx_min))
        T.append(abs(j-cx_max))
for j in u+d:
    if cy_max!=None:
        T.append(abs(j-cy_min))
        T.append(abs(j-cy_max))

try:
    for i in [r[0],r[-1]]:
        for j in [l[0],l[-1]]:
            T.append(abs(i-j)/2)
except:
    0
try:
    for i in [u[0],u[-1]]:
        for j in [d[0],d[-1]]:
            T.append(abs(i-j)/2)
except:
    0

def val(t):
    xmax,xmin,ymax,ymin=[[] for _ in range(4)]
    if u:
        ymax.append(u[-1]+t)
        ymin.append(u[0]+t)
    if d:
        ymax.append(d[-1]-t)
        ymin.append(d[0]-t)
    if cy_max!=None:
        ymax.append(cy_max)
        ymin.append(cy_min)
        
    if r:
        xmax.append(r[-1]+t)
        xmin.append(r[0]+t)
    if l:
        xmax.append(l[-1]-t)
        xmin.append(l[0]-t)
    if cx_max!=None:
        xmax.append(cx_max)
        xmin.append(cx_min)
    
    Y=max(ymax)-min(ymin)
    X=max(xmax)-min(xmin)
    return X*Y

ans=val(0)
for t in T:
    ans=min(ans,val(t))
    
print(ans)


Measured memory_bytes: 72536
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;


int main(){
  int n,a,b,c,d;
  string s;
  cin>>n>>a>>b>>c>>d>>s;
  int ns=s.size();

  int st=min(a,b);
  int goal=max(c,d);
  bool okTen3=false;
  bool okIwa2=true;
  int r_iwa=0;
  int r_ten=0;

  for (int i=st; i<=goal; i++){
    if(s[i-1]=='.'){
      r_ten++;
      r_iwa=0;
      if(r_ten>=3 && i>=b+1 && i<=d+1){
        okTen3=true;
      }
    }else{
      r_iwa++;
      r_ten=0;

      if(r_iwa>=2){
        okIwa2=false;
        cout<<"No"<<endl;
        return 0;
      }

    }
  }
  if(c<d){
    cout<<"Yes"<<endl;
    return 0;
  }

  if(c>d && okTen3){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;


}


Measured memory_bytes: 3764
import itertools

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

ans = 0
for i in itertools.permutations(range(n), n):
    if i[0] == 0:
        flag = True
        for j in range(n-1):
            if not i[j+1] in path[i[j]]:
                flag = False
        if flag:
            ans += 1
print(ans)

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

int n;
long long a, b, h[100005];
int main()
{
	std::cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
		std::cin >> h[i];

	std::sort(h, h + n, std::greater<long long>());

	long long lb = -1, ub = 1000000005;
	while (ub - lb > 1) {
		auto mid = (lb + ub) / 2;

		long long cnt = 0;
		for (int i = 0; i < n; ++i)
			cnt += std::max(0LL, (h[i] - mid * b + a - b - 1) / (a - b));

		if (mid >= cnt)
			ub = mid;
		else
			lb = mid;
	}

	std::cout << ub << std::endl;
	return 0;
}


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

using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	int vals[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", vals + i);
	}
	int m;
	scanf("%d", &m);
	for (int i = 0 ; i < m; i++) {
		int p, x;
		scanf("%d %d", &p, &x);
		long long ans = 0;
		for (int j = 0; j < n; j++) {
			if (j == p - 1){
				ans += x;
				continue;
			} 
			ans += vals[j];
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] arg) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		int n = s.length();
		for(int i = 0; i < (1 << n - 1); i++) {
	        long tmp = (int)s.charAt(0) - '0';
	        String result = "" + s.charAt(0);
	        for(int j = 1; j < n; j++) {
		        if((i & (1 << j-1)) != 0) {
		            tmp += (int)s.charAt(j) - '0';
		            if(j!=0)result += "+" + s.charAt(j);
		            else result += s.charAt(j);
	            } else {
	            	tmp -= (int)s.charAt(j) - '0';
		            if(j!=0)result += "-" + s.charAt(j);
		            else result += s.charAt(j);
	            }
		        //System.out.println("i:" + i + ",j:" + j);
		        //System.out.println(result);
		        //System.out.println("tmp:" + tmp);
	        }
	        if(tmp == 7){
	        	System.out.println(result + "=7");
		        break;
	        }
	    }
	}
}


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

int main(){

    int s;
    cin >> s;
    bool begin = false;
    bool end = false;
    if(s/100>=1 && s/100 <= 12){
        begin = true;
    }
    if(s%100 >= 1 && s%100 <= 12){
        end = true;
    }

    if(begin == false && end == false){
        cout << "NA" << endl;
    }
    if(begin == false && end == true){
        cout << "YYMM" << endl;
    }
    if(begin == true && end == false){
        cout << "MMYY" << endl;
    }
    if(begin == true && end == true){
        cout << "AMBIGUOUS" << endl;    
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b,k;
	cin>>a>>b>>k;
	vector<int> ans;
	FOR(i,1,1e5){
		if(a%i==0 && b%i==0){
			ans.push_back(i);
		}
	}
	sort(begin(ans),end(ans),greater<int>());
	cout<<ans[k-1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char** argv){
  int num;
  int cnt = 0;
  scanf("%d", &num);
  
  if(num%2 == 1) cnt++;
  if((num/10)%2 == 1) cnt++;
  if((num/100)%2 == 1) cnt++;
  printf("%d\n", cnt);
  return 0;
}  

Measured memory_bytes: 128
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void Solve()
{
    int N;
	std::cin >> N;
	std::cout << N * N * N << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
#include <queue>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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 main()
{
	int X,Y;
	cin >> X >> Y;
	int legs =4*X;
	while(X >= 0)
	{
		if(legs == Y)
		{
			cout << "Yes" << endl;
			return 0;
		}

		else
		{
			legs -= 2;
			X--;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    string s;   cin >> s;
    ll k;   cin >> k;
    int n=s.size();
    for(int i=0; i<n; i++){
        int x = 26-(s[i]-'a');
        if(k<x || s[i]=='a') continue;
        s[i] = 'a';
        k -= x;
    }
    s.back() = s.back()+k%26;

    for(char c: s) cout << c;
    cout << endl;

}



Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int x, a, b; cin >> x >> a >> b;
    if(abs(x-a)>abs(x-b)) cout << "B" << ln;
    else cout << "A" << ln;
}


Measured memory_bytes: 3508
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    
    scanf("%d",&N);
    
    if(N % 1000 == 0){
        printf("0\n");
    }
    else{
        printf("%d\n",1000*(N/1000+1) - N);
    }
}


Measured memory_bytes: 1728
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N):
    if B[i] > A[i]:
        ans += A[i]
        if B[i] - A[i] > A[i + 1]:
            ans += A[i + 1]
            A[i + 1] = 0
        else:
            ans += B[i] - A[i]
            A[i + 1] -= B[i] - A[i]
    else:
        ans += B[i]

print(ans)

Measured memory_bytes: 18624
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;

  if (l > r) cout << "Left" << endl;
  else if(l < r) cout << "Right" << endl;
  else cout << "Balanced" << endl;

  return 0;
}


Measured memory_bytes: 888
package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b, k int
	fmt.Scanf("%d", &k)
	fmt.Scanf("%d %d", &a, &b)

	for i := a; i <= b; i++ {
		if i % k == 0 {
			fmt.Print("OK\n")
			os.Exit(0)
		}
	}
	fmt.Print("NG\n")
}

Measured memory_bytes: 1836