akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>

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

using namespace std;

bool check(const char *s,const char *t){
	int m=strlen(s),n=strlen(t);
	for(int i=1;i<=n;i++) rep(j,n) { // i kizami, start at j
		int p=0;
		char u[128];
		for(int k=j;k<n;k+=i) u[p++]=t[k];
		u[m]='\0';
		if(p>=m && strcmp(u,s)==0) return true;
	}
	return false;
}

int main(){
	int n;
	char s[32]; scanf("%d%s",&n,s);
	int ans=0;
	rep(i,n){
		char t[128]; scanf("%s",t);
		if(check(s,t)) ans++;
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 1044
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a, sum = 1; cin >> n;
	int test[101] = { 0 }, uiop[101] = { 0 };
	for (int h = 1; h <= n; h++) {
		cin >> a; test[h] = a;
	}
	for (int h = 0; h < n; h++) {
		for (int i = 1; i <= n; i++) {
			if (i == test[i]) {
				sum = i;
			}
			if (sum == 0) {
				cout << -1 << endl; cin >> n; return 0;
			}
			uiop[h] = sum; 
		}
		for (int i = sum; i <= n; i++) {
			test[i] = test[i + 1];
		}
		sum = 0;
	}
	for (int h = n - 1; h >= 0; h--) {
		cout << uiop[h] << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
 
using namespace std;
using ll =long long;

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  string s ;
  cin>>s;
  int ob=0, ew =0, ow =0, eb = 0;
  
  for(int i =0; 2*i < s.size() ; i++){
    if(s[2*i]%2==1){
      ob++;
    }
  }
  for(int i =0; 2*i+1 < s.size() ; i++){  
    if(s[2*i+1]%2 ==0){
      ew++;
    }
  } 
  for(int i =0; 2*i < s.size() ; i++){
    if(s[2*i]%2==0){
      ow++;
    }
  }
  for(int i =0; 2*i+1 < s.size() ; i++){
    if(s[2*i+1]%2 ==1){
      eb++;
    }
  }
  cout<< min(ob+ew ,ow+eb)<<endl;
}

Measured memory_bytes: 512
# https://atcoder.jp/contests/abc141/tasks/abc141_b
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = input()
    for i in range(len(s)):
        num = i + 1
        if num % 2 == 1:
            # odd
            if s[i] not in 'RUD':
                print('No')
                return
        else:
            # even
            if s[i] not in 'LUD':
                print('No')
                return

    print('Yes')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<stdio.h>

int main(void){
  int s,n=0,i,p,flag=1;
  int a[2048];
  scanf("%d",&s);
  
  while(flag){
    a[n] = s;
    
    if(s%2==0){
      s = s/2;
    }else{
      s = 3*s+1;
    }
    
    for(i=0;i<n;i++){
      if((a[i]==a[n]) && i!=n){
        p = n+1;
        flag = 0;
        break;
      }
    }
    n++;
  }
  
  printf("%d\n",p);
  
  return 0;
}

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

int main()
{
    ll n, h;
    cin >> n >> h;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll maxa = 0; //aの最大値
    rep(i, n) maxa = max(maxa, a[i]);

    ll cnt = 0;  //maxaより大きいbの個数
    ll sumb = 0; //maxaより大きいbの合計を格納

    sort(b.begin(), b.end(), greater<ll>());
    rep(i, n)
    {
        if (b[i] > maxa)
        {
            cnt++;
            sumb += b[i];
            if (sumb >= h)
            {
                cout << cnt << endl;
                return 0;
            }
        }
    }

    ll ans = cnt + (h - sumb + (maxa - 1)) / maxa;
    cout << ans << endl;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  
    public static void main(String[] args)  {

    	try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line;
            while((line=br.readLine())!=null){if(line.isEmpty())break;
                    String[] spl = line.split(" ");
	            int n1 = Integer.parseInt(spl[0]), n2 = Integer.parseInt(spl[1]);
	            if(n1==0&&n2==0){break;}
                    String yuka[][] = new String[n1][n2];
                    
                    for(int i=0; i<n1; i++){
                        line=br.readLine();
                        char spl2[] =line.toCharArray();
                        for(int j=0; j<n2; j++){
                            yuka[i][j]=spl2[j]+"";
                        }
                    }
                    
                    int[] basyo = {0,0};
                    while(true){
                        String moji = yuka[basyo[0]][basyo[1]];
                        if(yuka[basyo[0]][basyo[1]].equals(".")){
                            System.out.println(basyo[1]+" "+basyo[0]);
                            break;
                        }
                        if(yuka[basyo[0]][basyo[1]].equals("already")){
                            System.out.println("LOOP");
                            break;
                        }
                        int hozon1 = basyo[0], hozon2 = basyo[1];
                        if(yuka[basyo[0]][basyo[1]].equals("<")){
                            basyo[1]--;
                        }
                        if(yuka[basyo[0]][basyo[1]].equals(">")){
                            basyo[1]++;
                        }
                        if(yuka[basyo[0]][basyo[1]].equals("^")){
                            basyo[0]--;
                        }
                        if(yuka[basyo[0]][basyo[1]].equals("v")){
                            basyo[0]++;
                        }
                        yuka[hozon1][hozon2]="already";

                    }
                    
                    
            }//End WHILE


        }catch(Exception e){e.printStackTrace();}

    }


}

Measured memory_bytes: 25368
#include <iostream>
using namespace std;
 
#define TIF(c,a,b) (c ? a : b)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define READ(v) std::cin >> v;
#define WRITE(v) std::cout << v;
#define USORT(a,n) sort(a, a + n);
#define LSORT(a,n) sort(a, a + n, greater<int>());
 
#define cin std::cin
#define cout std::cout
using ll = long long;
using ull = unsigned long long;
 
int main()
{
  int N;
  cin >> N;
  int i = 1;
  for(i = 1; i <= 9; i++)
  {
    int t = N / i;
    if(t > 0 && t <= 9 && N % i == 0) 
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    long long ans=0,c=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            ans+=i-c;
            c++;
        }
    }
    cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3792
using System;
using System.Linq;
using System.Collections.Generic;

public class AtCoderC
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        int[] nums1 = new int[n];
        int[] nums2 = new int[n];
        {
            for (int i = 0; i < n; i++)
            {
                int num = int.Parse(Console.ReadLine());
                nums1[i] = num;
                nums2[i] = num;
            }
        }

        Array.Sort(nums2);

        int max = nums2[n - 1];
        int max2 = nums2[n - 2];

        for (int i = 0; i < n; i++)
        {
            int num = nums1[i];
            Console.WriteLine(num == max ? max2 : max);
        }
    }
}

Measured memory_bytes: 17876
#include<stdio.h>
 
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int prim();
 
int n,M[MAX][MAX];
 
int main(){
  int i,j,e;
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      scanf("%d",&e);
      M[i][j] = (e == -1) ? INFTY : e; 
    }
  }
 
  printf("%d\n",prim());
 
  return 0;
}
 
 
int prim(){
  int u,minv,i,v;
  int d[MAX],p[MAX],color[MAX];
 
  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    minv = INFTY;
    u = -1;
    for( i = 0 ; i < n ; i++ ){
      if( minv > d[i] && color[i] != BLACK ){
    u = i;
    minv = d[i];
      }
    }
 
    if( u == -1 ) break;
 
    color[u] = BLACK;
 
    for( v = 0 ; v < n ; v++ ){
      if(color[v] != BLACK && M[u][v] != INFTY ){
    if( d[v] > M[u][v] ){
      d[v] = M[u][v];
      p[v] = u;
      color[v] = GRAY;
    }
      }
    }
  }
 
  int sum = 0;
 
  for( i = 0 ; i < n ; i++ ){
    if( p[i] != -1 ) sum += M[i][p[i]];
  }
 
  return sum;
} 

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

int main(){
	int k,a,b,i;
	bool ok = false;
	scanf("%d %d %d",&k,&a,&b);
	if(a%k==0){
		ok =true;
	}
	for(i=a;i<=b;i++){
		if(i%k==0){
			ok = true;
			break;
		}
	}
	if(ok){
		printf("OK\n");
	}
	else{
		printf("NG\n");
	}

	return 0;
}

Measured memory_bytes: 1636
n,m = map(int, input().split())
crd = [list(map(int, input().split())) for i in range(n)]
chk = [list(map(int, input().split())) for i in range(m)]

for x1, y1 in crd:
   ans = 0
   min_m = float("inf")
   for i, (x2, y2) in enumerate(chk, 1):
      m = abs(x1 - x2) + abs(y1 - y2)
      if min_m > m:
         ans = i
         min_m = m
 
   print(ans)

Measured memory_bytes: 3064
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  const s = input[1];
  let arr = [];
  for (let i = 0; i < n; i++) {
    arr.push(s[i]);
  }
  // console.log(arr);
  
    for(let j=0; j<arr.length-1; j++) {
      if (arr[j] == arr[j+1]) {
        arr.splice(j, 1);
        j--;       
      }
      // console.log(arr);
    }

  console.log(arr.length);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 28744
#include <bits/stdc++.h>
#define ll long long


using namespace std;

string str;


int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int n, m, k, i, j;
    ios::sync_with_stdio(false);
    cin >> n >> m >> k;
    for(i = 0; i <= m; i++) {
        int s = i * n;
        for(j = 0; j <= n; j++)
          if(s - j * i + (m - i) * j == k) {
              cout << "Yes";
              return 0;
          }
    }
    cout << "No";
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		for(;;){
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			if(x == 0 && y == 0)
				break;
			
			if(x > y){
				change = x;
				x = y;
				y = change;
			}
			
			System.out.println(x +" "+y);
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> f(N+1,1);

    ll sum = 1;
    for(int k = 2; k <= N; k++) {
        int m = k;
        while(m <= N) {
            f[m]++;
            m += k;
        }
        sum += (ll)k * (ll)f[k];
    }

    cout << sum << endl;
}

Measured memory_bytes: 42324
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long

int main()
{
  	unordered_map<string,int> mp;
  	int n;
  	string s;
    cin>>n;
  	for(int i=0;i<n;i++)
    {
      cin>>s;
      mp[s]++;
    }
  
  	cout<<"AC"<<" x "<<mp["AC"]<<"\n";
  	cout<<"WA"<<" x "<<mp["WA"]<<"\n";
  	cout<<"TLE"<<" x "<<mp["TLE"]<<"\n";
  	cout<<"RE"<<" x "<<mp["RE"]<<"\n";
  
    return 0;
}

Measured memory_bytes: 3644
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(read())
print((N-(N // 2)) / N)


Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var n int
	a := make([]int, 200)
	fmt.Scan(&n)
	for i:= 0; i < 200; i++ {
		fmt.Scan(&a[i])
	}
	can := true
	count := 0
	for can {
		for i := 0; i < n; i++ {
			if a[i]%2 == 1 {
				can = false
			}
			a[i] /= 2
		}
		if can {
			count++
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include<cstdio>
#define llong long long
using namespace std;

const int N = 3000;
const int P = 1e9+7;
const int INV2 = 5e8+4;
llong a[N+3];
llong dp[N+3][N+3];
int n,q;

llong quickpow(llong x,llong y)
{
	llong cur = x,ret = 1ll;
	for(int i=0; y; i++)
	{
		if(y&(1ll<<i)) {y-=(1ll<<i); ret = ret*cur%P;}
		cur = cur*cur%P;
	}
	return ret;
}

int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<i; j++) dp[i][j] = a[j]<a[i] ? 1 : 0;
		for(int j=i+1; j<=n; j++) dp[i][j] = a[i]>a[j] ? 1 : 0;
	}
	for(int i=1; i<=q; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		dp[x][y] = dp[y][x] = (dp[x][y]+dp[y][x])*INV2%P;
		for(int j=1; j<=n; j++)
		{
			if(j!=x && j!=y)
			{
				dp[j][x] = dp[j][y] = (dp[j][x]+dp[j][y])*INV2%P;
				dp[x][j] = dp[y][j] = (dp[x][j]+dp[y][j])*INV2%P;
			}
		}
	}
	llong ans = 0ll;
	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=n; j++)
		{
			ans = (ans+dp[i][j])%P;
		}
	}
	ans = ans*quickpow(2ll,q)%P;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a; cin >> a;
    if(a == 'a'||a == 'i'||a == 'u'||a == 'e'||a == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B):
    if A > B:
        return str(B) * A
    else:
        return str(A) *B


def main():
    A, B = read_int_n()
    print(slv(A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5448
#include<bits/stdc++.h>
using namespace std;
int D;
int main(){
 cin >> D;
 if(D == 25) puts("Christmas");
 if(D == 24) puts("Christmas Eve");
 if(D == 23) puts("Christmas Eve Eve");
 if(D == 22) puts("Christmas Eve Eve Eve");

 return 0; 
};


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


int main(){
  string N;
  cin>>N;
int sum=0;
  for(int i=0;i<(int)(N.length());i++){
    char a = N.at(i);
    int b = a - '0';
    sum+=b;
}
  int b = stoi(N);
  if(b%sum==0){
    cout<<"Yes"<<endl;
  }else{
cout<<"No"<<endl;
  }
}

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

int main(void){
    int n,v,j,A[100];
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    for (int i = 0; i < n; i++){
        cout << A[i];
        if (i != n - 1){
            cout << " ";
        }
    }
    cout << endl;
    for (int i = 1; i <= n - 1; i++){
        v = A[i];
        j = i - 1;
        while(j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j += -1;
        }
        A[j + 1] = v;
        for (int i = 0; i < n; i++){
            cout << A[i];
            if (i != n - 1){
                cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

ll a[200010];
ll b[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)b[i]=a[i];
	sortup(b,n);
	ll l=b[n/2-1],r=b[n/2];
	rep(i,0,n)printf("%lld\n",a[i]<=l?r:l);
	return 0;
}



Measured memory_bytes: 5216
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S,T;
    cin >> S >> T;
    int q;
  	cin >> q;
    vl acc0(S.size()+1,0),acc1(T.size()+1,0);
    rep(i,S.size()){
        acc0[i+1]=acc0[i]+(S[i]-'A')+1;
    }
    rep(i,T.size()){
        acc1[i+1]=acc1[i]+(T[i]-'A')+1;
    }
    rep(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        a--;c--;
        if((acc0[b]-acc0[a])%3==(acc1[d]-acc1[c])%3){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

using namespace std;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fo(i, n) for(int i = 1; i <= n; ++i)

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

const int N = 200200;
const int mod = 1e9 + 7;
vector<pii> cnt[3003];

int n, k;
int x[N], y[N];
char c[N];
int t[2002][2002];
int t2[2002][2002];
int MAX = 2002;
int dp[2002][2002];

int dp2[2002][2002];

inline void upd(int x, int y)
{
	for(int i = x; i < MAX; i |= (i + 1))
		for(int j = y; j < MAX; j |= (j + 1))
			t[i][j]++;
}

inline void upd2(int x, int y)
{
	for(int i = x; i < MAX; i |= (i + 1))
		for(int j = y; j < MAX; j |= (j + 1))
			t2[i][j]++;
}


inline int get(int x, int y)
{
	if(x < 0 || y < 0)
		return 0;
	if(dp[x][y] != -1)
		return dp[x][y];
	int res = 0;
	for(int i = x; i >= 0; i = (i & (i + 1)) - 1)
		for(int j = y; j >= 0; j = (j & (j + 1)) - 1)
			res += t[i][j];
	return dp[x][y] = res;
}
inline int get2(int x, int y)
{
	if(x < 0 || y < 0)
		return 0;
	if(dp2[x][y] != -1)
		return dp2[x][y];	
	int res = 0;
	for(int i = x; i >= 0; i = (i & (i + 1)) - 1)
		for(int j = y; j >= 0; j = (j & (j + 1)) - 1)
			res += t2[i][j];
	return dp2[x][y] = res;
}


inline int calc(int xa, int ya, int xb, int yb)
{
	if(xa > xb || ya > yb) return 0;
	return get(xb, yb) - get(xa - 1, yb) - get(xb, ya - 1) + get(xa - 1, ya - 1);
}
inline int calc2(int xa, int ya, int xb, int yb)
{
	if(xa > xb || ya > yb) return 0;
	return get2(xb, yb) - get2(xa - 1, yb) - get2(xb, ya - 1) + get2(xa - 1, ya - 1);
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);	
	cin >> n >> k;
	fo(i, n)
	{
		cin >> x[i] >> y[i] >> c[i];
		int mdx = x[i] % (k + k);
		if(mdx < 0) mdx += k + k;
		int mdy = y[i] % (k + k);
		if(mdy < 0) mdy += k + k;
		if(c[i] == 'W')
			upd(mdx, mdy);
		else 
			upd2(mdx, mdy);
	}
	int ans = 0;
	memset(dp,-1,sizeof dp);
	memset(dp2, -1, sizeof dp);
	for(int X = 0; X <= k; ++X)
	{	
		for(int Y = 0; Y <= k ; ++Y)
		{
		   int Lx = X, Rx = X + k - 1;
			int Ly = Y, Ry = Y + k - 1;
			ans = max(ans, n
				-calc(Lx, Ly, Rx, Ry) 
				-calc(0, 0, Lx - 1, Ly - 1)
				-calc(Rx + 1, 0, min(Rx + k, k + k - 1), Ly - 1)
				-calc(0, Ry + 1, Lx - 1, min(Ry + k, k + k - 1))
				-calc(Rx + 1, Ry + 1, min(Rx + k, k + k - 1), min(Ry + k, k +k - 1))
				-calc2(Lx + k, Ly, min(Rx + k, k + k - 1), Ry) 
				-calc2(Lx, Ly + k, Rx, min(Ry + k, k + k - 1))
				-calc2(Lx, 0, Rx, Ly - 1) 
				-calc2(0, Ly, Lx -  1, Ry)
				);
			ans = max(ans, n
				-calc2(Lx, Ly, Rx, Ry) 
				-calc2(0, 0, Lx - 1, Ly - 1)
				-calc2(Rx + 1, 0, min(Rx + k, k + k - 1), Ly - 1)
				-calc2(0, Ry + 1, Lx - 1, min(Ry + k, k + k - 1))
				-calc2(Rx + 1, Ry + 1, min(Rx + k, k + k - 1), min(Ry + k, k +k - 1))
				-calc(Lx + k, Ly, min(Rx + k, k + k - 1), Ry) 
				-calc(Lx, Ly + k, Rx, min(Ry + k, k + k - 1))
				-calc(Lx, 0, Rx, Ly - 1) 
				-calc(0, Ly, Lx -  1, Ry)
				);
		}
	}
	cout << ans;
	return 0;            
}

Measured memory_bytes: 64256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::ops::*;
use std::slice::*;
use std::*;

const MOD: isize = 1000000007;
fn main() {
    let (N, A, B) = {
        let v: Vec<usize> = read_vec();
        (v[0], v[1], v[2])
    };

    let mut k = 0;

    let sm = A + B;
    let d = N / sm;
    let md = N % sm;
    let ans = d * A + min(A, md);
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace() // iter
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    int sum = 0;
    int t = n;
    while(n){
        sum += n%10;
        n /= 10;
    }
    if(t % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int A;
			cin >> A;
			A--;
			a[A]++;
		}
	}
	int ans = 0;
	rep(i, n) {
		if (a[i] == 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

int app() {
  int h1,m1,h2,m2,k;
  cin>>h1>>m1>>h2>>m2>>k;

  return h2*60+m2-h1*60-m1-k;
}

int main(){cout<<app()<<endl;return 0;}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <queue>
#include <cstdio>
using namespace std;

int main(){

	int N;
	cin >> N;
	string s;
	cin >> s;

	int r = 0;
	int b = 0;

	for(int j = 0; j < N; j++){
		string str = s.substr(j, 1);
		if(str == "R"){r++;}
		else if(str == "B"){b++;}
	}

	if(r >b){cout << "Yes" << endl;}
	else{cout << "No" << endl;}


}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    n = int(input().rstrip())
    s_list = []
    for i in range(n):
        s_list.append(input().rstrip())


    ac_cnt = s_list.count("AC")
    wa_cnt = s_list.count("WA")
    tle_cnt = s_list.count("TLE")
    re_cnt = s_list.count("RE")

    print("AC  x " + str(ac_cnt))
    print("WA  x " + str(wa_cnt))
    print("TLE  x " + str(tle_cnt))
    print("RE  x " + str(re_cnt))



if __name__ == "__main__":
    resolve()



Measured memory_bytes: 16172
#include<bits/stdc++.h>
using namespace std;
int dp[1001][9];
int mask[3]={4,2,1};
int main(void){
	int n,i,j,k,x,a,b,sum;
	char s[1001];
	cin>>n>>s;
	if(s[0]=='J') x=mask[0];
	else if(s[0]=='O') x=mask[1];
	else x=mask[2];
	for(i=0;i<=n;i++){
		for(j=0;j<=8;j++) dp[i][j]=0;
	}
	for(i=0;i<=8;i++){
		a=i&4; b=i&x;
		if(a==4&&b==x) dp[0][i]=1;
	}
	for(i=0;i<n-1;i++){
		if(s[i+1]=='J') x=mask[0];
		else if(s[i+1]=='O') x=mask[1];
		else x=mask[2];
		for(j=1;j<=8;j++){
			for(k=1;k<=8;k++){
				a=j&k; b=k&x;
				if(a>0&&b==x) dp[i+1][k]=(dp[i+1][k]+dp[i][j])%10007;
			}
		}
	}
/*	for(i=0;i<n;i++){
		for(j=1;j<=8;j++) cout<<dp[i][j]<<' ';
		cout<<endl;
	}*/
	sum=0;
	for(i=1;i<=8;i++) sum+=dp[n-1][i];
	sum%=10007;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

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

    ll taka = 1,aoki = 1;
    for(int i = 0; i < n; i++){
        ll t,a; cin >> t >> a;
        ll x = max((taka+t-1)/t,(aoki+a-1)/a);
        taka = t*x,aoki = a*x;
    }
    cout << taka + aoki << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
input = sys.stdin.readline
from collections import *

N, M = map(int, input().split())
X = list(map(int, input().split()))
d = defaultdict(list)

for Xi in X:
    d[Xi%M].append(Xi)

ans = 0

for i in range(1, (M+1)//2):
    S = d[i]
    T = d[M-i]
    
    if len(S)>len(T):
        S, T = T, S
    
    cnt = Counter(T)
    ans += min(sum(v//2 for v in cnt.values()), (len(T)-len(S))//2)+len(S)
    
ans += len(d[0])//2

if M%2==0:
    ans += len(d[M//2])//2

print(ans)

Measured memory_bytes: 86620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

char city[11];
int n;
#define n_MAX 101
pair< pair<string, int>, int> P[n_MAX];

int main(){
    scanf("%d", &n);
    int t;
    string tmp;
    for(int i = 0; i < n; i++){
        scanf("%s %d", city, &t);
        tmp = city;
        P[i] = make_pair(make_pair(tmp, -t), i);
    }

    sort(P, P+n);

    for(int i = 0; i < n; i++){
        printf("%d\n", P[i].second+1);
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <cstdint>
#include <bits/stdc++.h>
#include <queue>
#include <set>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for (int i = n - 1; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif = uint_fast64_t;
using ll = long long int;

int qp(int a, ll b)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mod;
    a = 1ll * a * a % mod;
  } while (b >>= 1);
  return ans;
}
int qp(int a, ll b, int mo)
{
  int ans = 1;
  do
  {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll, ll);
ll mod_add(ll, ll);
ll mod_mul(ll, ll);
ll mod_div(ll, ll);
void make_fact(ll);
void make_invfact(ll);

int main(void)
{

  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;

  if (a1 > b1)
  {
    ll tmp1 = a1;
    ll tmp2 = a2;
    a1 = b1;
    a2 = b2;
    b1 = tmp1;
    b2 = tmp2;
  }
  ll diff = (t1 * b1 + t2 * b2) - (t1 * a1 + t2 * a2);
  if (diff == 0)
  {
    cout << "infinity" << endl;
    return 0;
  }
  if (diff > 0)
  {
    cout << 0 << endl;
    return 0;
  }
  else
  {
    ll Tdiff = t1 * (b1 - a1);
    if (Tdiff % (-diff) == 0)
    {
      cout << (Tdiff / -diff) * 2;
    }
    else
      cout << (Tdiff / -diff) * 2 + 1;
  }

  return 0;
}

ll mod_pow(ll x, ll r)
{
  if (r == 0)
    return 1;
  else if (r == 1)
    return x % mod;
  else if (r % 2 == 0)
  {
    ll t = mod_pow(x, r / 2) % mod;
    return t * t % mod;
  }
  else
  {
    ll t = mod_pow(x, r / 2) % mod;
    ll k = t * t % mod;
    return k * x % mod;
  }
}
ll mod_add(ll a, ll b)
{
  return (a + b) % mod;
}

ll mod_mul(ll a, ll b)
{
  return (a * b) % mod;
}

ll mod_div(ll a, ll b)
{
  return mod_mul(a, mod_pow(b, mod - 2));
}

void make_fact(ll n)
{
  fac[0] = 1;
  rep(i, n)
  {
    fac[i + 1] = mod_mul(fac[i], i + 1);
  }
}

void make_invfact(ll n)
{
  invfac[n] = mod_pow(fac[n], mod - 2);
  for (int i = n - 1; i >= 0; i--)
  {
    invfac[i] = mod_mul(invfac[i + 1], i + 1);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  int minus = 0;
  for(int i  =0; n > i; i++){
    cin>>a[i];
    if(a[i] < 0)minus++;
  }
  int mn = 1000000000; 
  long long ret = 0;
  if(minus%2 == 1){
    for(int i = 0; n > i; i++){
      int tmp = abs(a[i]);
      mn = min(mn,tmp);
    }
  }else mn = 0;
  for(int i = 0; n > i; i++){
      ret += abs(a[i]);
  }
  cout << ret - (mn * 2) << endl;
}

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

int main() {
 string s;
  cin >> s;
 string t = s;
 reverse(s.begin(), s.end());
  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(t.at(i) != s.at(i)) cnt++;
  }
  
  cout << cnt/2 << endl;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<String, Integer> map = new HashMap<>();

		int max = 0;
		for(int i = 0; i < n; i++) {
			String s = sc.next();

			Integer nowCount = map.get(s);
			Integer newCount = null;
			if(nowCount == null) {
				newCount = 1;
			} else {
				newCount = nowCount + 1;
			}

			map.put(s, newCount);
			max = Math.max(max, newCount);
		}

		Set<String> set = new TreeSet<>();
		for(Entry<String, Integer> entry : map.entrySet()) {
			if(max == entry.getValue()) {
				set.add(entry.getKey());
			}
		}

		for(String name : set) {
			System.out.println(name);
		}
	}
}


Measured memory_bytes: 91932
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

int SaB(){

	string s;

	cin >> s;

	if(s.find("A") != -1 && s.find("B") != -1)
		printf("Yes");
	else
		printf("No");

	return 0;

}

signed main() {

	 SaB();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    if(n>m){
        sum+=n;
        
        n--;
        
    }   
    else{
        sum+=m;
        m--;
    }
    sum+=max(n,m);
    cout<<sum<<endl;
    
}


Measured memory_bytes: 256
def longest_common(x, y):
    cost = [0]
    for c in y:
        for i in range(len(cost) -1, -1, -1):
            index = x.find(c, cost[i]) + 1
            if index:
                if i + 1 < len(cost):
                    cost[i + 1] = min(cost[i + 1], index)
                else:
                    cost.append(index)
    return len(cost)  - 1
            

n = int(input())
for _ in range(n):
    x = input()
    y = input()
    print(longest_common(x, y))


Measured memory_bytes: 5612
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
template<typename T>
struct UnionFind
{
	vector<T> par;
	vector<T> rank;
	vector<T> sizes;
	UnionFind(T n):par(n),rank(n,0),sizes(n,1){
	   for(T i=0;i<n;i++){
	     par[i]=i;
	   }
	}
	T root(T x){
	  return par[x]==x?x:par[x]=root(par[x]);
	}

	bool unite(T x,T y){
	  if(x==y) return false;
	  x=root(x); y=root(y);
	  if(x==y) return false;
	  if(rank[x]<rank[y]) swap(x,y);
	  if(rank[x]==rank[y]) rank[x]++;
	  par[y]=x;
	  sizes[x]=sizes[x]+sizes[y];
	  return true;
	}
	bool same(T x,T y){
	  return root(x)==root(y);
	}
	T size(T x){
	  return sizes[root(x)];
	}
};

int main(){
  ll n,m;
  cin>>n>>m;
  UnionFind<ll> uf(n+1);
  vvll t(m+1,vll(0));
  rep(i,n){
    ll k;
    cin>>k;
    rep(j,k){
      ll a;
      cin>>a;
      t[a].pb(i+1);
    }
  }
  for(int i=1;i<=m;i++){
    for(int j=1;j<sz(t[i]);j++){
      uf.unite(t[i][j],t[i][j-1]);
    }
  }
  set<ll> h;
  for(int i=1;i<=n;i++){
    h.insert(uf.root(i));
  }
  if(sz(h)==1){
    COUT("YES");
  }
  else COUT("NO");
}


Measured memory_bytes: 6136
import math

n = int(input())
s = n / 1.08
u = math.floor(s)
l = math.ceil(s)
if math.floor(u * 1.08) == n:
    print(u)
    exit()
elif math.floor(l * 1.08) == n:
    print(l)
    exit()
else:
    print(":(")


Measured memory_bytes: 3060
#include <stdio.h>
int main(){
    int n,ans[300];
    scanf("%d",&n);
    for(int i=1;i<=30;i++)ans[i]=i%7;
    if(ans[n]==2)printf("sat\n");
    else if(ans[n]==3)printf("sun\n");
    else if(ans[n]==4)printf("mon\n");
    else if(ans[n]==5)printf("tue\n");
    else if(ans[n]==6)printf("wed\n");
    else if(ans[n]==0)printf("thu\n");
    else if(ans[n]==1)printf("fri\n");
}


Measured memory_bytes: 2664
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
vector<vector<int> > a;
vector<int> vis;
int dfs(int i)
{
    vis[i]=1;
    int count=1;
    for(int j=0;j<a[i].size();j++)
    if(!vis[a[i][j]])
    {
        count+=dfs(a[i][j]);
    }
    return count;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        a.resize(n);
        vis.resize(n,0);
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            u--,v--;
            a[u].push_back(v);
            a[v].push_back(u);
        }
        int count=0;
        for(int i=0;i<n;i++)
        if(!vis[i])
        {
            count=max(dfs(i),count);
        }
        cout<<count<<"\n";
    }
    return 0;
}

Measured memory_bytes: 24216
/*
*   1. What was the key concept?
*   2. What mistake did I make? (if any)
*   3. Thing to remember from now on.
*/

#include <iostream>
using namespace std;

#define INF 0x3f3f3f3f;
#define INFL 0x3f3f3f3f3f3f3f3f;
#define NITRO ios_base::sync_with_stdio(false); cin.tie(false)
#define PRECISE cout << fixed << setprecision(9)

using ll = long long int;
using ld = long double;

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;

int main(){

    string s;
    cin >> s;

    int ans = 0;

    for (int i=0; i<s.size(); i++){
        ans += s[i] - '0';
    }

    if (ans % 9 == 0) puts("Yes");
    else puts("No");

    return 0;
}

// Check the corner cases. (n = 1).
// Check overflows. (int vs ll).
// Be consistent.

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#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(){
  string s;
  cin >> s;
  int n = s.length();
  
  int red = 0;
  int blue = 0;
  rep(i, n){
    if(s[i] == '0'){
      ++red;
    }else{
      ++blue;
    }
  }
  
  cout << min(red, blue) * 2 << endl;
  return 0;
}

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

int main () {
  int n;
  cin >> n;
  vector<string> a;
  for (int i=1; i<=n; i++) {
    if (i % 3 == 0 && i % 5 == 0) a.push_back("FizzBuzz");
    else if (i % 3 == 0) a.push_back("Fizz");
    else if (i % 5 == 0) a.push_back("Buzz");
    else a.push_back(to_string(i));
  }
  //for (string s : a) cout << s << endl;
  long long sum = 0;
  for (int i=0; i<n; i++) {
    if (to_string(i+1) == a.at(i)) sum += (i+1);
  }
  cout << sum << endl;
}

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

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int containerA, waterB, containerC;
    
    cin >> containerA >> waterB >> containerC;
    
    containerC -= (containerA - waterB);
    if(containerC < 0) containerC = 0;
    
    printf("%d", containerC);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

void A() {
	string s; cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

void B() {
	int N, K; cin >> N >> K;
	vector<int> snuke(N);

	for (int i = 0; i < K; i++) {
		int d; cin >> d;

		for (int j = 0; j < d; j++) {
			int A; cin >> A; A--;
			snuke[A]++;
		}
	}

	int cnt = 0;
	for (int k = 0; k < N; k++) {
		if (snuke[k] == 0) cnt++;
	}

	cout << cnt << endl;
}
int main() {
	A();
}


Measured memory_bytes: 3576
import math
from collections import Counter

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
s = []
for i in range(N):
    s.append(''.join(sorted(input())))

c = Counter(s)
l = len(c.most_common())
a = c.most_common()

cnt = 0
for i in range(l):
    if a[i][1] < 2:
        continue
    cnt += combinations_count(a[i][1], 2)

print(cnt)

Measured memory_bytes: 87384
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
  long long int N,C,K;
  cin >> N >> C >> K;
  vector<long long int>T(N);
  vector<long long int>D(N);
  for(int i=0; i < N; i++)
    cin >> T[i];
  sort(T.begin(), T.end());
  for(int i=0; i < N-1; i++)
    D[i] = T[i+1] - T[i];
  int ans = 0;
  int i=-1;
  long long int time=0;
  long long int cap=1;
  for(;;){
    for(;;){
      if(time+D[i+1] <= K && cap+1 <= C) i++;
      else break;
      if(i == N-2) break;
      time += D[i];
      cap += 1;
    }
    time = 0;
    cap = 1;
    ans++;
    if(i == N-2) break;
    i++;
    if(i == N-2){
      ans++;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
	int a,b;
	cin >> a >> b;
	if(a==1){
		if(b!=1){
			cout << "Alice\n";
		}else{
			cout << "Draw\n";
		}
	}else if(b==1){
		cout << "Bob\n";
	}else if(a>b){
		cout << "Alice\n";
	}else if(a == b){
		cout << "Draw\n";
	}else{
		cout << "Bob";
	}	
}

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

using i64 = int64_t;

int qa[100005]={0}, qb[100005];

int main(){
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> v;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());

    for(int i=1;i<=v.size();++i){
        qa[v[i-1].first] = i;
        qb[v[i-1].second] = i;
    }

    int ans = 0, k = 0, tmp = 0;
    for(int i=1;i<=n;++i){
        if(qb[i] > k){
            ans++;
            k = tmp;
        }
        tmp = max(tmp, qa[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2036
#include <stdio.h>

int main(){
  int N,i,ans=0;
  scanf("%d",&N);
  int H[N];
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  for(i=0;i<N-1;i++){
    if(H[i]==H[i+1]+1){
      H[i+1] += 1;
    }else if(H[i]>H[i+1]+1){
      ans = 1;
    }
  }
  if(ans == 1){
    printf("No");
  } else {
    printf("Yes");
  }
}

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

int64_t MOD = 1000000007;
int64_t MAX = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> list(N);
    for (int i = 0; i < N; i++)
        cin >> list[i];
    sort(list.begin(), list.end());
    int ans = 0;
    for (int i = 0; i < K; i++)
        ans += list[i];
    cout << ans;
}

Measured memory_bytes: 3608
count_val1 = 0
list1 = []
for count_val in range(1, 10001):
    input_val = input()
    list1.append(input_val)
    if int(input_val) == 0:
        print("Case 1: {}".format(list1[0]))
        for count_val1 in range(int(len(list1)) - 2):
            print("Case {}: {}".format(int(count_val1) + 2, list1[int(count_val1) + 1]))
            count_val1 += count_val1
        exit()
for count_val1 in range(len(list1)):
    print("Case {}: {}".format(int(count_val1) + 1, list1[count_val1]))
    count_val1 += count_val1


Measured memory_bytes: 6284
import bisect

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i] and is_prime[(i+1)//2]]

Q = int(input())
p_list = primes(10 ** 5)
for _ in range(Q):
    l, r = map(int, input().split())
    li = bisect.bisect_left(p_list, l)
    ri = bisect.bisect_right(p_list, r)
    print(ri-li)



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

typedef long long ll;
typedef long double ld;

int main()
{

  ll N,M;

  cin >> N >> M;

  ll a[M];

  rep(i,M)cin >> a[i];

  ll sum = 0,ans;

  rep(i,M) sum += a[i];

  ans = N - sum;

  if(ans >= 0){
    cout << ans << endl;
  }else{
    cout << "-1" << endl;
  }
  

  return 0;
}


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

int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	rep(i, n) {
		int d; scanf("%d", &d);
		for (int i = 1; i*i <= d; i++) {
			if ((d - i) % (2 * i + 1) == 0)goto g;
		}
		cnt++;
	g:;
	}
	printf("%d\n", cnt);
}

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

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

    map<int, int> mp;
    rep(i, n){
        int tmp;
        cin >> tmp;
        if(tmp>=1) mp[tmp-1]++;
        mp[tmp]++;
        mp[tmp+1]++;
    }

    int MAX = 0;
    for(auto u:mp){
        MAX = max(MAX, u.second);
    }
    cout << MAX << endl;
    // printf("%d\n", N);
    return 0;
}

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

const int lim = 50;

int n, m;
int a[lim], b[lim];

bool graph[lim][lim];
bool visited[lim];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; v2++) {
        if (!visited[v2] && graph[v2][v]) dfs(v2);
    }
}

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

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i]; a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < m; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        fill(visited, visited + lim, false);
        dfs(0);

        bool bridge = false;
        for (int j = 0; j < n; j++) if (!visited[j]) bridge = true;
        if (bridge) ans++;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;
}


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

char s[20];
int n;


void f(char next_char, int current_index) {
	if (current_index == n) {
		s[current_index] = '\0';
		printf("%s\n", s);
		return;
	}
	for(char tc = 'a'; tc <= next_char; tc++) {
		s[current_index] = tc;
		char nc = (tc == next_char) ? (next_char + 1) : next_char;
		f(nc, current_index + 1);
	}
}

int main() {
	cin >> n;
	f('a', 0);
}


Measured memory_bytes: 1536