akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n;cin>>n;
   int cnt=0;
   for(int i=1;i<n;i++){
    for(int j=1;i*j<n;j++){
        
            cnt++;
    }
   }
   cout<<cnt;
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
   int w,h,x,y,r;
   scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
   if(w-r>=x&&r<=x&&h-r>=y&&r<=y){
   	printf("Yes\n");
   }else{
   	printf("No\n");
    }
}


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

count = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0,
}

for i in range(n):
    s = input()
    count[s] += 1


for key, value in count.items():
    print(key + ' x ' + str(value))


Measured memory_bytes: 9056
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int c_cnt=0;
    int ans2 = c*max(x,y)*2;
    if(a+b>c*2){
        while(x>0 || y>0){
            c_cnt++;
            x--;
            y--;
            if(x==0 || y==0)break;
        }
    int ans = (x*a)+(y*b)+(c_cnt*c*2);
    cout << min(ans,ans2) << endl;
    return 0;
    }else{
        int ans = (x*a)+(y*b);
        cout << ans << endl;
        return 0;
    }
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{	//条件の確認
  	//1 <= N , a_i <= 100
  
    // 整数の入力
    int N;
     cin >> N;
	int vec[N];
 
  	for (int i = 0; i < N; i++) {
    cin >> vec[i];}
    // 出力
  	int ans = 0;
  for(int i=0; i < N; i+=2){
     if(vec[i] % 2 == 1){
   		 ans++;}}
                           
  cout << ans << endl;
  
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
}

Measured memory_bytes: 256
from sys import stdin


# f = open("./17/input_b1.txt")


# def input():
#     return f.readline().rstrip()


def main():
    N = int(input())
    C = [int(x) for x in stdin.readline().split()]
    V = [int(x) for x in stdin.readline().split()]

    sum_ = [C[x]-V[x] for x in range(N) if C[x]-V[x] > 0]
    print(sum(sum_))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 100001;

int n, m, k;
vector <int> v[MAX];
int inDeg[MAX];
int parent[MAX];

int main(void) {
	// in = fopen("D.in", "rt");
	
	fscanf(in, "%d %d", &n, &m);
	k = n - 1 + m;
	for (int i = 0; i < k; i++) {
	    int node1, node2;
	    fscanf(in, "%d %d", &node1, &node2);
	    node1--, node2--;
	    inDeg[node2]++;
	    v[node1].push_back(node2);
    }
    
    int root = 0;
    while (inDeg[root] > 0)
        root++;
    
    queue <int> q;
    q.push(root);
    parent[root] = -1;
    while (!q.empty()) {
        int node = q.front(); q.pop();
        for (int i = 0; i < (int)v[node].size(); i++) {
            inDeg[v[node][i]]--;
            if (inDeg[v[node][i]] == 0) {
                q.push(v[node][i]);
                parent[v[node][i]] = node;
            }
        }
    }
	for (int node = 0; node < n; node++)
	    fprintf(out, "%d\n", parent[node] + 1);
	
	return 0;
}

Measured memory_bytes: 7040
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

A, B, C, D = tuple(map(int, input().split()))

s = -1
c = C * (A // C + 1)
if A % C == 0:
    c = A
if c <= B:
    s += (B - c) // C + 1
        
d = D * (A // D + 1)
if A % D == 0:
    d = A
if d <= B:
    s += (B - d) // D + 1
    
cd_lcm = lcm(C, D)
cdl = cd_lcm * (A // cd_lcm + 1)
if A % cd_lcm == 0:
    cdl = A
if cdl <= B:
    s -= (B - cdl) // cd_lcm + 1

print(B - A - s)

Measured memory_bytes: 3064
N,D = map(int, input().split())
field = []
for i in range(N):
    field.append(list(map(int, input().split())))


def calc(i,j):
    dist2d = [x**2 for x in range(500)]
    ci = field[i]
    cj = field[j]
    dist2 = [(di-dj)**2 for di,dj in zip(ci,cj)] 

    
    if sum(dist2) in dist2d:
        return True
    else:
        return False

ans = 0
for i in range(N):
    for j in range(i+1,N):
        ans += calc(i,j)

print(ans)

Measured memory_bytes: 3064
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
way1 = 'U' * dy + 'R' * (dx+1) + 'D' * (dy+1) + 'L' * (dx+1) + 'U' * 1
way2 = 'R' * dx + 'U' * (dy+1) + 'L' * (dx+1) + 'D' * (dy+1) + 'R' * 1
print(way1 + way2)


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

int n,a[110];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

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

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

    cout << ((n / 10 % 111 == 0 || n % 1000 % 111 == 0) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 55;
int n;
long long arr[N];
long long sum;
long long k;
void big(){
	long long mx = -1;
	int idx = -1;
	for(int i = 1 ; i <= n ; ++i){
		if(arr[i] > mx){
			mx = arr[i];
			idx = i;
		}
	}
	long long val = mx / n;
	sum = 0;
	for(int i = 1 ; i <= n ; ++i){
		arr[i] += (i == idx) ? -n * val : val;
		sum += arr[i];
	}
	k += val;
}
void small(){
	while(1){
		int mx = -1;
		int idx = -1;
		for(int i = 1 ; i <= n ; ++i){
			if(arr[i] > mx){
				mx = arr[i];
				idx = i;
			}
		}
		if(mx < n){
			break;
		}
		for(int i = 1 ; i <= n ; ++i){
			arr[i] += (i == idx) ? -n : 1;
		}
		++k;
	}
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%lld" , arr + i);
		sum += arr[i];
	}
	while(sum > 1e5){
		big();
	}
	small();
	printf("%lld\n" , k);
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt64()
	a := make([]int64, n)

	var i, sum0, sumN int64
	for i = 0; i < n; i++ {
		a[i] = nextInt64()
	}
	var sum0idx, sumNidx int64
	for i = 0; i < n; i++ {
		if sum0 < sumN {
			sum0 += a[sum0idx]
			sum0idx++
		} else {
			sumN += a[n-1-sumNidx]
			sumNidx++
		}
		if sum0idx+sumNidx == n {
			break
		}
	}

	//fmt.Println(sum)
	//fmt.Println(sum0, sum0idx)
	//fmt.Println(sumN, sumNidx)
	fmt.Println(abs(sum0 - sumN))
}
func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, Y;
  cin >> N >> Y;

  Y /= 1000;
  REP(x,N+1) REP(y,N+1){
	if(x+y > N) continue;
	int z = N - x - y;
	if(x*10+y*5+z == Y){
	  cout << x << " " << y << " " << z << endl;
	  return 0;
	}
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}


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

n, k = map(int, input().split())
p = [int(i)-1 for i in input().split()]
c = list(map(int, input().split()))

rc = [0] * n
rp = [0] * n
for i in range(n):
    if rc[i]!=0:
        continue
    else:
        nw = set([i])
        np = c[i]
        nx = p[i]
        while not nx in nw:
            nw.add(nx)
            np += c[nx]
            nx = p[nx]
        cnt = len(nw)
        for x in nw:
            rc[x] = cnt
            rp[x] = np
ret = - 10 ** 18
for i in range(n):
    if rc[i] == 1:
        if rp[i]>=0:
            ret = max(ret, k*rp[i])
        else:
            ret = max(ret, rp[i])
        continue
    pseq = [0]
    nx = p[i]
    for j in range(1,rc[i]+1):
        pseq.append(pseq[-1]+c[nx])
        nx = p[nx]
    pseq = pseq[1:]
    if k <= rc[i]:
        ret = max(ret, max(pseq[:k]))
    elif rp[i] < 0:
        ret = max(ret, max(pseq))
    else:
        tmp = max(pseq)
        if k%rc[i]!=0:
            tmp = max(tmp, rp[i] + max(pseq[:k%rc[i]]))
        tmp += rp[i]*(k//rc[i]-1)
        ret = max(ret, tmp)
print(ret)


Measured memory_bytes: 82284
if __name__ == "__main__":
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    sum_all = sum(A)
    cnt = 0
    for a in A:
        if a >= sum_all/(4*m):
            cnt += 1

    if cnt >= m:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vvi g;
vi used;

int f(int v){
	used[v]=1;
	int res=1;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(!used[u]) res+=f(u);
	}
	return res;
}

int main(){
	cin>>n>>m;
	used=vi(n);
	g=vvi(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ll A=f(0),B=f(1);
	if(A<B) swap(A,B);
	for(int i=2;i<n;i++) if(!used[i]) A+=f(i);
	cout<<A*(A-1)/2+B*(B-1)/2-m<<endl;
}

Measured memory_bytes: 9216
n=int(input())
m=[]
for i in range(n):
    [p,q]=[int(x) for x in input().split()]
    m.append([p,q])
m.sort(key=lambda x:x[1])
su=0
flag=True
for i in m:
    su+=i[0]
    if su>i[1]:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38112
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    int s = h*w;
    int a[h][w];
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }

    int y[s], x[s];
    rep(i, h) {
        rep(j, w) {
            y[i*w+j] = i;
        }
    }
    rep(i, s) {
        int m = i%(2*w);
        if(m < w) {
            x[i] = m;
        }
        else {
            x[i] = (2*w - 1) - m;
        }
    }

    int n = 0, j = 0;
    int ans[s][4];
    rep(i, s-1) {
        if(a[y[i]][x[i]]%2 == 1) {
            a[y[i]][x[i]]--;
            a[y[i+1]][x[i+1]]++;
            ans[j][0] = y[i];
            ans[j][1] = x[i];
            ans[j][2] = y[i+1];
            ans[j][3] = x[i+1];
            j++;
            n++; 
        }
    }

    cout << n << "\n";

    rep(i, n) {
        rep(k, 3) {
            cout << ++ans[i][k] << " ";
        } 
        cout << ++ans[i][3] << "\n";
    }

    return 0;
}

Measured memory_bytes: 8832
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		
		Pair LU = new Pair(0,0);
		Pair RU = new Pair(0,Integer.MAX_VALUE);
		Pair LD = new Pair(Integer.MAX_VALUE,0);
		Pair RD = new Pair(Integer.MAX_VALUE,Integer.MAX_VALUE);

		Pair LUN = RD;
		Pair RUN = LD;
		Pair LDN = RU;
		Pair RDN = LU;

		for( int i=0; i<n ; i++ ) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			Pair c = new Pair(x,y);
			
			if(	LU.dist(c) < LU.dist(LUN) ) {
				LUN = c;
			}
			if(	RU.dist(c) < RU.dist(RUN) ) {
				RUN = c;
			}
			if(	LD.dist(c) < LD.dist(LDN) ) {
				LDN = c;
			}
			if(	RD.dist(c) < RD.dist(RDN) ) {
				RDN = c;
			}
		}

		long ans = Integer.MIN_VALUE;
		ans = Math.max( ans, LUN.dist(RUN) );
		ans = Math.max( ans, LUN.dist(LDN) );
		ans = Math.max( ans, LUN.dist(RDN) );
		ans = Math.max( ans, RUN.dist(LDN) );
		ans = Math.max( ans, RUN.dist(RDN) );
		ans = Math.max( ans, LDN.dist(RDN) );
		
		System.out.println(ans);
		
	}
	
	public static class Pair implements Comparable<Pair>{
		int c = 0;
		int d = 0;
		
		public Pair(int c, int d) {
			super();
			this.c = c;
			this.d = d;
		}

		public long dist( Pair o) {
			return Math.abs((long)o.c-c)+Math.abs((long)o.d-d);
		};
		
		@Override
		public int compareTo(Pair o) {
			int dd = this.d - o.d;
			if( dd != 0 ) {
				return dd;
			}
			int cc = this.c - o.c;
			return cc;
		}

		@Override
		public String toString() {
			return "Pair [c=" + c + ", d=" + d + "]";
		}
		
	}
}


Measured memory_bytes: 59528
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>

using namespace std;

#define rep(i,s,e) for(int i=s; i<e; i++)

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

    int t[n];
    rep(i,0,n){
        cin >> t[i];
    }

    int sum = 0;
    rep(i,0,n-1){
        sum += min(t[i+1] - t[i], tm);
    }
    sum += tm;

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1024
from math import atan, degrees

a, b, x = map(int,input().split())
if x <= a*a*b/2:
    y = 2*x/(a*b)
    z = b
    ans = atan(z/y)
    ans = degrees(ans)
else:
    y = a
    z = 2*(b-x/(a*a))
    ans = atan(z/y)
    ans = degrees(ans)

print(ans)

Measured memory_bytes: 3060
#coding utf-8
import math
from operator import mul
from functools import reduce
N,M=map(int,input().split())

def soinsu(m):
  fact =[]
  i = 2
  while i*i<=m:
    if m%i==0:
      fact.append(i)
      m //=i
    else:
      i +=1
  if m>1:
    fact.append(m)
  return fact

fact=soinsu(M)
counting=[]
for i in fact:
  counting.append(fact.count(i))
  del fact[:fact.count(i)-1]
  if fact==[]:
    break

def combi(n,r):
  r =min(r,n-r)
  if r==0:
    return 1
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1, r + 1))
  return over // under

ans = 1
for i in counting:
  ans *=combi(i+N-1,N-1)

print(ans%(10**9+7))

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;
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;}

const long long INF = 1LL << 60;

int N;
long long h[100060];
long long dp[100060];

int main () {
    char a; cin >> a;

    if((a>='a') && (a<='z')) {
        cout << 'a' << endl;
    } else {
        cout <<'A' << endl;
    } 

/*
    int K; cin >> K; 
    for (size_t i = 0; i < N; ++i) cin >> h[i];
    for (size_t i = 0; i < 100060; ++i) dp[i]= INF;

    dp[0]=0;


    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = 1; j <= K; j++)
        {
            chmin(dp[i+j], dp[i] +abs(h[i] - h[i+j]));
            
            //if (i > 1) chmin(dp[i], dp[i -2] + abs(h[i] - h[i-2]));
        }
        
    }
    cout << dp[N-1] << endl;
    */

    return 0;

}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	int N, M, C;
	int[] A, B;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		String s = cin.next();
		int num = 0;
		char f = s[0], e = s[s.Length - 1];
		if (f == e)
		{
			if(s.Length % 2 == 1)
			{
				Console.WriteLine("Second");
			}
			else
			{
				Console.WriteLine("First");
			}
		}
		else
		{
			if(s.Length % 2 == 1)
			{
				Console.WriteLine("First");
			}
			else
			{
				Console.WriteLine("Second");
			}
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 3416
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<string> vstring;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define mod llint(1e9+7)

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

//aのb乗をmodで割った余りを求める
llint power(llint a, llint b) {
	if (b == 1)return a;
	if (b == 0)return 1;
	llint tmp = power(a, (llint)b / 2);
	tmp *= tmp;
	tmp %= mod;
	if (b % 2 == 1) {
		tmp *= a;
		tmp %= mod;
	}
	return tmp;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a > b)swap(a, b);
	rep(i, b)cout << a;
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7,N = 1e5+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll h,w;
    cin>>h>>w;
    char ch[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>ch[i][j];
    }
    ll dp[h][w];
    dp[0][0]=1;
    for(int i=1;i<h;i++){
        if(ch[i][0]=='#'){
            dp[i][0]=0;
            continue;
        }
        dp[i][0]=dp[i-1][0];
    }
    for(int i=1;i<w;i++){
        if(ch[0][i]=='#'){
            dp[0][i]=0;
            continue;
        }
        dp[0][i] = dp[0][i-1];
    }
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            if(ch[i][j]=='#'){
                dp[i][j]=0;
                continue;
            }
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}


Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <set>
//#include <fstream>

#define ll long long int
using namespace std;

void Solve()
{
    //cout << "Case " << t << ": ";
    string x;
    cin >> x;
    cout << string(x.size(), 'x');
}

int main()
{
    //ios_base::sync_with_stdio( false );
    //cin.tie( nullptr );
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
   // int t;
   // cin >> t;
    //for(int i=1; i<=t; i++)
    {
        Solve();
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 3628
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

from itertools import permutations
from itertools import combinations

n, a, b, c = na()
l = [ni() for i in range(n)]
inf = 1 << 60

def dfs(i, x, y, z):
    if i == n:
        return abs(x - a) + abs(y - b) + abs(z - c) - 30 if min(x, y, z) > 0 else inf
    q = dfs(i + 1, x, y, z)
    w = dfs(i + 1, x + l[i], y, z) + 10
    e = dfs(i + 1, x, y + l[i], z) + 10
    r = dfs(i + 1, x, y, z + l[i]) + 10
    return min(q, w, e, r)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3188
readNumbers :: String -> [Int]
readNumbers = map read . words

checkCondition :: Int -> Int -> Int -> String
checkCondition a b c
 | b - a == c - b = "YES"
 | otherwise = "NO"

main :: IO ()
main = do
    inpLine <- getLine
    let inpArr = readNumbers inpLine
    putStrLn (checkCondition (inpArr!!0) (inpArr!!1) (inpArr!!2))


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

int main(){
    //input
    int d,n;
    cin >> d >> n;
    if(n==100){
        cout << int(pow(100,d) * (n+1)) << endl;
    }else{
        cout << int(pow(100,d) * n) << endl;
    }

    return 0;
}

Measured memory_bytes: 384
# import time

N, K, C = list(map(int, input().split()))
S = list(input())

F = []
L = []

# t1 = time.time()
# for i in range(N):
#     if S[i] == 'o':
#         if len(F) == 0:
#             F.append(i)
#         elif F[-1] + C < i:
#             F.append(i)
#     if len(F) >= K:
#         break
# print(F)
# t2 = time.time()
i = 0
while len(F) <= K and i < N:
    if S[i] == 'o':
        if len(F) == 0:
            F.append(i)
        elif F[-1] + C < i:
            F.append(i)
    i += 1
# print(F)
# t3 = time.time()

# print(t2 - t1, t3 - t2)

i = N - 1
while len(L) <= K and i >= 0:
    if S[i] == 'o':
        if len(L) == 0:
            L.append(i)
        elif L[-1] - C > i:
            L.append(i)
    i -= 1

if len(F) == K and len(L) == K:
    ans = [i + 1 for i in set(F) & set(L)]
    if len(ans) != 0:
        ans.sort()
        [print(i) for i in ans]

Measured memory_bytes: 51792
# -*- coding: utf-8 -*-
n, a, b = map(int, raw_input().split())

# get a string
s = raw_input()

cnt = 0
cnt_o = 0

ls = []

for c in s:
    if c is 'a' and cnt < a + b:
        cnt += 1
        ls.append(True)
    elif c is 'b' and cnt < a + b and cnt_o < b:
        cnt += 1
        cnt_o += 1
        ls.append(True)
    else:
        ls.append(False)
    if cnt is a + b:
        break

ls = ls + map(lambda x: False, range(n - len(ls)))
            
# output
print '\n'.join(map(lambda x: 'Yes' if x else 'No', ls))


Measured memory_bytes: 6692
import java.util.*;

public class Main {

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

		StringBuilder ans = new StringBuilder();
		int[] edgenum = new int[N + 1];
		UnionFind uf = new UnionFind(N);

		// 友達関係を精査
		for (int i = 1; i <= M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			uf.unite(a, b);
			edgenum[a]++;
			edgenum[b]++;
		}

		int[] x = new int[N + 1];
		// 各人の結果を計算
		for (int i = 1; i <= N; i++) {
			x[i] = uf.size(i) - edgenum[i] - 1;
		}
		// ブロック関係を精査
		for (int i = 1; i <= K; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (uf.isSame(a, b)) {
				x[a]--;
				x[b]--;
			}
		}
		for (int i = 1; i <= N; i++) {
			ans.append(x[i] + " ");
		}
		System.out.println(ans);

		sc.close();
	}

}

/**
 * UnionFind
 */
class UnionFind {

	int[] parent; // インデックスとノードを対応させ、そのルートノードのインデックスを保持
	int[] size; // 属しているグループのサイズを保持
	int[] rank; // parentと同様に、木の高さを保持

	public UnionFind(int n) {
		this.parent = new int[n + 1];
		this.size = new int[n + 1];
		this.rank = new int[n + 1];

		for (int i = 0; i < n; i++) {
			makeSet(i);
		}
	}

	public void makeSet(int i) {
		parent[i] = i;
		size[i] = 1;
		rank[i] = 0;
	}

	public int size(int i) {
		return size[find(i)];
	}

	public void unite(int x, int y) {
		int xRoot = find(x);
		int yRoot = find(y);

		if (xRoot == yRoot) {
			return;
		}
		// xが属する木の方が大きい場合
		if (rank[xRoot] > rank[yRoot]) {
			parent[yRoot] = xRoot; // yの親をxに更新
			size[xRoot] += size[yRoot];
		} else {
			// yが属する木のランクがxのそれ以上の場合
			parent[xRoot] = yRoot;
			size[yRoot] += size[xRoot];
			if (rank[xRoot] == rank[yRoot]) {
				rank[xRoot]++;
			}
		}
	}

	// 引数の属する木のルートを返す
	public int find(int i) {
		if (i != parent[i]) {
			parent[i] = find(parent[i]);
		}
		return parent[i];
	}

	// 同じ木に属しているか
	public boolean isSame(int x, int y) {
		return find(x) == find(y);
	}
}


Measured memory_bytes: 96432
#include <stdio.h>
#define N 100

void print(int a[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
}

int main()
{
    int n;
    int a[N];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", a+i);
    }

    print(a, n);

    for (int i = 1; i < n; i++)
    {
        int key = a[i];
        int j = i-1;
        while(a[j] > key && j >= 0)
        {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = key;
        print(a, n);
    }

    return 0;
}



Measured memory_bytes: 2732
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until 3).map {i ->
        (0 until n).map {j ->
            if (i == 2 && j == n - 1) {
                0
            } else {
                sc.next().toInt()
            }
        }.toMutableList()
    }
    println(problem140b(n, a))
}

fun problem140b(n: Int, a: List<MutableList<Int>>): Int {
    val dp = (0 until 2).map {
        (0..n).map {
            0
        }.toMutableList()
    }
    dp[1][0] = a[0][0]
    for (i in 1..n) {
        val tmp1 = a[1][a[0][i - 1] - 1]
        val tmp2 = dp[0][i - 1]
        dp[0][i] = tmp2 + tmp1
        dp[1][i] = a[0][i - 1]
        if (dp[1][i] == dp[1][i - 1] + 1) {
            dp[0][i] += a[2][dp[1][i - 1] - 1]
        }
    }
    return dp[0][n]
}

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

int main(){
    
    
    int A,B,C;
    
    cin >> A >> B >> C;
    
    if((A < C && B > C) || (A > C && B < C)){
        cout << "Yes" << endl;
}else{
     cout << "No" << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

int i,n,x[10000];

i=0;

while(1){
 scanf("%d",&x[i]);
 if(x[i] == 0){
 break;
}

i++;

}

n=i;

for(i=0;i<n;i++){
 printf("Case %d: %d\n",i+1,x[i]);
}
 return 0;
}

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

using namespace std;

int b[1000001];
char a[1000001];
int fac[1000001];
int n;
bool ok;
int ans = 0;
int c[101][101];
int C(int x, int y) {
	if (fac[x] > fac[y] + fac[x - y]) return 0;
	return 1;
}

int main( ) {
	while (scanf("%d", &n) != EOF) {
		ans = 0;
	scanf("%s", a + 1);
	for (int i = 1; i < n; i ++) {
		b[i] = abs(a[i] - a[i + 1]);
		if (b[i] == 1) ok = true;
	}
	-- n;
//	for (int i = 1; i <= n; i ++) c[1][i] = b[i];
//	for (int i = 2; i <= n; i ++)
//		for (int j = 1; j <= n - i + 1; j ++)
//			c[i][j] = abs(c[i - 1][j] - c[i - 1][j + 1]);
//		printf("%d\n", c[n][1]);
	for (int i = 1; i <= n; i ++) {
		fac[i] = fac[i - 1];
		int tn = i;
		while (tn % 2 == 0) fac[i] ++, tn /= 2;
	}
	for (int i = 0; i <= n - 1; i ++) {
		ans = (ans + C(n - 1, i) * b[i + 1]) % 2;
//		printf("%d: %d %d\n", i, C(n - 1, i), b[i + 1]);
	}
	if (ans == 1) printf("1\n");
	else if (ok) printf("0\n");
	else {
		for (int i = 1; i <= n; i ++)
			b[i] /= 2;
		ans = 0;
		for (int i = 0; i <= n - 1; i ++)
			ans = (ans + C(n - 1, i) * b[i + 1]) % 2;
		if (ans) printf("2\n");
		else printf("0\n");
	}
//	break;
	}
	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;
int N;

int left(int i){
    return i*2;
}
int right(int i){
    return i*2+1;
}
int parent(int i){
    return i/2;
}

void Maximize(int H[],int i){
    int l = left(i);
    int r = right(i);
    
    int largest = i;
    if (l <= N && H[l] > H[largest]) largest = l;
    if (r <= N && H[r] > H[largest]) largest = r;
    
    if (largest != i) {
        swap(H[largest],H[i]);//lageset???????????????????°????????????????????????¨?????????
        Maximize(H,largest);//???????????????????????£????°?????????????????????????????????°???
    }
    
}

void build(int H[]){
    for (int i = N/2; i >= 1; i--) {
        Maximize(H,i);
    }
}

int main(){
    int *H;
    cin >> N;
    H = (int *)malloc(sizeof(int)*(N+1));
    
    for (int i = 1; i <= N; i++) {
        scanf("%d",&H[i]);
    }
    
    build(H);
    
    for (int i = 1; i <= N; i++) {
        printf(" %d",H[i]);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3216
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string S; cin >> S;
    if (S =="hi" || S=="hihi" || S=="hihihi" || S=="hihihihi" || S=="hihihihihi") {
        cout << "Yes" << ln;
    } else cout << "No" << ln;
}


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


int main()
{
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	
	int N, M;
	scanf("%d%d", &N, &M);
	vvi edges(N), revEdges(N);
	for (int i{}; i < M; i++)
	{
		int A, B;
		scanf("%d%d", &A, &B);
		A--; B--;
		edges[A].push_back(B);
		revEdges[B].push_back(A);
	}

	int min{1 << 30};
	std::vector<int> ans;
	for (int begin{}; begin < N; begin++)
	{
		std::vector<int> distance(N, 1ll << 30), from(N, -1);
		distance[begin] = 0;
		using pii = std::pair<int, int>;
		std::queue<pii> que;
		que.push({0, begin});
		while (!que.empty())
		{
			auto now{que.front()};
			que.pop();
			if (distance[now.second] < now.first) continue;
			for (auto& e: edges[now.second])
				if (now.first + 1 < distance[e])
				{
					distance[e] = now.first + 1;
					from[e] = now.second;
					que.push({distance[e], e});
				}
		}
		int min_i{-1};
		for (auto& e: revEdges[begin])
			if (distance[e] + 1 < min)
			{
				min_i = e;
				min = distance[e] + 1;
			}
		if (min_i < 0) continue;
		ans.clear();
		for (int now{min_i}; now != begin; now = from[now])
			ans.push_back(now);
		ans.push_back(begin);
	}
	if (min == (1 << 30)) puts("-1");
	else
	{
		printf("%d\n", ans.size());
		for (int i{(int)ans.size() - 1}; i >= 0; i--)
			printf("%d\n", ans[i] + 1);
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int n,a,b,c,d,x;
  long long la,lb,lc,lx;
  double da,db,dc;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> n;
  vector<int> va(n);
  vector<int> vb(n);
  vector<int> vc(n-1);
  rep(i,0,n) cin >> va.at(i);
  rep(i,0,n) cin >> vb.at(i);
  rep(i,0,n-1) cin >> vc.at(i);
  //int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  //int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
ans += vb.at(va.at(0)-1);
  rep(i,1,n){
    ans += vb.at(va.at(i)-1);
    if(va.at(i)-1 == va.at(i-1)) ans += vc.at(va.at(i)-2);
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int a,b,c;
  cin >> a >> b >> c ;
  if(a+b+c>=22) cout << "bust" << endl;
  else cout << "win" << endl;
         
         
  
}


Measured memory_bytes: 256
#include<stdio.h>

int main()

{
    long long int x, a, b,c ;

    scanf("%lld", &x) ;
    a=x/500 ;
    c=x%500 ;
    b=c/5 ;

    printf("%lld\n", (a*1000)+(b*5)) ;

    return 0;

}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int A,B;
  cin >> A >> B;
  if(A%3==0||B%3==0||(A+B)%3==0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

const int mod = 1e9+7;

long long dp[3010][3010];
long long sum_dp[3010][3010];

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

	char s[n];
	scanf("%s", s);

	dp[1][1] = 1;
	sum_dp[1][1] = 1;
	for(int i=2; i<=n; i++) {
		char cur = s[i-2];
		if(cur=='<') {
			for(int j=1; j<=i; j++) {
				dp[i][j] = sum_dp[i-1][j-1];
			}
		} else {
			for(int j=1; j<=i; j++) {
				dp[i][j] = sum_dp[i-1][i-1] + mod-sum_dp[i-1][j-1];
				if(dp[i][j] >= mod) dp[i][j] -= mod;
			}
		}
		for(int j=1; j<=i; j++) {
			sum_dp[i][j] += sum_dp[i][j-1] + dp[i][j];
			if(sum_dp[i][j]>=mod) sum_dp[i][j] -= mod;
		}
	}
	printf("%lld\n", sum_dp[n][n]);
    return 0;
}

Measured memory_bytes: 139904
#include <stdio.h>
void ABC42(void);
void ABC43(void);
void ABC44(void);
void ABC45(void);
void ABC46(void);
void ABC47(void);
void ABC48(void);

int main(void){
    ABC48();
    return 0;
}

void ABC42(void){
    int a,b,c,n=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a==7||b==7||c==7){
        if((a==5&&b==5)||(b==5&&c==5)||(c==5&&a==5)){
            printf("YES");
            n++;
    }}
    if(n==0)printf("NO");
}

void ABC43(void){
    int i,n,sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        sum+=i;
    }
    printf("%d",sum);
}

void ABC44(void){
    int n,k,x,y,i,sum=0;
    scanf("%d",&n);
    scanf("%d",&k);
    scanf("%d",&x);
    scanf("%d",&y);
    if(n>k){
        for(i=1;i<=k;i++)sum+=x;
        for(i=k+1;i<=n;i++)sum+=y;
    }else{
        for(i=1;i<=n;i++)sum+=x;
    }
    printf("%d",sum);
}

void ABC45(void){
    int a,b,h;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&h);
    printf("%d",(a+b)*h/2);
}

void ABC46(void){
    int a,b,c,n;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b||b==c||c==a){
        n=2;
        if(a==b&&a==c)n=1;
    }else{
        n=3;
    }
    printf("%d",n);
}

void ABC47(void){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if((a+b==c)||(b+c==a)||(c+a==b)){
        printf("Yes");
    }else{
        printf("No");
    }
}

void ABC48(void){
    char str1[100],str2[100];
    scanf("%s %s",str1,str2);
    printf("A%c",str2[0]);
    printf("C");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<pair<char,int> > v;
    rep(i,q){
        char a,b;
        cin >> a >> b;
        if(b=='L'){
            v.PB(MP(a,-1));
        }else{
            v.PB(MP(a,1));
        }
    }
    int left,right;
    int ok = -1;
    int ng = n;
    while(ng-ok>1){
        int mid = (ng+ok)/2;
        int t = mid;
        rep(i,q){
            if(s[t]==v[i].first){
                t+= v[i].second;
                if(t==-1||t==n){
                    break;
                }
            }
        }
        if(t==-1){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    left = ok;
    ok = n;
    ng = -1;
    while(ok-ng>1){
        int mid = (ng+ok)/2;
        int t = mid;
        rep(i,q){
            if(s[t]==v[i].first){
                t+= v[i].second;
                if(t==-1||t==n){
                    break;
                }
            }
        }
        if(t==n){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    right = ok;
    cout << max(0,n-(n-right)-(left+1)) << endl;
    return 0;
}

Measured memory_bytes: 2680
from collections import defaultdict
import itertools

def main():
    node_num, edge_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(edge_num)]
    edge_dic = defaultdict(set)
    for i in range(edge_num):
        a, b = data[i]
        edge_dic[a].add(b)
        edge_dic[b].add(a)

    ori_list = [i for i in range(2, node_num + 1)]
    ans = 0
    for root in list(itertools.permutations(ori_list, node_num - 1)):
        root = [1] + list(root)
        for i in range(node_num - 1):
            if root[i + 1] not in edge_dic[root[i]]:
                break
        else:
            ans += 1

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool compare_by_a(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    else return a.second<b.second;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,c=1;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll mini=a[0];
    
    rrep(i,n-1) {
        if(mini>a[i]) {
            mini = a[i];
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

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

	bool win=false;
	const int n=s.size();

	if(s[0]==s[n-1]){
		win=(n-3)%2;
	}else{
		win=(n-2)%2;
	}

	if(win)
		puts("First");
	else
		puts("Second");

	return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;

class program
{
  static void Main(string[] args)
  {
    int n = Convert.ToInt32(Console.ReadLine());
    string[] input = Console.ReadLine().Split(' ');
    List<int> lst = new List<int>();
    for (int i = 0; i < n ; i ++)
    {
      lst.Add(Convert.ToInt32(input[i]));
    }
    lst.Sort();
    int cal = Math.Abs(lst[lst.Count - 1] - lst[0]);
    Console.WriteLine(cal);
  }
}

Measured memory_bytes: 27728
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
bool isP(ll n){
	if(n==1)return false;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)return false;
	}
	return true;
}
void solve(){
	ll m,n;
	cin>>m>>n;
	cout<<m*n/__gcd(m,n);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    for (int i = 1; i <= 1000; i++) {
        if ((x * i) % 360 == 0) {
            cout << i << newl;
            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 sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ll> cnt(26,0);
  for (int i = 0; i < n; i++) {
    cnt[s[i] - 'a']++;
  }
  ll res = 1;

  for (int i = 0; i < 26; i++) {
    (res *= cnt[i] + 1) %= mod;
  }
  cout << (res + mod - 1) % mod << endl;
  return 0;
} 


Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split(" ")))

ans = 0
for i in range(n):
    if a[i] % 2 == 0:
        if ( a[i] % 3 ==0 ) or ( a[i] % 5 == 0 ):
            ans += 1
    else:
        ans += 1

if ans == n:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060