akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for (long long i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

//pdfの疑似コードそのまま

int main(){
    ll h, w, k; cin >> h >> w >> k;
    char c[6][6];
    rep(i,h) rep(j,w) cin >> c[i][j];

    ll ans = 0;
    for(long long maskR = 0; maskR < (1 << h); maskR++){
        for(long long maskC = 0; maskC < (1 << w); maskC++){
            ll black = 0;
            for(long long i = 0; i < h; i++){
                for(long long j = 0; j < w; j++){
                    if(((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#'){
                        black++;
                    } 
                }
            }
            if (black == k) ans++;
        }
    }
    put(ans);

}

Measured memory_bytes: 3624
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
N,A,B,C=map(int,input().split())
S=[input() for i in range(N)]
idleA=10**20
idleB=10**10
idleC=1
stack=[[0,A,B,C]]
lst={}
dp=[defaultdict(str) for i in range(N+1)]
def main(a,b,c):
    return(a*idleA+b*idleB+c)

while stack:
    #print(stack)
    n,a,b,c=stack.pop()
    if n==N:
        stack.append([n,a,b,c])
        break
    s=S[n]
    if s=="AB":
        if a>0:
            Q=main(a-1,b+1,c)
            if not dp[n+1][Q]:
                dp[n+1][Q]="B"
                stack.append([n+1,a-1,b+1,c])
        if b>0:
            Q=main(a+1,b-1,c)
            if not dp[n+1][Q]:
                dp[n+1][Q]="A"
                stack.append([n+1,a+1,b-1,c])
    elif s=="BC":
        if b>0:
            Q=main(a,b-1,c+1)
            if not dp[n+1][Q]:
                dp[n+1][Q]="C"
                stack.append([n+1,a,b-1,c+1])
        if c>0:
            Q=main(a,b+1,c-1)
            if not dp[n+1][Q]:
                dp[n+1][Q]="B"
                stack.append([n+1,a,b+1,c-1])
    elif s=="AC":
        if a>0:
            Q=main(a-1,b,c+1)
            if not dp[n+1][Q]:
                dp[n+1][Q]="C"
                stack.append([n+1,a-1,b,c+1])
        if c>0:
            Q=main(a+1,b,c-1)
            if not dp[n+1][Q]:
                dp[n+1][Q]="A"
                stack.append([n+1,a+1,b,c-1])

if stack:
    print("Yes")
    lst=[]
    n,a,b,c=stack.pop()

    lst.append([dp[n][main(a,b,c)],a,b,c])
    #print(lst)
    for n in range(N-1)[::-1]:
        s=S[n+1]
        X,a,b,c=lst[-1]
        if s=="AB":
            if X=="A":
                Q=main(a-1,b+1,c)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a-1,b+1,c])
                    continue
            if X=="B":
                Q=main(a+1,b-1,c)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a+1,b-1,c])
                    continue
        elif s=="BC":
            if X=="B":
                Q=main(a,b-1,c+1)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a,b-1,c+1])
                    continue
            if X=="C":
                Q=main(a,b+1,c-1)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a,b+1,c-1])
                    continue
        elif s=="AC":
            if X=="A":
                Q=main(a-1,b,c+1)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a-1,b,c+1])
                    continue
            if X=="C":
                Q=main(a+1,b,c-1)
                if dp[n+1][Q]:
                    lst.append([dp[n+1][Q],a+1,b,c-1])
                    continue
        #print("a")
    for X,a,b,c in list(reversed(lst)):
        print(X)
else:
    print("No")


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

int main(){
  int n; cin >> n;
  vector<int> x(n);
 
  for(int i=0; i<n; i++){
    cin >> x.at(i);
  }
  
  vector<int> ans;
  
  for(int i=*min_element(x.begin(), x.end()); i<=*max_element(x.begin(), x.end()); i++){
    int sum = 0;
    for(int j=0; j<n; j++){
      sum += (x.at(j)-i)*(x.at(j)-i);
    }
    ans.push_back(sum);
  }
  cout << *min_element(ans.begin(), ans.end());
}

Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._
  val button = Array(" ", "',.!?", "abcABC", "defDEF", "ghiGHI", "jklJKL", "mnoMNO", "pqrsPQRS", "tuvTUV", "wxyzWXYZ")
  var line = readLine
  while(line != null){
    println(line.trim.map(_.asDigit).foldLeft(State()){case (s, b) ⇒ s.push(b)})
    line = readLine
  }
  case class State(input: List[Char] = Nil, prev: Option[(Int, Int)] = None) {
    def push(b: Int): State = {
      b match {
        case 0 ⇒
          prev match {
            case Some((0, _)) ⇒ State(' '::input, prev)
            case Some((c, i)) ⇒ State(button(c)(i % button(c).length)::input, Some((0, 0)))
            case _ ⇒ ???
          }
        case _ ⇒
          prev match {
            case Some((0, _)) ⇒ State(input, Some(b, 0))
            case Some((c, i)) if b == c⇒ State(input, Some(c, i + 1))
            case Some((c, i)) ⇒ State(button(c)(i % button(c).length)::input, Some(b, 0))
            case None ⇒ State(input, Some(b, 0))
          }
      }
    }

    override def toString: String = prev match {
      case Some((c, i)) ⇒ (button(c)(i % button(c).length)::input).reverse.mkString("")
      case None ⇒ input.reverse.mkString("")
    }
  }
}


Measured memory_bytes: 44048
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int H,W;
	while (1)
	{
		cin>>H>>W;
		if(H==0 && W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0 || i==H-1)
					cout<<"#";
				else{
					if(j==0 || j==W-1)
						cout<<"#";
					else
						cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <stack>
#include <string>
#include <cstdlib>
#include <iostream>

using namespace std;

int main(){
	stack<int> D;
	string S;
	while (cin >> S){
		if (S == "+" || S == "-" || S == "*") {
			int B = D.top();
			D.pop();
			int A = D.top();
			D.pop();
			if (S == "+")D.push(A + B);
			if (S == "-")D.push(A - B);
			if (S == "*")D.push(A * B);
		}
		else D.push(atoi(S.c_str()));
	}
	cout << D.top() << endl;
}


Measured memory_bytes: 3180
n, k, q = map(int, input().split())
A = []
for _ in range(q):
    a = int(input())
    A.append(a)
    
p = [k-q]*n
for i in range(len(A)):
    val = A[i]-1
    p[val] += 1

for l in range(len(p)):
    if p[l] > 0:
        print('Yes')
    elif p[l] <= 0:
        print('No')

Measured memory_bytes: 10436
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

int main()

{
    int n,k,i,j;
    scanf("%d %d",&n,&k);
    int num[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
    }
    int swap;
    for(i=0;i<n;i++)
    {
        for(j=0;j<i;j++)
        {
            if(num[i]<num[j])
            {
                swap=num[i];
                num[i]=num[j];
                num[j]=swap;
            }
        }
    }
    int sum=0;
    for(i=0;i<k;i++)
    {
        sum=sum+num[i];
    }
    printf("%d\n",sum);


    return 0;
}


/*
presented by codeRumi
thanks for watching & being here,thank me later... :)
*/



Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr lint mod = 998244353;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }
inline lint powm(lint a, lint n, lint p = mod) { return !n ? 1 : powm(a * a % p, n >> 1, p) * (n & 1 ? a : 1) % p; }

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  if (n < 10) {
    set<string> vis;
    queue<string> que;
    vis.insert(s); que.push(s);
    while (!que.empty()) {
      string t = que.front(); que.pop();
      for (int i = 0; i < n - 1; ++i) if (t[i] != t[i + 1]) {
        string u = t;
        u[i] = u[i + 1] = 'a' + 3 - (t[i] - 'a') - (t[i + 1] - 'a');
        if (vis.count(u)) continue;
        vis.insert(u); que.push(u);
      }
    }
    cout << vis.size() << '\n';
  } else {
    int r = 0;
    for (char c : s) r += c - 'a';
    r %= 3;
    VV< V<lint> > dp; assign(dp, n + 1, 3, 3);
    for (int i = 0; i < 3; ++i) dp[1][i][i] = 1;
    for (int i = 1; i < n; ++i) for (int j = 0; j < 3; ++j) for (int k = 0; k < 3; ++k) {
      (dp[i + 1][(j + k + 1) % 3][(k + 1) % 3] += dp[i][j][k]) %= mod;
      (dp[i + 1][(j + k + 2) % 3][(k + 2) % 3] += dp[i][j][k]) %= mod;
    }
    lint res = powm(3, n - 1) - accumulate(begin(dp[n][r]), end(dp[n][r]), 0LL);
    if (all_of(begin(s), end(s), [&](char c) { return c == s[0]; })) return cout << 1 << '\n', 0;
    if (adjacent_find(begin(s), end(s)) == end(s)) ++res;
    cout << emod(res) << '\n';
  }
}

Measured memory_bytes: 39572
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>

using namespace std;

int main() {
	string sq, t;
	cin >> sq;
	cin >> t;
	
	bool allcheck = false;
	
	for(int i = (int)(sq.length() - t.length()); i >= 0; --i) {
		bool check = true;
		
		for(int j = 0; j < (int)t.length(); ++j) {
			if (sq[i + j] != t[j] && sq[i + j] != '?') {
				// printf("sq: %c, t: %c\n", sq[i+j], t[j]);
				check = false;
				break;
			}
		}
		
		if (check) {
			for(int j = 0; j < (int)t.length(); ++j) {
				sq[i + j] = t[j];
			}
			allcheck = true;
			break;
		}
	}
	
	if(allcheck) {
		for(auto x : sq) {
			if(x == '?') {
				cout << 'a';
			} else {
				cout << x;
			}
		}
		cout << endl;
	} else {
		cout << "UNRESTORABLE" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
r, c = map(int, input().split())
rc = [list(map(int,input().split())) for _ in range(r)]
for i in range(r):
    rc[i].append(sum(rc[i]))
sum_cs = []

for j in range (len(rc[0])):
    sum_c = 0
    for i in range(len(rc)):
        sum_c = sum_c + rc[i][j]
    sum_cs.append(sum_c)
rc.append(sum_cs)
for i in range(len(rc)):
    for j in range(len(rc[0])):
        print(rc[i][j],end = "")
        if j != len(rc[0])-1:
            print(" ",end = "")
        else:
            print("")


Measured memory_bytes: 6752
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

d = defaultdict(list)
cnt = 0
for i, a in enumerate(A):
    if i+1 in d[a]:
        cnt += 1
    d[i+1].append(a)


print(cnt)



Measured memory_bytes: 28836
def all_lightsup(A, switches, k, p):
    for i in range(M):
        light = 0
        elements = k[i]
        for j in range(elements):
            if A[switches[i][j]-1] == 1:
                light += 1
        if light % 2 != p[i]:
            return False
    return True

N, M = map(int,input().split())
switches = []
k = []
ans = 0
for i in range(M):
    temp = list(map(int,input().split()))
    k.append(temp[0])
    switches.append(temp[1:])
p = list(map(int,input().split()))

num_of_state = 2**N
for i in range(num_of_state):
    val = i
    temp = []
    for j in range(N):
        temp.append(val%2)
        val //= 2
    if all_lightsup(temp, switches, k, p):
        ans += 1
print(str(ans))

Measured memory_bytes: 44396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] ans = new int[n];

		for (int i = 0; i < n; i++) {
			ans[i] = k - q;
		}

		for (int i = 0; i < q; i++) {
			ans[sc.nextInt() - 1]++;
		}

		for (int i : ans) {
			System.out.println((i > 0) ? "Yes" : "No");
		}

	}
}

Measured memory_bytes: 55316
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

int N, K; ll A[1010];
ll sm[1010];

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

    cin >> N >> K;
    rep(i, N) cin >> A[i];

    sm[0] = A[0];
    rep1(i, N - 1) sm[i] = sm[i - 1] + A[i];

    vector<ll> v;
    rep(l, N) reps(r, l, N) {
        ll tot = sm[r];
        if (l) tot -= sm[l - 1];
        v.push_back(tot);
    }
    int n = v.size();
    vector<int> ok(n, 1);

    ll ans = 0;
    per(d, 60) {
        ll msk = 1LL << d;
        int cnt = 0;
        rep(i, n) if (v[i] & msk and ok[i]) cnt++;
        if (K <= cnt) {
            ans += msk;
            rep(i, n) if (!(v[i] & msk) and ok[i]) ok[i] = 0;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	long double r; cin>>r;
	cout<<r*2*PI<<endl;

	return 0;
}


Measured memory_bytes: 3812
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, i, j, k;
	int c[500], s[500], f[500];
	scanf("%d", &n);
	for(i=0; i<n-1; i++){
		scanf("%d%d%d", c+i, s+i, f+i);
	}
	for(i=0; i<n; i++){
		int t=0;
		for(j=i; j<n-1; j++){
			int T=(t<=s[j]?s[j]:((t-1)/f[j]+1)*f[j]);
			t=T+c[j];
		}
		printf("%d\n", t);
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define int long long
#define maxn 200001
#define mod 1312344234139
using namespace std;
inline ll read(){
    reg ll s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
 
ll prime[maxn], is_prime[maxn], a[maxn], b[maxn], c[maxn], f[maxn], ans, maxx = 10000, cnt, n;
map<ll, ll> mp, d;
signed main(){
    n = read();
    for(int i = 1; i <= n; i++) a[i] = read();
    for(int i = 2; i <= maxx; i++){
        if(!is_prime[i]) prime[++cnt] = i;
        for(int j = 1; j <= cnt && prime[j] * i <= n; j++){
            is_prime[i * prime[j]]  = 1;
            if(i % prime[j] == 0) break;
        } 
    }
    for(int i = 1; i <= n; i++) c[i] = 1, b[i] = 1;
    for(int i = 1; i <= cnt; i++){
        ll t = prime[i] * prime[i] * prime[i];
        for(int j = 1; j <= n; j++) {
        while(a[j] % t == 0) a[j] = a[j] / t;
        }
    }
    for(int i = 1; i <= n; i++) mp[a[i]]++, f[i] = a[i];
    for(int i = 1; i <= cnt; i++){
        ll t = prime[i] * prime[i]; 
        for(int j = 1; j <= n; j++){
            if(a[j] % t == 0)  a[j] = a[j] / t, b[j] = b[j] * t;
            else if(a[j] % prime[i] == 0) a[j] = a[j] / prime[i], c[j] = c[j] * prime[i];
        }
    }
    for(int i = 1; i <= n; i++) {
        if((ll)sqrt(a[i]) * (ll)sqrt(a[i]) == a[i]) b[i] = b[i] * a[i];
        else c[i] = c[i] * a[i]; 
    }
    for(int i = 1; i <= n; i++){
        a[i] = c[i] * c[i] % mod * (ll)sqrt(b[i]) % mod;
        if(d[a[i]] == 0 && d[f[i]] == 0){
          if(a[i] != 1)   ans += max(mp[f[i]], mp[a[i]]);
          else ans++;
        }
        d[a[i]] = 1;
    }   
    cout << ans << endl;
}

Measured memory_bytes: 32640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;



int main(){
	string s;
	cin >> s;
	if ( 'A' <= s[0] && s[0] <= 'Z' )
		cout << "A" << endl;
	else
		cout << "a" << endl;
	
	return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define int long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int pallindr(string s, int i, int j)
{
	while (i <= j)
	{
		if (s[i] != s[j])
			return 0;
		i++;
		j--;
	}
	return 1;
}
int dp[1001][1001];
int pallindrome_partitioning(string s, int i, int j)
{
	if (i >= j)
		return 0;
	if (pallindr(s, i, j))
	{
		return dp[i][j] = 0;

	}

	if (dp[i][j] != -1)
		return dp[i][j];

	int ans = INT_MAX;
	for (int k = i; k < j; k++)
	{
		int left, right;
		if (dp[i][k] != -1)
			left = dp[i][k];
		else
		{
			left = pallindrome_partitioning(s, i, k);
			dp[i][k] = left;
		}

		if (dp[k + 1][j] != -1)
			right = dp[k + 1][j];
		else
		{
			right = pallindrome_partitioning(s, k + 1, j);
			dp[k + 1][j] = right;
		}

		int xx = left + right + 1;
		ans = min(ans, xx);
	}
	return dp[i][j] = ans;


}

int32_t main()
{
	std::ios::sync_with_stdio(false);

	int n, m, k;
	cin >> n >> m >> k;

	if (n / k <= m && n % k == 0)
		cout << "Yes" << endl;
	else if (n / k + 1 <= m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3652
def main():
    h, w = map(int, input().split())
    grid = [["." for _ in range(w + 2)]]
    for _ in range(h):
        grid.append(["."] + list(input()) + ["."])
    grid.append(grid[0])
    answer = [["0" for _ in range(w)] for _ in range(h)]
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            now_ans = 0
            if grid[i][j] == ".":
                for k in range(-1, 2):
                    now_ans += ("".join(grid[i + k][j - 1:j + 2])).count("#")
                answer[i - 1][j - 1] = str(now_ans)
            else:
                answer[i - 1][j - 1] = "#"
    for ans in answer:
        print("".join(ans))


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
#include <iostream>
#include <string>

using namespace std;

int main(){

string s;
string t;
  
  cin >> s;
  
  switch(s[0]){
    case 'A': t="T"; 
      break;
    case 'T': t="A"; 
      break;
    case 'C': t="G"; 
      break;
    case 'G': t="C"; 
      break;
  }
  
  cout << t << endl;
  



}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define fi first
#define se second
using namespace std;

const int N = 100005, M = 100005;

int n, m, a[N];
pair<int, int> rep[M];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++)
        cin >> rep[i].se >> rep[i].fi;
    sort(a + 1, a + n + 1);
    sort(rep + 1, rep + m + 1, greater<pair<int, int>>());
    for (int i = 1, pt = 1; i <= m && pt <= n; i++)
        while (rep[i].se--)
            if (pt > n || a[pt] >= rep[i].fi)
            {
                pt = n + 1;
                break;
            }
            else
                a[pt++] = rep[i].fi;
    long long su = 0;
    for (int i = 1; i <= n; i++)
        su += a[i];
    cout << su;
}


Measured memory_bytes: 1408
using System;

namespace The_Number_of_Area
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                int n = int.Parse(input);
                int sum = 4;
                if (n == 1) Console.WriteLine(2);
                else if (n == 2) Console.WriteLine(sum);
                else if (n >= 3)
                {
                    for (int i = 3; i <= n; ++i)
                    {
                        sum += i;
                    }
                    Console.WriteLine(sum);
                }
            }
        }
    }
}



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

int main()
{
    int N, ans = 0; 
    cin >> N;
    vector<int> A(N), B(N - 1);
    for(int i = 0; i < N - 1; i++)
    {
        cin >> B.at(i);
    }
    for(int i = 0; i < N; i++)
    {
        if(i == 0) A.at(i) = B.at(i); 
        else if (i == N - 1) A.at(i) = B.at(i - 1);
        else A.at(i) = min(B.at(i), B.at(i - 1));
    }
     for(int i = 0; i < N; i++)
    {
        ans += A.at(i);
    }
    cout << ans << endl;
    return 0;
}

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

#define task "D"
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define pb push_back
#define F first
#define S second

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;

// Variables
const ll mod=1e9+7;
string s;
int du[100004];
ll dp[100004][13];
//
// Function

//

int main()
{
	//freopen(task".in","r",stdin);
	//freopen(task".out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	cin >> s;
	int n=s.size();
	du[0]=1;
	rep(i,1,n) du[i]=(du[i-1]%13*10)%13;
	//rep(i,1,n) cout << du[i] << ' ';
	//cout << '\n';
	s='='+s;
	if (s[1]=='?') rep(i,0,9) {dp[1][i*du[n-1]%13]=1;}
	else dp[1][(s[1]-'0')*du[n-1]%13]=1;
	//cout << (s[1]-'0')*du[n-1]%13 << '\n';
	/*if (s[n]!='?')
    {
        if (s[n]>='5') s[n]-=5;
        else s[n]+=5;
    }*/
    //cout << s[n] << '\n';
	rep(i,2,n)
	{
	    rep(j,0,12)
	    {
	        if (s[i]=='?')
            {
                rep(k,0,9)
                {
                    dp[i][(j+(k*du[n-i])%13)%13]=(dp[i][(j+(k*du[n-i])%13)%13]+dp[i-1][j])%mod;
                    //cout << j << ' ' << k << ' ' << dp[i][(j+(k*du[n-i])%13)%13] << '\n';
                }
            } else
            {
                dp[i][(j+(((s[i]-'0')*du[n-i])%13))%13]=(dp[i][(j+((s[i]-'0')*du[n-i])%13)%13]+dp[i-1][j])%mod;
                //cout << "j : " << j << ". " << dp[i][j+(((s[i]-'0')*du[n-i])%13)%13] << '\n';
                //cout << j+(((s[i]-'0')*du[n-i])%13)%13 << '\n';
            }
	    }
	}
	/*rep(j,0,12)
    {
	        if (s[n]=='?')
            {
                rep(k,0,9)
                {
                    dp[n][(j+k+8)%13]=(dp[n][(j+k+8)%13]+dp[n-1][j])%mod;
                }
            } else dp[n][(j+s[n]-'0'+8)%13]=(dp[n][(j+s[n]-'0'+8)%13]+dp[n-1][j])%mod;
    }*/
    cout << dp[n][5];
}






Measured memory_bytes: 11008
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int[] am = new int[32];
        int n,i,w,a,b,t;
        String st;
        String[] x;
        w = s.nextInt();
        n = s.nextInt();
        for(i=1;i<=w;i++)am[i]=i;
        for(i=1;i<=n;i++){
            st = s.next();
            x = st.split(",");
            a = Integer.parseInt(x[0]);
            b = Integer.parseInt(x[1]);
            t = am[a];
            am[a] = am[b];
            am[b] = t;
        }
        for(i=1;i<=w;i++)System.out.println(am[i]);
    }
}


Measured memory_bytes: 26232
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
const int MAXN = 100 + 10;

int n;
int x[MAXN], y[MAXN];
namespace solver1 {
  typedef long long LL;
  struct Point {
    long long x, y;
    int id;
  }p[MAXN];
  long long cross(Point a, Point b, Point c) {
    return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
  }
  
  bool cmpx(Point a, Point b) {
    return a.x < b.x || (a.x == b.x && a.y < b.y);
  }
  Point seq[MAXN << 1];
  void main() {
    if (n == 2) {
      printf("0.5\n0.5\n");
      return;
    }
    for (int i = 1; i <= n; i++) p[i] = {x[i], y[i], i};
    std::sort(p + 1, p + n + 1, cmpx);
    int top = 1;
    seq[1] = p[1];
    for (int i = 2; i <= n; i++) {
      while(top > 1 && cross(seq[top - 1], seq[top], p[i]) < 0) top--;
      seq[++top] = p[i];
    }
    int cur = top;
    for (int i = n - 1; i >= 1; i--) {
      while(top > cur && cross(seq[top - 1], seq[top], p[i]) < 0) top--;
      seq[++top] = p[i];
    }
    static double ang[MAXN];
    for (int i = 1; i < top; i++) {
      ang[i] = atan2(-(seq[i + 1].x - seq[i].x), seq[i + 1].y - seq[i].y);
    }
    static double ans[MAXN];
    const double PI = acos(-1);
    ang[0] = ang[top - 1] - 2 * PI;
    for (int i = 1; i < top; i++) {
      
      ans[seq[i].id] = (ang[i] - ang[i - 1]) / 2 / PI;
    }
    for (int i = 1; i <= n; i++) {
      printf("%.12lf\n", ans[i]);
    }
  }
    
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &x[i], &y[i]);
  solver1::main();
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
inline void Rd(int &res){
	char c;res=0;
	while(c=getchar(),c<'0');
	do{
		res=(res<<1)+(res<<3)+(c^48);
	}while(c=getchar(),c>='0');
}
const int M=(int)2e5+5;
int n,m;
int A[M];
ll add[M],val[M],V[M];
int dist(int a,int b){
	if(b>=a)return b-a;
	else return b+m-a;
}
void Add(int x,int v){
	if(!v)return;
	int l=x-(v-1);
	if(l<=0)l+=m,x+=m;
	add[l]++;
	add[x+1]--;
	val[x+1]-=v;
}
int main(){
	Rd(n),Rd(m);
	for(int i=1;i<=n;i++)Rd(A[i]);
	for(int i=2;i<=n;i++){
		int d=dist(A[i-1],A[i])-1;
		//+1 +2 +3 +4...+d
		Add(A[i],d);
	}
	ll a=0,v=0;
	for(int i=1;i<=m*2;i++){
		a+=add[i];
		v+=val[i];
		v+=a;
		V[i]=v;
	}
	for(int i=1;i<=m;i++)
		V[i]+=V[i+m];
	int pos;ll mx=-1;
	for(int i=1;i<=m;i++)
		if(V[i]>mx)mx=V[i],pos=i;
	ll ans=0;
	for(int i=2;i<=n;i++)
		ans+=min(dist(pos,A[i])+1,dist(A[i-1],A[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
N = int(input())
dic = {}
for i in range(N):
  a = int(input())
  dic[i+1] = a
counter = 0
place = 1
while place != 2:
  if dic[place] in dic and dic[place] != place:
    temp = dic[place]
    dic.pop(place)
    place = temp
    counter += 1
  else:
    counter = -1
    break
print(counter)

Measured memory_bytes: 17892
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  rep(i,5)
  {
    ll x;
    cin>>x;
    if(x==0) {cout<<i+1<<endl; return 0;}
  }  
  return 0;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int K;
int main(){
  int i;
  int res = 0;
  rd(N);
  rd(K);
  for(i=(0);i<(N);i++){
    if(K <= rd_int()){
      res++;
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190928-1

// --- original code ---
// int N, K;
// {
//   int res = 0;
//   rd(N,K);
//   rep(i,N) if(K <= rd_int()) res++;
//   wt(res);
// }


Measured memory_bytes: 256
//Code by Mukul Totla
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool check(int temp[], int a[], int n)
{
  int i;
  for(i=0; i<n; i++)
  {
    //cout<<temp[i]<<" "<<a[i]<<'\n';
    if(temp[i]!=a[i])
      return false;
  }
  return true;
}
int main()
{   
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,i;
  cin>>n;
  int a[n], b[n];
  int temp[n];
  for(i=0; i<n; i++)
    temp[i]=i+1;

  for(i=0; i<n; i++)
    cin>>a[i];

  for(i=0; i<n; i++)
    cin>>b[i];

  int cnt1=0,cnt2=0;
  bool chk;
  while(1)
  {
    cnt1++;
    chk=check(temp,a,n);
    if(chk==true)
      break;
    else
      next_permutation(temp,temp+n);
  }

  //cout<<cnt1;

  for(i=0; i<n; i++)
    temp[i]=i+1;

  while(1)
  {
    cnt2++;
    chk=check(temp,b,n);
    if(chk==true)
      break;
    else
      next_permutation(temp,temp+n);
  }
  int ans=abs(cnt1-cnt2);
  cout<<ans;

  return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
#include<random>
 
using namespace std;

int partition(vector<int>::iterator b, vector<int>::iterator e) {
	int i{ 1 };
	int j{ e - b - 1 };
	int x = *b;
	while (true) {
		while (b[i] <= x && i<j) i++;
		while (b[j] > x) j--;
		if (j <= i) break;
		swap(b[i], b[j]);
	}
	swap(b[0], b[j]);
	return j;
}


int select(vector<int>::iterator b, vector<int>::iterator e,int i) {
    int mine = *min_element(b, e);
	int maxe = *max_element(b, e);
	if (i == 0||mine== maxe) return mine;
	if (i == e - b - 1) return maxe;
	int j = partition(b, e);
	if (i == j) return b[j];
	if (i < j) return select(b, b + j, i);
	if (i > j) return select(b + j + 1, e, i - j - 1);
}




int main() {	
	int n;
	cin >> n;
	vector<int> a;
	int k;
	for (int i = 1; i <= n; i++) {
		cin >> k;
		a.push_back(k - i);
	}
	mt19937 get_rand_mt;
    shuffle( a.begin(), a.end(), get_rand_mt );
	int med = select(a.begin(), a.end(), n / 2);
	long long ans{ 0 };
	for (auto e : a) {
		ans += abs(e - med);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
/*
* @Author: WZY
* @School: HPU
* @Date:   2018-10-13 20:01:51
* @Last Modified by:   WZY
* @Last Modified time: 2018-10-13 21:21:42
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <string>
#include <time.h>
#define ll long long
#define ull unsigned long long
#define ms(a,b) memset(a,b,sizeof(a))
#define pi acos(-1.0)
#define INF 0x7f7f7f7f
#define lson o<<1
#define rson o<<1|1
#define bug cout<<"---------"<<endl
#define debug(...) cerr<<"["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"<<"\n"
const double E=exp(1);
const int maxn=1e6+10;
const int mod=1e9+7;
using namespace std;
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	ll n,m;
	while(cin>>n>>m)
	{
		ll lcm=n/__gcd(n,m)*m;
		map<ll,char>mp;
		string ch1,ch2;
		cin>>ch1>>ch2;
		if(ch1[0]!=ch2[0])
		{
			cout<<-1<<endl;
			continue;
		}
		int flag=0;
		for(int i=1;i<n;i++)
			mp[(lcm/n)*i+1]=ch1[i];
		for(int i=1;i<m;i++)
		{
			if(mp[(lcm/m*i)+1])
			{
				if(mp[(lcm/m*i)+1]!=ch2[i])
				{
					flag++;
					break;
				}
			}
		}
		if(flag)
			cout<<-1<<endl;
		else
			cout<<lcm<<endl;
	}
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
signed main() {
    int a,n,m;cin>>a>>n>>m;
    //x=(sum(x)+a)^n x<=m
    int ans=0;
    for(int i=1;;i++){
        int now=1;
        rep(j,n)now*=i;
        if(now>m)break;
        if(sum(now)+a==i)ans++;
    }
    cout<<ans<<endl;
    
}



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

using namespace std;


void solve() {
    int n,k;
    cin >> n >> k;
    long long res = 0;
    for (int b = k+1; b <= n; b++) {
        res += 1ll*(b-k) * (n/b);
        int a = n%b;
        res += a>=k? a-k+1:0;
        res -= (k==0)?1:0;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
#define repe(i, a, n) for(int i=(a);i<(int)(n);i++)
#define repi(i, a, n) for(int i=(a);i<=(int)(n);i++)
int main() {
	int n;
	cin >> n;
	vector<int>a(n + 2);
	rep(i, n)cin >> a[i + 1];
	a[0] = 0;
	a[n + 1] = 0;
	int m = a.size();
	ll sum = 0;
	rep(i, m - 1)sum += abs(a[i + 1] - a[i]);

	repe(i, 1, m - 1) {
		int sumi = sum - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]);
		ll ans = sumi;
		cout << ans << endl;
	}

	return 0;
}





Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int N; cin >> N;
  set<string> s;
  while(N--){
	string q, str;
	cin >> q >> str;
	if(q == "insert"){
	  s.insert(str);
	}
	else{
	  if(s.count(str))
		cout << "yes" << endl;
	  else
		cout << "no" << endl;
	}
  }
  
  return 0;
}

Measured memory_bytes: 27056
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include <functional>

using namespace std;
int a,b,c;
int main() {
	cin >> a >> b >> c ;
	int i = 1;
	string s;
	while (true) {
		if (i*a%b == c) {
			s = "YES";
			break;
		}
		else if (i > 10000) {
			s = "NO";
			break;
		}
		i++;
	}
	cout << s << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	string s;
  	cin>>s;
  	int z=0,o=0;
  	for(int i=0;i<s.length();i++)
    {
    	if(s[i]=='0')
          z++;
      	else
          o++;
    }
  	cout<<min(z,o)*2;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

		String string = sc.nextLine();
		String[] a = string.split(" ");

		Poppin poppin = new Poppin(1000);

		for (int i = 0; i < a.length; i++) {

			if (a[i].equals("+")) {
				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p + q);
				continue;

			}
			if (a[i].equals("-")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(q - p);
				continue;
			}
			if (a[i].equals("*")) {

				int p = poppin.pop();
				int q = poppin.pop();
				poppin.add(p * q);
				continue;
			}

			int n = Integer.parseInt(a[i]);
			poppin.add(n);

		}

		System.out.println(poppin.pop());

	}

}

class Poppin {
	int top = 0;
	int[] a;

	public Poppin(int n) {
		a = new int[n];
	}

	void add(int x) {
		top++;
		a[top] = x;

	}

	int pop() {
		int x = a[top];
		top--;
		return x;
	}
}

Measured memory_bytes: 26304
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#define ll long long
using namespace std;

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  if (c - a - b >= 0 && (c - a - b) * (c - a - b) - 4 * a * b > 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#define MAX 1000
#define BIG_NUM 1000000007
using namespace std;


int M;	//number of rows
int N;	//number of columns
int dp[MAX][MAX];
string table[MAX];

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

	memset(dp,0,sizeof(dp));

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

	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(table[i][j]=='.'){
				if(i==0 && j==0)
					dp[i][j]=1;
				else if(i==0)
					dp[i][j]=dp[i][j-1];
				else if(j==0)
					dp[i][j]=dp[i-1][j];
				else
					dp[i][j]=(dp[i-1][j]+dp[i][j-1])%BIG_NUM;
			}
		}
	}
	cout<<dp[N-1][M-1]<<endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
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; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int a,b,c; cin >> a >> b >> c;
  cout << max(c-(a-b),0) << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int N;
  cin >> N;
  vll A(N, 0), M(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int j = 0; j < N; j++) {
    int k = j % N;
    if (j % 2 == 0) {
      M[0] += A[k];
    } else {
      M[0] -= A[k];
    }
  }
  cout << M[0] << ' ';
  for (int i = 1; i < N; i++) {
    M[i] = 2 * A[i - 1] - M[i - 1];
    cout << M[i] << ' ';
  }
  cout << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 2944
import math

n = int(input())
s = input()
ex = 0

for i in range(n-2):
  for x in range(1, int(math.ceil((n-i)/2))):
    if s[i] != s[i+x] and s[i] != s[i+2*x] and s[i+x] != s[i+2*x]:
      ex += 1

print(s.count("R") * s.count("G") * s.count("B")-ex)

Measured memory_bytes: 9200
N = int(input())
A_list = list(map(int, input().split()))

ans = 1

for i in A_list:
    if i == 0:
        ans = 0

if ans != 0:
    for i in A_list:
        ans = ans * i
        if ans > 10 ** 18:
            ans = -1
            break

print(ans)

Measured memory_bytes: 21648
#include <bits/stdc++.h>
using namespace std;
int main(){
int a[7], sum1 = 0,sum2 = 0;
int n = 5;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    sum1 += a[i];
    sum2 += i;
  }
  cout << sum2 - sum1;
}

Measured memory_bytes: 3624
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int N;
  cin >> N;
  vi ans(N + 1);
  rep(x, 1, 101) {
    rep(y, 1, 101) {
      rep(z, 1, 101) {
        int t = x * x + y * y + z * z + x * y + y * z + z * x;
        if (t <= N) {
          ans[t]++;
        }
      }
    }
  }
  rep(i, 1, N + 1) { cout << ans[i] << endl; }
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3580
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>













const int N=1e4+10,N2=110;
int n,s[N2],res;
bool dp[N2][N+10];


void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=0;i<=N;i++)dp[0][i]=0;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=N;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j>=s[i])dp[i][j]|=dp[i-1][j-s[i]];
		}
	}
	res=0;
	for(int i=0;i<=N;i++)
	{
		if(i%10>0&&dp[n][i])res=i;
	}
	cout<<res<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 1280
def main():
    import sys
    input = sys.stdin.readline
    
    R,C,N = map(int,input().split())
    P = []
    X = {0,R}
    Y = {0,C}
    M = 0
    for i in range(N):
        x1,y1,x2,y2 = map(int,input().split())
        if (x1 in X or y1 in Y) and  (x2 in X or y2 in Y):
            if y1==0:
                L1 = x1
            elif x1==R:
                L1 = R+y1
            elif y1==C:
                L1 = 2*R + C - x1
            else:
                L1 = 2*(R+C) - y1
            
            if y2==0:
                L2 = x2
            elif x2==R:
                L2 = R+y2
            elif y2==C:
                L2 = 2*R + C - x2
            else:
                L2 = 2*(R+C) - y2
                
            P.append([min(L1,L2), max(L1,L2)])
    P = sorted(P, key = lambda a:a[0])
    M = len(P)
    
    flag = 0
    Q = []
    for i in range(M):
        x1,x2 = P[i]
        if Q == []:
            Q.append([x1,x2])
        else:
            while Q!=[] and Q[-1][1] < x1:
                Q.pop()
            if Q==[]:
                Q.append([x1,x2])
            else:
                y1,y2 = Q[-1]
                if y2 < x2:
                    flag = 1
                    break
                else:
                    Q.append([x1,x2])
    if flag == 1:
        print("NO")
    else:
        print("YES")
    
main()

Measured memory_bytes: 74844
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public class Main{

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int V = in.nextInt();
		int E = in.nextInt();
		int r = in.nextInt();
		
		lEdge = new List[V];
		for (int i=0;i<V;i++) {
			lEdge[i] = new ArrayList<P>();
		}
		for (int i=0;i<E;i++) {
			lEdge[in.nextInt()].add(new P(in.nextInt(), in.nextDouble()));
		}
		dist = new double[V];
		Arrays.fill(dist, Double.MAX_VALUE);
		
		if(bellmanFord(r)) {
			System.out.println("NEGATIVE CYCLE");
		} else {
			for (int i=0;i<dist.length;i++) {
				System.out.println(dist[i]==Double.MAX_VALUE ? "INF" : (int)dist[i]);
			}
		}
	}

	static List<P>[] lEdge;
	static double[] dist;

	static boolean bellmanFord(int s) { // s is start
		dist[s] = 0.0;
		int nLoop = 0;
		while (true) {
			boolean bUpdate = false;
			for (int i=0;i<lEdge.length;i++) {
				int from = i;
				if (dist[from]==Double.MAX_VALUE) continue;
				for (P p : lEdge[i]) {
					int to = p.index;
					if (dist[to] > dist[from] + p.length) {
						dist[to] = dist[from] + p.length;
						bUpdate = true;
					}
				}
			}
			if (bUpdate && nLoop==lEdge.length) return true; // has negative loop
			nLoop++;
			if (!bUpdate) break;
		}
		return false; // has no negative loop
	}

	static class P implements Comparable<P> {
		int index; double length;
		public P(int index, double length) {this.index = index; this.length = length;}
		public int compareTo(P p) {return this.length < p.length ? -1 : this.length == p.length ? 0 : 1;}
		public String toString() {return index+","+length;}
	}
}

Measured memory_bytes: 60400