akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    d = []
    A = []
    for i in range(K):
        d.append(I())
        A.append(LI_())

    snuke = [False]*N
    ans = 0
    for i in A:
        for j in i:
            snuke[j] = True

    print(len([i for i in snuke if not i]))
        
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9312
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e2+1;
 
#define ll int
// typedef long long ll;
typedef long double ld;

void test_case()
{
	ll h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	string s[h];
	for(int i = 0; i < h; i++)
	{
		cin >> s[i];
	}
	if(s[ch-1][cw-1] == '#')
	{
		cout << -1 << '\n';
		return;
	}
	ch--, cw--, dh--, dw--;
	ll dp[h][w];
	for(int i = 0; i < h; i++)
	{
		for(int j = 0; j < w; j++)
			dp[i][j] = INT_MAX;
	}
	priority_queue<array<ll,3>> q;
	q.push({0,ch, cw});
	dp[ch][cw] = 0;
	ll dx[] = {-2, -1, 0, 1, 2};
	ll dy[] = {-2, -1, 0, 1, 2};
	ll dxx[] = {-1, 1, 0, 0};
	ll dyy[] = {0, 0, -1, 1};
	while(!q.empty())
	{
		int x = q.top()[1], y = q.top()[2], z = -q.top()[0];
		q.pop();
		if(dp[x][y] < z)
			continue;
		for(int i = 0; i < 4; i++)
		{
			if((x + dxx[i] >= 0) && (x + dxx[i] < h) && (y + dyy[i] >= 0) && (y + dyy[i] < w))
			{
				if((s[x + dxx[i]][y + dyy[i]] != '#') && (dp[x + dxx[i]][y + dyy[i]] > dp[x][y]))
				{
					dp[x+dxx[i]][y+dyy[i]] = dp[x][y];
					q.push({-dp[x+dxx[i]][y+dyy[i]], x+dxx[i], y+dyy[i]});
				}
			}
		}
		for(int i = 0; i < 5; i++)
		{
			for(int j = 0; j < 5; j++)
			{
				if((x + dx[i] >= 0) && (x + dx[i] < h) && (y + dy[j] >= 0) && (y + dy[j] < w))
				{
					if((s[x + dx[i]][y + dy[j]] != '#') && (dp[x + dx[i]][y + dy[j]] > dp[x][y] + 1))
					{
						dp[x+dx[i]][y+dy[j]] = dp[x][y] + 1;
						q.push({-dp[x+dx[i]][y+dy[j]], x+dx[i], y+dy[j]});
					}
				}
			}
		}
	}
	if(dp[dh][dw] == INT_MAX)
		cout << -1 << '\n';
	else
		cout << dp[dh][dw] << '\n';
}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

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

using namespace std;

struct DATA{
  int w;
  int d;
};

DATA MakeOneData(int, int);
void Swap(int&, int&);
bool Compare(const DATA&, const DATA&);

int main(){
  int i, n, w, d, p, s, t;
  vector<DATA> data;

  while(1){
    cin >> n >> w >> d;
    if(n == 0 && w == 0 && d == 0) break;
    data.push_back(MakeOneData(w, d));

    for(i=0; i<n; ++i){
      cin >> p >> s;
      --p;
      w = data[p].w;
      d = data[p].d;
      s %= (w + d);
      data.erase(data.begin()+p);

      if(s < w){
	t = w-s;
	if(s > t) Swap(s, t);
	data.push_back(MakeOneData(s, d));
	data.push_back(MakeOneData(t, d));
      }else{
	s -= w;
	t = d-s;
	if(s > t) Swap(s, t);
	data.push_back(MakeOneData(w, s));
	data.push_back(MakeOneData(w, t));
      }
    }
    sort(data.begin(), data.end(), Compare);

    for(i=0; i<data.size()-1; ++i)
      cout << (data[i].d * data[i].w) << " ";
    cout << (data[data.size()-1].d * data[data.size()-1].w) << endl;

    data.clear();
  }
  return 0;
}

DATA MakeOneData(int w, int d){
  DATA data;
  data.w = w;
  data.d = d;
  return data;
}

void Swap(int& a, int& b){
  int c;
  c = a;
  a = b;
  b = c;
}

bool Compare(const DATA& x, const DATA& y){
  return ((x.d * x.w) < (y.d * y.w));
}

Measured memory_bytes: 1224
import itertools

n,m,R=map(int,input().split())
r=list(map(int,input().split()))
INF = 10**10
d=[[INF for i in range(n)] for i in range(n)]

for i in range(m):
    a,b,c=map(int,input().split())
    d[a-1][b-1]=c
    d[b-1][a-1]=c

for k in range(n):
    for i in range(n):
        for j in range(n):
            d[i][j] = min(d[i][j] ,d[i][k] +d[k][j])

for i in range(R):
    r[i] -= 1

res = INF
for rp in itertools.permutations(r):
    tres = 0
    for i in range(R-1):
        tres += d[rp[i]][rp[i+1]]
    res = min(res,tres)

print(res)

Measured memory_bytes: 47960
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;

    int n = s.size();
    int ans = 0;

    for(int i = 0; i < (1 << (n - 1)); i++) {
        int now = 0;
        int sum = 0;
        for(int j = 0; j < n; j++) {
            now *= 10LL;
            now += s[j] - '0';
            if(j < n - 1 && (i >> j & 1)) {
                sum += now;
                now = 0;
            }
        }
        sum += now;
        ans += sum;
    }

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


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

int main(){
  int N, D;
  cin >> N >>D;
  if(N%(2*D+1)==0){
    cout << N/(2*D+1) << endl;
  }
  else{
    cout << (N/(2*D+1))+1 << endl;
  }
  return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;

string s;

vector<int> z;

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

       cin >> s;
       rep(i,s.size()){
           if(s[i]!=s[i+1]){
               ans++;
           }
       }
       Cout(ans-1);
return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();
	int x; cin >> x;
	if (x >= 30) cout << "Yes\n";
	else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int INF = INT_MAX / 2;

int solve(string s)
{
    int n = s.size();
    vector<int> dp(5, -INF);
    // dp[0] : init
    // dp[1] : 1*011111
    // dp[2] : 10*11111
    // dp[3] : 1*111101
    // dp[4] : 111110*1

    dp[0] = 0;
    for(int i=0; i<n; ++i){
        vector<int> nextDp(5, -INF);
        if(s[i] == '0'){
            nextDp[0] = max(dp[0], dp[2]);
            nextDp[2] = dp[1];
            nextDp[4] = dp[3];
        }
        else{
            nextDp[0] = max(dp[0], dp[4]);
            nextDp[1] = max({dp[0], dp[1], dp[2]});
            nextDp[2] = dp[2] + 1;
            nextDp[3] = max(dp[0], dp[3]) + 1;
        }
        dp.swap(nextDp);
    }
    return *max_element(dp.begin(), dp.begin()+3);
}

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

    int ans = solve(s);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1412
#include <iostream>

using namespace std;
using ll = long long;

ll gcd(ll A, ll B) {
  ll d;
  while ((d = A % B)) {
    A = B;
    B = d;
  }
  return B;
}

int main() {
  ll A, B;
  cin >> A >> B;
  cout << A / gcd(A, B) * B << endl;
}


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

int countFactor2(int x) {
    // xが素因数として2をいくつもつか調べて返す
    bool Proceed = true;
    int n = 1;
    int count = 0;
    while(Proceed) {
        if(x%int(pow(2,n)) == 0) {
            count = n;
            n++;
        }
        else {
            Proceed = false;
        }
    }
    return count;
}


int main() {
    //[0] import
    int N; cin >> N;
    int a[N+1]; for(int i=0; i<N; i++) cin >> a[i];

    //[1] main logic
    //数列の中の2の素因数の個数を求めれば良い?
    int counts = 0;
    for(int i=0; i<N; i++) {
        counts += countFactor2(a[i]);
    }

    cout << counts << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    ll w,h,x,y;
    cin >> w >> h >> x >> y;
    cout << setprecision(20) << (long double)(w*h) / 2 << " ";
    if(x * 2 == w and y * 2 == h){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var comb [][]int

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	a, _ := strconv.Atoi(stringLineScan())
	b, _ := strconv.Atoi(stringLineScan())
	c, _ := strconv.Atoi(stringLineScan())
	l := make([]int, n)
	for i := 0; i < n; i++ {
		l[i], _ = strconv.Atoi(stringLineScan())
	}
	x := make([]int, 0)
	allcomb(n, x)
	ans := 1000000000
	for _, list := range comb {
		p0, p1, p2 := 0, 0, 0
		l0, l1, l2 := 0, 0, 0
		for i, y := range list {
			if y == 0 {
				p0++
				l0 += l[i]
			} else if y == 1 {
				p1++
				l1 += l[i]
			} else if y == 2 {
				p2++
				l2 += l[i]
			}
		}
		if p0*p1*p2 == 0 {
			continue
		}
		z := abs(a-l0) + abs(b-l1) + abs(c-l2) + (p0+p1+p2-3)*10
		if z < ans {
			ans = z
		}
	}
	fmt.Println(ans)
}
func allcomb(n int, l []int) {
	if len(l) == n {
		x := make([]int, n)
		copy(x, l)
		comb = append(comb, x)
	} else {
		for i := 0; i < 4; i++ {
			allcomb(n, append(l, i))
		}
	}
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}


Measured memory_bytes: 11520
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;i++)a[i]=sc.nextInt();
		long pair_count=0;
		for(int i=0;i<n;i++){
			pair_count+=(long)a[i]/2;
			a[i]=a[i]%2;
			if(i<n-1){
			if(a[i]==1 && a[i+1]>=1){
				pair_count+=1;
				a[i]--;
				a[i+1]--;
			}
			}
		}
		System.out.println(pair_count);
		
	}

}


Measured memory_bytes: 51196
N=int(input())
list1=[0]*(N+1)
for i in range(1,N+1):
	list2=[list1[i-1]]
	l=list2.append
	if i>=6:
		l(list1[i-6])
		if i>=9:
			l(list1[i-9])
			if i>=36:
				l(list1[i-36])
				if i>=81:
					l(list1[i-81])
					if i>=216:
						l(list1[i-216])
						if i>=729:
							l(list1[i-729])
							if i>=1296:
								l(list1[i-1296])
								if i>=6561:
									l(list1[i-6561])
									if i>=7776:
										l(list1[i-7776])
										if i>=46656:
											l(list1[i-46656])
											if i>=59049:
												l(list1[i-59049])
	list1[i]=min(list2)+1
print(list1[N])

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define I INT32_MAX
#define IM INT_MIN
#define MOD 1000000007
#define ll long long
#define lli long long int
#define rep(i,n) for (int i = 0; i < n; i++)
#define repk(i,k,n) for (int i = k; i <= n; i++)
#define repr(i,k,n) for (int i = k; i >= n; i--)
#define all(v) (v).begin(),(v).end()
typedef vector<int> vi;
typedef set<int> si;
ll dp[100005];
ll arr[100005];
ll n;

ll mincost(ll i) {
	// int n = sizeof(arr);
	if (i == n - 1) {
		return 0;

	}
	if (i >= n) return INT_MAX;

	if (dp[i] != -1) {
		return dp[i];
	}
	ll onejump = mincost(i + 1) + abs(arr[i] - arr[i + 1]);
	ll twojump = INT_MAX;
	if (i + 2 < n) {
		twojump = mincost(i + 2) + abs(arr[i] - arr[i + 2]);

	}
	return dp[i] = min(onejump, twojump);

}

void solve() {
	// int n;
	cin >> n;

	memset(dp, -1, sizeof(dp));
	rep(i, n) {
		cin >> arr[i];
	}
	cout << mincost(0);
}

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

	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;

}






Measured memory_bytes: 9896
import sys
import math
 
 
def input():
    return sys.stdin.readline().rstrip()
 
 
def main():
    N, Q = map(int, input().split())
    S = list(input())
    t = [0] * N
    count =0
    for i in range(1,N):
        if S[i-1]=="A" and S[i] =="C":
            count +=1
        t[i] =count
 
    for j in range(Q):
        l, r = map(int,input().split())
        print(t[r-1]-t[l-1])
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 12356
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1){
    c=c-b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a=a-d;
    if(a<=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  return 0;
}
  

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#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-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    ll n,y;
    cin>>n>>y;
    REP(i,n+1) REP(j,n+1) {
        if(n-i-j<0) continue;
        ll k=n-i-j;
        if(y==10000*i+5000*j+k*1000){
        cout<<i<<" "<<j<<" "<<k<<endl;
        return 0;
    
            
        }
        
    }
//答え出力パート    
    cout<<"-1 -1 -1"
    <<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vector<string> s(n);
		for(auto&m:s) cin >> m;
		vector<string> sym={"AC", "WA", "TLE", "RE"};
		vi c(sym.size());

		for(auto&m:s)
		{
			for(int i=0;i<(int)sym.size();i++)
			{
				if(m==sym[i]) c[i]++;
			}
		}

		for(int i=0;i<(int)sym.size();i++)
		{
			cout << sym[i] << " x " << c[i] << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 6312
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const LL MOD = 1000000007LL;
using namespace std;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
}

Measured memory_bytes: 256
arr=Array.new
while str=STDIN.gets
    lines=str.chomp.split.map{|v|v.to_i}
    break if lines[0]==0 && lines[1]==0
    arr.insert(arr.length,lines)
end
arr.each do | lines |
    row=0
    while(row<lines[0])
    col=0
    while(col<lines[1])
        ch = "."
        if (row==0 || row==lines[0]-1) || (col==0 || col==lines[1]-1) then
                ch = "#"
        end
        printf ch
        col=col+1
    end
    printf "\n"
    row=row+1
    end
    printf "\n"
end

Measured memory_bytes: 6112
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const n = Number(stdin.split('\n')[0])

const [, ..._sp] = stdin.trim().split('\n')
const sp = _sp.map(e => e.split(' '))

const ans = _ => {
  for (let i = 0; i < sp.length; i++) {
    sp[i][1] = Number(sp[i][1])
    sp[i].push(i + 1)
  }

  // sp.sort((a, b) => b[1] - a[1])

  sp.sort((a, b) => {
    const nameA = a[0]
    const nameB = b[0]
    if (nameA < nameB) {
      return -1
    }
    if (nameA > nameB) {
      return 1
    }
    return 0
  })

  let tmp = []
  for (let i = 0; i < sp.length; i++) {
    const [name, score, id] = sp[i]
    const nextName = i < sp.length - 1 ? sp[i + 1][0] : 0

    if (name === nextName) {
      tmp.push([score, id])
    } else if (name !== nextName) {
      tmp.push([score, id])
      const res = tmp.sort((a, b) => b[0] - a[0])
      res.forEach(e => {
        console.log(e[1])
      })
      tmp = []
    }
  }
}

ans()


Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

//約数列挙
vector<int> divisor(int n){

    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n){
                ret.push_back(n / i);
            } 
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

class Prime{
public:
    int n;
    vector<int> f, primes;
  
    // エラストテネスの篩
    Prime(int n = 1) : n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int i = 2; i <= n; ++i){
            if(f[i]){
                continue;
            }
            primes.push_back(i);
            f[i] = i;
            for(int j = i*i; j <= n; j += i){
                if(!f[j]){
                    f[j] = i;
                }
            }
        }
    }

    // 素数判定
    bool isPrime(int x){ 
        return f[x] == x;
    }
    
    // 約数列挙
    vector<int> factorList(int x){
        vector<int> res;
        while(x != 1){
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }

    // 素因数分解　（xがnより小さい版）
    vector<pair<int, int>> factor1(int x){
        vector<int> fl = factorList(x);
        if(fl.size() == 0){
            return {};
        }
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for(int p : fl){
            if(res.back().first == p){
                res.back().second++;
            } 
            else{
                res.emplace_back(p, 1);
            }
        }
        return res;
    }

    // 素因数分解　（xがnより大きい版）
    vector<pair<int,int>> factor2(int x){
        vector<pair<int,int>> res;
        for(int p : primes){
            int y = 0;
            while(x % p == 0){
                x /= p;
                ++y;
            }
            if(y != 0){
                res.emplace_back(p, y);
            }
        }
        if(x != 1){
            res.emplace_back(x, 1);
        }
        return res;
    }
};

signed main(){

    int n;
    cin >> n;

    // Prime prime(n);

    int ans = 0;
    vi dp(n+1);
    REP(i, 1, n+1){
        for(int j = i; j <= n; j += i){
            dp[j]++;
        }
    }


    REP(i, 1, n+1){
        ans += i * dp[i];
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 81356
#include <iostream>

typedef long long ll;

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

#define debug(x) cout << #x << "=" << x << endl;

using namespace std;

int main(void){

    int N;
    cin >> N;

    int a[N];

    REP(i,N){
        int tmp;
        cin >> tmp;
        tmp--;
        a[i] = tmp;
    }

    int cnt = 0;

    REP(i,N-1){
        if(a[i] == i){
            swap(a[i],a[i+1]);
            cnt++;
        }
    }

    if(a[N-1] == N-1){
        cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vector<ll> data1;
    vector<ll> data2;
    ll i, j, k, l, n, m;
    cin >> n;
    for (i = 1; i <= n;i++){
        cin >> k >> l;
        data1.pb(k);
        data2.pb(l);
    }
    sort(data1.begin(), data1.end());
    sort(data2.begin(), data2.end());
    if (n % 2 == 0)
    {
        ll kola1 = data1[(n - 1) / 2] + data1[n / 2];
        ll kola2 = data2[(n - 1) / 2] + data2[n / 2];
        cout << kola2 - kola1 + 1;
    }
    else{
        cout << (data2[n / 2] - data1[n / 2] + 1);
    }
        return 0;
}

Measured memory_bytes: 6696
def add_dic(x, dic):
  y = x // 10
  if y < 6:
    dic[y] += 1
  else:
    dic[6] += 1

def main():
  while True:
    n = int(input())
    if n == 0:
      break
    dic = [0] * 7
    for _ in range(n):
      add_dic(int(input()), dic)
    print(*dic, sep="\n")

main()


Measured memory_bytes: 5616
#include<iostream>  
#include<cmath>
#include<string>
#include<stack>
#include<queue> 
#include<algorithm>
#include<stdlib.h> 
#include<ctime>
using namespace std;
int main(){ 
	string s;
	cin>>s;
	int flag=0;
	for(int i=s.length()-1,j=0;i-j>=2;i--,j++){
		if(s[i]!=s[j])
			flag=1;
	}
	for(int i=(s.length()-1)/2-1,j=0;i>j;i--,j++){
		if(s[i]!=s[j])
			flag=1;
	}
	if(flag==1)
		cout<<"No";
	else
		cout<<"Yes";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 100005
#define LL long long
struct data{
	int a,b,c;
}w[MN];
bool cmp1(data x,data y){
	return x.b+y.c>y.b+x.c;
}
int x,y,z;
LL f[MN],g[MN],res,ans;
priority_queue<LL>Q;
inline int read(){
	int a=0;char c=getchar();
	while(c>'9'||c<'0')c=getchar();
	while('0'<=c&&c<='9'){
		a=a*10+c-48;
		c=getchar();
	}
	return a;
}
int main(){
	x=read();y=read();z=read();
	int n=x+y+z;
	for(int i=1;i<=n;++i){
		w[i].a=read();w[i].b=read();w[i].c=read();
		res+=w[i].a;
	}
	sort(w+1,w+1+n,cmp1);
	for(int i=1;i<=y;++i){
		Q.push(w[i].a-w[i].b);
		f[y]+=w[i].a-w[i].b;
	}
	for(int i=y+1;i<=n;++i){
		f[i]=f[i-1];
		if(Q.top()>w[i].a-w[i].b){
			Q.push(w[i].a-w[i].b);
			f[i]+=w[i].a-w[i].b;
			f[i]-=Q.top();
			Q.pop();
		}
	}
	while(!Q.empty())Q.pop();
	for(int i=n;i>n-z;--i){
		g[n-z+1]+=w[i].a-w[i].c;
		Q.push(w[i].a-w[i].c);
	}
	for(int i=n-z;i;--i){
		g[i]=g[i+1];
		if(Q.top()>w[i].a-w[i].c){
			Q.push(w[i].a-w[i].c);
			g[i]+=w[i].a-w[i].c;
			g[i]-=Q.top();
			Q.pop();
		}
	}
	for(int i=y;i<=n-z;++i){
		ans=max(ans,res-f[i]-g[i+1]);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int a, b;
  cin >> a >> b;
  cout << __gcd(a, b) << endl;	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}



Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#define pii pair<int,int>
#define pb push_back
using namespace std;
 
 
int main(){
  int n;
  cin>>n;
  
  vector<int> v;
  v.pb(1);
  
  int t=6;
  while(t<=n){
    v.pb(t);
    t*=6;
  }
  
  t=9;
  while(t<=n){
    v.pb(t);
    t*=9;
  }
 
  int dp[111111];
  for(int i=0;i<=n;i++){
    dp[i]=i;
  }
 sort(v.begin(),v.end());
  for(int i=0;i<=n;i++){
    for(int j=0;j<v.size();j++){
      if(i+v[j]>n) break;
      dp[i+v[j]]=min(dp[i+v[j]],dp[i]+1);
    }
  }
  
  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;cin>>n;
    map<string,int>mp;
    vector<string>v;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(auto x:v)
    {
        mp[x]++;
    }
    int l=-1;
    for(auto x:mp)
    {
        l=max(l,x.second);
    }
    for(auto x:mp)
    {
        if(x.second==l)
        {
            cout<<x.first<<endl;
        }

    }
}


Measured memory_bytes: 25068
n = int(input())

ans = 0
for i in range(1, n+1):
    if i % 2 == 0:
        continue
    d = 0
    for x in range(1, i+1):
        if i % x == 0:
            d += 1
    if d == 8:
        ans += 1

print(ans)


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


using namespace std;

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


const int D = 1000 * 1000 * 1000 + 7;




string s, t[4] = {"eraser", "erase", "dreamer", "dream"};

int main() {
	for (int i = 0; i < 4; i++)
		reverse(t[i].begin(), t[i].end());
	cin >> s;
	reverse(s.begin(), s.end());
	int pt = 0;
	while (pt < s.size()) {
		bool b = false;
		for (int i = 0; i < 4; i++)
			if (s.size() - pt >= t[i].size() && s.substr(pt, t[i].size()) == t[i])
				pt += t[i].size(), b = true;
		if (!b)
			return cout << "NO", 0;
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 512
import sys
input = sys.stdin.readline
from collections import defaultdict, deque
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]

g = defaultdict(set)
for a,b in AB:
    g[a].add(b)
    g[b].add(a)

visited = [False] * (N+1)

ans = 0
for s in range(1,N+1):
    if visited[s]:
        continue
    dq = deque([s])
    cnt = 0
    while dq:
        v = dq.popleft()
        if visited[v]:
            continue
        cnt += 1
        visited[v] = True
        for nv in g[v]:
            if not visited[nv]:
                dq.append(nv)
    ans = max(ans,cnt)

print(ans)
                




Measured memory_bytes: 180620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    long double a,b,h,m,angle;
    cin>>a>>b>>h>>m;
    cout<<fixed;
    cout<<setprecision(20);

    angle = abs((h*30 + (m/60)*30) - (m*6));
    angle = angle*(pi/180);

    long double c = sqrt(a*a + b*b - 2*a*b*cos(angle));

    cout<<c<<"\n";
    
    return 0;
}

Measured memory_bytes: 4184
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

struct Seed {
  string L;
  int P, A, B, C, D, E, F, S, M;
  Seed() {}
  Seed(string L, int P, int A, int B, int C, int D, int E, int F, int S, int M)
  : L(L), P(P), A(A), B(B), C(C), D(D), E(E), F(F), S(S), M(M) {}
  double calc() const {
    double b = A + B + C;
    for (int i = 0; i < M; i++) {
      b += D + E;
    }
    double a = F * S * M - P;
    return a / b;
  }
  bool operator<(const Seed& rhs) const {
    double l = calc();
    double r = rhs.calc();
    return (l != r) ? l > r : L < rhs.L;
  }
};

int N;
vector<Seed> seeds;

void init() {
  seeds.clear();
}

int main() {
  while (true) {
    cin >> N;
    if (N == 0) {
      return 0;
    }
    init();
    for (int i = 0; i < N; i++) {
      string L;
      int P, A, B, C, D, E, F, S, M;
      cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
      seeds.push_back(Seed(L, P, A, B, C, D, E, F, S, M));
    }
    sort(seeds.begin(), seeds.end());
    for (int i = 0; i < seeds.size(); i++) {
      cout << seeds[i].L << endl;
    }
    cout << "#" << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	map<ll,ll> mp;
	rep(i,n){
		cin>>a[i];
		mp[a[i]]++;
	}
	ll ans=0;
	for(auto itr:mp){
		ans+=itr.se*(itr.se-1)/2;
	}
	rep(i,n){
		ll cnt=mp[a[i]];
		ll now=ans;
		now=now-cnt*(cnt-1)/2+(cnt-1)*(cnt-2)/2;
		cout<<now<<endl;
	}
}

Measured memory_bytes: 11136
fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let t: Vec<char> = read::<String>().chars().collect();
    // [sの文字目][tの文字目]
    let mut memo = vec![vec![0; t.len() + 1]; s.len() + 1];

    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                memo[i + 1][j + 1] = max(memo[i][j] + 1, memo[i + 1][j + 1]);
            } else {
                memo[i + 1][j + 1] = max(memo[i + 1][j], memo[i][j + 1]);
            }
        }
    }
    let mut curx = s.len();
    let mut cury = t.len();
    let mut ans = vec![];
    while ans.len() != memo[s.len()][t.len()] {
        if memo[curx - 1][cury] == memo[curx][cury] {
            curx -= 1;
        } else if memo[curx][cury - 1] == memo[curx][cury] {
            cury -= 1;
        } else {
            curx -= 1;
            cury -= 1;
            ans.push(s[curx]);
        }
    }
    ans.reverse();
    println!("{}", ans.into_iter().collect::<String>());
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: isize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 90492
#include<stdio.h>

int main(){
  char sA[8];
  scanf("%s", sA);
  sA[1] = '\0';

  char ss[100];
  scanf("%s", ss);
  ss[1] = '\0';

  char sC[8];
  scanf("%s", sC);
  sC[1] = '\0';

  printf("%s%s%s\n", sA, ss, sC);

  return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c,d;
   ll mod =1e9+7;
   string s1,s2;
   stack<ll>stck1;
   stack<ll>stck2;

   set<ll>st;
   cin>>n;
   ll arr[n+5];

   for(ll i=0;i<n;i++){
    cin>>arr[i];
   }
   ll flag=0;
   for(ll i=0;i<n;i++){
    if(arr[i]%2==0){
            if(arr[i]%3==0){
                continue;
            }
            else if(arr[i]%5==0){
                continue;
            }
            else{
        flag=1;
        break;
            }   
    }
   }
   if(flag){
    cout<<"DENIED"<<endl;
   }
   else
    cout<<"APPROVED"<<endl;
}


Measured memory_bytes: 3616
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    maxA = A.pop()
    if maxA < K:
        return print("IMPOSSIBLE")
    if N == 1:
        if maxA == K:
            return print("POSSIBLE")
        else:
            return print("IMPOSSIBLE")
    g = A[0]

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    for a in A[1:]:
        g = gcd(g, a)

    if (maxA - K) % g == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


Measured memory_bytes: 62576
import java.util.*;

class Main {
	static final int INF = (1 << 30);

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
      	int[][] studentC = new int[n][2];
      	int[][] checkpointC = new int[m][2];
      	
      	for (int i = 0; i < n; i++) {
          	studentC[i][0] = Integer.parseInt(sc.next());
          	studentC[i][1] = Integer.parseInt(sc.next());
        }
      
      	for (int i = 0; i < m; i++) {
        	checkpointC[i][0] = Integer.parseInt(sc.next());
         	checkpointC[i][1] = Integer.parseInt(sc.next());
        }
      
      	for (int i = 0; i < n; i++) {
          int minDis = INF;
          int ans = 0;
        	 for (int j = 0; j < m; j++) {
                int x = Math.abs(studentC[i][0] - checkpointC[j][0]);     
                int y = Math.abs(studentC[i][1] - checkpointC[j][1]);
               	if (minDis > x + y) {
                  ans = j + 1;
                  minDis = x + y;
                }
             }
          System.out.println(ans);
        }
    }
}

/**
・static
・INF
・変数名
**/

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

int f(int x){
    if(x == 1) return 300000;
    if(x == 2) return 200000;
    if(x == 3) return 100000;
    return 0;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    int ans = f(X) + f(Y);
    if(X+Y == 2) ans += 400000;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm: canFind;

void main() {
	string[] inputs = split(readln());
	int x = to!int(inputs[0]);
	int y = to!int(inputs[1]);
	
	int res_x = group(x);
	int res_y = group(y);
	if(res_x == res_y) "Yes".writeln;
	else "No".writeln;
}

ubyte group(int a) {
	switch(a) {
		case 1,3,5,7,8,10,12:
			return 0;
		case 4,6,9,11:
			return 1;
		case 2:
			return 2;
		default:
			return 3;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
    ll n,sm=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sm+=__gcd(__gcd(i,j),k);
            }
        }
    }

    cout<<sm<<endl;









    return 0;
}


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

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

   if (x == 7 || x == 5 || x == 3) {
       cout << "YES" << endl;
   } else {
       cout << "NO" << endl;
   }
}

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

using namespace std;

const int N = 1000005;
const int pr[2] = {37, 1999};
const int md[2] = {(int) 1e9 + 7, (int) 1e9 + 9};
const int inf = 2e9;

int mark[N];
string a[N / 4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  multiset<long long> st;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    int hsh[2] = {0, 0};
    for (int t = (int) a[i].size() - 1; t >= 0; t--) {
      int c = a[i][t] - 'a' + 1;
      for (int j : {0, 1}) {
        hsh[j] = (1ll * hsh[j] * pr[j] + c) % md[j];
      }
    }
    long long ok = 1ll * hsh[0] * hsh[1];
    st.insert(ok);
  }
  long long res = 0;
  for (int it = 0; it < n; it++) {
    string s = a[it];
    int m = (int) s.size();
    mark[0] = 0;
    for (int i = 0; i < m; i++) {
      mark[i + 1] = mark[i] | (1 << (s[i] - 'a'));
    }
    if (m > 1) {
      while (mark[m] > 0) {
        int j = __builtin_ctz(mark[m] & -mark[m]);
        mark[m] -= 1 << j;
        int ok = (j + 1) * (j + 1);
        res += st.count(ok);
      }
    }
    int cur[2] = {0, 0};
    for (int i = m - 1; i > 1; i--) {
      for (int j : {0, 1}) {
        cur[j] = (1ll * cur[j] * pr[j] + (s[i] - 'a' + 1)) % md[j];
      }
      while (mark[i] > 0) {
        int j = __builtin_ctz(mark[i] & -mark[i]);
        mark[i] -= 1 << j;
        int need[2] = {0, 0};
        for (int k : {0, 1}) need[k] = (1ll * cur[k] * pr[k] + j + 1) % md[k];
        long long ok = 1ll * need[0] * need[1];
        res += st.count(ok);
      }
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 20664
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int r;
  scanf("%d", &r);
  printf("%d\n", r*r);
  return 0;
}


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

int main(){
        ll h, w;
        scanf("%ld %ld", &h, &w);

        vector<string> ss(h);
        for(ll i=0; i<h; i++) cin>>ss[i];

        vector<vector<ll>> mp1(h, vector<ll>(0));
        for(ll i=0; i<h; i++){
                string s = ss[i];
                char prev = s[0];
                ll cnt = 0;
                for(ll j=0; j<w; j++){
                        if(prev==s[j]) cnt++;
                        else{
                                for(ll k=0; k<cnt; k++) mp1[i].push_back(cnt*(s[j]=='#'));
                                cnt = 1;
                        }
                        prev = s[j];
                }
                for(ll j=0; j<cnt; j++) mp1[i].push_back(cnt*(s[w-1]=='.'));
        }

        vector<vector<ll>> mp2(w, vector<ll>(0));
        for(ll i=0; i<w; i++){
                char prev = ss[0][i];
                ll cnt = 0;
                for(ll j=0; j<h; j++){
                        if(prev==ss[j][i]) cnt++;
                        else{
                                for(ll k=0; k<cnt; k++) mp2[i].push_back(cnt*(ss[j][i]=='#'));
                                cnt = 1;
                        }
                        prev = ss[j][i];
                }
                for(ll j=0; j<cnt; j++) mp2[i].push_back(cnt*(ss[h-1][i]=='.'));
        }

        ll ans = 0;
        for(ll i=0; i<h; i++){
                for(ll j=0; j<w; j++){
                        ans = max(ans, mp1[i][j]+mp2[j][i]-1);
                }
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 68608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

bool notuse[10];
int cnt;

void dfs(int n,int k)
{
    if(n==0 && k == 0){
        cnt++;
        return ;
    }else{
        for(int i = 0; i < 10; i++){
            if(notuse[i] && k - i >= 0){
                notuse[i] = false;
                dfs(n-1,k-i);
                notuse[i] = true;
            }
        }
    }
}

int main() 
{
    ll div[9] = {1};
    for(int i = 1; i < 9; i++){
        div[i]=div[i-1]*(i+1);
    }
    while(true){
        int n,s; cin >> n >> s;
        if(n==0 && s == 0) break;
        for(int i = 0; i < 10; i++){
            notuse[i] = true;
        }
        cnt = 0;
        dfs(n,s);
        cout << cnt/div[n-1] << endl;
    }
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, m;
    cin >> n >> m;
    vector<ll> s(n+1);
    rep(i,n) {
        ll a;
        cin >> a;
        s[i+1] = (s[i] + a)%m;
    }
    ll ans = 0;
    map<int,ll> mp;
    for (int i = 0; i <= n; i++) {
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8004