akhauriyash/Code-Regression huggingface dataset:
# test
def test():
    param = []
    val = ['issii', '2', '4']
    param.append(val)
    
    # issii issii issii
    #   x x   x x   x x
    val = ['issii', '3', '6']
    param.append(val)
    
    # qq qq qq
    #  x  x  x
    val = ['qq', '81', '81']
    param.append(val)

    val = ['cooooooooonteeeeeeeeeest', '999993333', '8999939997']
    param.append(val)

    # aaa aaa aaa aaa
    # _x_ x_x _x_ x_x
    val = ['aaa', '4', '6']
    param.append(val)
    
    # aaaa aaaa aaaa aaaa
    #  x x  x x  x x  x x
    val = ['aaaa', '4', '8']
    param.append(val)
    
    # aaaaa aaaaa aaaaa aaaaa
    #  x x  x x x  x x  x x x
    val = ['aaaaa', '4', '10']
    param.append(val)
    
    # i i i i
    #   x   x
    val = ['i', '4', '2']
    param.append(val)
    
    # isi isi isi isi
    #     x   x   x
    val = ['isi', '4', '3']
    param.append(val)
    
    # isssi isssi isssi
    #   x   x x   x x
    val = ['isssi', '3', '5']
    param.append(val)
    
    # isiii isiii isiii
    #    x  x  x  x  x
    val = ['isssi', '3', '5']
    param.append(val)
    
    # iissi iissi iissi
    #  x x  x  x  x  x
    val = ['iissi', '3', '6']
    param.append(val)
    
    print(param)

    for i in range(len(param)):
        ret = f(param[i][0], param[i][1])
        if ret == param[i][2]:
            chk = 'o'
        else:
            chk = 'x'
        space = '  '
        print(chk + space + param[i][0] + space + param[i][1] + space + param[i][2] + space + 'test...' + ret)

def f(s, k):
    
    k = int(k)
    
    cnt = 0
    ss = s
    for i in range(len(ss)):
        if i == 0:
            continue

        if ss[i-1] == ss[i]:
            ss = ss[:i] + '\\' + ss[i+1:]
            cnt += 1
        
    cnt = cnt * k
    
    if s.count(s[0]) == len(s):
        if len(s) % 2 == 1:
            cnt = cnt + (k//2)
    else:    
        cntchk1 = 0
        cntchk2 = 0
        if s[0] == s[len(s)-1]:
            for i in range(len(s)):
                if s[len(s)-1] == s[len(s)-1 - i]:
                    cntchk1 += 1
#                 else:
#                     break
                if i < len(s)-1 and s[0] == s[i+1]:
                    cntchk2 += 1
                    
            if cntchk1 % 2 == 0 and cntchk1 % 2 == 0:
                cnt = cnt + (k -1)
                
    return str(cnt)

## Submit
print(f(input(),input()))

Measured memory_bytes: 3192
#include <iostream>
using namespace std;
 
int main() {
	char a[5];
	int th;
	th=0;
	cin>>a[0]>>a[1]>>a[2]>>a[3];
	for(int i=0;i<4;i++){
		if(a[i]=='+'){
			th++;
		}
		if(a[i]=='-'){
			th--;
		}
	}
	cout<<th<<endl;
}


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

const int N = 2005;

int n, m;
bool a[N][N], b[N][N];
int t[N], l[N], r[N];
int ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			char c; cin >> c;
			a[i][j] = (c == '.') ? 0 : 1;
		}
	}
	
	// 1 x k
	ans = max(n, m);

	// k x h (k >= 2, h >= 2)
	for (int i = 1; i <= n - 1; ++i) {
		for (int j = 1; j <= m - 1; ++j) {
			int cnt0 = 0;
			for (int k = i; k <= i + 1; ++k) for (int h = j; h <= j + 1; ++h) {
				if (a[k][h] == 0) ++cnt0;
			}
			if (cnt0 & 1) b[i][j] = 0; else b[i][j] = 1;
		}
	}

	// find the largest rectangle with all '1' cells inside it
	--n; --m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) t[j] = (b[i][j]) ? (t[j] + 1) : 0;
		for (int j = 1; j <= m; ++j) {
			l[j] = j;
			while(l[j] > 1 && t[l[j] - 1] >= t[j]) l[j] = l[l[j] - 1];
		}
		for (int j = m; j >= 1; --j) {
			r[j] = j;
			while(r[j] < m && t[r[j] + 1] > t[j]) r[j] = r[r[j] + 1];
		}

		for (int j = 1; j <= m; ++j) {
			ans = max(ans, (t[j] + 1) * (r[j] - l[j] + 2));
		}
	}

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

Measured memory_bytes: 8192
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	char x;
	cin >> x;
    if (isupper(x))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
  
}

Measured memory_bytes: 3636
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC ZZZZZZ.
        01 C PIC 9(15).
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		COMPUTE A = 3 * A * A.
      		MOVE A to B.
      		DISPLAY B.
		STOP RUN.

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

int main() {
    string s;
    cin >> s;
    int result = s.size();
    for (char c : set<char>(begin(s), end(s))) {
        string copy = s;
        set<char> chars(begin(s), end(s));
        int current = 0;
        while (chars.size() > 1) {
            string t;
            for (int i = 1; i < copy.size(); i++) {
                if (copy[i] == c || copy[i - 1] == c) {
                    t.push_back(c);
                } else {
                    t.push_back(copy[i]);
                }
            }
            swap(t, copy);
            chars = set<char>(begin(copy), end(copy));
            current++;
        }
        result = min(result, current);
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int [n];
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
    }

    Arrays.sort(a);
    System.out.println(Math.abs(a[0] - a[n-1]));
  }
}

Measured memory_bytes: 21716
n =  int(input())
s = str(n)
if len(s)==1:
    print(n)
elif len(s)==2:
    print(9)
elif len(s)==3:
    print(n-100+10)
elif len(s)==4:
    print(909)
elif len(s)==5:
    print(n-10000+910)
elif len(s)==6:
    print(90909)

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

using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    vector<int> rem(2019);
    ll r = 0, pw = 1, ans = 0;
    rem[r] = 1;
    for (int i = s.size() - 1; i >= 0; i--) {
        r = ((s[i] - '0') * pw + r) % 2019;
        pw = pw * 10 % 2019;
        ans += rem[r];
        rem[r]++;
    }
    cout << ans << "\n";
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

int N;

int main(void) {
    set<string> S;

    cin >> N;

    int ans = 0;
    rep(i, N) {
        string s;
        cin >> s;

        if (S.find(s) == S.end()) {
            S.insert(s);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19204
#include <iostream>

using namespace std;

int combination(int n)
{
	int count = 0;
	for (int i = 0; i <= 9; i++)
	{
		for (int j = 0; j <= 9; j++)
		{
			for (int k = 0; k <= 9; k++)
			{
				for (int l = 0; l <= 9; l++)
				{
					if (i + j + k + l == n)
					{
						count++;
					}
				}
			}
		}
	}
	return count;
}

int main()
{
	int n;
	while (cin >> n, !cin.eof())
	{
		cout << combination(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
#include<stdio.h>
int main(void){
	int r,c,i,j,num[102][102]={0};
	scanf("%d %d",&r,&c);
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			scanf("%d",&num[i][j]);
		}
	}
	for(i = 0;i < r;i++){
		for(j = 0;j < c;j++){
			num[i][c] += num[i][j];
		}
	}
	for(i = 0;i < r;i++){
		for(j = 0;j < c+1;j++){
			num[r][j] += num[i][j];
		}
	}
	for(i = 0;i < r+1;i++){
		for(j = 0;j < c+1;j++){
			printf("%d",num[i][j]);
			if(j < c) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

typedef long long ll;
ll n, p, a[100], f[100][2];

int main() {
    cin >> n >> p;
    rep(i, 1, n) cin >> a[i], a[i] %= 2;
    f[0][0] = 1;
    rep(i, 1, n) {
        rep(j, 0, 1) {
            f[i][j] += f[i - 1][j ^ a[i]] + f[i - 1][j];
        }
    }
    printf("%lld\n", f[n][p]);
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, sum = 0, k;
	cin >> n;
	vector<ll> a(n);
	rep (i, n) {
		cin >> a[i];
		sum += a[i];
	}
	if ((2 * sum) % n == 0 && (2 * sum) % (n + 1) == 0) {
		k = (2 * sum) / n;
		k /= n + 1;
		// cout << k << "\n";
		bool ok = true;
		rep (i, n) {
			if ((k - (a[(i + 1) % n] - a[i])) % n != 0 || (k - (a[(i + 1) % n] - a[i])) / n < 0) ok = false;
		}
		cout << (ok ? "YES" : "NO") << "\n";
	} else {
		cout << "NO\n";
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int  N,M;
		long max=0;
		long sum=0;
		N = sc.nextInt();
		M = sc.nextInt();
		if(N>M) {
			System.out.print("0");
			return;
		}
		long[] X=new long[M];
		for(int i=0;i<M;i++) {
		X[i] = sc.nextInt();
		}
		Arrays.sort(X);
		long[] Dif=new long[M-1];
		for(int i=0;i<M-1;i++) {
          Dif[i]=X[i+1]-X[i];
		}
		Arrays.sort(Dif);
		long ans=0;
		for(int i=0;i<M-N;i++) ans=ans+Dif[i];	
		System.out.println(ans);
			
	}
}


Measured memory_bytes: 48240
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c){if(c>='0' and c<='9'){return (int)(c-'0');}return -1;}



int main()
{
  //IOS; /* making cin faster */
  int N,M,X,Y;
  scanf("%d%d%d%d",&N,&M,&X,&Y);

  vector<int> x(N);
  vector<int> y(M);
  
  REP(i,N)
    {
      scanf("%d",&x[i]);
    }

  REP(i,M)
    {
      scanf("%d",&y[i]);
    }
  
  int flag_peace = 0;
  int flag_val;
  
  FOR(Z,X+1,Y+1)
    {
      flag_val = 1;
      
      REP(i,N)
	{
	  if( x[i] >= Z  )
	    {
	      flag_val = 0;
	      break;
	      
	    }
	}

      REP(i,M)
	{
	  if( y[i] < Z )
	    {
	      flag_val = 0;
	      break;
	      
	    }
	}

      if(flag_val)
	{
	  flag_peace = 1;
	  break;
	  
	}

    }

  if(flag_peace)
    {
      printf("No War\n");
      
    }
  else
    {
      printf("War\n");
    }

  

}


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

// QQ(0000)
int main()
{
	for (int i = 1; i < 10; ++i) {
		for (int j = 1; j < 10; ++j) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}

	return 0;
}

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

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

    if((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=b)) {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
def main():
    S_ = S()
    S_que = deque(S_)
    Q = I()
    cnt = 0
    for i in range(Q):
        q = LS()
        if int(q[0]) == 1:
            cnt += 1
        elif int(q[0]) == 2:
            if int(q[1]) == 1:
                if cnt % 2 == 0:
                    S_que.appendleft(q[2])
                else:
                    S_que.append(q[2])
            else:
                if cnt % 2 == 1:
                    S_que.appendleft(q[2])
                else:
                    S_que.append(q[2])
    if cnt % 2 == 1:
        S_que.reverse()
    print(''.join(map(str, S_que)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 121948
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll a,b; cin >> a >> b;
  if(a>=13) cout << b;
  else if(a>=6) cout << b/2;
  else cout << 0; 
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (s.at(i) == '+') {
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def cumsum(l):
    c = [0] * len(l)
    for i in range(len(l)):
        c[i] = c[i-1] + l[i]
    return c

N, K = map(int, input().split())
a = [int(i) for i in input().split()]
c = [0] + cumsum(a)

s = [bin(c[j+i] - c[j]).replace('0b','').zfill(40) for i in range(1, N+1) for j in range(N-i+1)]

ans = [0] * 40

for i in range(40):
    t = [j for j in s if j[i] == '1']
    if len(t) >= K:
        ans[i] = 1
        s = t

print(sum([ans[i] * 2**(39-i) for i in range(40)]))

Measured memory_bytes: 55724
#include <iostream>
using namespace std;
typedef long long  ll;

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

int main()
{
	ll K, S; cin >> K >> S;

	ll cnt = 0;
	repe(i, 0, K) {
		repe(j, 0, K) {
			ll Z = S - i - j;
			if (Z >= 0 && Z <= K) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

const int mod=1e9+7;

int modPow(int x,int p){
    if(p==1) return x%mod;
    if(p%2==1) return x*modPow(x,p-1)%mod;
    if(p%2==0) return modPow(x,p/2)*modPow(x,p/2)%mod;
}

signed main(){
    int N,K;
    cin>>N>>K;
    int A=0;
    vector<int>ans(K,0);
    for(int i=K;i>=1;i--){
        int a=K/i;
        if(a==1) ans[i-1]++;
        else{
            ans[i-1]+=modPow(a,N);
            for(int j=2;j<=a;j++){
                ans[i-1]-=ans[j*i-1];
              	while(ans[i-1]<0) ans[i-1]+=mod;
            }
        }
      	A+=ans[i-1]*i%mod;
    }
  	A=A%mod;
  	if(A<0) A+=mod;
    cout<<A<<endl;
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main(){
	int n,m;
	cin >> n >> m;
	double sum=0;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sum=sum/4.0/m;
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]>=sum) ans++;
	}
	if(ans>=m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
} 

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(101, 0);
  rep(i, N) {
    int buf;
    cin >> buf;
    p[buf]++;
  }

  rep(i, 1000) {
    if (X - i >= 0 && p[X - i] == 0) {
      cout << X - i << endl;
      return 0;
    }

    if (X - i < 0) {
      cout << X - i << endl;
      return 0;
    }

    if (X + i <= 100 && p[X + i] == 0) {
      cout << X + i << endl;
      return 0;
    }

    if (X + i > 100) {
      cout << X + i << endl;
      return 0;
    }
  }
  if(N == 0){
    cout << X << endl;
  }
}

Measured memory_bytes: 3640
n=int(input())
h=list(map(int,input().split()))
dp=[0]*(n)
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    dp[i]=min(abs(h[i-1]-h[i])+dp[i-1],abs(h[i-2]-h[i])+dp[i-2])
print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define INF 999999999
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long unsigned int 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; }

int dy[] = { 0, 0, 1, -1 };
int dx[] = { 1, -1, 0, 0 };


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

	int ans = (a + b) % 2;

	if (ans == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


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

using namespace std;

int main(){
	int d, g, ans = 1e8;
	cin >> d >> g;
	vector<int> p(d), c(d);
	for(int i = 0; i < d; i++) cin >> p[i] >> c[i];

	for (int i = 0; i < (1 << d); i++) {
    // cout << "i: " << i << endl << endl;
		int t = 0, q = -1, x = 0;
		for (int j = 0; j < d; j++) {
			if (i & (1 << j)) {
				t += (j + 1) * 100 * p[j] + c[j];
				x += p[j];
			} else {
				q = j;
			}
      // cout << "j: " << j << endl;
      // cout << "t: " << t << ", x: " << x << ", q: " << q << endl << endl;
		}
		if (t < g) {
			int po = (q + 1) * 100;
			if (g - t <= po * (p[q] - 1)) {
				x += (g - t + po - 1) / po;
			} else {
        // cout << "continue" << endl << endl;
				continue;
			}
		}
    // cout << "ans: " << ans << ", x: " << x << endl;;
    // cout << endl;
		ans = min(ans, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
            cout<<"F"<<endl;
            }else if(m+f>=80){
                cout<<"A"<<endl;
            }else if(m+f<80 && m+f>=65){
                cout<<"B"<<endl;
            }else if((m+f<65 && m+f>=50)||(m+f<50 && m+f>=30 && r>=50)){
                cout<<"C"<<endl;
            }else if(m+f<50 && m+f>=30){
                cout<<"D"<<endl;
            }else{
                cout<<"F"<<endl;
            }
    }
    return 0;
}



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {
    int n,m;cin>>n>>m;
    vector<int> vec(n,0);
    rep(i,m) {
        int a,b;cin>>a>>b;
        vec.at(a-1)++;vec.at(b-1)++;
    }
    rep(i,n) cout<<vec.at(i)<<endl;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;

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

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()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
    a[i];
  }
  vi b(n);
  rep(i,n)cin>>b[i];
  vi c(n-1);
  rep(i,n-1)cin>>c[i];
  
  vi v;
  rep(i,n-1){
    if(a[i+1]-a[i]==1) v.push_back(c[a[i]-1]);
  }
  
  int ans=0;
  rep(i,n){
    ans+=b[i];
  }
  for(int e: v){
    ans+=e;
  }
  
  cout(ans);
}

Measured memory_bytes: 256
using System;
class Info{
        public int p;
        public string anser = "Yes"; 
     }
class Program
{
  	
  
	static void Main(string[] args)
	{
      	
		string S = Console.ReadLine();
      	string[] arr =  S.Split(' ');
      int N = int.Parse(arr[0]);
      	int K = int.Parse(arr[1]);
      int Q = int.Parse(arr[2]);
      
      Info[] Point = new Info[N];
      
      for (int i = 0; i< Point.Length;i++){
        Point[i] = new Info();
      	Point[i].p = K - Q;
      }
      int ANSER;
      for(int i = 0;i< Q;i++){
      	ANSER = int.Parse(Console.ReadLine());
        Point[ANSER - 1].p++;
      }
      
      	for(int i =0 ;i<Point.Length;i++){
          	if ( Point[i].p <=0){
            	Point[i].anser = "No";
            }
      	Console.WriteLine(Point[i].anser);
        }

	}
}



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

string str;

int cal1(){

  int ans=0;
  
  for(int i=1 ; i <= str.size() ; i+=2){
    if(str[i]=='+' || i == str.size()){
      ans+=atoi(&str[i-1]);
    }else if(str[i]=='*'){
      int temp=atoi(&str[i-1]);
      while(str[i] == '*'){
	temp*=atoi(&str[i+1]);
	i+=2;
      }
      ans+=temp;
    }
  }
  
  return ans;
}
int cal2(){
  
  int ans=atoi(&str[0]);
  
  for(int i=1 ; i < str.size() ; i+=2){
    int x=atoi(&str[i+1]);
    if(str[i]=='+'){
      ans+=x;
    }else if(str[i]=='*'){
      ans*=x;
    }
  }
  
  return ans;
  
}
int main(){
  
  int x;
  
  cin >>str;
  cin >>x;
  
  int ans1=cal1();
  int ans2=cal2();
  
  if(x==ans1 && x==ans2){
    cout <<"U"<<endl;
  }else if(x==ans1){
    cout <<"M"<<endl;
  }else if(x==ans2){
    cout <<"L"<<endl;
  }else{
    cout <<"I"<<endl;
  }
  
  return 0;
}

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

using namespace std;

typedef long long ll;

long long test_cases;
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    /* cin >> test_cases; */
    test_cases = 1;

    while (test_cases > 0)
    {
        int x[6];

        for (int i = 1; i <= 5; i++)
        {
            cin >> x[i];
            if (x[i] == 0)
            {
                cout << i << endl;
                return 0;
            }
        }
        
        test_cases--;
    }

    
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> p;

int atooi(char s){
  string n="0123456789";
  for(int i=0;i<=10;i++){
    if(s==n[i]){
      return i;
    }
  }
  return 0;
}

int timetime(string s){
  int hh,mm,ss,st,ft,h1,h2,m1,m2,s1,s2;
  h1= atooi(s[0]);
  h2= atooi(s[1]);
  m1= atooi(s[3]);
  m2= atooi(s[4]);
  s1= atooi(s[6]);
  s2= atooi(s[7]);
  hh=h1*10+h2;
  mm=m1*10+m2;
  ss=s1*10+s2;
  st=hh*3600+mm*60+ss;
  return st;
}

int main(){
  while(true){
  int n,st,ft;
  cin>>n;
  if(n==0) return 0;
  int  tm[100000]={};
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    st =timetime(s);
    tm[st]+=1;
   cin>>s;
   ft=timetime(s);
    tm[ft]-=1;
  }

  int val=0,ans=0;
  for(int i=0;i<=89899;i++){
    tm[i]+=val;
    val=tm[i];
    ans=max(ans,tm[i]);
  }
  cout<<ans<<endl;
}
}

Measured memory_bytes: 3396
L, R = map(int, input().split())
if R-L+1 >= 2019:
    print(0)
else:
    ans = 2019
    for i in range(L, R):
        for j in range(i+1, R+1):
            tmp = (i*j) % 2019
            if tmp < ans:
                ans = tmp

    print(ans)

Measured memory_bytes: 42860
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int n;
    cin >> n;

    vector<int> l(n*2);
    rep(i, n*2) cin >> l[i];
    sort(l.begin(), l.end());

    int ans = 0;
    for(int i = 0; i < n * 2; i += 2){
        ans += l[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int d, n;
  cin >> d >> n;
  int ans = 0;
  if(d == 0){
    ans = n;
    if(n == 100){
      ans = 101;
    }
  }else{
    ans = pow(100,d)*n;
    if(n == 100){
      ans += pow(100,d);
     }
  }
  cout << ans << endl;
}


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

int main () {
  string s;
  cin >> s;
  if ((s.at(0) == s.at(1)) && (s.at(2) == s.at(3)) && (s.at(0) != s.at(2))) cout << "Yes" << endl;
  else if ((s.at(0) == s.at(2)) && (s.at(1) == s.at(3)) && (s.at(0) != s.at(1))) cout << "Yes" << endl;
  else if ((s.at(0) == s.at(3)) && (s.at(1) == s.at(2)) && (s.at(0) != s.at(1))) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>

#include <cassert>
#include <cmath>
#include <ctime>

#pragma comment(linker, "/STACK:200000000")

using namespace std;

mt19937 mt (736);

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    int n;

    cin >> n;

    vector<int> arr (n);

    for (auto &it : arr)
        cin >> it;

    auto tmp = arr;

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

    int a = tmp[tmp.size () / 2 - 1];
    int b = tmp[tmp.size () / 2];

    for (auto it : arr)
        if (it <= a)
            cout << b << endl;
        else
            cout << a << endl;
}

int main ()
{
    ios_base::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);

#ifdef LOCAL
    solve ();

    cout << "clock: " << clock () << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
typedef pair<ll, ll> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a == b) {
        cout << a + b << endl;
    } else {
        cout << 2 * max(a, b) - 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100003;
const ll P=1e18;
ll x;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>x;
	if(x<1200)pri("ABC");
	else pri("ARC");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, beg, end, step) for (int i = beg; i < end; i += step)


int main()
{
    int s,w;
    cin >> s >> w;

    if(w>=s)
        cout << "unsafe";
    else
        cout << "safe";
    

    return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string s;
map<string,ll> ans;
rep(i,n){
    cin>>s;
    ans[s]++;
}
vector<string> k{"AC","WA","TLE","RE"};
for(auto s:k){
    cout<<s<<" x "<<ans[s]<<endl;
}

return 0;
}

Measured memory_bytes: 3660
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll M;
  cin >> M;

  ll res = 0;

  // 操作を行うと、
  // 1. 繰り上がりがある時： 桁数はそのままに、 digitSum が 9 減る
  // 2. 繰り上がりが無い時： 桁数が 1 減り、 digitSum はそのまま
  // よって、ある数に行える操作の回数は （桁数 - 1） + (digitSum-1) / 9

  ll cur = 0;
  rep(i, M) {
    ll d, c;
    cin >> d >> c;

    res += c;

    cur += c * d;

    if (cur >= 10) {
      ll ct = (cur - 1) / 9;
      res += ct;
      cur = cur - 9 * ct;
    }
  }

  res--;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 2001
 
char resultTable[SIZE];
int n,q,elems[20];
 
void calc(int sum,int index){
    if(index == n){
        if(sum >= 1 && sum <= 2000){
            resultTable[sum] = 'y';
        }
    }else{
        calc(sum+elems[index],index+1);
        calc(sum,index+1);
    }
}
 
int main(){
 
    for(int i = 0;i < SIZE; i++) resultTable[i] = 'n';
 
    scanf("%d",&n);
    for(int i = 0; i < n; i++) scanf("%d",&elems[i]);
    calc(0,0);
 
    scanf("%d",&q);
 
    int tmp;
    for(int i = 0; i < q; i++){
        scanf("%d",&tmp);
        if(resultTable[tmp] == 'y'){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<ll,ll> mp;
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }

  int q;
  cin >> q;
  while(q--){
    ll b,c;
    cin >> b >> c;
    sum = sum + mp[b]*(c-b);
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << ln;
  }

  return 0;
}

Measured memory_bytes: 9460
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<double, double> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

const ll mod = 1000000007;
const ll INF = 100000000000010000;

ll bit[1000010];
//ll kai[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

/*ll sum(ll i)
{
	i += 1;
	ll t = 0;
	while (i > 0)
	{
		(t += bit[i]) %= mod;
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	i += 1;
	while (i <= 1000005)
	{
		(bit[i] += x) %= mod;
		i += i & -i;
	}
}*/

void test() {
	cout << "888888888888888888888888" << endl;
}

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

ll pow_mod(ll x, ll y) {
	if (y == 0) return 1;
	if (y % 2 == 1) {
		return x * pow_mod(x, y - 1) % mod;
	}
	else {
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

/*ll com(ll x, ll y) {
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
	//毎回オーダーlog(n)かかる
}

void kaijo() {
	kai[0] = 1;
	for (ll i = 1; i <= 1000005; i++) {
		kai[i] = kai[i - 1] * i % mod;
	}
}*/

ll N, K;
ll a[101];
bool dp[100010][2], flg[100010][2];

bool saiki(ll sum, ll turn) {
	if (sum < a[0]) return turn == 1;
	if (flg[sum][turn]) return dp[sum][turn];
	flg[sum][turn] = true;
	if (turn == 0) {
		rep(i, N) {
			if (sum >= a[i] && saiki(sum - a[i], 1)) return dp[sum][turn] = true;
		}
		return dp[sum][turn] = false;
	}
	else {
		rep(i, N) {
			if (sum >= a[i] && !saiki(sum - a[i], 0)) {
				return dp[sum][turn] = false;
			}
		}
		return dp[sum][turn] = true;
	}
}

void solve() {
	cin >> N >> K;
	rep(i, N) cin >> a[i];
	if (saiki(K, 0)) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 5376
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int T=in.nextInt();
		int count=0;
		double a=Math.pow(in.nextDouble(),2);
		for(int i=0;i<T;i++) {
			double a1=in.nextDouble(),a2=in.nextDouble();
			if(Math.pow(a1,2)+Math.pow(a2,2)<=a) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

int main() {
	int N, a;
	int min=10000, max = -1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a > max)
			max = a;
		if (a < min)
			min = a;
	}
	cout << max - min << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

int main()
{
  int h,a,answer;
  cin >> h >> a;

  answer = (h+a-1)/a;

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
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 << "Right" <<endl;}
  else if( R < L ){cout << "Left" <<endl;}
  else{cout << "Balanced" <<endl;}
}

Measured memory_bytes: 256
n, lights = int(input()), input().split()
con, seq = 1, []
prev = lights.pop()
while lights:
    light = lights.pop()
    if light == prev:
        seq.append(con)
        con = 1
    else:
        con += 1
    prev = light
seq.append(con)
if len(seq) <= 3:
    print(sum(seq))
else:
    print(max(sum(seq[i:i + 3]) for i in range(len(seq) - 2)))

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

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

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

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

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


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll r; cin>>r;
  cout<<3*r*r<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int count(int n){
	int res=0;
	int i,j,k,tem,tem1;
	for(i=0; i<10; i++){
		if(n-i<0)return res;
		tem=n-i;
		for(j=0; j<10; j++){
			if(tem-j<0)break;
			tem1=tem-j;
			for(k=0; k<10; k++){
				if(tem1-k<0 || tem1-k>9)continue;
				res++;
			}
		}
	}

	return res;
}

int main(void) {
	int n;
	while(scanf("%d",&n)!=EOF)printf("%d\n",count(n));

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    vector<ll> v(n);
    vector<ll> sum(n + 1, 0);

    rep(i, n)
    {
        cin >> v[i];

        v[i]--;
    }

    rep(i, n)
    {
        sum[i + 1] = sum[i] + v[i];
        cerr << sum[i + 1] << " ";
    }
    cerr << endl;
    ll ans = 0;
    rep(i, 1, n + 1)
    {
        if (i > k)
        {
            //cerr << "del " << i - k << endl;
            mp[sum[i - k] % k]--;
        }
        ll cur = sum[i] % k;
        if (cur == 0)
        {
            //cerr << i << " " << cur << " " << mp[0] << endl;
            ans += mp[0];
            if (i < k)
                ans++;
        }
        else
        {
            //cerr << i << " " << cur << " " << mp[cur] << endl;
            ans += mp[cur];
        }
        mp[cur]++;
    }
    cout << ans << endl;

    return 0;
}


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

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

  long long sum = 0;

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

  int neg_n = 0;
  for (int i = 0; i < N; i++)
  {
    if (A[i] < 0)
      neg_n++;
  }

  int check = 0;

  for (int i = 0; i < N; i++)
  {
    if (A[i] == 0)
    {
      check = 1;
    }
  }

  if (check == 1)
  {
    for (int i = 0; i < N; i++)
    {
      sum += abs(A[i]);
    }
  }
  else if (neg_n % 2 == 0)
  {
    for (int i = 0; i < N; i++)
    {
      sum += abs(A[i]);
    }
  }
  else
  {
    vector<int> B(N);
    for (int i = 0; i < N; i++)
    {
      B[i] = abs(A[i]);
    }
    sort(B.begin(), B.end());
    for (int i = 1; i < N; i++)
    {
      sum += abs(B[i]);
    }
    sum -= abs(B[0]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
    int a, b, tmp;
    scanf("%d %d", &a, &b);
    if(b>0)
        tmp=a+b;
    else
        tmp=a-b;
    if(tmp<(a*b))
        tmp=a*b;
    printf("%d", tmp);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000005];
int k,first=1,last=9;
int main()
{
	cin>>k;
	for(int i=1;i<=9;i++)a[i]=i;
	if(k<=9)
	{
		cout<<a[k];return 0;
	}
	while(1)
	{
		ll t=a[first];
		for(int i=-1;i<=1;i++)
		{
			if(t%10==0&&i==-1)continue;
			if(t%10==9&&i==1)continue;
			ll nt=t*10+t%10+i;
			a[++last]=nt;
			if(last>=k)
			{
				cout<<a[k];
				return 0;
			}		
		}
		first++;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 100000;
bool prime[100001];
bool similar[100001];
int cnt[100001];

void sieve(){
	for(int i=0;i<=Max;i++) prime[i] = true;

	prime[0] = false;
	prime[1] = false;
	for(int i=2;i<=Max;i++){
		if(prime[i]){
			for(int j=2*i;j<=Max;j+=i) prime[j] = false;
		}
		
	}
}
void check(){
	for(int i=1;i<=Max;i+=2){
		if(prime[i] && prime[(i+1)/2]) similar[i] = true;
		else similar[i] = false;
	}
}
void counting(){
	cnt[0] = 0;
	for(int i=1;i<=Max;i++){
		if(similar[i]) cnt[i] = cnt[i-1] + 1;
		else cnt[i] = cnt[i-1];
	}
}
int main(){
	sieve();
	check();
	counting();

  	int Q, l, r;
  	cin >> Q;
  	int ans[Q];
  	for(int i=0;i<Q;i++){
  		cin >> l >> r;
  		ans[i] = cnt[r]- cnt[l-1];
  	}

  	for(int i=0;i<Q;i++){
  		cout << ans[i] <<endl;
  	}

    
  	return 0;
}













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

void maxheapify(int *, int);
void buildmaxheap(int *);

int n;

int main(){

  int i;
  int *a;
  
  scanf("%d", &n);
  
  a = (int *)malloc(sizeof(int) * (n + 1));
  
  for(i = 1; i <= n; i++){
    scanf("%d", &a[i]);
  }
 
  buildmaxheap(a);

  for(i = 1; i <= n; i++){
    printf(" %d", a[i]);
  }
  printf("\n");
 
  return 0;
}

void maxheapify(int *a, int i){
  int l = i * 2;
  int r = i * 2 + 1;
  int largest;
  int tmp;

  if(l <= n && a[l] > a[i]) largest = l;
  else largest = i;

  if(r <= n && a[r] > a[largest]) largest = r;

  if(largest != i){
    tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxheapify(a, largest);
  }
}

void buildmaxheap(int *a){

  int i;

  for(i = n / 2; i != 0; i--){
    maxheapify(a, i);
  }

}

Measured memory_bytes: 2984
S=input()
s=""
for i in range(len(S)):
    s=S[i]+s
N=len(S)
L=""
for i in range((N-1)//2):
    L=L+S[i]
M=""
for i in range((N+3)//2-1,N):
    M=M+S[i]
l=""
m=""
for i in range(len(L)):
    l=L[i]+l
for i in range(len(M)):
    m=M[i]+m
flag=False
if S==s:
    if L==l:
        if M==m:
            flag=True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38464
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));


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

    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char> (w+2,'0'));

    for(int i = 1;i < h+1;++i){
        for(int j = 1;j < w+1;++j){
            cin >> s[i][j];
        }
    }
    bool ok = true;
    rep(i,h+1){
        rep(j,w+1){
            if(s[i][j] == '#'){
                if(s[i-1][j] != '#' && s[i][j-1] != '#' && s[i][j+1] != '#' && s[i+1][j] != '#'){
                    ok = false;
                }
            }
        }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 256