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

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

using namespace std;

int main() {
  int ticket;
  cin >> ticket;
  int A, B, C, D;
  A = ticket / 1000;
  B = (ticket % 1000) / 100;
  C = (ticket % 100) / 10;
  D = ticket % 10;
  for (int flags = (1 << 3) - 1; flags >= 0; --flags) {
    vector<int> sign(3, 1);
    for (int i = 0; i < 3; ++i) sign[i] = flags & (1 << i) ? 1 : -1;
    if(A + sign[0] * B + sign[1] * C + sign[2] * D == 7) {
      vector<char> signChar(3, '+');
      for (int i = 0; i < 3; ++i) signChar[i] = flags & (1 << i) ? '+' : '-';
      cout << A << signChar[0] << B << signChar[1] << C << signChar[2] << D << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		int h = scan.nextInt();
		int w = scan.nextInt();
		System.out.println((H -h)*(W - w));

		scan.close();
	}
}

Measured memory_bytes: 21588
import numpy as np
n = int(input())
a = tuple(map(int, input().split()))
b = np.full(n, np.inf)
f = 0
s = sum(a)
for i in range(n-1):
    f += a[i]
    s -= a[i]
    x = abs(f - s)
    b[i] = x
print(int(min(b)))


Measured memory_bytes: 34396
N,K = map(int,input().split())
num = 0
point = 0
cnt = 0
for i in range(1,N+1):
    if 1 <= i and i <= (K-1):
        point = i
        cnt = 0
        while 1:
            if point >= K:
                break
            else:
                point *= 2
                cnt += 1
        num += float((1/N) * ((1/2) ** cnt))
    elif i >= K:
        num += float((1/N))

print(num) 

Measured memory_bytes: 3060
#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--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

// bool gousei(llong *x,llong *y){
//     if(*x<*y){
//         *y=x+y
//     }
// }

int main() {
	llong N;
    cin >> N;
    string S;
    cin >> S;

    llong ans=0;
    LV char_v(26,0);
    REP(i,N){
        char_v[S[i]-'a']++;
    }
    llong t = 1;
    REP(i,26){
        t =t*(1+char_v[i]) % MOD;
    }
    ans=(ans+t)%MOD;



    cout << ans-1 << endl;





}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
int num;

struct SegmentTree
{
    std::vector<int> segment;
    const int infval = std::numeric_limits<int>::max();

    SegmentTree(const int n)
    {
        Init(n);
    }

    void Init(const int n)
    {
        // サイズを 2 の累乗にして実装を簡単にする
        num = 1;
        while(num < n) num *= 2;
        segment.assign(2 * num - 1, infval);
    }

    void update(int index, int value)
    {
        // 葉のノード番号に変換
        index += num - 1;
        segment[index] = value;
        // 登りながら更新
        while(index > 0)
        {
            index = (index - 1) / 2;
            segment[index] = (std::min)(segment[2 * index + 1], segment[2 * index + 2]);
        }
    }

    // [first, last) の区間における最小値を返す
    // node , left , right は再帰呼び出しで必要となる引数
    // node : 節の番号, left, right : 節が対応している区間[left, right)
    int find(int first, int last, int node = 0, int left = 0, int right = num) const
    {
        // [first, last) が[left, right) と交差していない場合、inf を返す
        if (right <= first || last <= left) return infval;
        
        // [first, last) が [left, right) を完全に含んでいる場合、節に格納されている値を返す
        if (first <= left && right <= last) return segment[node];
        else
        {
            // 部分的に含んでいる場合は2つの子の最小値
            int vl = find(first, last, 2 * node + 1, left, (left + right) / 2);
            int vr = find(first, last, 2 * node + 2, (left + right) / 2, right);
            return (std::min)(vl, vr);
        }
    }
};

int main()
{
    int n, q;
    std::cin >> n >> q;
    SegmentTree segtree(n);

    for (int i = 1; i <= q; ++i)
    {
        int com, x, y;
        std::cin >> com >> x >> y;
        if (com == 0)
        {
            segtree.update(x, y);
        }
        else
        {
            int minval = segtree.find(x, y + 1);
            std::cout << minval << std::endl;
        }
    }
    return 0;
}


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

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

	std::sort(diff, diff + n);
	int bpos = n - 1;
	long long sum = 0;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		while (diff[i] + sum < 0) {
			if (diff[bpos] < 0 || i == bpos) {
				ans = -1;
				break;
			}
			sum += diff[bpos--];
			++ans;
		}
		if (ans == -1)
			break;
		if (diff[i] < 0) {
			sum += diff[i];
			++ans;
		}
		else
			break;
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 2560
//Author: AnandRaj anand873
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 2e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vi A(n),B(n);
	for(int i=0;i<n;i++)
	{
		cin>>A[i]>>B[i];
	}
	sort(all(A));
	sort(all(B));

	if(n%2)
	{
		cout<<B[n/2]-A[n/2]+1<<endl;
	}
	else
	{
		int MA = A[n/2-1]+A[n/2];
		int MB = B[n/2-1]+B[n/2];

		cout<<MB-MA+1<<endl;
	}

}		

Measured memory_bytes: 8796
s = input()
ans = 0
cnt = 1
l = []
for i in range(1, len(s)):
  if s[i] != s[i-1]:
    l.append(cnt)
    cnt = 1
  else:
    cnt += 1
l.append(cnt)
if s[0] == ">":
  ans += l[0]*(l[0]+1)//2
  l.pop(0)
for i in range(len(l)//2):
  if l[2*i] > l[2*i+1]:
    ans += l[2*i]*(l[2*i]+1)//2
    ans += l[2*i+1]*(l[2*i+1]-1)//2
  else:
    ans += l[2*i]*(l[2*i]-1)//2
    ans += l[2*i+1]*(l[2*i+1]+1)//2
if len(l)%2 == 1:
  ans += l[-1]*(l[-1]+1)//2
print(ans)

Measured memory_bytes: 6300
# coding: utf-8
n = int(input())
lis = list(map(int, input().split()))
ans = 0
temp = 0
for i in range(len(lis)-1):
    if(lis[i]>=lis[i+1]):
        temp+=1
        if(temp>ans):
            ans = temp
    else:
        if(temp>ans):
            ans = temp
        temp = 0
print(ans)

Measured memory_bytes: 63984
N=int(input())
T=list(map(int,input().split()))
M=int(input())
t=list(T)
for i in range(M):
  P,X=map(int,input().split())
  t[P-1]=X
  print(sum(t))
  t[P-1]=T[P-1]  
  
  
  

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  std::cout << 0 << endl <<  std::flush;
  string s;std::cin >> s;
  if(s=="Vacant") return 0;
  ll l = 0, r = n;
  while(r-l>1){
    ll mid = (l+r)/2;
    std::cout << mid << endl << std::flush;
    string t;std::cin >> t;
    if(t=="Vacant") return 0;
    if((mid%2!=0)^(t==s))l = mid;
    else r = mid;
  }
  std::cout << r << endl << std::flush ;
  return 0;
}


Measured memory_bytes: 852
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cur = 0;
    int ans = 0;
    while (cur < n) {
        int cnt = 0;
        for (int i = cur; i < n; i++) {
            if (a[i] == a[cur]) {
                cnt++;
            } else {
                cur = i;
                break;
            }
            if (i == n - 1) {
                cur = n - 1;
            }
        }
        ans += cnt / 2;
        if (cur == n - 1)
            break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


int main(void){
	ll n, a, b;
	cin >> n >> a >> b;

	ll ans = 0;

	for(int i = 1; i <= n; i++){
		ll tmp = 0;
		string s = to_string(i);
		for(int j = 0; j < s.size(); j++){
			tmp += s[j] - '0';
		}


		if(tmp >= a && tmp <= b){
			ans += i;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	int s = a * n;
	cout << min(s, b) << endl;
	return 0;
}



Measured memory_bytes: 256
//https://atcoder.jp/contests/abc141/tasks/abc141_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    string S;
    cin >> S;
    vector<string> W{"Sunny", "Cloudy", "Rainy"};
    cout << W[S == W[0] ? 1 : S == W[1] ? 2 : 0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < (n); i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (n); i++)
#define REPEACH(itr, k) for (auto &&itr : k)
#define MOD 1000000007

using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;


int main()
{
    int n;
    cin >> n;
    vector<pair<double,double>> v(n);
    REP(i,n){
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(),v.end());
    double sum;
    int count=0;
    do{
        count++;
        REP(i,n-1){
            sum += sqrt(pow(v[i + 1].first - v[i].first, 2.0) + pow(v[i + 1].second - v[i].second, 2.0));
        }
    }while(next_permutation(v.begin(),v.end()));
    cout << fixed << setprecision(10);
    cout << sum/count << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(map(int, input().split()))
c = 0
a = 'a'
def merge(A, left, mid, right):
    global c
    L = A[left:mid]
    R = A[mid:right]
    L.append(10 ** 9)
    R.append(10 ** 9)
    i = 0
    j = 0
    for k in range(left, right):
        c += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergesort(A, left, right):
    if left+1 < right:
        mid = (left+right)//2
        mergesort(A, left, mid)
        mergesort(A, mid, right)
        merge(A, left, mid, right)

mergesort(s, 0, n)

for i in range(n-1):
    print(s[i], end=' ')
print(s[n-1])
print(c)


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	int n;
	cin >> n;
	int a[n];
	int cnt=0;
	REP(i,n){
		cin >> a[i];
		while(a[i]%2 == 0){
			a[i] /= 2;
			cnt ++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
        int L = Integer.parseInt(sc.next());
        int tasteOfPie = 0;
        int minApple = 300;
        int minIndex = 0;
        for (int i = 1; i < N+1; ++i){
            int taste =  L + i - 1;
            tasteOfPie += taste;
            if (minApple > Math.abs(taste)){
                minApple = Math.abs(taste);
                minIndex = i;
            }
        }
        System.out.println(tasteOfPie - (L+minIndex-1));
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main(){
	int n;
	ll a,b,c=0;
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i=3;i<=n;i++){
		ll x;
		scanf("%lld",&x);
		c^=x;
	} 	
	ll s=a+b,d=(s-c),ans=d/2;
	if((d&1)||d<0||ans>a||(ans&c)) return puts("-1"),0;
	for(ll i=(1LL<<61);i;i>>=1){
		if((i&c)&&ans+i<=a) ans+=i; 
	}
	printf(ans?"%lld\n":"-1\n",a-ans);
	return 0;
}

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

bool linear_search(int A[], int n, int m) {
    int i = 0;
    A[n] = m;
    while(A[i] != m) {
        i++;
    }
    return i != n;
}

int main() {
    int n;
    cin >> n;
    int S[n];
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }
    int q;
    int count = 0;
    cin >> q;
    int t;
    for (int j = 0; j < q; ++j) {
        cin >> t;
//        for (int i = 0; i < n; ++i) {
//           if(S[i] == t) {
//               count++;
//           }
//        }
        if(linear_search(S, n, t)){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3104
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque

n,k = [int(x) for x in stdin.readline().rstrip().split()]
a = [0] + [int(x) for x in stdin.readline().rstrip().split()]

m = 0
b = [1]
visited = [-1 for i in range(n+1)]

c = 1
visited[1] = 1
for i in range(n):
    c = a[c]
    if visited[c] != 1:
        b.append(c)
        visited[c] = 1
        if i == k-1:
            print(c)
            sys.exit()
    else:
        break

idx = b.index(c)
bn = len(b[idx:])
sn = len(b[:idx])

# print(b,idx,sn,bn)
kk = (k-sn) % bn
print(b[idx+kk])

Measured memory_bytes: 32024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


vector<ll> a;

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        ll b;
        cin >> b;
        a.push_back(b);
    }
    sort(a.begin(), a.end(),greater<ll>());

    ll ans = 0;

    vector<ll> tmp;
    tmp.push_back(a[0]);
    
    rep(i, n-1){
        tmp.push_back(a[i+1]);
        tmp.push_back(a[i+1]);
    }

    rep(i, n-1) ans += tmp[i];

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 9032
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  string s;std::cin >> s;
  vll num(26, 0);
  re(i, s.size()){
    if(num[s[i]-'a']>0){
      std::cout << "no" << '\n';
      return 0;
    }
    num[s[i]-'a']++;
  }
  std::cout << "yes" << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int w[100];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++) cin>>w[i];
    int sum=0;
    for(int i=0;i<n;i++){
        sum+=w[i];
    }
    int temp=sum;
    int min=sum;
    int is=0;
    for(int i=0;i<n;i++){
        sum-=w[i];
        if(abs(2*sum-temp)<min) {
            min=abs(2*sum-temp);
            is=i;
        }
    }
    cout << min<< "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main()
{
    int a,b,ans;
    double c,d;
    while(scanf("%d %d",&a, &b) != EOF)
    {
        c=(double)(a+b);
        d=log10(c);
        ans=((int) d)+1;
        printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];
    int64 sum = accumulate(a.begin(), a.end(), 0LL);
    map<int64,int64> mp;
    for (auto ai : a) mp[ai]++;

    int q;
    cin >> q;
    for (int i=0; i<q; i++) {
        int b,c;
        cin >> b >> c;
        sum -= mp[b] * b;
        sum += mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 9400
#include <stdio.h>
int main()
{
    int x,y,r,w,h;
    scanf("%d",&w);
    scanf("%d",&h);
    scanf("%d",&x);
    scanf("%d",&y);
    scanf("%d",&r);
    if(-100<=x&&x<=100){
        if(-100<=y&&y<=100){
            if(0<w&&w<=100){
                if(0<h&&h<=100){
                    if(0<r&&r<=100){
                        //うんち
                        if(r<=x&&x<=w-r&&r<=y&&y<=h-r){
                            printf("Yes\n");
                        }
                        else{
                            printf("No\n");
                        }
                    }
                }
            }
        }
    }
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;
int main(){
	while(true){
		int m,f,r; cin >> m >> f >> r ;
		if(m==-1 && f==-1 && r==-1 ) break;
		if(m==-1 || f==-1) cout << 'F';
		else if(m+f>=80) cout << 'A';
		else if(m+f>=65) cout << 'B';
		else if(m+f>=50) cout << 'C';
		else if(m+f>=30){
			if(r>=50) cout << 'C';
			else cout << 'D';
		}
		else cout << 'F';
		cout << '\n';
	}
}

Measured memory_bytes: 1124
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
struct edge {
	int to, cost;
};

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){
    if(b==0)
    return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;base%=mod;
        pow/=2;
    }return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
 
const int M = 2e5 + 5;


int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector <string> vec(n);
    for(int i = 0; i < n; i++) cin >> vec[i];
    int ans = 0;
    for(int mask1 = 0; mask1 < (1<<n); mask1++){
        for(int mask2 = 0; mask2 < (1<<m); mask2++){
            int cnt = 0;
            for(int i = 0; i < n; i++){
                for(int j = 0; j < m; j++){
                    if(vec[i][j] == '.') continue;
                    int cond1 = ((mask1>>i)&1);
                    int cond2 = ((mask2>>j)&1);
                    if(!cond1 && !cond2) cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}


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

dp = [{} for __ in range(N+1)]

dp[0][0] = 0
dp[1][0] = 0
dp[1][1] = A[0]

for i in range(2, N+1):
    for j in range((i-1)//2, (i+1)//2+1):
        app = (dp[i-2][j-1] if j-1 in dp[i-2] else -float('inf')) + A[i-1]
        napp = dp[i-1][j] if j in dp[i-1] else -float('inf')
        dp[i][j] = max(app, napp)

print(dp[N][N//2])


Measured memory_bytes: 140124
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int n, d, x; cin >> n >> d >> x;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  int ans = x;
  rep(i, n) {
    int day = 1;
    int tmp = 1;
    while(true) {
      day += a[i];
      if(day > d) break;
      ++tmp;
    }
    ans += tmp;
  }
  cout << ans << '\n';

  return 0;
}


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

int n;
void init(){
  n=0;
}

int input(){
  cin>>n;
  return n;
}

int solve(){
  int res=n;
  for(int z=0;z*z*z<=n;z++){
    for(int y=0;y*y+z*z*z<=n;y++){
      res=min(n-(z*z*z)-(y*y)+y+z,res);
    }
  }
  return res;
}




int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        int[] px = new int[90001];
        int[] py = new int[90001];
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int a = sc.nextInt();
                px[a] = i;
                py[a] = j;
            }
        }
        int[] c = new int[90001];

        for (int i = d + 1 ; i <= h * w ; i++) {
            c[i] = c[i - d] + Math.abs(px[i] - px[i - d]) + Math.abs(py[i] - py[i - d]);
        }

        int q = sc.nextInt();
        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0; i < q; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        for (int i = 0 ; i < q ; i++) {
            System.out.println(c[r[i]] - c[l[i]]);
        }

    }

}

Measured memory_bytes: 91144
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=3e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int cunt_e[MAX+1],cunt_w[MAX+1],cc_e[MAX+1],cc_w[MAX+1];
int n,ans,total_e;
string s;

void solve(){
    
    for(int i=0;i<s.size();i++)if(s[i]=='E')total_e++;
    
    cc_e[0]=0; cc_w[0]=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='E')cunt_e[i]=1;
        else if(s[i]=='W')cunt_w[i]=1;
        
        cc_e[i+1]=cunt_e[i]+(i?cc_e[i]:0);
        cc_w[i+1]=cunt_w[i]+(i?cc_w[i]:0);
    }
    
    int ans=INF;
    
    for(int i=0;i<=s.size();i++){
        int flag_e=total_e-cc_e[i];
        ans=min(ans,flag_e+cc_w[i]);
    }
    
    cout<<ans<<"\n";
}


int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>n>>s;
    solve();
    return 0;
}


Measured memory_bytes: 5396
import Control.Monad

solvable_adj::[(Int,Int)]->(Bool,Bool)
solvable_adj ls = let (i:rest) = (map (\(x,y)->mod (x+y) 2) ls) in
                  (and (map (i==) rest),i==0)

bin31::[Int]
bin31 = [2^i|i<-[0..30]]

--関数、終了条件、初期値、リスト
ls_accum::(b->(b,c))->(b->Bool)->b->[c]
ls_accum f condition state = if condition state then [] else let (next,res) = f state  in res:(ls_accum f condition next)

bin_31bit::Int->[Bool]
bin_31bit n = let bits = ls_accum (\ i -> (div i 2 , (mod i 2)==1) ) (0==) n in
              bits++(take (31 - (length bits)) (repeat False))

bin_31bit_t::[Bool]->Int
bin_31bit_t = sum.(map (\(i,b)->if b then 2^i else 0)).(zip [0..30])
--need odd num
pm_bin_31_bit::Int->[Bool]
pm_bin_31_bit n = bin_31bit (div (n + (2^31 - 1)) 2)

pm_bin_31_t::[Bool]->Int
pm_bin_31_t  = sum.(map (\(i,b)->if b then 2^i else (- 2^i))).(zip [0..30])

without_adj_1_solver::(Int,Int)->[Char]
without_adj_1_solver (x,y) = (map to_char) (zip (pm_bin_31_bit (x+y)) (pm_bin_31_bit (x-y)))
                                  where to_char (b,c) = case (b,c) of
                                                        (True,True)  -> 'R'
                                                        (True,False) -> 'U'
                                                        (False,True) -> 'D'
                                                        (False,False)-> 'L'
--修正の必要フラグ
adj_1_solver::(Int,Int)->[Char]
adj_1_solver (x,y) = if mod (x+y) 2 == 1
                          then without_adj_1_solver (x,y)
                          else 'R':(without_adj_1_solver (x-1,y))

solver_test::[Char]->(Int,Int)
solver_test ls =let b = length ls == 32 in
                let fl = if b then (zip [0..30] (tail ls)) else (zip [0..30] ls) in
                let x= sum [(if c == 'R' then 2^i else (-(2^i)))|(i,c)<-fl,c=='L'||c=='R'] in
                let y= sum [(if c == 'U' then 2^i else (-(2^i)))|(i,c)<-fl,c=='U'||c=='D'] in
                ((if b then 1 else 0 )+ x,y)

main::IO()
main=do
  nc<-getLine
  let n = read nc::Int
  dat<- forM [1..n] (\_->(return.(\(x:y:[])->(x,y)).(map read).words)=<<getLine)
  case solvable_adj dat of
    (False,_) -> do
                putStr "-1\n"
    (True,b)->do
                putStr (if b then "32\n" else "31\n")
                (putStr.((if b then "1 " else [])++).concat.(map ((\x->x++" ").show))) bin31
                putStr "\n"
                forM_ dat (\(x,y)->do
                                  putStr (adj_1_solver (x,y))
                                  putStr "\n"
                             )


Measured memory_bytes: 2172
program main;
var a : integer;
begin
read(a);
if (a >= 100) and (a <= 999)  and (frac((a-7)/10) = 0) then write('Yes')
	else if (a > 99) and (a < 1000)  and ((frac(trunc((a-70)/10)/10)) = 0) then write('Yes')
    	else if (a > 99) and (a < 1000)  and ((a-700) >= 0) and ((a-700) <= 99) then write('Yes')
        	else write('No');
end.

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	string S;
	cin >> S;
	fx(S.size()) {
		cout << 'x';
	}
	cout << endl;

    return 0;
}



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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
#define swap(x, y)    \
  {                   \
    auto ___temp = x; \
    x = y;            \
    y = ___temp;      \
  }

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a + a - 1, max(b + b - 1, a + b)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=(a+b+c)+max({a,b,c})*((1<<k)-1);
    cout<<ans<<endl;
}


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 n, a, b;
  cin >> n >> a>>b;
  int ans = 0;
  for(int i = 1;i <= n; i ++){
    string tmp = to_string(i);
    int sum = 0;
    for(int k = 0;k < tmp.size();k++){
      sum += tmp[k] - '0';
    }
    if(a <= sum&& sum<= b){
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
def main():
    N, W = map(int, input().split())
    Ws = []
    Vs = []
    for _ in range(N):
        w, v = map(int, input().split())
        Ws.append(w)
        Vs.append(v)
    mv = sum(Vs)
    dp = [[float('INF')] * (mv + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(mv + 1):
            if Vs[i] > j:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i])
    ans = 0
    for r in dp:
        for v, w in enumerate(r):
            if W >= w:
                ans = max(ans, v)
    print(ans)


main()


Measured memory_bytes: 301160
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
//int l[n+1];
int main() {
  int n;
  cin >>n;
  priority_queue<long double,vector<long double>,greater<long double>>pq;
  int tmp;
  for(int i = 0;i<n;i++){
    cin >> tmp;
    pq.push(tmp);
  }

  long double a,b;
  for(int i=0;i<n-1;i++){
    a = pq.top();
    pq.pop();
    b = pq.top();
    pq.pop();
    pq.push((a+b)/2);
    //cout << a << " " << b<< endl;
  }
  
  cout << fixed << setprecision(10);
  cout << pq.top();
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)

vector<ll> par(100001);//親
vector<ll> Rank(100001);//木の深さ

void init(ll n){//初期化
	rep1(i,n){
		par[i]=i;
		Rank[i]=0;
	}
}

ll find(ll x){
	if(par[x]==x){
		return x;
	}
	else {
		return  par[x]=find(par[x]);
	}
}
void unite(ll x,ll y){
	x=find(x);
	y=find(y);
	if(x==y) return;

	if(Rank[x]<Rank[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(Rank[x]==Rank[y]) Rank[x]++;
	}
}
bool same(ll x,ll y){
	return find(x)==find(y);
}

int main(){
	ll N,M; cin>>N>>M;
	vector<ll> p(N+1);
	rep1(i,N) cin>>p[i];
	init(N+1);
	rep(i,M){
		ll x,y; cin>>x>>y;
		unite(x,y);
	}
	ll ans=0;
	rep1(i,N){
		if(same(i,p[i])) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
const int maxn=200005;
int n,m,d[maxn],t[maxn];
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;++i) {
        int t;
        scanf("%d",&t);
        ++mp[t];
    }
    scanf("%d",&m);
    for (int i=0;i<m;++i) {
        int t;
        scanf("%d",&t);
        if (mp.find(t)==mp.end()||mp[t]==0) {
            puts("NO");
            return 0;
        }
        --mp[t];
    }
    puts("YES");
    return 0;
}


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

int main(void) {
	
	char input[9];
	int h, w;
	int i, j;
	
	while (1){
		
		fgets(input, sizeof(input), stdin);
		h = atoi(strtok(input," "));
		w = atoi(strtok(NULL, " "));
		
		if (h == 0 && w == 0){
			break;
		}
		
		for (i = 1; i <= h; i++){
				
				for (j = 1; j <= w; j++){
					printf("#");
				}
			
			printf("\n");
		}
		
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}

int main()
{
 int n=D();
 int x=n/3;
 cout<<x<<endl;
}


Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    s=0
    for i in range(n):
        x,y,h,w=map(int,input().split())
        k=x+y+h
        if k<=60 and w<=2:
            s+=600
        elif k<=80 and w<=5:
            s+=800
        elif k<=100 and w<=10:
            s+=1000
        elif k<=120 and w<=15:
            s+=1200
        elif k<=140 and w<=20:
            s+=1400
        elif k<=160 and w<=25:
            s+=1600
        else:
            pass
    print (s)
        


Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long K = sc.nextLong();

		if (K <= A) {
			System.out.println(A - K+" "+B);
		
		} else if (K <= A + B) {
			System.out.println(0+" "+(B - (K - A)));
		} else {
			System.out.println(0+" "+0);
		}
	}
}

Measured memory_bytes: 27056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> trump(4,vector<int>(13,0));
  rep(i,n) {
    char suit; int num;
    cin >> suit >> num;
    num--;
    if(suit=='S') trump[0][num] = 1;
    if(suit=='H') trump[1][num] = 1;
    if(suit=='C') trump[2][num] = 1;
    if(suit=='D') trump[3][num] = 1;
  }
  rep(i,4){
    rep(j,13) {
      if(!trump[i][j]) {
        if(i==0) cout << "S " << j + 1 << endl;
        if(i==1) cout << "H " << j + 1 << endl;
        if(i==2) cout << "C " << j + 1 << endl;
        if(i==3) cout << "D " << j + 1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3052
from itertools import accumulate
n = int(input())
div = 10 ** 9 + 7
lst = list(map(int, input().split()))
ACC = list(accumulate(lst))
ACC.pop(n - 1)
res = 0
for i in range(n - 1):
  res += (lst[i + 1] * ACC[i])
  res %= div
print(res)

Measured memory_bytes: 31288
#include <iostream>
#include <string>
using namespace std;
int main(){
int a,b,c,atta=0;
cin>>a>>b>>c;
for(int i=0;i<10000;i++){
int t1=a*i;
for(int i=0;i<10000;i++){
int t2=b*i+c;
if(t1==t2){
atta+=1;
}
}
}
if(atta>0){
cout<<"YES"<<endl;
}
else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    m = A[0]
    s = 0
    for i in range(1,len(A)):
        a = A[i]
        if a < m:
            s += m-a
        else:
            m = a
    print(s)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


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

int main(){
    string s;
    unsigned long long k;
    cin >> s >> k;

    int one_num = 0;
    unsigned char n;
    for(int i=0;i<s.size();i++){
        if(s[i] != '1'){
            n = s[i];
            break;
        }
        one_num++;
    }

    if(k <= one_num){
        cout << '1' << endl;
    }
    else{
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#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;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 10, M = 1e3 + 10;
const int INF = INT_MAX;
const db PI = acos(-1);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int ans = ((a + 9) / 10) * 10 + ((b + 9) / 10) * 10 + ((c + 9) / 10) * 10 + ((d + 9) / 10) * 10 + ((e + 9) / 10) * 10;
    a %= 10, b %= 10, c %= 10, d %= 10, e %= 10;
    if (!a) {
        a += 10;
    }
    if (!b) {
        b += 10;
    }
    if (!c) {
        c += 10;
    }
    if (!d) {
        d += 10;
    }
    if (!e) {
        e += 10;
    }
    if (a == b and b == c and c == d and d == e and a == 10) {
        cout << ans << "\n";
    } else {
        cout << ans + min(a, min(b, min({c, d, e}))) - 10 << "\n";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,n,s=0,a,m=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    s+=a;
    if(m<a)m=a;
  }
  puts(s>2*m?"Yes":"No");
  return 0;
}

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  if(H>W){
    if(N%H!=0){
      cout << (N/H)+1 << endl;
    }
    if(N%H==0){
      cout << N/H << endl;
    }
  }
  if(H<=W){
    if(N%W!=0){
      cout << (N/W)+1 << endl;
    }
    if(N%W==0){
      cout << N/W << endl;
    }
  }
  
    
}
      
  
  
  

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int W, H, x, y, r;
	int hanx,hany,tate, yoko;
	

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	tate = y + r;
	yoko = x + r;
	hanx = x-r;
	hany = y-r;

	if((hanx>=0)&&(yoko<=W))
	{
		if((hany>=0)&&(tate<=H))
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
	else if((hanx<0)||(yoko>W))
	{
		printf("No\n");
	}
	else if((hany<0)||(tate>W))
	{
		printf("No\n");
	}
	else
	{
		printf("No\n");
	}


	return 0;

}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int N,i;
  double value;
  cin >> N;
  vector<double> V(N);
  for(i=0;i<N;i++)cin >> V.at(i);
  sort(V.begin(),V.end());
  value=V.at(0);
  for(i=1;i<N;i++)value=(value+V.at(i))/2;
  cout << value << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
int main(){
    int n; cin >> n;
    ll h[n]; cinf(n,h);
    h[0] -= 1;
  if(n > 1){
    bool res=true;
    for(int i=0;i<n-1;i++){
        if(h[i+1]>h[i]){
            h[i+1] -=1;
        }else if(h[i+1] < h[i]) res=false;
    }
    if(res) cout << "Yes";
    else cout << "No";
  }
  if(n == 1) cout << "Yes";
    return 0;
}

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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	ll n; cin >> n;
	ll ans = 0;
	ll h; cin >> h;
	Rep(n-1){
		ll a; cin >> a;
		if(a <= h){
			ans += (h-a);
		}else{
			h = a;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n;
	long long t, a;
	cin >> n;
	
	long long ansA = 0, ansB = 0;
	
	n--;
	cin >> ansA >> ansB;
	
	while(n-- > 0){
		cin >> t >> a;
		ansA = max(ansA, t);
		ansB = max(ansB, a);
		long long i = max(ansA / t, ansB /a);
		while(((t * i) < ansA) || ((a * i) < ansB)){
			i++;
		}
		ansA = t * i;
		ansB = a * i;
	}
	
	cout << ansA + ansB << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"strconv"
	"text/scanner"
)

var sin scanner.Scanner
var ans int

func scan() string {
	tok := sin.Scan()
	if tok == scanner.EOF {
		return ""
	}
	return sin.TokenText()
}

func main() {
	sin.Init(os.Stdin)

	n, _ := strconv.Atoi(scan())
	q, _ := strconv.Atoi(scan())

	s := scan()
	num := []int{0}

	//fmt.Printf("%d\n", num)

	for i := 0; i < n-1; i++ {
		if s[i:i+1] == "A" && s[i+1:i+2] == "C" {
			num = append(num, 1+num[i])
		} else {
			num = append(num, num[i])
		}
	}

	//fmt.Printf("%d\n", num)

	for i := 0; i < q; i++ {

		//a := 0

		l, _ := strconv.Atoi(scan())
		r, _ := strconv.Atoi(scan())
		fmt.Printf("%d\n", num[r-1]-num[l-1])

	}

}


Measured memory_bytes: 6912