akhauriyash/Code-Regression huggingface dataset:
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = nextIntArray();
	for(var i = N - 1; i > 0; i--){
		if(list[i - 1] > list[i]){
			list[i - 1]--;
			if(list[i - 1] > list[i]){
				myout("No");
				return;
			}
		}
	}
	myout("Yes");
}


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

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

	if (S.at(0) != S.at(1) || S.at(1) != S.at(2) || S.at(0) != S.at(2)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//L0=2,L1=1,Li=Li-1+Li-2
main() {
  int a;
  cin >> a;
  long long A[a];
  A[0]=2;
  A[1]=1;
  for(int i=2; i<=a; i++) {
    A[i]=A[i-1]+A[i-2];
  }
  cout << A[a] <<endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

count = 0
max = 0

for i in range(N-1):
    if(H[i] >= H[i+1]):
        count += 1
    else:
        if(max < count):
            max = count
        count = 0
if(max < count):
    max = count
print(max)


Measured memory_bytes: 14252
#include "iostream"
#include <algorithm>

using namespace std;

void CountingSort(int A[],int B[],int k){
  int C[2000000];
  for (int i = 0; i < k; i++) {
    C[i] = 0;
    for(int j = 1;j<k;j++){
      C[A[j]]++;
    }
    for(int j = k;j<1;j--){
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
  }
}

int main(){
  int A[2000000],B[2000000];
  int n;
  int cnt = 0;
  cin >> n;
  for (int i=0; i < n; i++) {
    cin >> A[i];
  }
    for (int i=0; i < n; i++) {
    B[i] = A[i];
    cnt++;
  }
CountingSort(A,B,n);
sort(B,B+cnt);
cout << B[0];
  for (int i=1; i < n; i++) {
    cout << " ";
cout << B[i];
}
cout << endl;
return 0;
}



Measured memory_bytes: 18712
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    int a = abs(A1-A2);
    int b = abs(A2-A3);
    int c = abs(A3-A1);

    int x = min(a+b,min(b+c,c+a));

    cout << x << endl;



	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int d[N];
    for(int n=0; n<N; n++){
        cin >> d[n];
    }
    sort(d,d+N);
    int small = d[N/2-1];
    int big = d[N/2];
    int res = big-small;
    cout << res << endl;
}


Measured memory_bytes: 640
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

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

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

	int ans = 0;
	rep(i, b) {
		if (((a * i) - i + 1 >= b)) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();

		if(op.equals("+")){
			System.out.println(a + b);
		} else {
			System.out.println(a - b);
		}
	}
}



Measured memory_bytes: 23764
import sys
import random
test = False

def solve(c_list, days, now):
    r = sum(c_list[i]*(now-days[i]) for i in range(26))
    return r


if test == True:
    seed = 24
    random.seed(seed)
    d = 365
    c = [random.randrange(0, 101) for _ in range(26)]
    s = [[random.randrange(0, 20001) for _ in range(26)] for _ in range(d)]
    c_ = ' '.join(map(str, c))
    s_ = '\n'.join([' '.join(map(str, i)) for i in s])
    with open('./input.txt', 'w') as f:
        f.write('\n'.join([str(d), c_, s_]))
else:
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _i in range(d)]


last_days = [-1 for _i in range(26)]
result = []
score = 0
for today in range(d):
    checker = [s[today][j]-c[j]*(today-last_days[j]) for j in range(26)]
    x = checker.index(max(checker))
    x = s[today].index(max(s[today]))
    last_days[x] = today
    result.append(x+1)
    #score += s[today][x] - solve(c, last_days, today)
#print(score)


if test == True:
    with open('./output.txt', 'w') as f:
        f.write('\n'.join(map(str, result)))
else:
    for i in result:
        print(i)

Measured memory_bytes: 83240
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>

constexpr int Inf = std::numeric_limits<int>::max();

class SegTree {
public:
	explicit SegTree(int _n) {
		n = 1;
		while (n < _n)
			n *= 2;

		node = std::vector<int>(2 * n - 1, Inf);
	}

	void update(int i, int x) {
		i += n - 1;

		node[i] = x;
		while (i > 0) {
			i = parent(i);
			const auto c = children(i);
			node[i] = std::min(node[c.first], node[c.second]);
		}
	}

	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r == -1)
			r = n;

		if (r <= a || b <= l)
			return Inf;
		if (a <= l && r <= b)
			return node[k];

		const auto c = children(k);
		return std::min(
			query(a, b, c.first, l, (l + r) / 2),
			query(a, b, c.second, (l + r) / 2, r)
		);
	}

private:
	int parent(int i) {
		return (i - 1) / 2;
	}
	std::pair<int, int> children(int i) {
		return { 2 * i + 1, 2 * i + 2 };
	}

	int n;
	std::vector<int> node;

};

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

	SegTree tree(n);
	for (int i = 0; i < q; ++i) {
		int com, x, y;
		std::cin >> com >> x >> y;

		if (com == 0)
			tree.update(x, y);
		else
			std::cout << tree.query(x, y + 1) << std::endl;
	}
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  
  string s;
  cin >> s;
  
  if(a + b + 1 == s.size() && s[a] == '-' && s[a - 1] != '-' && s[a + 1] != '-')cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3604
n, k = map(int, input().split())
P = [*map(lambda x: int(x)-1, input().split())]
C = [*map(int, input().split())]

score = -10**18
for st in range(n):
    lap_cn = 0
    lap_sc = 0
    nx = st
    while True:
        lap_cn += 1
        lap_sc += C[nx]
        nx = P[nx]
        if nx == st: break
    lap_sc = max(0, lap_sc)

    sum_sc = 0
    for k_cn in range(k):
        sum_sc += C[nx]
        score = max(score, sum_sc + lap_sc * ((k - (k_cn + 1)) // lap_cn))
        nx = P[nx]
        if nx == st: break

print(score)


Measured memory_bytes: 68436
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
result = []

left = [0] * (n+1)
right = [0] * (n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for j in range(n-1, -1, -1):
    right[j] = gcd(right[j+1], a[j])
for i in range(n):
    result.append(gcd(left[i], right[i+1]))

print(max(result))


Measured memory_bytes: 16136
#include <stdio.h>

int main()
{
	int S, h, m, s;
	scanf("%d", &S);

	h = S / 3600;
	m = (S - 3600 * h) / 60;
	s = S - (3600 * h + 60 * m);

	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int N;
std::vector <int> e[110000];
int size[110000];
int magic[110000];

int dfs (int x, int f = -1) {
	int d = 0, cnt = 0, cnt_ = 0, del = 1;
	for (int i = 0; i < e[x].size (); i++) {
		if (e[x][i] == f) continue;
		d = std::max (d, dfs (e[x][i], x));
		if (magic[e[x][i]] != 1) del = 0;
		if (magic[e[x][i]] == 2) {
			cnt++;
			magic[x] = 1;
		}
		if (magic[e[x][i]] == 1) {
			cnt_++;
		}
		size[x] += size[e[x][i]];
	}
	if (del) magic[x] = 2;
	size[x]++;
//	printf ("%d %d %d\n", x, magic[x], cnt);
	if (cnt >= 2) return 1;
	if (f == -1 && cnt_ >= 2 && del) return 1;
	return d;
}

int main () {
	scanf ("%d", &N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		scanf ("%d%d", &u, &v);
		e[u].push_back (v);
		e[v].push_back (u);
	}
	int b = 1;
	while (b <= N && e[b].size () <= 1) ++b;
	if (b > N) {
		puts ("Second");
		return 0;
	}
	if (dfs (b))
		puts ("First");
	else
		puts ("Second");
	return 0;
}



Measured memory_bytes: 6912
#include <iostream>

int main(){
   int r, g, b;
   std::cin >> r >> g >> b;

   int n = 100*r + 10*g + b;
   if(n%4==0) std::cout << "YES" << std::endl;
   else std::cout << "NO" << std::endl;
   return 0;
}


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

int main(){
  int X;
  cin>>X;
  bool flag=false;
  int ans;
  while(!flag){
    for (int b=1; b<=1000; b++){
      for (int p=2; p<=10; p++){
        if (X==pow(b,p)){
          flag=true;
          ans=pow(b,p);
        }
      }
    }
    X-=1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4144
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
cin >> a >> b;
if(b!=100){
if(a==0){
    c=b;
}
else if(a==1){
    c=100*b;
}
else if(a==2){
    c=10000*b;
}
}
else{
    if(a==0){
    c=101;
}
else if(a==1){
    c=100*101;
}
else if(a==2){
    c=10000*101;
}
}
cout << c;
return 0;
}


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

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

typedef long long ll;

inline void File() {
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
}

int n, k, t; ll ans;

int main() {

	cin >> n >> k;
	
	t = (k & 1) ? (n / k) : (n / (k / 2));	

	if (k & 1) ans = 1ll * t * t * t;
	else {
		int d1 = t >> 1, d2 = t - d1;	
		ans = 1ll * d1 * d1 * d1 + 1ll * d2 * d2 * d2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 764
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;


int main(){
  ll N,a[1000000];
  cin>>N;
  for(int i=0;i<3*N;i++){
    cin>>a[i];
  }
  sort(a,a+3*N);
  ll ans=0;
  for(int i=N;i<3*N;i+=2){
    ans+=a[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4608
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
n=read()
a=list(reads())
num=0
l=len(a)
ls=[]
k=0
for i in range(l-1,0,-1):
    k+=a[i]
    ls.append(k)
for i in range(l-1):
    num+=a[i]*ls[-i-1]
num%=10**9+7
print(num)

Measured memory_bytes: 29572
# 解説 imos
n, C = map(int, input().split())
L = [tuple(map(int, input().split())) for _ in range(n)]
m = 10 ** 5
S = [0] * m
for i in range(1, C + 1):
    T = [0] * (m + 1)
    for s, t, c in L:
        if c == i:
            T[s - 1] += 1
            T[t] -= 1
    for i in range(m):
        T[i + 1] += T[i]
    for i in range(m):
        S[i] += T[i] > 0
print(max(S))

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

typedef pair<int, int> Team;

int main(void){  
  int n;
  
  while (cin >> n){
    vector<Team> v;
    if (n==0) break;
    for (int i=0; i<n; i++){
      int id, t;
      cin >> id;
      t = 0;
      for (int j=0; j<4; j++){
        int m,s;
        cin >> m >> s;
        t += m*60+s;
      }
      v.push_back(make_pair(t, id));
    }
    sort(v.begin(), v.end());
    cout << v[0].second << endl;
    cout << v[1].second << endl;
    cout << v[n-2].second << endl;
  }
  
  return 0;
}


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

using namespace std;

int main() {
  int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  k--;
  cout<<arr[k];
  return 0;
}

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

bool q[110][110],v[110][110],f;
int num[110][110],sum,pos;
int p,s,tp[110],ts[110],cq[110],rq[110];
string tmp;

int stoi(string x){
  stringstream ss(x);
  int n;
  ss >> n;
  return n;
}


int main(){
  f = true;
  while(cin >> p,p){
    if(!f)cout << endl;
    f = false;
    cin >> s; cin.ignore();
    
    for(int i=0;i<p;i++)rq[i] = 0;
    for(int i=0;i<s;i++)cq[i] = 0;

    for(int i=0;i<p;i++){
      for(int j=0;j<s;j++){
	cin >> tmp;
	if(tmp == "?"){
	  q[i][j] = v[i][j] = false;
	  rq[i]++; cq[j]++;
	}else{
	  q[i][j] = v[i][j] = true;
	  num[i][j] = stoi(tmp);
	}
      }
      cin >> tp[i]; cin.ignore();
    }
    for(int i=0;i<s;i++)cin >> ts[i];
    cin >> tmp;

    bool update = true;
    while(update){
      update = false;
      for(int i=0;i<p;i++){
	if(rq[i] == 1){
	  sum = 0;
	  for(int j=0;j<s;j++){
	    if(!v[i][j])pos = j;
	    else sum += num[i][j];
	  }
	  num[i][pos] = tp[i] - sum;
	  v[i][pos] = true;
	  rq[i]--; cq[pos]--;
	  update = true;
	}
      }
      for(int i=0;i<s;i++){
	if(cq[i] == 1){
	  sum = 0;
	  for(int j=0;j<p;j++){
	    if(!v[j][i])pos = j;
	    else sum += num[j][i];
	  }
	  num[pos][i] = ts[i] - sum;
	  v[pos][i] = true;
	  rq[pos]--; cq[i]--;
	  update = true;
	}
      }
    }

    int ans = 0;
    for(int i=0;i<p;i++)ans |= rq[i];
    for(int i=0;i<s;i++)ans |= cq[i];
    

    if(ans)cout << "NO\n";
    else{
      for(int i=0;i<p;i++){
	for(int j=0;j<s;j++){
	  if(!q[i][j])cout << num[i][j] << endl;
	}
      }
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll BigN = 1000000000000000000LL;
ll arr[200001];
int main(){
	ll N,K;
	scanf("%lld %lld",&N,&K); //k번째로 작은 숫자
	for(int i=0;i<N;i++) scanf("%lld",arr+i);
	sort(arr,arr+N);
	ll L=-BigN, R=BigN;
	while(L<R){
		ll mid = (L+R)/2;
		ll low=0,high=0;
		for(ll i=0;i<N;i++){
			if(arr[i]==0){
				if(mid>0){
					low += N-1-i;
				}
				else if(mid<0){
					high += N-1-i;
				}
			}
			else{
				ll x = mid/arr[i];
				ll left,right;
				if(x*arr[i] == mid){
					right = x;
					left = x-1;
				}
				else{
					for(ll t=-1;t<=1;t++){
						if(((x+t)*arr[i]<mid)^((x+t+1)*arr[i]<mid)){
							left = x+t;
							right = x+t;
							break;
						}
					}
				}
				ll ub = upper_bound(arr,arr+N,right)-arr;
				ll lb = upper_bound(arr,arr+N,left)-arr;
				if(arr[i]>0){
					high += max(0LL,min(N-ub,N-1-i)); //arr[i]*arr[ub~N-1]
					low += max(0LL,min((ll)lb-1-i,N-1-i)); //arr[i]*arr[i+1~lb-1]
				}
				else{
					low += max(0LL,min(N-ub,N-1-i)); //arr[i]*arr[ub~N-1]
					high += max(0LL,min(N-1-i,(ll)lb-1-i)); //arr[i]*arr[i+1~lb-1]
				}
				
			}
		}
	//	printf("%lld %lld %lld\n",low,high,mid);
		if(high>N*(N-1)/2-K) L=mid+1;
		else if(low>K-1) R=mid-1;
		else break;
		
	}
	printf("%lld",(L+R)/2);
	
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline

N=int(input())
S=[input().strip() for i in range(N)]

ANS=0
for s in S:
    ANS+=s.count("AB")


_A=0
B_=0
BA=0

for s in S:
    if s[0]=="B" and s[-1]=="A":
        BA+=1
    elif s[0]=="B":
        B_+=1
    elif s[-1]=="A":
        _A+=1


#print(ANS,_A,B_,BA)

if _A!=0 or B_!=0:
    print(ANS+BA+min(_A,B_))

else:
    if BA!=0:
        print(ANS+BA-1)
    else:
        print(ANS+BA)

Measured memory_bytes: 3700
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        int index = 0;
        int num = 1;
        for (int i = 0 ; i < s.length(); i++) {
            if (!s.substring(i, i + 1).equals("1")) {
                index = i;
                num = Integer.valueOf(s.substring(i, i+ 1));
                break;
            }
        }
        if (k <= index) {
            System.out.println(1);
        } else {
            System.out.println(num);
        }
    }
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (k == (n - i) * j + (m - j) * i) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    for (int i = 1; i <= m; i++) {
        for (int j = 0; j <= n; j++) {
            if (k == (m - i) * j + (n - j) * i) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}


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

int main(){
    int n;
    cin>>n;
    vector<int> b(n);
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        b[i]=a-(i+1);
    }
    sort(b.begin(),b.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=abs(b[i]-b[n/2]);
    }
    cout<<ans<<endl;
}

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

int main(){
  
  long long n;
  long long count = 0;
  long long tmp;
  char *str;
  
  cin>>n;
  tmp = n;
  count = 1;
  while(tmp){
    tmp /= 26;
    count++;
  }
  
  str = (char *)malloc(count);
  count = 0;
  while( n > 0){
  	n--;
    str[ count++ ] = 'a'  + (n%26); 
    n /= 26;
  }

  
  for(long long i=count-1; i>=0; i--)
  	cout << str[i];
  
  return 0;
  
}


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

int main(void){
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    rep(i,3){
        if (s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);
    rep(i, n) cin >> s[i] >> t[i];
    string x;
    cin >> x;
    int ans = 0;
    bool sleep = false;
    for (int i = 0; i < n; i++) {
        if (sleep) {
            ans += t[i];
        }
        if (s[i] == x) {
            sleep = true;
        }
    }
    cout << ans << endl;
}

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

int main()
{
  int m, f, r;

  while(1)
    {
      cin >> m >> f >> r;

      if(m == -1 && f == -1 && r == -1)
	break;

      if(m == -1 || f == -1)
	{
	  cout << "F" << endl;
	}else
	{
	  if(m+f >= 80){cout << "A" << endl;}
	  else if(65<=m+f && m+f<80){cout << "B" << endl;}
	  else if(50<=m+f && m+f<65){cout << "C" << endl;}
	  else if(m+f < 30){cout << "F" << endl;}
	  else if(30<=m+f && m+f<50)
		   {
		     if(r>=50){cout << "C" << endl;}
		     else{cout << "D" << endl;}
		   }
	}
    }
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n;
    string s, t;

    cin >> s >> t;
    t = t.substr(0, t.length() - 1);
    cout << (s == t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int h = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if (r <= x && x <= w-r && r <= y && y <= h-r) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
	
}

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

using namespace std;
typedef long long ll;

const ll LIM = 1e10;
vector<ll> a(100010);

bool check(int key,int index){
    if(a[index]>=key)return true;
    else return false;
}

int binary_search(int key){
    int ok,ng;
    ok=a.size();
    ng=-1;
    while(abs(ok-ng)!=1){
        int mid = (ok+ng)/2;
        if(check(key,mid)){
            ok = mid;
        }else ng = mid;
    }
    return ok;
}

int main(){
    int n;
    cin >> n;
    a.resize(n);
    fill(a.begin(),a.end(),LIM);
    int i;
    for(i=0;i<n;i++){
        ll x;
        cin >> x;
        int p=binary_search(x);
        a[p] = x;
    }
    for(i=0;i<n;i++){
        if(a[i]==LIM)break;
        //cout << a[i] << endl;
    }
    cout << i << endl;
    return 0;
}


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

int main(){
  int a,b,t,sum;
  sum=0;
  cin >> a >> b >> t;
  for(int i=1;i*a<t+0.5;++i){
    sum=sum+b;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
for i in range(n):
    import math
    s=input()
    s_l=list(map(str,s.split()))
    s_ci=[]
    for i in s_l:
        if len(i)==4:
            k_l=[]
            for j in i:
                k=ord(j)-97
                k_l.append(k)
            s_ci.append(k_l)
    a_list=[]
    for i in range(1,1000):
        if math.gcd(i,26)==1:a_list.append(i)
    for a in a_list:
        for b in range(26):
            for k in s_ci:
                word=""
                for l in k:
                    word+=chr(((l*a-b)%26)+97)
                if word=="that" or word=="this":break
            if word=="that" or word=="this":break
        if word=="that" or word=="this":break
    s_l=[]
    for i in s:
        if i==" ":
            s_l.append(-1)
        else:
            k=ord(i)-97
            s_l.append(k)
    ans=""
    for i in s_l:
        if i==-1:ans+=" "
        else:
            ans+=chr(((i*a-b)%26)+97)
    print(ans)


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

int n, fp;
string s;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	for(int i = 0; i < n - 2; ++i) {
		if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ++fp;
	}
	cout << fp << endl;
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;

const int mod = 998244353;
const int MN = 100010;

int exp(int x, ll n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}

int N, M;
map<pii, int> G, chk;
int A[5][MN];
int dp[MN][2];

int main() {
    scanf("%d %d", &N, &M);

    int Xor = 0;
    for(int i = 0; i < M; i++) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        a--; b--;

        G[ pii(a, b) ] = c;
        Xor ^= c;
    }

    if(N == 2) {
        if(M == 4) {
            printf("%d", Xor == 0);
        }
        else printf("%d", exp(2, 3 - M));
        return 0;
    }

    memset(A, -1, sizeof(A));

    int cnt = 0;
    for(auto it = G.begin(); it != G.end(); it++) {
        pii p = it->first;
        if(abs(p.first - p.second) <= 2) {
            A[ p.first - p.second + 2 ][ min(p.first, p.second) ] = it->second;
        }
        else {
            if(G.find(pii(p.second, p.first)) != G.end() && G[ pii(p.second, p.first) ] != G[p]) {
                printf("0");
                return 0;
            }
            if(p.first > p.second) swap(p.first, p.second);
            if(!chk[p]) {
                chk[p] = 1;
                cnt++;
            }
        }
    }

    int ans = exp(2, (1LL * N * N - 5 * N + 6) / 2 - cnt);

    dp[N][0] = 1;
    dp[N][1] = 1;
    for(int x = N - 1; x >= 0; x--) {
        for(int p = 0; p < 2; p++) {
            int &ret = dp[x][p];
            if(x == 0) {
                if(A[2][x] == -1) {
                    ret += dp[1][0];
                    ret %= mod;
                    ret += dp[1][1];
                    ret %= mod;
                }
                else ret = dp[1][ A[2][x] ];
                continue;
            }

            for(int i = 0; i < (1 << 5); i++) {
                if(A[2][x] != -1 && A[2][x] != (i & 1)) continue;
                if(A[1][x - 1] != -1 && A[1][x - 1] != (i & 2? 1 : 0)) continue;
                if(A[3][x - 1] != -1 && A[3][x - 1] != (i & 4? 1 : 0)) continue;
                if(A[0][x - 1] != -1 && A[0][x - 1] != (i & 8? 1 : 0)) continue;
                if(A[4][x - 1] != -1 && A[4][x - 1] != (i & 16? 1 : 0)) continue;

                if(((i & 2? 1 : 0) ^ (i & 4? 1 : 0)) != (p ^ (i & 1))) continue;
                if(x != N - 1 && ((i & 8? 1 : 0) ^ (i & 16? 1 : 0)) != (i & 1)) continue;
                ret += dp[x + 1][i & 1];
                ret %= mod;
            }
            if(x == N - 1) {
                ret = 1LL * ret * inv(4) % mod;
            }
        }
    }

    printf("%d", 1LL * ans * dp[0][0] % mod);
}


Measured memory_bytes: 9216
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout, setrecursionlimit
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
setrecursionlimit(100000)
mod = 1000000007

n = ii1()
arr = iia()
dp = [[0 for i in range(n + 1)] for j in range(n + 1)]
for i in range(1, n + 1)[::-1]:
    for j in range(i, n + 1):
        if i == j:
            dp[i][j] = arr[i - 1]
        else:
            dp[i][j] = max(arr[i - 1] - dp[i + 1][j], arr[j - 1] - dp[i][j - 1]
        )
print(dp[1][-1])

Measured memory_bytes: 153088
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


int a,b;
string s[100][100];

int main(){
	cin >> a >> b;
	int ans1,ans2;
	for(int i = 0; i < a; i++){
		for(int j = 0; j < b; j++){
			cin >> s[i][j];
			if(s[i][j] == "snuke"){
				ans1 = i;
				ans2 = j;
			}
		}
	}
	
	cout << (char)('A'+ans2) << ans1+1 << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>


int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a<=c&&b>=d) printf("%d\n",d-c);
	else if(a<=c&&b<=d&&b>=c) printf("%d\n",b-c);
	else if(a>=c&&b>=d&&a<=d) printf("%d\n",d-a);
	else if(a>=c&&b<=d) printf("%d\n",b-a);
	else if(b<=c) printf("0\n");
	else if(d<=a) printf("0\n");
	return 0;
}
/*
A
int main(){
	int a;
	scanf("%d",&a);
	if(a<=99){
		if(a/10==a%10) printf("Yes\n");
		else printf("No\n");
	}
	else if(a<=999){
		if(a/100==a%10) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
} 
*/


Measured memory_bytes: 128
data = list(map(int,input().split()))

A = data[0]
B = data[1]
K = data[2]

ans = []
for i in range(K):
    a = A+i
    b = B-i
    
    if a <= b:
        ans.append(a)
    if a >= b:
        break
    
    ans.append(b)
    
ans.sort()

for i in ans:
    print(i)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int yen = 0;
			while (n-- > 0) {
				int sum = 0;
				for (int i = 0; i < 3; i++) {
					sum += scanner.nextInt();
				}
				int w = scanner.nextInt();
				if (sum <= 60 && w <= 2)
					yen += 600;
				else if (sum <= 80 && w <= 5)
					yen += 800;
				else if (sum <= 100 && w <= 10)
					yen += 1000;
				else if (sum <= 120 && w <= 15)
					yen += 1200;
				else if (sum <= 140 && w <= 20)
					yen += 1400;
				else if (sum <= 160 && w <= 25)
					yen += 1600;
				else
					yen += 0;
			}
			System.out.println(yen);
		}
	}
}

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

using namespace std;

long long int f(long long int a, long long int b) {
	if(a > b)	swap(a, b);
	if(b%a == 0)	return (2 * a * (b/a)) - a;
	return (2 * a * (b/a) + f(a, b%a));
}

int main(void) {

	long long int n, x;
	cin>>n>>x;

	cout<<(n + f(x, n-x));

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
 
 
void swap (int *x, int *y) {
  int temp;    
 
  temp = *x;
  *x = *y;
  *y = temp;
}
 
int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }
 
  if(b==0){
    return a;
  }
 
  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }
 
  return b;
}
 
/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}
 
 
int modpow(int a,int n,int mod){
  int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}
 
int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}
 
int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}
 
void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }
 
  return;
}
 
void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }
 
  return;
}
 

int main(void){
  int n;
  scanf("%d",&n);
  long int l[n+1];
  l[0]=2;
  l[1]=1;
  for(int i=2;i<n+1;i++){
    l[i]=l[i-1]+l[i-2];
  }
  printf("%ld\n",l[n]);
  return 0;
}

Measured memory_bytes: 1728
n,m=map(int,input().split())
SC=[list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    if len(str(i))==n and all(str(i)[s-1]==str(c) for s,c in SC):
        print(i)
        break
else:
    print(-1)

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

int main(){
  int a,b,c,d;
  string res;
  cin >> a >> b >> c >> d;
  res = "Balanced";
  if((a+b) > (c+d)){
    res = "Left";
  }else if((a+b) < (c+d)){
    res = "Right";
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c(h);
  for (int i = 0; i < h; ++i) {
    cin >> c.at(i);
  }
  int ans = 0;
  for (int i = 0; i <= ((1 << h) - 1); ++i) {
    for (int j = 0; j <= ((1 << w) - 1); ++j) {
      int m = 0;
      for (int k = 0; k < h; ++k) {
        for (int l = 0; l < w; ++l) {
          if (!(i >> k & 1) && !(j >> l & 1) && (c.at(k).at(l) == '#')) {
            ++m;
          }
        }
      }
      if (m == k) {
        ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
n, k = map(int, input().split())
res = 0
v = list(map(int, input().split()))

mp = {}

for i in range(20000):
    mp[i] = (0, 0)

for i in range(n):
    for j in range(0, i):
        if(v[i] > v[j]):
            mp[i] = (mp[i][0]+1, mp[i][1])
    for j in range(i+1, n):
        if(v[i] > v[j]):
            mp[i] = (mp[i][0], mp[i][1]+1)

for i in mp:
    tmp = mp[i][1] * ((k + 1) * k) // 2
    res += tmp
    tmp = mp[i][0] * ((k - 1) * k) // 2
    res += tmp

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


Measured memory_bytes: 4868
H, W = map(int, input().split())
s = []
for _ in range(H):
  s.append(input())
  
def main(H, W, s):
  # 動的計画法
  
  INF = float('inf')
  dp = [[INF]*W for _ in range(H)]
  if s[0][0] == '#':
    dp[0][0] = 1
  else:
    dp[0][0] = 0

  dx = (1, 0)
  dy = (0, 1)
  for i in range(H):
    for j in range(W):
      for dir_ in range(2):  # 右に行くか下に行くかの2通り
        ni = i + dx[dir_]
        nj = j + dy[dir_]
        if ni >= H or nj >= W:
          continue
        add = 0
        if s[ni][nj] == '#' and s[i][j] == '.':
          add = 1
        dp[ni][nj] = min(dp[ni][nj], dp[i][j] + add)

  return dp[H-1][W-1]

print(main(H, W, s))

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

#define ll long long
#define ar array
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define endl "\n"

int main(){
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    for (int i=1; i<=5;++i){
        int temp;
        cin>>temp;
        if (temp==0){
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    
    char str[1001],str2[1001];
    int q,i,j,a,b;
    
    scanf("%s",str);
    scanf("%d",&q);
    for(i=0; i<q; i++){
        scanf("%s %d %d",str2, &a,&b);
        
        if(strcmp(str2, "replace") == 0){
            scanf("%s",str2);
            memcpy(str+a, str2, b-a+1);
        }
        
        if(strcmp(str2, "reverse") == 0){
            strncpy(str2, str+a, b-a+1);
            for(j=b; j>=a; j--) str[j]=str2[b-j];
        }
        
        if(strcmp(str2, "print") == 0){
            strncpy(str2, str+a, b-a+1);
            str2[b-a+1]=0;
            printf("%s\n",str2);
        }
    }
    return 0;
}



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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

string parse(string& s,int& idx){
  if(s[idx]=='#'){
    return "";
  }
  
  if(s[idx]=='['){
    idx++;
    string str = parse(s, idx);
    string ans = "";
    REP(i,str.size()){
      ans += str[str.size() - i - 1];
    }
    return ans + parse(s,idx);
  }
  else if (s[idx] == ']')
  {
    idx++;
    return "";
  }
  else
  {
    LL cnt = 0;
    while(s[idx]=='+'||s[idx]=='-'){
      if(s[idx]=='+'){
        cnt++;
      }
      else
      {
        cnt--;
      }
      cnt = (cnt + 26) % 26;
      idx++;
    }
    if(s[idx]=='?'){
      idx++;
      return 'A' + parse(s, idx);
    }else{
      char c = (s[idx] - 'A' + cnt)%26 + 'A';
      idx++;
      return c + parse(s, idx);
    }
  }
}

LL mod = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true)
  {
    string s;
    cin >> s;
    if(s[0]=='.'){
      break;
    }

    s += "#";

    int idx = 0;
    string str = parse(s, idx);
    cout << str << endl;
  }
}



Measured memory_bytes: 3224
// Aizu 1020: Cleaning Robot
// 2017.9.17 bal4u@uu

#include <stdio.h>
#include <string.h>

double f[17][3][3];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};

int main()
{
	int n, s, t, b, i, j, r, c, r2, c2;
	char t1[5], t2[5], t3[5];

	while (scanf("%d", &n) && n) {
		scanf("%s%s%s", t1, t2, t3), s = *t1 - 'A', t = *t2 - 'A', b = *t3 - 'A';
		memset(f, 0, sizeof(f)), f[0][s/3][s%3] = 1;
		for (j = 1; j <= n; j++) {
			for (r = 0; r < 3; r++) for (c = 0; c < 3; c++) {
				for (i = 0; i < 4; i++) {
					r2 = r + mv[i][0], c2 = c + mv[i][1];
					if (r2 < 0 || r2 >= 3 || c2 < 0 || c2 >= 3 || 3*r2+c2 == b) r2 = r, c2 = c;
					f[j][r2][c2] += f[j-1][r][c] / 4;
				}
			}
		}
		printf("%.8lf\n", f[n][t/3][t%3]);
	}
	return 0;
}

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

int main(){
//srandom((unsigned long)time(NULL));
long long n;
string s;
cin>>n>>s;
vector<char> a;
for(int i=0;i<n;i++){
    a.emplace_back(s[i]);
}
long long cnt=0;
//int x=0;
//1233334556
//123456
//112211
for(int i=0;i<n-1;i++){
if(a[i]==a[i+1]){
    
        cnt++;
    
   
}
}
cout<<n-cnt<<endl;

return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    long long ans=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            ans+=i;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3612
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStrings solver = new AStrings();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStrings {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            String str1 = s.nextString();
            String str2 = s.nextString();
            out.println(str2 + str1);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

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

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int cou[100010], ans;
string s;

int main(){
	cin >> s;
	ans = INF;
	bool f = false;
	for(int i=0;i<s.size()-1;i++){
		if((s[i]-'0')^(s[i+1]-'0')){
			f = true;
			ans = min(ans, max(i+1, (int)s.size()-1-i));
		}
	}
	if(!f){
		cout << s.size() << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>ac(n),pena(n);
  rep(i,m){
    int p;
    string s;
    cin>>p>>s;
    --p;
    if(ac[p])continue;
    if(s=="AC"){
      ac[p]=1;
    }else{
      pena[p]++;
    }
  }
  int AC=0, PENA=0;
  rep(i,n){
    AC+=ac[i];
    if(ac[i]) PENA+=pena[i];
  }
   cout<<AC<<" "<<PENA<<endl;
}
  
  
  
      
      
      
      
      


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int d;
    cin >> d;
    if(d==25) cout << "Christmas" << endl;
    if(d==24) cout << "Christmas Eve" << endl;
    if(d==23) cout << "Christmas Eve Eve" << endl;
    if(d==22) cout << "Christmas Eve Eve Eve" << endl;
    return 0;
}


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

int main()
{
    cin.tie(NULL);
    ios::sync_with_stdio(false);    
    int i, n;
    cin>>n;
    int a[n];
    bool b=1;
    rep(i,n)
    {
        cin>>a[i];
        if(a[i]%2==0 ){
        if(a[i]%3==0 or a[i]%5==0)
        {
            continue;
            
        }
        else{
              b=0;
              break;
            }
        }
    }
    cout<<(b? "APPROVED":"DENIED")<<endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

c_min = -1
c_max = n+1

for i in range(m):
    tmp_min, tmp_max = map(int, input().split())
    if tmp_min > c_min:
        c_min = tmp_min
    if tmp_max < c_max:
        c_max = tmp_max

if c_max >= c_min:
    print(c_max - c_min +1)
else:
    print(0)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm>
#include<map>
#include<utility>
#include<cstdio>
#include<bits/stdc++.h>

using namespace std;

typedef pair<long long,bool> Pair;
const long long INF = 1LL<<60;

int main(){

long long K,N;
long long ans;
long long tmp;

cin >> N >> K;

ans = N%K;

if(ans > abs(ans - K)) ans = abs(ans - K);

cout << ans << endl;

return 0;

}   


Measured memory_bytes: 256
n, l = map(int,input().split())

apple = []
for i in range(1,n+1):
    apple.append(i+l-1)
pai = sum(apple)
ans = 10**9
for i in range(n):
    if ans > abs(apple[i]):
        ans = abs(apple[i])
        eat = apple[i]
print(pai-eat)

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
using namespace std;
#define NIL -999
bool mark[105][105];
int n;

int d[105] = { 0 };

inline int next(int i) {
	for (int tmp = 1; tmp <= n; ++tmp) {
		if (mark[i][tmp] && d[tmp]==-1) {
			//cout << endl << i << "的下一个节点是：" << tmp << endl;
			return tmp;
		}
	}
	//cout << endl << i << "的下一个节点是：" << NIL << endl;
	return NIL;
}
void bfs_IN(int i) {
	int tm = 0;
	queue<int> q;
	int now, nt;
	int status = 1;;
	q.push(i);
	d[i] = tm;
	//cout << 3 << endl;
	++tm;
	while (!q.empty()) {
		now = q.front();
		nt = next(now);
		while (nt != NIL) {
			//status = true;
			q.push(nt);
			if (-1==d[nt])d[nt] = tm;
			nt = next(now);
		//	cout << 4 << endl;
		}
		q.pop();
		--status;
		if (!status){
			status = q.size();
			++tm;
		}
		//status = false;
	}
}
void bfs() {
	int k, Node, tmp;

	for (int i = 1; i <= n; ++i)
		for (int j = 0; j <= n; ++j)
			mark[i][j] = false;

	cin >> n;
	for (int i = 0; i <= n; ++i)
		d[i] = -1;
	for (int i = 1; i <= n; ++i) {
		cin >> Node >> k;
		for (int j = 1; j <= k; ++j) {
			cin >> tmp;
			mark[Node][tmp] = true;
		}
	}

	bfs_IN(1);

	//cout << 1 << endl;
	for (int p = 1; p <= n; ++p) {
		cout << p << ' ' << d[p] << endl;
	}

}



int main() {

	bfs();
	return 0;
}


Measured memory_bytes: 3124
#include "bits/stdc++.h"
using namespace std;
typedef long long li;


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

    li n;
    cin >> n;
    string s;
    cin >> s;
    vector<li> as(n);
    for (int i = 0; i < n; ++i) {
        as[i] = s[i] - '1';
    }

    vector<li> pow2(n);
    for (int i = 1; i < n; ++i) {
        li x = i;
        pow2[i] = pow2[i - 1];
        while ((x & 1) == 0) {
            x >>= 1;
            pow2[i]++;
        }
    }
    auto comb = [&](li n, li k) {
        li e1 = pow2[n];
        li e2 = pow2[k];
        li e3 = pow2[n - k];
        return e1 <= e2 + e3 ? 1 : 0;
    };

    // check 1
    li parity_sum = 0;
    for (int i = 0; i < n; ++i) {
        parity_sum += comb(n - 1, i) * (as[i] & 1);
    }

    if (parity_sum % 2 == 1) {
        cout << 1 << endl;
        return 0;
    }

    // check zero
    bool has_one = false;
    for (int i = 0; i < n; ++i) {
        has_one |= as[i] == 1;
    }

    if (has_one) {
        cout << 0 << endl;
        return 0;
    }

    li two_parity_sum = 0;
    for (int i = 0; i < n; ++i) {
        two_parity_sum += comb(n - 1, i) * (as[i] / 2);
    }
    two_parity_sum %= 2;
    cout << two_parity_sum * 2 << endl;

    return 0;
}

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

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

  vector<string> vec(N);

  for (int i = 0; i < N; i++)
    cin >> vec.at(i);

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

  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  cout << vec.size() << endl;
}


Measured memory_bytes: 9596
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
	std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

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

int N=50;
ll K;

int main(){
	scan(K);
	ll q = K/N;
	ll r = K%N;
	printf("50\n");
	FOR(i,0,r) printf("%lld ",q+N);
	FOR(i,0,N-r) printf("%lld ",q-r+(N-1));
}

Measured memory_bytes: 256