akhauriyash/Code-Regression huggingface dataset:
ListM = []
ListA = []
ListR = []
ListC = []
ListH = []
N = int(input())
for j in range(N):
 S = input()
 if S[0] == "M":
  ListM.append(S)
 elif S[0] == "A":
  ListA.append(S)
 elif S[0] == "R":
  ListR.append(S)
 elif S[0] == "C":
  ListC.append(S)
 elif S[0] == "H":
  ListH.append(S)
 S = ()
print(len(ListM)*len(ListA)*len(ListR)+len(ListM)*len(ListA)*len(ListC)+len(ListM)*len(ListA)*len(ListH)+len(ListM)*len(ListR)*len(ListC)+len(ListM)*len(ListH)*len(ListR)+len(ListM)*len(ListC)*len(ListH)+\
len(ListC)*len(ListA)*len(ListR)+len(ListH)*len(ListA)*len(ListR)+len(ListC)*len(ListA)*len(ListH)+len(ListH)*len(ListC)*len(ListR))


Measured memory_bytes: 10208
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC158
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            string s = Console.ReadLine();
            if(s[0] == s[1] && s[1] == s[2])
            { Console.WriteLine("No"); }
            else
            { Console.WriteLine("Yes"); }
        }
    }
}


Measured memory_bytes: 11092
import math
l = input().split()
N = int(l[0])
l = input().split()
A = [0] * 13
for i in l:
    index = int(i) // 400
    if index < 8:
        A[index] = 1
    else:
        A[index] += 1
x = sum(A[:8])
y = sum(A[8:])

print(max(1, x), x + y)

Measured memory_bytes: 38256
#include <iostream>
#include <queue>
#include <map>
using namespace std;

typedef pair<int,int> pint;
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
int dx[8] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
const double EPS = 1e-9;
int N;
double R;
map<pint,int> ma;

int intup(double x) {
    int res = (int)(x) - 2;
    while (res < x - EPS) ++res;
    return res;
}

int main() {
    while (cin >> N >> R) {
        ma.clear(); int t = 0;
        for (int i = 0; i < N; ++i) {
            double x,y; cin >> x >> y;
            int ix = intup(x/R), iy = intup(y/R);
            ma[pint(ix,iy)] = t++;
        }
        bool used[200100] = {0};
        int res = 0;
        EACH(it,ma) {
            if (used[it->second]) continue;
            used[it->second] = true;
            queue<pint> que;
            que.push(it->first);
            while (!que.empty()) {
                pint p = que.front(); que.pop();
                for (int j = 0; j < 8; ++j) {
                    pint np = pint(p.first+dx[j], p.second+dy[j]);
                    if (!ma.count(np)) continue;
                    if (!used[ma[np]]) {
                        used[ma[np]] = true;
                        que.push(np);
                    }
                }
            }
            ++res;
        }
        cout << res << endl;
    }
    
    return 0;
}


Measured memory_bytes: 12816
#!/usr/bin/env python3
import sys
from itertools import accumulate
sys.setrecursionlimit(10**8)
INF = float("inf")
MOD = 10**9+7

N, K = map(int, input().split())

ans = 1
for k in range(K, N+1):
    l = k*(k-1)//2
    u = N*(N+1)//2 - (N-k)*(N-k+1)//2
    n = u-l+1
    ans += n
    ans %= MOD
print(ans)


Measured memory_bytes: 9188
// D - Prediction and Restriction
#include <bits/stdc++.h>
using namespace std;

map<char,char> win={{'r','p'},{'s','r'},{'p','s'}};
map<char,char> lose={{'r','s'},{'s','p'},{'p','r'}};
map<char,int> point={{'r',0},{'s',0},{'p',0}};

int main(){
	int N,K; string T;
	cin>>N>>K>>point['r']>>point['s']>>point['p']>>T;
	int ans = 0;
	for(int i=0; i<N; ++i){
		ans += point[win[T[i]]];
		if(i-K >= 0 && T[i-K] == T[i]){
			ans -= point[win[T[i]]];
			if(i+K < N && T[i] == T[i+K]) T[i] = lose[T[i]];
		}
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 512
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
string s[55];
int prime[55559];
vector<int> p;

void f() {
	rep(i, 55556)prime[i]=1;
	for(int i = 2; i < 300; i++){
		for (int j = i*i; j < 55556; j += i) {
			prime[j] = 0;
		}
	}

	for (int i = 10; i < 55556; i++) {
		if (prime[i]&&i % 5 == 1) {
			p.push_back(i);
		}
	}
}
int main() {
	f();
	cin >> n;
	int cnt = 0;

	rep(i, n) {
		if (i)
			cout << " ";
		cout << p[i];
	}
	cout << endl;
	return 0;
}

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

#define iii tuple<int, int, int>

int n; 
vector<iii> E;

int main() {
    scanf("%d", &n);
    for(int i = 0, a, b, c; i < n; ++i) {
        scanf("%d %d %d", &a, &b, &c);
        E.emplace_back(a, b, c);
    }
    for(int cx = 0; cx <= 100; ++cx) for(int cy = 0; cy <= 100; ++cy) {
        int hei = -1;
        bool st = true;
        vector<int> ret;
        for(auto x : E) {
            int u, v, w; tie(u, v, w) = x;
            int val = abs(cx - u) + abs(cy - v);
            if(w) {
                if(hei == -1) hei = w + val; 
                if(hei != w + val) st = false;
            } else ret.emplace_back(val);
        }
        for(auto x : ret) if(hei > x) st = false;
        if(st) return !printf("%d %d %d\n", cx, cy, hei);
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b,k;
  scanf("%d %d %d",&a,&b,&k);
  
  for(int i=1;i<=k;i++){
    if(i%2==1){
      b+=a/2;
      a/=2;
    }else if(i%2==0){
      a+=b/2;
      b/=2;
    }
  }
  printf("%d %d",a,b);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    char ch1,ch3,ch4,ch2;
    ch3='H';
    ch4='D';
    cin>>ch1>>ch2;
    if(ch1=='H' && ch2=='H')
     cout<<ch3;
    else
    {
       if(ch1=='H' && ch2=='D')
        cout<<ch4;
       else
       {
             if(ch1=='D' && ch2=='H')
               cout<<ch4;
             else
             {
                if(ch1=='D' && ch2=='D')
                 cout<<ch3;
             }
       }
    }
	return 0;
}


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

using namespace std;

typedef pair<int, int> pi;
int n, m;
char s[100001];
int main() {
	rep(i, 4) cin >> s[i];
	n = (s[0] - '0') * 10 + (s[1] - '0');
	m = (s[2] - '0') * 10 + (s[3] - '0');
	if (n > 12 || n == 0) {
		if (0 < m && m < 13) cout << "YYMM";
		else cout << "NA";
	}
	else {
		if (0 < m && m < 13) cout << "AMBIGUOUS";
		else cout << "MMYY";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
N = int(input())
A = list(map(int,input().split()))

minus = []
plus = []
for i in range(len(A)):
    minus.append(A[i]-(i+1))
    plus.append(A[i]+(i+1))

d = {}
for m in minus:
    d[m] = d.get(m,0) + 1

ans = 0
for p in plus:
    ans += d.get(-p,0)
print (ans)

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

using namespace std;

int main() {
	string input;
	cin >> input;
	if (input.size() == 2) {
		cout << input;
	} else {
		for (int i = input.size() - 1; i >= 0; --i) {
			cout << input[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, m;
priority_queue<LL> q;

int main() {
	cin >> n >> m;
	inc(i, n) {
		LL a; cin >> a;
		q.push(a);
	}
	
	inc(i, m) {
		LL v = q.top(); q.pop();
		q.push(v / 2);
	}
	
	LL ans = 0;
	inc(i, n) {
		LL v = q.top(); q.pop();
		ans += v;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1400
from collections import deque
N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int, input().split())
    E[a-1].append(b-1)
    E[b-1].append(a-1)

used = [-1]*N
for i in range(N):
    if used[i] >= 0:
        continue
    q = deque()
    q.append(i)
    used[i] = i
    while q:
        temp = q.popleft()
        for e in E[temp]:
            if used[e] == i:
                continue
            used[e] = i
            q.append(e)

L = [0]*N
for c in used:
    L[c] += 1
ans = max(L)
print(ans)

Measured memory_bytes: 46416
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,u,k,v,i,j,tt,n;
int M[200][200],d[200],f[200],c[200];
 
void visit(int u){
  int v;
  c[u] = GRAY;
  d[u] =++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(c[v]==WHITE){
      visit(v);
    }
  }
  c[u]=BLACK;
  f[u]=++tt;
}
 
int main(){
 
  scanf("%d",&n);
  for(i = 0;i <n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
 
  for(i = 0;i < n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
 
 
  for (u=0;u<n;u++)c[u] = WHITE;
  tt=0;
 
  for(u=0;u<n;u++)if(c[u]==WHITE)visit(u);
  for(u=0;u<n;u++)printf("%d %d %d\n",u + 1,d[u],f[u]);
 
  return 0;
}

Measured memory_bytes: 676
#include <bits/stdc++.h>
using namespace std;
int main(){
    const long long ten = 1000000000000000000;
    //write code  here
    int n;
    cin >> n;
    vector<long long>a(n);
    long long sum=1;
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
        if (a.at(i) == 0){
            sum = 0;
        }
    }
    if(sum != 0) {
        for (int i = 0; i < n; ++i) {
            if (sum > ten / a.at(i)) {
                sum = -1;
                break;
            } else{
                sum *= a.at(i);
            }
        }
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 4052
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9;
#define INFL 1e18;
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class AOddsOfOddness {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        double ans;
        if (n % 2 == 0) ans = 0.5;
        else {
            ans = (n+1) / 2;
            ans /= n;
        }
        out << setprecision(12) << ans << '\n';
	}
};


int main() {
	AOddsOfOddness solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  5 21:33:15 2020

"""

N, K = map(int,input().split())
A = list(map(int, input().split())) 
A = sorted(A, key=abs, reverse=True)
mod = 10**9+7
ans = 1
lp = 10**6
lm = 10**6
lpflag = 0
lmflag = 0
rp = 10**6
rm = 10**6
rpflag = 0
rmflag = 0
ans1 = 0
ans2 = 0
minus = 0
flag0 = 0
for i in range(K):
    if A[i] < 0:
        minus = (minus+1)%2
    ans = ans * A[i] % mod
if not minus:
    print(ans)
else:
    for i in range(K-1,-1,-1):
        if lp < 10**6 and lm < 10**6:
            break
        if A[i] > 0 and lpflag == 0:
            lpflag = 1
            lp = i
        elif A[i] < 0 and lmflag == 0:
            lmflag = 1
            lm = i
    for i in range(K,N):
        if rp < 10**6 and rm < 10**6:
            break
        if A[i] > 0 and rpflag == 0:
            rpflag = 1
            rp = i
        elif A[i] < 0 and rmflag == 0:
            rmflag = 1
            rm = i
        elif A[i] == 0:
            flag0 = 1
    if lpflag*rmflag == 1:
        ans = 1
        for i in range(K):
            if not i == lp:
                ans = ans * A[i] % mod
        ans = ans * A[rm] % mod
        ans1 = ans
    if lmflag*rpflag == 1:
        ans = 1
        for i in range(K):
            if not i == lm:
                ans = ans * A[i] % mod
        ans = ans * A[rp] % mod    
        ans2 = ans
    if lpflag*rmflag == 0 and lmflag*rpflag == 0:
        ans = 1
        for i in range(N-1,N-1-K,-1):
            ans = ans * A[i] % mod
        if flag0:
            print(0)
        else:
            print(ans)

    else:
        if ans1 > 0 and ans2 > 0:
            if A[rm]*A[lm] > A[rp]*A[lp]:
                print(ans1)
            else:
                print(ans2)
        else:
            print(max(ans1,ans2))

        
        
   


Measured memory_bytes: 31848
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int isshuu = sc.nextInt();
			int ienokazu = sc.nextInt();
			int[] ienozahyo = new int[ienokazu];
			for (int i = 0; i < ienokazu; i++) {
				ienozahyo[i] = sc.nextInt();
			}

			int[] ienoaida = new int[ienokazu];
			for (int i = 0; i < ienokazu - 1; i++) {
				ienoaida[i] = ienozahyo[i + 1] - ienozahyo[i];
			}
			ienoaida[ienokazu - 1] = isshuu - ienozahyo[ienokazu - 1] + ienozahyo[0];

			//一番間隔が広い家の間の距離を探す
			int maxtooi = 0;
			for (int i = 0; i < ienokazu - 1; i++) {
				if (ienoaida[i] > ienoaida[i + 1]) {
					if (maxtooi < ienoaida[i]) {
						maxtooi = ienoaida[i];
					}
				}
			}
			if (maxtooi < ienoaida[ienokazu - 1]) {
				maxtooi = ienoaida[ienokazu - 1];
			}

			System.out.println(isshuu - maxtooi);
		} finally {
			sc.close();
		}
	}

}


Measured memory_bytes: 65604
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>
 
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; }
 
const long long mod = 1e9 + 7;
 
int main()
{
    int n; std::cin >> n;
    std::vector<int> X(n);    
    for(int i=0; i<n; i++) std::cin >> X[i];

    int ans = 1e9;
    for(int i=1; i<=100; i++)
    {
        int cost = 0;
        for(int j=0; j<n; j++)
        {
            cost += (X[j] - i) * (X[j] - i);
        }
        ans = std::min(ans, cost);
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>g[20];
int in[20];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int c,d;
		scanf("%d%d",&c,&d);c--;d--;
		g[c].push_back(d);
		in[d]++;
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			if(in[j]==0){
				printf("%d\n",j+1);
				for(int k=0;k<g[j].size();k++)in[g[j][k]]--;
				in[j]=-1;
				break;
			}
		}
	}
}

Measured memory_bytes: 1048
N,K=map(int,input().split())
lst = [0]*N
for _ in range(K):
  d = int(input())
  a = list(map(int,input().split()))
  for i in range(d):
    lst[a[i]-1] += 1
#print(lst)
ans = lst.count(0)
print(ans)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 1e4+1;
int ct[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	for(int i=1;i<=100;i++)
	{
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				int z = i*i+j*j+k*k+i*j+i*k+j*k;
				if(z<M)
					ct[z]++;
			}
		}
	}
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cout<<ct[i]<<"\n";
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> S( H );
	for( auto &x : S )
	{
		cin >> x;
	}
	for( int i = 0; i < H; ++i )
	{
		for( int j = 0; j < W; ++j )
		{
			if( S[ i ][ j ] == '#' )
			{
				continue;
			}
			int cnt{};
			for( int k = i - 1; k <= i + 1; ++k )
			{
				for( int l = j - 1; l <= j + 1; ++l )
				{
					if( k >= 0 && l >= 0 && k != H && l != W && S[ k ][ l ] =='#' )
					{
						cnt++;
					}
				}
				S[ i ][ j ] = '0' + cnt;
			}
		}
	}
	for( auto &x : S )
	{
		cout << x << endl;
	}
	return 0;
}

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

int main()
{
	int a, b, c;
	int a1, b1, c1;
	int count;
	while(scanf("%d%d%d", &a, &b, &c) != EOF)
	{
		count = 0;
		while(1)
		{
			if((a % 2)||(b % 2)||(c % 2))
			{
				printf("%d\n", count);
				break;
			}
			if(a == b && a == c)
			{
				printf("-1\n");
				break;
			}
			a1 = b / 2 + c / 2;
			c1 = a / 2 + b / 2;
			b1 = a / 2 + a / 2;
			a = a1;
			b = b1;
			c = c1;
			count ++;
		}
			
	}
	
	
	
	
	return 0;
}

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

f_adj_list = [[] for i in range(n)]
b_adj_list = [[] for i in range(n)]

for i in range(m):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  f_adj_list[_].append(__)
  f_adj_list[__].append(_)
  
for j in range(k):
  _, __ = map(int, input().split())
  _ -= 1
  __ -= 1
  b_adj_list[_].append(__)
  b_adj_list[__].append(_)
  
  
group_id = [None for i in range(n)]
for i in range(n):
  if group_id[i] is not None: continue
  # i から DFS
  newly_visited = [i]
  group_id[i] = i
  while len(newly_visited) > 0:
    now = newly_visited.pop()
    for j in f_adj_list[now]:
      if group_id[j] is not None: continue
      newly_visited.append(j)
      group_id[j] = i

# group_id
# print(group_id)

# 連結成分のサイズ
from collections import Counter
cnt = Counter(group_id)
# cnt[5] = 7

ans_list = []
for i in range(n):
  ans = cnt[group_id[i]]
  ans -= 1 # 自分自身
  ans -= len(f_adj_list[i]) # 直接の友達
  for j in b_adj_list[i]:
    if group_id[i] == group_id[j]:
      ans -= 1
  ans_list.append(ans)

print(" ".join(map(str, ans_list)))


Measured memory_bytes: 57736
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second
#define sz(a) ((int)(a.size()))

const int MAX = 500005;
const int mod = 998244353;
int a[100005];
int main()
{
	ios_base::sync_with_stdio(0);
	int n , t;
	cin >> n >> t;
	map<int, int> res;
	for(int i = 0; i < n; i++)	
		cin >> a[i];
	int ans = 0;
	for(int i = n - 1; i >= 0; i--)
	{
		ans = max(ans , a[i]);
		res[ans - a[i]]++;
	}
	cout << (--res.end())->y;
			
}


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

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

    int n, k;
    cin >> n >> k;
    if(n % k == 0) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
X=list(input())

counter_s = 0

counter_t = 0

for i in range(len(X)):
    if counter_s == 0 and X[i] == 'T':
        counter_t += 1
    elif 0 < counter_s and X[i] == 'T':
        counter_s -= 1
    elif X[i] == 'S':
        counter_s += 1
print(counter_s+counter_t)


Measured memory_bytes: 82664
#include<iostream>
 
using namespace std;
 
int main()
{
	int n, k;
	cin >> n >> k;
	char s[50];
  	cin >> s;
  
  	if (s[k-1] == 'A')
      s[k-1] = 'a';
  	else if(s[k-1] == 'B')
      s[k-1] = 'b';
  	else
      s[k-1] = 'c';
  
  
	cout << s << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

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

typedef long long ll;



int main()
{
    int n;
    string str;
    cin >> n >> str;
    
    for(int i = 0; i < str.size(); i++)
    {
        if(str.at(i) + n > 90)
        {
            str.at(i) = char(64 + (str.at(i) + n) % 90);
        }
        else
        {
            str.at(i) = char(str.at(i) + n);
        }
        
    }

    cout << str << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[])
{
    int A, B, C, a, i;
    scanf("%d %d %d", &A, &B, &C);
    a = A;
    for ( i = 0, a = A; i < 1000; i++, a+=A ){
        if ( a < B ){
            continue;
        }
        if ( a%B==C ){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
					if (ans == 28985.17494996295) {
						tr(ans, xa[0], ya[0], xa[i], ya[i], xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1]);
						tr(cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1]));
					}
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 37916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

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

    ll res = 0;

    ll m = 1e18;
    rep(i,5) m = min(m, a[i+1]);

    cout << (a[0]-1)/m + 5<< endl;


	return 0;
}

int main(){

	return mainsolve();
}

Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

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

  for(int j = 1; j <= n; j++){
    if(j%3==0){
      printf(" %d", j);
    }else{
      int tmp = j;
      for(int i = 10000; i != 1; i=i/10){
	if((tmp%i)==3 || (tmp/i)==3){
	  printf(" %d", j);
	  break;
	}
	tmp = tmp % i;
      }
    }
  }
  printf("\n");
}



Measured memory_bytes: 2752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var a = ReadLine();
            var b = ReadLine();
            var rotation = "";
            
            for (int i = a.Length-1; i >= 0; i--) {
                rotation += a[i].ToString();
            }

            var result = (rotation == b) ? "YES" : "NO";

            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <random>
#include <chrono>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
std::istream& operator>>(std::istream &is, std::vector<T> &v)
{
  for (typename std::vector<T>::size_type i = 0; i < v.size(); ++i) {
    is >> v[i];
  }
  return is;
}

using namespace std;

struct Point
{
  uint64_t y, x;
  Point(uint64_t y, uint64_t x) : y(y), x(x) {}
  bool operator==(const Point &rhs) const {
    return y == rhs.y && x == rhs.x;
  }
  bool operator<(const Point &rhs) const {
    return y == rhs.y ? x < rhs.x : y < rhs.y;
  }
};

int main()
{
  uint64_t H, W, M;
  cin >> H >> W >> M;

  vector<uint64_t> rows(H, 0), cols(W, 0);

  map<uint64_t, set<uint64_t>> hash;
  N_TIMES(m, M) {
    uint64_t h, w;
    cin >> h >> w;
    --h; --w;

    ++rows[h];
    ++cols[w];
    
    hash[h].insert(w);
  }

  uint64_t max_h = 0;
  set<uint64_t> max_h_index;
  N_TIMES(h, H) {
    if (max_h < rows[h]) {
      max_h = rows[h];
      max_h_index = set<uint64_t>();
      max_h_index.insert(h);
    } else if (max_h == rows[h]) {
      max_h_index.insert(h);
    }
  }

  uint64_t max_w = 0;
  set<uint64_t>  max_w_index;
  N_TIMES(w, W) {
    if (max_w < cols[w]) {
      max_w = cols[w];
      max_w_index = set<uint64_t>();
      max_w_index.insert(w);
    } else if (max_w == cols[w]) {
      max_w_index.insert(w);
    }
  }

  bool flag = false;
  for (uint64_t y : max_h_index) {
    for (uint64_t x : max_w_index) {
      if (hash[y].find(x) == hash[y].end()) {
        flag = true;
        break;
      }
    }
  }
  
  if (flag) {
    cout << (max_h + max_w) << endl;
  } else {
    cout << (max_h + max_w - 1) << endl;
  }

  return 0;
}

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

int main() {
  int N; cin >> N;
  long A[N],B[N],C[N];
  for (int i =0; i<N; i++) cin >> A[i];
  for (int i =0; i<N; i++) cin >> B[i];
  for (int i =0; i<N; i++) cin >> C[i];
  
  sort(A,A+N); sort(B,B+N); sort(C,C+N);
  
  long count =0;
  for (int i =0; i<N; i++) {
    count += (lower_bound(A,A+N,B[i]) - A) * (N - (upper_bound(C,C+N,B[i]) - C));
  }  
  cout << count << endl; 
} 

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

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

	vector<vector<unsigned long long>> dp(2, vector<unsigned long long>(3, 0));
	{
		int i = n[0] - '0';
		dp[0][0] = 1;
		dp[1][0] = i - 1;
	}

	for (size_t i = 1; i < n.size(); ++i)
	{
		vector<vector<unsigned long long>> dpcpy = dp;
		int j = n[i] - '0';
		if (0 < j) {
			dp[0][0] -= dpcpy[0][0];
			dp[0][1] -= dpcpy[0][1];
			dp[0][1] += dpcpy[0][0];
			dp[0][2] -= dpcpy[0][2];
			dp[0][2] += dpcpy[0][1];

			dp[1][0] = 9 + dpcpy[0][0] + dpcpy[1][0];
			dp[1][1] = dpcpy[0][0] * (j - 1) + dpcpy[1][0] * 9 + dpcpy[0][1] + dpcpy[1][1];
			dp[1][2] = dpcpy[0][2] + dpcpy[0][1] * (j - 1) + dpcpy[1][1] * 9 + dpcpy[1][2];
		}
		else {
			dp[0][0] = dpcpy[0][0];
			dp[0][1] = dpcpy[0][1];
			dp[0][2] = dpcpy[0][2];

			dp[1][0] = 9 + dpcpy[1][0];
			dp[1][1] = dpcpy[1][1] + dpcpy[1][0] * 9;
			dp[1][2] = dpcpy[1][2] + dpcpy[1][1] * 9;
		}
	}

	cout << dp[0][k - 1] + dp[1][k - 1] << endl;

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,c;
	cin>>a>>b;c=a-b+1;
	if(a>0&&b>0)
	{
		cout<<"Positive"<<endl;
		return 0;
	}
	if(a>0&&b<0)
	{
		cout<<"Zero"<<endl;
		return 0;
	}
	if(a<0&&b>0)
	{
		cout<<"Zero"<<endl;
		return 0;
	}
	if(c%2==0)
	cout<<"Positive"<<endl;
	else
	cout<<"Negative"<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var ans = n;

            for(var i = 1; i < n; i++)
            {
                var sum = DigitSum(i) + DigitSum(n - i);
                if (sum < ans) ans = sum;
            }

            Console.WriteLine(ans);
        }

        public static int DigitSum(int num)
        {
            var sum = 0;

            while (num > 0)
            {
                sum += num % 10;                
                num = num / 10;
            }

            return sum;
        }
    }
}

Measured memory_bytes: 11220
//666yuchen
//超过AC80
#include<bits/stdc++.h>
using namespace std;
string st;
int main()
{
  cin>>st;
  if(st[0]==st[st.size()-1])
  {
  	if(st.size()%2==0)cout<<"First";
  	else cout<<"Second";
  }
  else
  {
  	if(st.size()%2==0)cout<<"Second";
  	else cout<<"First";
  }
  cout<<endl;
  return 0;
}

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

long gcd(long a, long b);

int main() {
    long k, ans = 0;
    cin >> k;
    rep(i, k) rep(j, k) rep(l, k) {
        long temp = gcd(max(i + 1l, j + 1l), min(i + 1l, j + 1l));
        ans += gcd(max(temp, l + 1l), min(temp, l + 1l));
    }
    cout << ans << endl;
}

long gcd(long a, long b) {
    if(a % b) return gcd(b, a % b);
    return b;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define NL << endl

using namespace std;
using ll = long long;


int main() {

	int n;

	cin >> n;
	if (n < 1200) {
		cout << "ABC" NL;
	} else if (n < 2800) {
		cout << "ARC" NL;
	} else {
		cout << "AGC" NL;
	}


	return 0;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
//#include "h.h"
using namespace std;

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int times(vector<int> in, int pos){
	for(int i = 0; i < 5; i ++){
		if(i == pos)continue;
		if(in[i]%10 != 0){
			in[i] -= in[i]%10;
			in[i] += 10;
		}
	}
	int ret = 0;
	for(int i = 0; i < 5; i ++)ret += in[i];
	return ret;
}
int main(){

	vector<int> in(5);
	for(int i = 0; i < 5; i ++){
		cin >> in[i];
	}
	int ans = 1000;
	for(int i = 0; i < 5; i ++){
		ans = min(ans, times(in, i));
	}
	cout << ans << endl;

	return 0;
}

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

vector<int>E[200];
int in[200];
bool used[200];
int main() {
	int n; cin >> n;
	rep(i, n) {
		int a, b; string s; cin >> a >> s >> b; a--; b--; b += 100;
		if (s == "wait") {
			E[a].push_back(b); in[b]++;
		}
		else {
			E[b].push_back(a); in[a]++;
		}
	}
	queue<int>que;
	rep(i, 200) {
		if (!in[i] && !used[i])que.push(i);
		while (!que.empty()) {
			int d = que.front(); que.pop();
			used[d] = true;
			for (int v : E[d]) {
				in[v]--;
				if (!in[v] && !used[v])que.push(v);
			}
		}
	}
	rep(i, 200) {
		if (!used[i]) { puts("1"); return 0; }
	}
	puts("0");
}

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

using namespace std;

typedef unsigned int uint;

int finds(int n, vector<uint> &nb, uint x, uint l1, uint r1) {
    int lr = 0, rr = n;
    while (rr - lr > 1) {
        int mid = (lr + rr) / 2;
        if (nb[mid] + x <= r1) {
            lr = mid;
        } else {
            rr = mid;
        }
    }
    if (nb[lr] + x > r1) {
        return 0;
    }
    
    int ll = -1, rl = n - 1;
    while (rl - ll > 1) {
        int mid = (rl + ll) / 2;
        if (nb[mid] + x >= l1) {
            rl = mid;
        } else {
            ll = mid;
        }
    }
    if (nb[rl] + x < l1) {
        return 0;
    }
    
    return lr - rl + 1;
}

int main() {
    int n;
    cin >> n;
    
    vector<uint> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    
    uint ans = 0;
    for (int i = 0; i < 30; ++i) {
        vector<uint> na(n), nb(n);
        
        for (int j = 0; j < n; ++j) {
            na[j] = a[j] % (1 << (i + 1));
            nb[j] = b[j] % (1 << (i + 1));
        }
        
        sort(nb.begin(), nb.end());
        
        uint cnts = 0;
        
        uint l1 = (1 << i), r1 = (1 << (i + 1)) - 1;
        uint l2 = (1 << i) + (1 << (i + 1)), r2 = (1 << (i + 2)) - 1;

        for (int j = 0; j < n; ++j) {
            cnts += finds(n, nb, na[j], l1, r1);
            cnts += finds(n, nb, na[j], l2, r2);
        }
        ans |= ((cnts % 2) << i);
    }
    cout << ans << endl;
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) {
        cin >> A.at(i);
    }
    for(int i = 1; i <= n; i++){
        sort(A.begin(), A.begin() + i);
        for(int j= 0; j< n-1;j++) cout << A.at(j)<< " ";
        cout << A.at(n-1) <<  endl;
    }
}


Measured memory_bytes: 3160
n, m = map(int, input().split())
a = [0 for i in range(1, n + 2)]
for i in range(m):
    x, y = map(int, input().split())
    a[x] = a[x] + 1
    a[y] = a[y] + 1
for i in range(1, n + 1):
    print(a[i])


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

from sys import stdin

N, T = map(int, raw_input().split())

h=[]
for i in range (N):
    h.append( map(int, stdin.readline().split()) )

h.sort(key=lambda x: x[0])

for i in range( N ):
    if h[i][1] <= T:
        print h[i][0]
        exit()
        
print 'TLE'


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b; cin >> a >> b;
    bool ok = 0;
    if(a%3==0||b%3==0||(a+b)%3==0) ok = 1;
    if(ok) out("Possible"); else out("Impossible");

    return 0;
}

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

const int N = 2e5 + 10;

int n, k, a[N], cum[N];

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] += k-1;
        a[i] %= k;
        cum[i+1] = (a[i] + cum[i]) % k;
    }
    long long res = 0;
    map<int,int> cnt;
    for (int i = 0; i <= n; i++)  {
        if (i >= k) cnt[cum[i-k]]--;
        res += cnt[cum[i]]++;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int n = sc.nextInt();
		String s = sc.next();
		
		int max = 0;
		
		int x = 0;
		
		for(int i = 0; i < n; i++) {
			x+=s.charAt(i)=='I'?1:-1;
			max = Math.max(x, max);
		}
		
		out.println(max);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static int lcm(int a, int b) {
		return a / gcd(a, b) * b;
	}
	
	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21076
#include <iostream>
using namespace std;
int main ()	{
	int count = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++)	{
		for (int j = i + 1; j < s.size(); j++)	{
			if (s[i] == s[j])	count++;
		}
	}
	if (count != 0)	cout << "No" << endl;
	else	cout << "Yes" << endl;
	return 0;
}

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

signed main(void)
{
	string s, t, u;
	bool ok, flag;
	int ans, cnt;

	cin >> s;
	ans = s.size();
	flag = true;
	rep(i, s.size() - 1)
	{
		if (s[i] != s[i + 1])
		{
			flag = false;
		}
	}
	if (flag)
	{
		cout << 0 << endl;
		return 0;
	}
	rep(i, 26)
	{
		t = s;
		char c = i + 'a';
		ok = false;
		while (!ok)
		{
			ok = true;
			u = "";
			rep(j, t.size() - 1)
			{
				if (t[j] == c || t[j + 1] == c) 
					u += c;
				else
				{
					u += t[j];
					ok = false;
				}
			}
			t = u;
		}
		cnt = s.size() - t.size();
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

from itertools import permutations
asc = list(range(1, N+1))
#print(len(list(permutations(asc))))
xp, xq = -1, -1
for i, arr in enumerate(permutations(asc)):
  #print(i, arr)
  if arr == P:
    xp = i
  if arr == Q:
    xq = i
  if xp > -1 and xq > -1:
    break
ans = abs(xp - xq)
print(ans)

Measured memory_bytes: 3064
require 'prime'
def f(x)
  t = 1
  s = 1
  while s <= x
    t += 1
    s += t
  end
  t -= 1
  t
end
dd = gets.to_i.prime_division
p dd.empty? ? 0 : dd.map{|q,c| f(c)}.reduce(:+)


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

S = input()
if S[2] == S[3] and S[4] == S[5]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3896
import sys

x,n = map(int,input().split())
if n != 0 :
  p = list(map(int,input().split()))
else :
  print(x)
  sys.exit()
    
for i in range(200) :
  ans1 = x-i
  ans2 = x+i
  if not ans1 in p :
    ans = ans1
    break
  if not ans2 in p :
    ans = ans2
    break
    
print(ans)

Measured memory_bytes: 9128
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

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

  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B/2 << endl;
  } else {
    cout << B << endl;
  }
  
}


Measured memory_bytes: 256