akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BRACK 2
void visit(int);
int t=0,n;
int array[N][N], road_color[N] ,time1[N], time2[N];
int main(){
  int i,j,num1,num2,num3;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      array[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&num1,&num2);
    num1--;
    for(j=0;j<num2;j++){
      scanf("%d",&num3);
      num3--;
      array[num1][num3] = 1;
    }
  }
  for(i=0;i<n;i++) road_color[i] = WHITE;
 
  for(i=0;i<n;i++)  if(road_color[i] == WHITE) visit(i);
 
  for(i=0;i<n;i++) printf("%d %d %d\n", i+1,time1[i],time2[i]);
 
  return 0;
}
void visit(int u){
  int i;
  road_color[u] = GRAY;
  time1[u] = ++t;
  for(i=0;i<n;i++){
    if(array[u][i] == 0) continue;
    if(road_color[i] == WHITE) visit(i);
  }
    road_color[i] = BRACK;
    time2[u]=++t;
}

Measured memory_bytes: 640
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef  pair<int,int> P;
typedef long long LL;

const LL  INF=1<<31;



int main(){
     char a;
     cin>>a;
     if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o')cout<<"vowel"<<endl;
     else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    bool v1 = true;
    bool v2 = true;
    int n = s.size();
    rep(i,n)if(s[i]!=s[n-i-1])v1=false;
    rep(i,(n-1)/2)if(s[i]!=s[((n-1)/2)-i-1])v2=false;
    if(v1 and v2)cout << "Yes";
    else cout << "No";
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a<b) {
    for (int i=0; i<b; i++) {
      if (i!=b-1) cout << a;
      else cout << a << endl;
    }
  }
  else {
    for (int i=0; i<a; i++) {
      if (i!=a-1) cout << b;
      else cout << b << endl;
    }
  }
}

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

const int INF = 1<<30;

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int,int>> v[n];
    int a, b, c;
    while(m-- > 0){
        cin >> a >> b >> c;
        a--, b--;
        v[a].push_back({b,c});
    }
    priority_queue<pair<int,int>> pq;
    pq.push({-0, 0});
    vector<int> d(n, 1<<30);
    int ans = 0;
    while(!pq.empty()){
        pair<int,int> p = pq.top(); pq.pop();
        int cost = -p.first, pos = p.second;
        if(d[pos] <= cost)  continue;
        d[pos] = cost;
        for(pair<int,int> q : v[pos]){
            int to = q.first, c = q.second;
            if(cost > c)    continue;
            if(to == n-1){
                ans = max(ans, c);
            }else if(d[to] > c){
                pq.push({-c, to});
            }
        }
    }
    cout << (ans == 0 ? -1 : ans) << endl;
    return 0;
}



Measured memory_bytes: 8636
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()

score_dic = {}
score_dic['r']=P
score_dic['s']=R
score_dic['p']=S

past_list = []

score = 0
for i in range(N):
    t = T[i]
    if i >= K:
#         print("ik:",i,K)
#         print("T,plist[i-k]",t,past_list[i-K])
        if past_list[i-K] != t:
            score += score_dic[t]
            past_list.append(t)
        else:
            past_list.append("n")
    else:
        score += score_dic[t]
        past_list.append(t)
#     print("i,t,score", i,t,score)
print(score)
        
    

Measured memory_bytes: 4212
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll dp[101][305];

int main(){
    int n, w;
    cin >> n >> w;
    int ws = 0, sum = 0;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        if ( !i ) {
            ws = a;
        }
        a -= ws;
        for ( int j = i; j >= 0; --j ) {
            for ( int k = sum; k >= 0; --k ) {
                dp[j+1][k+a] = max(dp[j+1][k+a], dp[j][k]+b);
            }
        }
        sum += a;
    }
    ll ans = 0;
    rep(i, n+1) rep(j, sum+1) {
        ll x = (ll)ws*i+j;
        if ( x <= w ) {
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  int s=N/2;
    cin>>s;
  if(N%2==1){
    for(int i=0; i<M; i++){
      cout<<N-i<<" "<<i+1<<endl;
    }
  }
  else{
    
    if(M%2==0){
      int a=M/2;
      cin>>a;
    for(int i=0; i<a; i++){
      cout<<N-i<<" "<<i+1<<endl;
      cout<<s-i-1<<" "<<s+i+1<<endl;
    }
    }
    else{
      int b=M/2;
      cin>>b;
      for(int i=0 ;i<b; i++){
        cout<<N-i<<" "<<i+1<<endl;
      cout<<s-i-1<<" "<<s+i+1<<endl;
      }
      cout<<N-b<<" "<<b+1<<endl;
    }
      
  }    
      
   
}


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

using namespace std;

const int maxn = 1000010;

int binom(int n, int m) {
	for (int i = 0; i < 20; i++) {
		int x = n & (1<<i), y = m & (1<<i);
		if (!x && y) return 0;
	}
	return 1;
}

char str[maxn];
int a[maxn], n;

int main() {
	scanf("%d", &n);
	scanf("%s", str + 1);
	for (int i = 1; i <= n; i++) a[i] = int (str[i] - '1');
	int f = 0;
	for (int i = 1; i <= n; i++) if (a[i] == 1) f = 1;
	if (f) {
		int s = 0;
		for (int i = 1; i <= n; i++) {
			s += (binom(n-1, i-1) * a[i]) & 1;
		}
		printf("%d\n", s & 1);
	} else {
		int s = 0;
		for (int i = 1; i <= n; i++) s += (binom(n-1, i-1) * (a[i] / 2)) & 1;
		printf("%d\n", (s & 1) * 2);
	}
	return 0;
}

Measured memory_bytes: 8560
<?php
$n = (int)trim(fgets(STDIN));
$s = trim(fgets(STDIN));

$alp = range('A', 'Z');
$map = array_flip($alp);

$l = strlen($s);
$ret = '';
for ($i=0; $i < $l; $i++) { 
	$tmp = $s[$i];
	$idx = $map[$tmp];
	$mov = ($idx + $n) % 26;
	$ret .= $alp[$mov];
}
echo $ret;

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
 
#define ll long long
#define ar array
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	bool ans = false;
  	for(int i = n; i > 0; i/=10)
    {
        if(i%10 == 7)
        {
          ans = true;
          break;
        }
    }
  	if(ans)
    {
      cout << "Yes";
    }
  	else
    {
      cout << "No";
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int N;
    int get;
    int counter=0;
    int COUNTER=0;
    vector < vector <int> > a;
    vector <int> c;
    
    cin>>N;
    
    for(int i=0;i<2*N;i++)
    {
        cin>>get;
        c.push_back(get);
    }
    
    sort(c.begin(),c.end());
    
    for(int i=0;i<N;i++)
    {
        vector <int> d;
        d.push_back(c[i+COUNTER]);
        d.push_back(c[i+COUNTER+1]);
        a.push_back(d);
        COUNTER++;
    }
    
    for(int i=0;i<N;i++)
    {
        if(a[i][0]<=a[i][1])
        {
            counter+=a[i][0];
        }
        else if(a[i][0]>a[i][1])
        {
            counter+=a[i][1];
        }
        
    }
    
    cout<<counter;
    
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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

ll N, M;
vector<vector<edge>> g;

vector<bool> see;

vector<ll> pos;

void dfs(ll v) {
	see[v] = 1;

	for (edge e : g[v]) {
		if (see[e.to] == 1) { continue; }
		pos[e.to] = pos[v] + e.d;
		dfs(e.to);
	}

	return;
}




int main() {

	ll A, B, C, X;
	cin >> A >> B >> C >> X;

	ll ans = 0;

	rep(i, A + 1)rep(j, B + 1)rep(k, C + 1) {
		if (500 * i + 100 * j + 50 * k == X) { ans++; }
	}

	cout << ans;

	system("PAUSE");

	

}


Measured memory_bytes: 504
#include <stdio.h>

int x, y;

int main() {
    while (1) {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0) break;
        for (int i = 1; i <= x; i++) {
            for (int j = 1; j <= y; j++) {
                if (i == 1 || i == x || j == 1 || j == y) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
    int K;
    cin >> K;
    int A, B;
    cin >> A >> B;

    int mod = A % K;
    if (mod == 0) {
        COUT("OK");
        return 0;
    }
    if (A + K - mod <= B) {
        COUT("OK");
    } else {
        COUT("NG");
    }
    return 0;
}

Measured memory_bytes: 3620
N, M = map(int, input().split())

if M == 0:
    print(0)
    exit()

es = [[] for i in range(M+1)]
for i in range(M):
    a, b = map(int, input().split())
    a,b = a-1, b-1
    es[a].append(b)
    es[b].append(a)

def dfs(v, visited, es, cnt):

    #print("--------------")
    #print((v, visited, cnt))

    if cnt == N-1:
        return 1
    ret = 0
    for i in es[v]:
        if visited[i] == True:
            continue

        visited[i] = True
        ret += dfs(i, visited, es, cnt+1)
        visited[i] = False

    return ret

visited = [False] * N
visited[0] = True

ans = dfs(0,visited,es,0)
print(ans)

Measured memory_bytes: 3064
a =  int(input())
b =  int(input())
c =  int(input())
d =  int(input())
e =  int(input())

a_syo = a//10
b_syo = b//10
c_syo = c//10
d_syo = d//10
e_syo = e//10
time1 = (a_syo + b_syo + c_syo + d_syo + e_syo) * 10

a_amari = a%10
b_amari = b%10
c_amari = c%10
d_amari = d%10
e_amari = e%10
lst = []
if a_amari == 0:
    pass
else:
    lst = lst + [a_amari]
if b_amari == 0:
    pass
else:
    lst = lst + [b_amari]
if c_amari == 0:
    pass
else:
    lst = lst + [c_amari]
if d_amari == 0:
    pass
else:
    lst = lst + [d_amari]
if e_amari == 0:
    pass
else:
    lst = lst + [e_amari]
if len(lst) == 0:
    print (time1)
else:
    #print (lst)
    count = len(lst) - 1
    #print (count)
    lst.sort()
    #print (lst)
    time2 = (len(lst) -1)*10 + lst[0]
    print (time1 + time2)

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


public class Main {
	private	static	BufferedReader br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double[][]	aRect = null;

		while((aRect = parseRect()) != null) {
			result(aRect);
		}
	}

	private static double[][] parseRect() {
		double[][]	aRect = null;
		String[]	as    = null;

		try {
			String line = br.readLine();
			if (line != null) {
				if (!line.isEmpty()) {
					aRect       = new double[4][2];	
					as          = line.split(" ");
					aRect[0][0] = Double.parseDouble(as[0]);
					aRect[0][1] = Double.parseDouble(as[1]);
					aRect[1][0] = Double.parseDouble(as[2]);
					aRect[1][1] = Double.parseDouble(as[3]);
					aRect[2][0] = Double.parseDouble(as[4]);
					aRect[2][1] = Double.parseDouble(as[5]);
					aRect[3][0] = Double.parseDouble(as[6]);
					aRect[3][1] = Double.parseDouble(as[7]);
				}
			}
		}
		catch (NumberFormatException e) {}
		catch (IOException e) {}

		return aRect;
	}

	private static void result(double[][] aRect) {
		if (aRect[0][0] > aRect[3][0] || aRect[1][0] < aRect[2][0] || aRect[0][1] > aRect[3][1] || aRect[1][1] < aRect[2][1]) {
			System.out.println("NO");
		}
		else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 16948
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (c / a) * b << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 510;

const char S[5] = "RYGB";
char col[N][N];
int d, n, m;

int main(){
	scanf("%d%d%d", &n, &m, &d);
	For(i, 1, n) For(j, 1, m)
		col[i][j] = S[(((i + j) / d) & 1) << 1 | (((i - j + m) / d) & 1)];
	For(i, 1, n) printf("%s\n", col[i] + 1);
	return 0;
}

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

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

	for (int i = 0; i < s.length(); i++) {
		if (i%w == 0) {
			cout << s[i];
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	
	int r[n][3];
	int i;
	for (i=0;i<n;i++) {
		scanf("%d %d %d", &r[i][0], &r[i][1], &r[i][2]);
	}
	int a, b, c;
	for (i=0;i<n;i++) {
		if (r[i][0] > r[i][1]) {
			if (r[i][0] > r[i][2]) {
				a = r[i][0];
				b = r[i][1];
				c = r[i][2];
			} else {
				a = r[i][2];
				b = r[i][0];
				c = r[i][1];
			}
		} else {
			if (r[i][1] > r[i][2]) {
				a = r[i][1];
				b = r[i][0];
				c = r[i][2];
			} else {
				a = r[i][2];
				b = r[i][0];
				c = r[i][1];
			}
		}
		if ( (long)(a * a) == (long)(b * b + c * c) ) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	return 0;
}

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

using namespace std;
using ll = long long;


int main(){
  int N;
  cin >> N;
  int ans = 100000;
  int k = N/9;
  
  for(int i = 0; i <= k; i++){
    int x = i;//９の倍数で支払う額
    int y = (N-9*x)/6;//６の倍数で支払う額
    int z = N-9*x-6*y;//１で支払う額
    int countx = 0;
    int county = 0;
    while(x>0){
      countx += x%9;
      x /= 9;
    }
    while(y>0){
      county += y%6;
      y /= 6;
    }
    ans = min(ans, countx+county+z);
  }


    
      
    
  
  
  cout << ans << endl;
}
   
      
    
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> X(N), L(N);
	vector<int> ord(N);
	REP(i, N) ord[i] = i;
	REP(i, N) scanf("%d %d", &X[i], &L[i]);
	
	sort(ALL(ord), [&](int a, int b) {
		return X[a] + L[a] < X[b] + L[b];
	});
	
	int pre = -INF;
	int ans = 0;
	for (int i : ord) {
		int cur = X[i] - L[i];
		if (pre <= cur) {
			++ans;
			pre = X[i] + L[i];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n, m, l;
    cin >> n >> m >> l;

    vector<vector<int>> a(n, vector<int>(m)), b(m, vector<int>(l));

    roop(i, n){
        roop(j, m){
            cin >> a[i][j];
        }
    }

    roop(i, m){
        roop(j, l){
            cin >> b[i][j];
        }
    }

    ll sum;
    roop(i, n){
        roop(j, l){
            sum = 0;
            roop(k, m){
                sum += a[i][k]*b[k][j];
            }
            if(j == l-1) cout << sum;
            else cout << sum << " ";
        }
        cout << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;


void countingSort(vector<int>& A, vector<int>& B, int k)
{
  int n = A.size();
  vector<int> freqs(k + 1, 0);
  for (int i = 0; i < n; ++i) { ++freqs[A[i]]; }
  for (int i = 1; i <= k; ++i) { freqs[i] += freqs[i - 1]; }
  for (int i = 0; i < n; ++i) {
    B[freqs[A[i]] - 1] = A[i];
    --freqs[A[i]];
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n), B(n);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
    k = max(k, A[i]);
  }
  countingSort(A, B, k);
  for (int i = 0; i < n; ++i) {
    if (i) { fprintf(stdout, " "); }
    fprintf(stdout, "%d", B[i]);
  }
  fprintf(stdout, "\n");
  return 0;
}

Measured memory_bytes: 16764
#include<iostream>
#include<math.h>
using namespace std;

int main(void){
    double a,b,x;
    int y;
    cin>>a>>b;
    x=(a+b)/2;
    y=(int)x;
    if(x-(double)y<0.5) cout<<y<<endl;
    else cout<<y+1<<endl;
    return 0;
}


Measured memory_bytes: 256
fn main() {
	proconio::input!{
		mut n: i128,
		mut m: i128,
	}

	if (n-m).abs() > 1 {
		println!("0");
		return;
	} 

	if n > m {
		let tmp = m;
		m = n;
		n = tmp;
	}

	//n! * m!
	let mut nf: i128 = 1;
	for i in 2..=n {
		nf = (nf * i) % 1000000007;
	}
	if n != m {
		println!("{}", (nf * nf * m) % 1000000007);
	}
	else {
		println!("{}", (nf * nf * 2) % 1000000007);
	}
}


Measured memory_bytes: 2088
fun main(args: Array<String>) {
    val N = readInputLine().toInt()

    val tmp = Array(10) { IntArray(10) }
    var ans = 0

    for (i in 1..N) {
        val iStr = i.toString()
        tmp[iStr.first().toInt() - '0'.toInt()][iStr.last().toInt() - '0'.toInt()]++
    }

    for (i in 0..9) {
        for (j in 0..9) {
            ans += tmp[i][j] * tmp[j][i]
        }
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 38652
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    sum=c
    for j in range(m):sum+=a[j]*b[j]
    if sum>0:ans+=1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    
    REP(i,n)cin >> a[i];

    REP(i,n){
        if(a[i] % 2 == 0){
            if(a[i] %3 == 0 || a[i] %5 == 0){
                //continue;
            }
            else{
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int n;
	cin >> n;
	int res = 0;
	vector<int> a(n), b(n), c(n);

	fi(n) {
		cin >> a[i];
	}
	fi(n) {
		cin >> b[i];
	}
	fi(n-1) {
		cin >> c[i];
	}

	fi(n) {
		int at = a[i];
		res += b[at-1];
		if (i > 0) {
			if (at-1 == a[i - 1] ) {
				res += c[at - 2];
			}
		}
	}
	ce(res);
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 51
#define ll long long 
#define mo 1000000007
using namespace std;

int n,i,j,k,l;
ll f[maxn][maxn][2],C[maxn][maxn],ans;

int main(){
	scanf("%d",&n);
	for(C[0][0]=1,i=1;i<=n;i++) for(C[i][0]=1,j=1;j<=i;j++)
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	f[0][0][0]=1;
	for(i=0;i<n;i++) for(j=0;j<=i;j++) for(int p=0;p<2;p++) if (f[i][j][p]){
		int x=(p==1)*j,y=(p==0)*j;
		for(k=0;i+j+k<=n;k++) for(l=0;i+j+k+l<=n;l++) if (j+k+l>0) if (i+j+k+l<n||i+j+k+l==n&&j+k+l==1)
		(f[i+j+k+l][max(x+k,y+l)-min(x+k,y+l)][x+k<=y+l]+=f[i][j][p]*C[i+j+k+l][i]%mo*C[j+k+l][y+k])%=mo;
	}
	printf("%lld\n",f[n][1][0]);
}

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


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        String s = in.next();
        HashSet<Character> set = new HashSet<>();
        for (char c : s.toCharArray()) set.add(c);
        out.println(set.size() == 2 ? "Yes" : "No");
        out.flush();
    }
    static int gcd (int a,int b) {
        return b == 0 ? a : gcd(b,a%b);
    }


    private static int [] mergeTwoArrays(int [] a, int [] b) {
        int [] res = new int[a.length + b.length];
        int i = 0;
        int j = 0;
        int index = 0;
        while (i<a.length && j<b.length) {
            if(a[i]<b[j]) {
                res[index++] = a[i++];
            }
            else {
                res[index++] = b[j++];
            }
        }
        System.out.println(i + " " + j);
        if(j == b.length - 1) {
            while (i<a.length) {
                res[index++] = a[i++];
            }
        }
        else {
            while (j<b.length) {
                res[index++] = b[j++];
            }
        }
        return res;
    }
}
class Point {
    private int left;
    private int right;

    public int getLeft() {
        return left;
    }

    public int getRight() {
        return right;
    }
    public Point(int left,int right) {
        this.left = left;
        this.right = right;
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21460
// AOJ 2921: Working
// 2019.2.17 bal4u

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, a, sum, min;

	scanf("%d", &N);
	sum = 0, min = 101;
	for (i = 1; i <= N; i++) {
		scanf("%d", &a);
		sum += a;
		if (sum / i < min) min = sum / i;
	}
	printf("%d\n", min);
	return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
long long getans(long long st,long long en,long long k,long long n) {
	long long mid = (st+en)/2;
	if(k>mid) {
		return getans(mid+1,en,k,n-1);
	} 
	else if(k<mid)
		return getans(st,mid-1,k,n-1);
	else
		return n;

}
int main(int argc, char const *argv[]) {
	
	long long en=1;
	long long n,k;
	char op;
	cin>>n>>op>>k;
	if (op == '+')
		cout<<n+k<<endl;
	else
		cout<<n-k<<endl;
	
	//cout<<getans(1,en,k,n)<<endl;

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int a1, a2, ans = 1, flag = 0;
  cin >> a1;
  for (int i = 1; i < N; i++) {
    cin >> a2;
    if (flag == 0 && a1 < a2) {
      flag = 1;
    } else if (flag == 0 && a1 > a2) {
      flag = -1;
    } else if (flag == 1 && a1 > a2 || flag == -1 && a1 < a2) {
      flag = 0;
      ans++;
    }
    a1 = a2;
  }
  cout << ans << endl;
}

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

int main(){
	int A,B,C,D,E;
    cin >> A >> B >> C >> D;
    int L = A + B, R = C + D;
  	
  	E = L - R;
  	if(E > 0){
      cout << "Left" << endl;
    }
  	else if (E < 0){
      cout << "Right" << endl;
    } 
  	else{
      cout << "Balanced" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    io
    long n,a[100005],i,c=0;
    cin>>n;
    for(i=1;i<=n;++i)
    cin>>a[i];
    for(i=1;i<=n;)
    {
        if(a[i]==i)
        {
            if(a[i+1]==i+1)
            {
                swap(a[i],a[i+1]);
                c++;
                i+=2;
            }
            else if(a[i+1]!=i)
            {
                swap(a[i],a[i+1]);
                c++;
                i+=2;
            }
            else
            {
                swap(a[i],a[i-1]);
                c++;
                i++;
            }
        }
        else i++;
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
int n,a[101010],mi=0x7f7f7f7f,ma;
bool check1(int x,int y)
{
	if(x<=0) return 0;
	if(2*x<=y) return 1;
	return 0;
}
bool check(int x,int y)
{
	if(2*x<=y||x==y-1) return 1;
	return 0;
}
void work1(int x,int y)
{
	if(y-x>1)
	{
		puts("No");
		return ;
	}
	int sum=0;
	for(int i=1;i<=n;i++)
	if(a[i]==x) sum++;
	if(check1(y-sum,n-sum))
		puts("Yes");
	else puts("No");
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),mi=min(a[i],mi),ma=max(ma,a[i]);
	if(mi!=ma) 
	{
		work1(mi,ma);
		return 0;
	}
	if(check(a[1],n))
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define es cout<<" "
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;
template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<class T, class... Ts> 
auto make_vec(size_t a, Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

int main(void) {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    repeat (i, n) cin >> v[i];
    
    int ans = 0;
    repeat_from_to (i, 0, n - 1) {
        repeat_from_to (j, i, n) {
            int denum = i + (n - j);
            if (denum > k) continue;
            if (denum == 0) continue;
            vector<int> p;
            repeat_from_to (a, 0, i - 1) p.push_back(v[a]);
            repeat_from_to (a, j, n - 1) p.push_back(v[a]);
            assert ((int)p.size() == denum);
            assert (k - denum >= 0);
            int sum = accumulate(p.begin(), p.end(), 0);
            sort(p.begin(), p.end());
            repeat (a, k - denum) {
                if (a >= (int)p.size()) continue;
                if (p[a] < 0) sum += (-p[a]);
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 3005;
const ll inf = 1e16;
int arr[MAX], n;
ll memo[MAX][MAX];
ll func(ll x, ll y, int p)
{
	return (p > 0 ? max(x, y) : min(x, y));
}
ll solve(int bg, int en)
{
	if(bg > en)
	return 0;
	
	if(memo[bg][en] != inf)
	return memo[bg][en];
	
	int p = ((n - (en - bg)) % 2 ? 1 : -1);
	return memo[bg][en] = func(solve(bg, en - 1) + p * arr[en], solve(bg + 1, en) + p * arr[bg], p);
}
int main()
{
	boost;
	int i, j;
	cin >> n;
	fo(i, 0, n)
	cin >> arr[i];
	fo(i, 0, MAX)
	{
		fo(j, 0, MAX)
		memo[i][j] = inf;
	}
	cout << solve(0, n - 1) << '\n';
}

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

int main() {
	int n; cin >> n;
	int a[101];
	for (int i=0; i<n; ++i) cin >> a[i];
	
	int cnt = 0;
	for (int i=0; i<n-2; ++i)
		for (int j=i+1; j<n-1; ++j)
			for (int k=j+1; k<n; ++k) {
				int x = a[i], y = a[j], z = a[k];
				cnt += (x+y > z && y+z > x && x+z > y && x != y && y != z && x != z);
				//cout << x << " " << y << " " <<z<< endl;
			}
	cout << cnt << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long t = sc.nextLong();
		long ans = x - t;
		if(ans >= 0) {
			System.out.println(ans);
		} else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include<numeric>
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
bool ispal(int n)
{
    int t=n;
    int res=0;
    while(n>0)
    {
        res=res*10+n%10;
        n/=10;


    }
    return (res==t);
}
void solve() {
    int a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=a;i<=b;++i)
    {
        if(ispal(i)) cnt++;
    }
    cout<<cnt;
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();

    //int t;cin>>t;while(t--)
        solve();
}

Measured memory_bytes: 3804
#include <stdio.h>

int main(void) {
	int n, x;
	while (scanf("%d%d", &n, &x) == 2 && (n|x) != 0) {
		int i, j;
		int count = 0;
		for (i = 1; i <= n; i++) {
			for (j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (j < k && k <= n) count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}



Measured memory_bytes: 2080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<28

using namespace std;
typedef pair<int,int> P;


struct edge
{
	int to;
	int cost;

	edge(int to,int cost) : to(to),cost(cost) {}
};

int d[101][11];
vector<edge> G[101];

void dijkstra(int s,int n,int ticket)
{
	priority_queue<P,vector<P>,greater<P> > que;
	rep(i,n) d[i][ticket] = INF;
	d[s][ticket] = 0;
	que.push(P(0,s));

	while(!que.empty())
	{
		P p = que.top();
		que.pop();

		int v = p.second;
		if(d[v][ticket] < p.first) continue;

		rep(i,G[v].size())
		{
			edge e = G[v][i];
			int temp;

			if(ticket == 0)
			{
				temp = d[v][ticket] + e.cost;
			}
			else
			{
				temp =  min(d[v][ticket]+e.cost,d[v][ticket-1]+e.cost/2);
			}

			if(d[e.to][ticket] > temp)
			{
				d[e.to][ticket] = temp;
				que.push(P(d[e.to][ticket],e.to));
			}
		}
	}
}

int main()
{
	int c,n,m,s,t;
	while(cin >> c >> n >> m >> s >> t)
	{
		if(c == 0 && n == 0 && m == 0 && s == 0 && t == 0) break;
		
		s--;
		t--;
		rep(i,100) G[i].clear();

		rep(i,m)
		{
			int a,b,cost;
			cin >> a >> b >> cost;
			a--;
			b--;

			edge e(b,cost);
			G[a].push_back(e);

			edge e2(a,cost);
			G[b].push_back(e2);
		}
		
		rep(i,c+1) dijkstra(s,n,i);

		cout <<  d[t][c] << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <map>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr int nx[4] = {1,0,-1,0};
constexpr int ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    Yes(s[2] == s[3] && s[4] == s[5]);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

struct UnionFind {
	UnionFind(int n) {
		par = new int[n + 1];
		size = new int[n + 1];
		height = new int[n + 1];
		for (int i = 0; i <= n; ++i) {
			par[i] = i;
			size[i] = 1;
			height[i] = 1;
		}
	}

	void unite(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b) return;
		if (height[a] < height[b]) {
			par[a] = b;
			size[b] += size[a];
		}
		else {
			par[b] = a;
			size[a] += size[b];
			if (height[a] == height[b]) {
				height[a]++;
			}
		}

	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	int getSize(int a) {
		return size[root(a)];
	}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int* size;
	int* height;
	int* par;
};

void dfs(UnionFind& uf, vector<vector<int>>& tree, int a, int b) {

}

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

	ll n,d,a; cin >> n >> d >> a;
	vector<pair<ll,ll>> xh(n);
	rep(i,n) cin >> xh[i].first >> xh[i].second;
	sort(all(xh));
	vector<ll> damage(n,0);
	ll r = 0, ans = 0;
	rep(l, n) {
		if (l-1 >= 0) damage[l] += damage[l - 1];

		ll atackN = xh[l].second + damage[l] <= 0 ? 0 : (xh[l].second + damage[l] + a - 1) / a;
	  ans += atackN;
	  damage[l] -= atackN*a;
		while (r < l) r++;
		while (r+1 < n && xh[r+1].first - xh[l].first <= 2*d ) {
			r++;
		}
		if(r+1 < n)damage[r+1] += atackN * a;
	}

	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <list>
#include <stack>
#include <set>
#include <cctype>
#include <cmath>

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

#define ll long long
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)


int main() {

	ll a, b;
	cin >> a >> b;

	if (b % a == 0) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;

	}
	

}


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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    int N;
    cin >> N;
    vector<int> num_cnt(100001);
    ll sum = 0;
    REP(i, N)
    {
        ll tmp;
        cin >> tmp;
        sum += tmp;
        num_cnt.at(tmp)++;
    }

    int Q;
    cin >> Q;

    vector<ll> ans(Q);
    REP(i, Q)
    {
        ll B, C;
        cin >> B >> C;

        int cnt = num_cnt.at(B);
        ll minus = cnt * B;
        ll plus = cnt * C;
        num_cnt.at(B) = 0;
        num_cnt.at(C) += cnt; 


        sum = sum - minus + plus;
        ans.at(i) = sum;
    }

    REP(i, Q)
    {
        cout << ans.at(i) << endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 4488
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
 int main()
 {
 	 int a,b;
 	 scanf("%d%d",&a,&b);
 	 if ( a + b < 10 )
	 {
	 	 printf("%d",a+b);
	 }
	 else printf("error");
		 return 0;
 }

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

int main()
{
    char a,b;
    cin >> a >> b;
    if(a == 'H'){
        if(b == 'H'){
            cout << "H" << endl;
            
        }
        else if(b == 'D'){
            cout << "D" << endl;
        }
    }
    else if(a == 'D'){
        if(b == 'H'){
            cout << "D" << endl;
            
        }
        else if(b == 'D'){
            cout << "H" << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  string s;
  cin>>n>>s;
  if(n&1){
    cout<<"No"<<'\n';
    return 0;
  }
  bool ok=true;
  REP(i, n/2){
    if(s[i]!=s[i+n/2]){
      ok=false;
      break;
    }
  }
  cout<<(ok ? "Yes" : "No")<<'\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	long long n,m,p,a[10003];
	while(~scanf("%lld %lld",&n,&m))
	{
	a[0]=n+m;
	a[1]=n-m;
	a[2]=n*m;
	sort(a,a+3);
	printf("%lld\n",a[2]);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    ll n,m;
    cin>>n>>m;
    ll x[100000];
    for(int i=0;i<m;i++) cin>>x[i];
    sort(x,x+m);
    ll d[100000];
    for(int i=0;i<m-1;i++){
        d[i]=x[i+1]-x[i];
    }
    sort(d,d+m-1);
    ll ans=0;
    for(int i=0;i<m-1-(n-1);i++){
        ans+=d[i];
    }
    cout<<ans<<endl;
}

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

int main()
{
	string x;

	while (1)
	{
		int all = 0;


		cin >> x;

		if (x == "0") return 0;

		for (int i = 0; i < x.length(); i++)
		{
			all += x[i] - '0';
		}
		cout << all << "\n";

	}
	return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int X = sc.nextInt();
		int A = sc.nextInt();

		if (X>=A) {
			System.out.println("10");

		} else {
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 21844
def resolve():
    '''
    code here
    '''
    from functools import lru_cache
    import sys
    sys.setrecursionlimit(10**6)

    N, M = [int(item) for item in input().split()]
    As = [int(input()) for _ in range(M)]
    memo = [False for _ in range(N+1)]

    for item in As:
        memo[item] = True

    res_list = []

    prev = 0
    for i in range(1,N+1):
        if memo[i] == True:
            res_list.append(i-1 - prev)
            prev = i+1
    else:
        if memo[N] == False and memo[N] == False:
            res_list.append(N - prev)

    @lru_cache
    def cal(num):
        if 0 <= num <= 1:
            return 1
        elif num == -1:
            return 0
        else:
            return cal(num-1) + cal(num-2)
    # print(res_list)
    res = 1
    for item in res_list:
        res *= cal(item)% (10**9 + 7)

    print(res % (10**9 + 7))



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 148432
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <cstring>

using namespace std;
#define int long long
const int mod = 1000000007;

char flag[1000][1000] = {};
int z[1000][1000][3] = {};
char base[2][2];
signed main()
{
	int ans = 0;
	int H, W; cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> flag[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> base[i][j];
		}
	}
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W - 1; j++) {
			int tmp = 0;
			int x, y;
			int m = 0;
			for (int k = 0; k < 2; k++) {
				for (int l = 0; l < 2; l++) {
					if (flag[i + k][j + l] == base[k][l]) {
						tmp++;
					}
					else {
						x = i + k; y = j + l;
						if (base[k][l] == 'J') m = 0;
						else if (base[k][l] == 'O') m = 1;
						else m = 2;
					}
				}
			}
			if (tmp == 4) {
				ans++;
			}
			else if (tmp == 3) z[x][y][m]++;
		}
	}
	int tmp = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k < 3; k++) {
				if (z[i][j] != 0) {
					tmp = max(tmp, z[i][j][k]);
				}
			}
		}
	}
	cout << ans+tmp << endl;
}

Measured memory_bytes: 27492
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", (a-1)*(b-1));
}


Measured memory_bytes: 256
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1e9+7;
ll fac[100001];
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}


int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k,c;
    cin>>n>>k;
    ll ar[n];
    forn(i,n)cin>>ar[i];
    sort(ar,ar+n,greater<ll>());
    if(k>=n){
        cout<<0;
        return 0;
    }
    ll ans=0;
    for(int i=k;i<n;i++){
        ans+=ar[i];

    }
    cout<<ans;

	return 0;
}


Measured memory_bytes: 1792
import sys, math
import numpy as np
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial

sys.setrecursionlimit(10**7)
N, K = map(int, input().split())
pss = list(map(int, input().split()))
ps = [(p+1)/2 for p in pss]

acc = [0] * N
acc[0] = sum(ps[:K])
for i in range(1, N-K+1):
    acc[i] = acc[i-1] - ps[i-1] + ps[i+K-1]

mi = np.argmax(acc)

print(sum(ps[mi:mi+K]))



Measured memory_bytes: 33844