akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, M; cin >> N >> M;
    vector<int> T(N+1);
    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        l--; r--;
        T[l]++;
        T[r+1]--;
    }
    
    int cur = 0;
    int ans = 0;
    for(int i=0; i<N+1; i++){
        cur += T[i];
        if(cur==M) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N) { cin >> A[i]; B[i] = A[i];}
  sort(B.begin(), B.end(), greater<ll>());
  rep(i,N){
    if(A[i]==B[0]){
      cout << B[1] << endl;
    }
    else cout << B[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 4736
class unionfind():

    def __init__(self,n):
        #親番号<0なら根
        #根の場合、数値の絶対値が要素数
        self.par=[-1 for i in range(n)]
        
    def root(self,x):
        
        par=self.par
        if par[x]<0:
            return x
        else:
            self.x = self.root(par[x])
            return self.x
        
    def unite(self,x,y):
        #高いほうに低いほうをくっつける
        rx=self.root(x)
        ry=self.root(y)
        
        if rx==ry:
            return
        else:
            if self.par[rx]>self.par[ry]:
                rx,ry = ry,rx
                
            self.par[rx]+=self.par[ry]
            self.par[ry] = rx

            
    def same(self, x,y):
        return self.root(x) == self.root(y)
    
    def par_print(self):
        print(self.par)
        
    def count(self, x):
        return -self.par[self.root(x)]

n,m,k = map(int,input().split())

friend = [[] for i in range(n)]
block = [[] for i in range(n)]

uf = unionfind(n)

for i in range(m):
    
    a,b = map(int,input().split())
    a-=1
    b-=1
    
    friend[a].append(b)
    friend[b].append(a)
    
    uf.unite(a,b)
    
    
    
for i in range(k):
    
    a,b = map(int,input().split())
    a-=1
    b-=1
    
    block[a].append(b)
    block[b].append(a) 
    
    
for i in range(n):
    
    ans = uf.count(i)-1 -len(friend[i])
    
    for j in block[i]:
        if uf.same(i,j):
            ans -= 1
    
    print(ans, end = " ")


Measured memory_bytes: 117448
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	char S[100010];
	
	scanf("%d %d", &N, &M);
	scanf("%s", S);
	
	int count = 0;
	int now = N;
	int history[100001];
	
	while(now > 0){
		for(int i = M; i > 0; i--){
			if(S[now-i] == '0'){
				now = now - i;
				history[count] = i;
				count++;
				break;
			}
			if(i == 1){
				now = -1;
			}
		}
	}
	
	if(now == -1){
		printf("-1\n");
	}else{
		for(int i = 0; i < count; i++){
			printf("%d ", history[count - i - 1]);
		}
			printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 896
/// referenced: https://beta.atcoder.jp/contests/abc066/submissions/2252964
#include <bits/stdc++.h>
using namespace std;

constexpr int64_t MOD = 1000000007;

int64_t Power(int64_t base, int64_t exp) {
  int64_t x = 1;
  while (exp) {
    if (exp % 2) {
      x = x * base % MOD;
    }
    base = base * base % MOD;
    exp /= 2;
  }
  return x;
}

int64_t inv(int64_t i){
  return Power(i,MOD-2);
}
int64_t fact[100002],factinv[100002];
int64_t C(int64_t n,int64_t r){
  return fact[n]*factinv[r]%MOD*factinv[n-r]%MOD;
}

int main(){
  int64_t n,a;
  bool c[100002];
  cin >> n;
  for(int64_t i=1;i<=n;i++) c[i]=false;
  int64_t p[100002];
  int64_t x,y;

  for(int64_t i=0;i<=n;i++){
    cin >> a;
    if(c[a]){
      x=p[a];
      y=i;
    }
    c[a]=true;
    p[a]=i;
  }


  fact[0]=1;
  for(int64_t i=1;i<=n+1;i++) fact[i]=i*fact[i-1]%MOD;
  for(int64_t i=0;i<=n+1;i++) factinv[i]=inv(fact[i]);

  for(int64_t i=1;i<=n+1;i++){
    int64_t ans;
    ans=C(n+1,i);
    if(i-1<=n-(y-x)) ans+=MOD-C(n-(y-x),i-1);
    cout << (ans%MOD) << endl;
  }

  return 0;
}


Measured memory_bytes: 3584
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
	int cnt=0,n,d,x;
	cin >> n >> d >> x;

	vector<int>a(n);
	rep(i, n)
		cin >> a[i];
	rep(i, n) {
		for (int j = 1; j <= d; j += a[i])
			cnt += 1;
	}
	cout << cnt + x;
	
}

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

int main(){
	int n;
	cin >> n;
	for (int i=1; i<10; i++){
		for (int j=1; j<10; j++){
			if(i*j == n) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Maxn 200010
 
int n, a[Maxn], b[Maxn], c[Maxn], P[Maxn];
set<int >S;
int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
	{
		scanf("%d", &a[i]);
		P[a[i]]++;
		S.insert(a[i]);
	}
	for (int i=1; i<=n; i++)
	{
		scanf("%d", &b[i]);
		P[b[i]]++;
		S.insert(b[i]);
	}
	bool flag = 0; for (auto p:S) if (P[p]>n) { flag = 1; break; }
	if (flag) puts("No");
	else
	{
		puts("Yes");
		for (int i=1; i<=n; i++) c[i]=b[n-i+1];
		int cur = n, top = 1;
		for (int i=1; i<=n; i++)
			while ((a[i]==c[i]) && (cur >= top))
                if(c[cur] != c[i] && a[cur] != c[i]){ swap(c[i], c[cur]);}
                else if(c[top] != c[i] && a[top] != c[i]) {swap(c[i], c[top]);}
                else cur--, top++;
		for (int i=1; i<=n; i++) printf("%d ", c[i]); puts("");
	}
}

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


int main(){
int n;
cin >> n;
vector<double>a(n);
rep(i,n) cin >> a[i];
double count = 0, ans = 0;
rep(i,n){
    count+= 1/a[i];
    
}
cout << setprecision(20) << 1.0/ count << endl;
}  

Measured memory_bytes: 256
N = int(input())
S = input()
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(i+1, N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)


    




Measured memory_bytes: 9100
int main(void)
{
  int n,m,i,j,sum;

  for(;;){
    sum=1;
    int Q[1000][100]={0};
    int ans[100]={0};
    scanf("%d %d", &n, &m);
    if(n==0&&m==0) break;

    for(i=0;i<n;i++){
      for(j=0;j<m;j++){
	scanf("%d", &Q[i][j]);
	if(Q[i][j]==1) ans[j]++;
      }
    }

    for(i=0;i<n+1;i++){
      for(j=0;j<m;j++){
	if(ans[j]==n-i&&sum==m){
	  printf("%d\n", j+1);
	  sum++;
	  break;
	}
	if(ans[j]==n-i&&sum<m){
	  printf("%d ", j+1);
	  sum++;
	}
      }
      if(sum>m) break;
    }
  }

  return 0;
}


Measured memory_bytes: 996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
ll n, m, q, ans;
vector<vll> com;
vll a;
void dfs(ll pos, ll num){
    a[pos] = num;
    if(pos == n-1){
        ll tmp = 0;
        //rep(i,n)cout << a[i] << ((i < n-1)?" ": "      ");
        rep(i,q){
            if(a[com[i][1]] - a[com[i][0]] == com[i][2])tmp += com[i][3];
            //rep(j,4)cout << com[i][j] << ((j < 3)?" ":"     ");
        }

        //cout << tmp << endl;
        ans = max(ans, tmp);

        return;
    }
    REP(i, num, m+1)dfs(pos+1, i);
    return;
}
int main(){
    cin >> n >> m >> q;
    com.resize(q, vll(4));
    a.resize(n);

    rep(i,q){
        ll c1, c2;
        cin >> c1 >> c2;
        c1--; c2--; 
        com[i][0] = c1;
        com[i][1] = c2;
        cin >> com[i][2] >> com[i][3];
    }
    
    /*cout << endl;
    rep(i,q)rep(j,4)cout << com[i][j] << ((j < 3)?" ":"\n");
    cout << endl;*/

    REP(i,1,m+1)dfs(0, i);
    cout << ans << endl;
    return 0;
}  

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

int	main() {
	long x;
	cin >>x;
	long x1=x/11*2;
	long x2=x%11;
	if (6<x2)
		x1 +=2;
	else if (x2!=0)
		x1++;
	cout <<x1 <<endl;
	return 0;
};


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

using namespace std;

#define sp << " " <<

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(a,b) sp max(0,a+b-n);
    return 0;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N, K; cin >> N >> K;
	vector<ll> x(N); rep(i, N)cin >> x[i];

	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += 2 *  min(abs(x[i] - K), x[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
addition = 0
price=0
for i in range(0, N-1):
    if a[i]+1 == a[i+1]:
        addition+=c[a[i]-1]
    else:
        
        addition+=0

print(sum(b) + addition)

Measured memory_bytes: 3064
'use strict'

function main(inp) {
  inp = inp.trim().split('\n')
  const NQ = inp.shift().split(' ').map(n => Number(n))
  let node = {}
  for (let i = 1; i <= NQ[0]; i++) {
    node[i] = {score: 0, next: []}
  }

  for (let i = 0; i < inp.length; i++) {
    const arr = inp[i].split(' ').map(n => Number(n))
    let j = arr[0]
    if (i < NQ[0] - 1) {
      node[j].next.push(arr[1])
    } else {
      node[j].score += arr[1]
    }
  }

  let stack = [1]
  while(stack.length) {
    let n = stack.pop()
    for (let i = 0; i < node[n].next.length; i++) {
      let j = node[n].next[i]
      node[j].score += node[n].score
      stack.push(j)
    }
  }
  
  let ans = []
  for (let i = 1; i <= NQ[0]; i++) ans.push(node[i].score)
  console.log(ans.join(' '))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 134844
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define ll long long

int dist(int x, int y, int x2, int y2) {
    return abs(x-x2) + abs(y-y2);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
        if((abs(x[i]) + abs(y[i]))%2 != (abs(x[0]) + abs(y[0]))%2) {
            cout << "-1\n";
            return 0;
        }
    }
    vector<int> dx = {1, -1, 0, 0};
    vector<int> dy = {0, 0, 1, -1};
    string dirs = "LRDU";
    vector<int> dists;
    for(int i = 31; i >= 0; --i) {
        dists.push_back(1LL<<i);
    }
    dists.push_back(1);
    if((abs(x[0]) + abs(y[0]))%2 == 1) dists.pop_back();
    cout << dists.size() << '\n';
    for(int dist : dists) cout << dist << ' ';cout << '\n';
    for(int i = 0; i < n; ++i) {
        int currX = x[i], currY = y[i];
        string s = "";
        int power = 31;
        for(int currDist : dists) {
            int best = 1e12;
            char dir;
            int pos;
            for(int k = 0; k < 4; ++k) {
                const int nextX = currX + dx[k]*currDist;
                const int nextY = currY + dy[k]*currDist;
                if(abs(nextX)+abs(nextY) <= (1LL<<power)) {
                    currX = nextX;
                    currY = nextY;
                    dir = dirs[k];
                    break;
                }
            }
            power = max(0LL, power-1);
            s += dir;
        }
        //cout << "currs (should be origin): " << currX << ' ' << currY << '\t';
        cout << s << '\n';
    }
    
    return 0;
}
















Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Integer> list2 = new ArrayList<>();
    //final List<Long> list3 = new ArrayList<>();

    int n = sc.nextInt();
    int x = sc.nextInt();
    int count = 0;

    for(int i = 0 ; i < n ; i++){
        list.add(sc.nextInt());
        x -= list.get(i);
        count++;
    }

    Collections.sort(list);
    count += x / list.get(0);

    System.out.println(count);

    

    




    







}
}

Measured memory_bytes: 36000
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int main(){    
  int N,L;
  cin >> N >> L;
  int l=L,A[N],sum=0;


  if(L>=0){
    for(int i=0;i<N-1;i++){
      l++;
      sum += l;
    }
  }
  else if(L < 0 && L+N <= 0){
    for(int i=0;i<N-1;i++){
      sum += l;
      l++;
    }
  }
  else{
    for(int i=0;i<N;i++){
    sum += l;
    l++;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n):
    if i == n - 1 and i + 1 == p[i]:
        count += 1
    elif i + 1 == p[i]:
        tmp = p[i]
        p[i] = p[i+1]
        p[i+1] = tmp
        count += 1
print(count)


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

int main()
{
int i;
int N;
int K;
char S[ 100 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N;
	cin >> K;
	cin >> S;

	S[ K - 1 ] += 'a' - 'A';

	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(M)]

ball_count = [1]*N
visited = [0]*N
visited[0] = 1

for x,y in xy:
  ball_count[x-1] -= 1
  ball_count[y-1] += 1
  if visited[x-1] == 1:
    visited[y-1] = 1
  if ball_count[x-1] == 0:
    visited[x-1] = 0

print(sum(visited))

Measured memory_bytes: 28836
def judge(m,f,r):
    if m == -1 or f == -1:
        return 'F'
    if m + f >= 80:
        return 'A'
    if m + f >= 65:
        return 'B'
    if m + f >= 50:
        return 'C'
    if m + f >= 30 and r >= 50:
        return 'C'
    if m + f >= 30:
        return 'D'
    else:
        return 'F'

Data = []

while True:
    m,f,r = input().split()
    m = int(m)
    f = int(f)
    r = int(r)
    if m == -1 and f == -1 and r == -1:
        break
    Data.append([m,f,r])

for a in Data:
    print(judge(a[0],a[1],a[2]))



Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var TA = ReadSplitInt();
            var T = TA[0];
            var A = TA[1];
            var H = ReadSplitInt();

            var min = double.MaxValue;
            var ans = -1;
            for (int i = 0; i < N; i++)
            {
                if (min > Abs(A - (T - (H[i] * 0.006))))
                {
                    min = Abs(A - (T - (H[i] * 0.006)));
                    ans = i + 1;
                }
            }
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13332
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    # s = input().rstrip()
    a, b, c, k = [int(x) for x in input().rstrip().split(" ")]

    if abs(a - b) > 10**18:
        print("Unfair")
        return

    if k % 2 == 0:
        print(a - b)
    else:
        print(b - a)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61900
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int a, p, i, max;
    int[] x;

    x = new int[5];
    for(;;){
      a = sc.nextInt(); p = sc.nextInt();
      if(a == 0 && p == 0)break;
      x[0] = a + p; max = 0;
      for(i = 1;i < 5;i++){
        a = sc.nextInt(); p = sc.nextInt();
        x[i] = a + p;
        if(x[max] < x[i])max = i;
      }

      if(max == 0)out.println("A " + x[max]);
      else if(max == 1)out.println("B " + x[max]);
      else if(max == 2)out.println("C " + x[max]);
      else if(max == 3)out.println("D " + x[max]);
      else out.println("E " + x[max]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 21128
import math

s = int(input())

mod = 10**9

if s <= mod:
    print(0, 0, 0, 1, s, 0)
else:
    x1, x2 = mod, 1
    y2 = math.ceil(s / mod)
    y1 = y2 * mod - s
    print(0, 0, x1, x2, y1, y2)

Measured memory_bytes: 3060
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
template <class T, class... A>
void printd(const T &first, const A &... rest) { cout << fixed << setprecision(15) << first; prints_rest(rest...); }


namespace {
	// printElems(&a[0], &a[n]);　みたいな感じで使う。
	void printElems(const int* begin, const int* end)
	{
		for (const int* p = begin; p != end; ++p) {
			cout << *p << ' ';
		}
		cout << endl;
	}
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const ll BIG = 1LL<<60;

//----------------------------------------------

string c[10];

int main(){
	int h,w,k;
	cin >> h >> w >> k;
	rep(i,h) cin >> c[i];
	ll ans = 0;
	rep(i,1<<h){
		rep(j, 1<<w){
			int cnttmp = 0;
			rep(tmp,h)rep(tmp2,w){
				if((i&1<<tmp) || (j&1<<tmp2)) continue;
				if(c[tmp][tmp2] == '#') cnttmp++;
			}
			if (cnttmp == k) ans++;
		}
	}

	prints(ans);


	return 0;
}




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

int main() {
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int ans_wat = 0;
  int ans_sug = 0;
  double ans_rate = -1.0;
  
  for ( int i = 0; i * a * 100 < f ; i++){
    for( int j = 0; j * b * 100 < f - i * a * 100; j++){
      int water = (i * a + j * b )  * 100;
      int maxsugar = min((e * (i * a + j * b)) ,f - water);
      if (water){
        for ( int k = 0; k * c < maxsugar ; k++){
          int l = (maxsugar - c * k ) / d;
          int sugar = k * c + l * d;
          double rate = (100.0 * sugar) / ( water + sugar);
          if (ans_rate <= rate && water <= f && sugar <= e * (i * a + j * b)){
            ans_wat = water;
            ans_sug = sugar;
            ans_rate = rate;
          }//if k          
        }//4_k
      }//ifj
    }//4 j
  }//4 i
  cout << ans_wat + ans_sug << " " << ans_sug << endl;  
}


Measured memory_bytes: 256
N, *A = map(int, open(0).read().split())

s = 0
m = 1000
for i in range(N):
    m += s * A[i]
    s = 0
    if i+1 < N and A[i] < A[i+1]:
        s = m // A[i]
        m -= s * A[i]

print(m)

Measured memory_bytes: 9040
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
z = set(x)
t1 = y[n//2-1]
t2 = y[n//2]
idx = dict([])
idx[y[0]] = 0
l = y[0]
cnt = 0
for i in y:
    if i == l:
        cnt += 1
        continue
    else:
        idx[i] = cnt
        l = i
        cnt += 1

for i in x:
    t = idx[i]
    if t<n//2:
        print(t2)
    else:
        print(t1)

Measured memory_bytes: 52396
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)

int main() {
    int K;
    char S[105];
    scanf("%d\n%s", &K, S);
    if (strlen(S) > K) {
        S[K + 2] = S[K + 1] = S[K] = '.';
        S[K + 3] = 0;
    }
    printf("%s\n", S);
    return 0;
}

void print_log() {
    printf("===finish!===\n");
}

void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}

Measured memory_bytes: 1648
#include <iostream>

using namespace std;

int main()
{
    int i,a[3];
    int temp=0;
    for(i=0;i<3;i++)
    {
        cin>>a[i];
    }
    temp=a[0];
    a[0]=a[1];
    a[1]=temp;

    temp=a[0];
    a[0]=a[2];
    a[2]=temp;
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;

    return 0;
}


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

int n;
int a[1000009],dp[1000009];

int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dp[n-1];
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
int n;
cin>>n;
ll a[n];
rep(i,n){
    cin>>a[i];
}
ll sum[n];
sum[0] = a[0];
rep(i,n-1){
sum[i+1] = sum[i] + a[i+1];
}
ll ans = llINF;
rep(i,n-1){
    ll Q = abs((sum[n-1] - sum[i]) - sum[i]);
ans = min(ans,Q);
}
cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 6652
import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.math;

void main(){

    while(true){
	auto s = readln();
	if(stdin.eof()) break;
	char[] res;
	for(int i=0;i<s.length;i++){
	    if(s[i]!='@') res ~= s[i];
	    else{
		if(i+2 >= s.length) continue;
		int c = to!int(s[i+1]-'0');
		char c1 = s[i+2];
		for(int j=0;j<c;j++) res ~= c1;
		i += 2;
	    }
	}
	for(int i=0;i<res.length;i++)
	    writef("%c",res[i]);
    }
}

Measured memory_bytes: 2412
#include <iostream>
#include<bits/stdc++.h>
#define li long long int
using namespace std;

int main()
{

int n;
cin>>n;

int counts=0;

for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if((i+1)%2==1 && x%2==1){
        counts++;
    }

}
    cout<<counts<<endl;
    return 0;
}


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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

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

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

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

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

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

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N + 1,0);
	repn(i, N) cin >> a[i];
	sort(++a.begin(), a.end(),greater<ll>());
	a.push_back(0);

	string ans = "First";
	repn(i, N) {
		if (i <= a[i] && i > a[i + 1] && (a[i] - i) % 2 == 0) { ans = "Second"; }
		
		else if (i == a[i+1]) {
			ll c = i+1;
			while (i == a[c+1]) { c++; }
			if ((c - i) % 2 == 0&&(a[i]-i)%2==0) { ans = "Second"; }
			
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <array>
#include <climits>
#include <cassert>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x","<<#y":"<<x<<","<<y<<endl

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

void mv(vvi& t,int H){
    rep(c,H){
        for(int j=0;j<5;j++){
            for(int i=H-2;i>=0;i--){
                if(t[i+1][j]==0){
                    swap(t[i][j],t[i+1][j]);
                }
            }
        }
    }
}

bool check(vvi& t,int H){
    bool f=false;
    for(int i=0;i<H;i++){
        for(int j=0;j<5;j++){
            int cnt = 0;
            if(t[i][j]==0) continue;
            for(int k=j;k<5;k++){
                if(t[i][j]!=t[i][k]) break;
                cnt++;
            }
            if(cnt>=3){
                int n = t[i][j];
                for(int k=j;k<5;k++){
                    if(n!=t[i][k]) break;
                    t[i][k] = 0;
                }
                f=true;
                break;
            }
        }
    }
    mv(t,H);
    return f;
}

void solve(int H){
    vector<vector<int>> t(H,vi(5));
    int score=0;
    rep(i,H) rep(j,5) cin >> t[i][j];

    rep(i,H) rep(j,5) score += t[i][j];

    while(check(t,H)){
//        cout << endl;
//        rep(i,H){
//            rep(j,5) cout << t[i][j] << " ";
//            cout << endl;
//        }
    }
    
    rep(i,H) rep(j,5) score -= t[i][j];
    cout << score << endl;
}

int main(){
    int H;
    while(cin>>H){
        if(H==0) break;
        solve(H);
    }
}

Measured memory_bytes: 3164
<?php
fscanf(STDIN, "%d %d %d %d", $w, $h, $x, $y);

$diff_x = abs($x*2-$w);
$diff_y = abs($y*2-$h);
$rtn1 = $w*$h/2;

$rtn2 = 0;
if(($diff_x==0) and ($diff_y==0)){
  $rtn2 = 1;
}

printf("%f %d\n",$rtn1,$rtn2);


?>

Measured memory_bytes: 3576
<?php

while($line = trim(fgets(STDIN))) {
$line = explode(' ', $line);
if ($line[0] == 0 && $line[1] == 0) {
  break;
}
                                                                                                                                                                                                                                              
sort($line);
print(implode(' ', $line)."\n");
}

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

using namespace std;

int main(){
	string s,t; cin>>s;
	for(int i=0;i<s.length();){
		t+=s[i];
		if(s[i]=='e') i+=3;
		else          i+=7;
	}

	string ans;
	for(int i=1,pre=0;i<=t.length();i++){
		if(i==t.length() || t[i-1]==t[i]){
			string tmp=t.substr(pre,i-pre);
			if(ans.length()<tmp.length()) ans=tmp;
			pre=i;
		}
	}

	cout<<(*ans.rbegin()=='e'?"egg":"chicken")<<endl;

	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int wide = sc.nextInt();

		char[][] masu = new char[height][wide];

		for (int i = 0; i < height ; i++) {
			String row = sc.next();
			for (int j = 0; j < wide ; j++) {
				masu[i][j] = row.charAt(j);
			}
		}

//		for (int i = 0; i < height ; i++) {
//			for (int j = 0; j < wide ; j++) {
//				masu[i][j] = sc.next();
//			}
//		}
		ArrayList<Integer> deleteColumns = new ArrayList<>();
		ArrayList<Integer> deleteLines = new ArrayList<>();


		for (int i = 0; i < height ; i++) {
			boolean allWhileLine = true;
			for (int j = 0; j < wide ; j++) {
				if ("#".equals(String.valueOf(masu[i][j]))) {
					allWhileLine = false;
					continue;
				}

				boolean allWhileColumn = true;
				for (int k = 0; k < height ; k++) {
					if ("#".equals(String.valueOf(masu[k][j]))) {
						allWhileColumn = false;
						break;
					}
				}
				if (allWhileColumn) {
					deleteColumns.add(j);
				}

			}
			if (allWhileLine) {
				deleteLines.add(i);
			}
		}

		for (int i = 0; i < height ; i++) {
			if (deleteLines.contains(i)) {
				continue;
			}
			for (int j = 0; j < wide ; j++) {
				if (deleteColumns.contains(j)) {
					continue;
				}
				System.out.print(masu[i][j]);

			}
			System.out.println();
		}


	}
}


Measured memory_bytes: 42144
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <cmath>

using namespace std;


int main(){
    int a, b;
    char* str;
    str = (char*)malloc(sizeof(char) * 50);

    while(fgets(str, 50, stdin) != NULL) {
        sscanf(str, "%d%d", &a, &b);
        cout << (int)log10(a+b) + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3324
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
//#include <ostream>


using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> d(K);
  int A[110][110];
  rep(i,K){
    cin >> d[i];
    rep(j,d[i])cin >> A[i][j];
  }
  vector<int> okasi(110,0);
  rep(i,K)rep(j,110){
    okasi[A[i][j]]++;
  }
  int ans = 0;
  for(int i = 1;i <= N;i++){
    if(okasi[i]==0)ans++;
  }
  cout << ans << endl;
 }


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
const int N = 2e5+5;


vector<ll>ans,veca,vecb;
vector<int>adj[N];
vector<double>aka;
vector<pair<int,double>>dp[N];
vector<bool>vis;


void init(int n){
    ans.clear();veca.clear();aka.clear();vis.clear();
    vecb.clear(),vecb.resize(n);veca.resize(n);vis.resize(n);
    for (int i = 0; i <n; i++) {
        vis[i]=0;
    }
    for (int i = 0; i<=n; i++) {
        adj[i].clear();
    }
    for (int i = 0; i <=n; i++) {
        dp[i].clear();
    }
    
}
int power(int a,int n){
    int res=1;
    for (int i = 0; i < n; i++) {
        res=(1LL*res*a)%mod;
    }
    return res%mod;
}
int add(int a){
    if(a<0) a+=mod;
    return a;
}
void solve(){
    string s;
    cin>>s;
    int asn=0;
    for (int i = 0; i < s.length(); i++) {
        asn+=s[i]-'0';
    }
    cout<<(asn%9?"No":"Yes")<<"\n";
}

int main(){
   
   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
        
        
    return 0;
}

Measured memory_bytes: 13108
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
using namespace std;
const int maxd=998244353,N=100000;
const double pi=acos(-1.0);
typedef long long ll;
int n,sumr[3030],sumb[3030],dp[4060][4060];
char s[3030];

int read()
{
	int x=0,f=1;char ch=getchar();
	while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
	while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
	return x*f;
}

int main()
{
	scanf("%s",s+1);
	int i,j;n=strlen(s+1);
	sumr[0]=0;sumb[0]=0;
	for (i=1;i<=n;i++)
	{
		sumr[i]=sumr[i-1];sumb[i]=sumb[i-1];
		if (s[i]=='0') sumr[i]+=2;
		else if (s[i]=='1') {sumr[i]++;sumb[i]++;}
		else if (s[i]=='2') sumb[i]+=2;
	}
	//for (i=1;i<=n;i++) cout << sumr[i] << " ";cout << endl;
	//for (i=1;i<=n;i++) cout << sumb[i] << " ";cout << endl; 
	dp[0][0]=1;
	for (i=1;i<=2*n;i++)
	{
		int nowr=sumr[min(i,n)],nowb=sumb[min(i,n)];
		for (j=0;j<=i;j++)
		{
			if ((nowr>=j) && (nowb>=i-j))
			{
				dp[i][j]=dp[i-1][j];
				if (j>0) dp[i][j]=(dp[i][j]+dp[i-1][j-1])%maxd;
			}
		}
	}
	printf("%lld",dp[2*n][sumr[n]]);
	return 0;
}
		


Measured memory_bytes: 62336
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 1e6 + 10;
lli dp[N];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	lli n, w;
	cin >> n >> w;
	int maxi = n*1000;
	for(int i = 0; i <= maxi; i++) dp[i] = INF64;
	dp[0] = 0;
	for(int i = 1; i <= n; i++) {
		lli ww, vv;
		cin >> ww >> vv;
		for(int j = maxi; j >= vv; j--)
			if(dp[j-vv] != INF64)
				dp[j] = min(dp[j], dp[j-vv] + ww);
	}
	lli ans = 0;
	for(int j = maxi; j >= 0; j--) {
		if(dp[j] <= w && dp[j] != 0) {
			cout << j << "\n";
			return 0;
		} 
	}	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a < b && b < c)
		{
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

using namespace std;

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

#define int ll


main(){
	int n;
	cin >> n;
	string s[n];
	int ac  = 0;
	int wa  = 0;
	int tle  = 0;
	int re  = 0;
	for(int i=0;i<n;i++){
		cin >> s[i];
		if(s[i]=="AC") ac++;
		if(s[i]=="WA") wa++;
		if(s[i]=="TLE") tle++;
		if(s[i]=="RE") re++;
	}

	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;


	return 0;
}


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

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

using namespace std;
using lint=long long;

class union_find{
	int n;
	vector<int> p;
public:
	union_find(int n):n(n),p(n,-1){}
	int find(int u){ return p[u]<0?u:p[u]=find(p[u]); }
	void unite(int u,int v){
		u=find(u); v=find(v);
		if(u!=v){
			if(p[v]<p[u]) swap(u,v);
			p[u]+=p[v]; p[v]=u; n--;
		}
	}
	bool is_same(int u,int v){ return find(u)==find(v); }
	int size()const{ return n; }
	int size(int u){ return -p[find(u)]; }
};

int main(){
	int h,w; cin>>h>>w;
	vector<string> B(h);
	rep(i,h) cin>>B[i];

	union_find U(h*w);
	rep(i,h) rep(j,w) {
		if(i<h-1 && B[i][j]!=B[i+1][j]) U.unite(i*w+j,(i+1)*w+j);
		if(j<w-1 && B[i][j]!=B[i][j+1]) U.unite(i*w+j,i*w+(j+1));
	}

	map<int,lint> fb,fw;
	rep(i,h) rep(j,w) {
		if(B[i][j]=='#') ++fb[U.find(i*w+j)];
		if(B[i][j]=='.') ++fw[U.find(i*w+j)];
	}

	lint ans=0;
	for(auto p:fb) ans+=fb[p.first]*fw[p.first];
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 21284
a = input()
b = input()

if(len(a) > len(b)):
  print("GREATER")
elif(len(a) < len(b)):
  print("LESS")
elif(len(a) == len(b)):
  if(int(a) == int(b)):
    print("EQUAL")
  elif(int(a) > int(b)):
    print("GREATER")
  else:
    print("LESS")

Measured memory_bytes: 38256
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
const int N = 1e6 + 10;
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int cnt = 0;



signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/
	
	cin >> n;
	vpii vec;

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		vec.pb({ b, a });
	}

	sort(all(vec));

	cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cnt += vec[i].second;

		if (cnt > vec[i].first)
		{
			return cout << "No", 0;
		}
	}

	cout << "Yes";
	return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  
  int gate[m][2];
  int l = -1;
  int r = n+1;
  int res = 0;
  for (int i = 0; i < m; i++){
    cin >> gate[i][0] >> gate[i][1];
  }
  for (int j = 0; j < m; j++){
    l = max(l, gate[j][0]);
    r = min(r, gate[j][1]);
  }
  res = (r - l + 1)*(l <= r);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
int N;
int k = -1;
vector<vector<int>> A;

void dfs(int x, int c) {
  for (int i = c; i < k+1; i++) {
    A[c-1][i] = x + (i-c);
  }
  for (int i = c; i < k+1; i++) {
    A[i][c] = x + (i - c);
  }
  if (x == N) return;
  else {
    dfs(A[k][c]+1,c+1);
    return;
  }
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  cin >> N;
  for (int i = 1;i < 10000; i++) {
    if (i * (i+1) / 2 == N) k = i;
  }
  if (k == -1) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    cout << k+1 << endl;
    A.resize(k+1, vector<int>(k+1));
    rep(i,k+1) A[i][0] = k;
    dfs(1,1);
    rep(i,k+1) {
      rep(j,k+1) cout << A[i][j] << " ";
      cout << endl;
    }
  }
}

Measured memory_bytes: 2176
#aとbが0のとき処理を終わる
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:break

    #カラリストの作成と変数のリセット
    line = []
    kei = []
    i = 0
    
    #標準入力
    for _ in range(a):line.append(int(input()))
    
    #しゃくとり法の最初の数を変数に代入する
    for j in range(0,b):i += line[j]
    
    #しゃくとり法の更新
    for l in range(b,a):
        i += line[l] - line[l - b]
        kei.append(i)
        
    #出力
    print(max(kei))


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

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

const int MAXN = 100;
const int MAXK = 1e5;
const ll MOD = 1e9+7;

int N, K, arr[MAXN+10];
ll dp[MAXN+10][MAXK+10];

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    scanf("%d%d", &N, &K);
    for(i=1; i<=N; i++) scanf("%d", &arr[i]);
    for(i=0; i<=K; i++) dp[0][i]=1;
    for(i=1; i<=N; i++)
    {
        for(j=0; j<=K; j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j>=arr[i]+1) dp[i][j]=(dp[i][j]-dp[i-1][j-arr[i]-1]+MOD)%MOD;
            dp[i][j]=(dp[i][j-1]+dp[i][j])%MOD;
        }
    }
    printf("%lld", (dp[N][K]-dp[N][K-1]+MOD)%MOD);
    return 0;
}


Measured memory_bytes: 80128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] sList = sc.next().split("");
        List<String> alphabet = Arrays.asList("ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""));

        int count = sList.length;
        
        String[] result = new String[count];
        for (int i = 0; i < count; i++) {
            int index = alphabet.indexOf(sList[i]);
          
            if (index + n > 25) {
                result[i] = alphabet.get(index + n - 26);
            } else {
                result[i] = alphabet.get(index + n);
            }
        }

        for (int i = 0; i < count; i++) {
            System.out.print(result[i]);
        }
    }
}

Measured memory_bytes: 27232
A, B = map(int,input().split())

kai = []

for i in range(1,10):
    for j in range(0,10):
        for k in range(0,10):
            num = int(str(i)+str(j)+str(k)+str(j)+str(i))
            kai.append(num)
            
kai2 = filter((lambda x: x >= A and x <= B), kai)
print(len(list(kai2)))

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
	ll n, k, t, r;
	scanf("%lld %lld", &n, &k);
	t = n / k;
	r = t * t * t;
	if (k % 2 == 0) {
		t = (n + k / 2) / k;
		r += t * t * t;
	}
	printf("%lld\n", r);
}

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

int main() {
	int n, w;
	while (cin >> n >> w, n) {
		vector<int> v(n);
		int m = 0;
		for (int i = 0; i < n; i++) {
			cin >> v[i];
			m = max(m, v[i]);
		}
		vector<int> u(m / w + 1);
		for (auto i : v) {
			u[i / w]++;
		}
		int h = 0;
		for (auto i : u) {
			h = max(h, i);
		}
		double r = 0.01;
		for (int i = 0; i < u.size(); i++) {
			r += double(u.size() - 1 - i) / (u.size() - 1) * u[i] / h;
		}
		cout << fixed << setprecision(6) << r << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
<?php
  fscanf(STDIN,"%d%d", $n,$T);
  $t = explode(" ",trim(fgets(STDIN)));
  
  $s = 0;
  for($i=1; $i<$n; $i++){
      if($T > ($t[$i]-$t[$i-1])){
          $s += $T-($t[$i]-$t[$i-1]);
      }
  }
  
  echo ($T*$n)-$s;

Measured memory_bytes: 23028