akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string w, s;
  cin >> w;
  int ans = 0;
  while (1) {
    cin >> s;
    if (s == "END_OF_TEXT")
      break;
    rep(i, s.size()) if (isupper(s[i])) s[i] = tolower(s[i]);
    if (s == w)
      ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3200
import java.util.*

fun main(args: Array<String>) = abc160d()

fun abc160d() {
    val (n, x, y) = readLine()!!.split(' ').map { it.toInt() }

    val graph = Array(n) {
        Vertex(it, setOf(it - 1, it + 1).filter { it in 0 until n }.toMutableSet())
    }

    graph[x - 1].neighbor.add(y - 1)
    graph[y - 1].neighbor.add(x - 1)
    
    val count = IntArray(n)

    for (fromIndex in 0 until n) {
        val queue: Queue<Pair<Int, Int>> = ArrayDeque(listOf(fromIndex to 0))
        val visited = mutableSetOf(fromIndex)

        while (queue.isNotEmpty()) {
            val (index, dist) = queue.poll()

            count[dist]++
            graph[index].neighbor.filter { visited.add(it) }
                .map { it to dist + 1 }.let { queue.addAll(it) }
        }
    }

    val answer = count.drop(1).map { it / 2 }.joinToString(System.lineSeparator())

    println(answer)
}

private data class Vertex(val index: Int, val neighbor: MutableSet<Int> = mutableSetOf())


Measured memory_bytes: 122992
#include <iostream>
#include <math.h>

using namespace std;

struct Point {
    double x;
    double y;
};

void koch(int n, Point a, Point b) {
    if (n == 0) return;

    Point s, t, u;
    double th = M_PI * 60.0 / 180.0;

    s.x = (2.0 * a.x + 1.0*b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;

    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

    koch(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);

    koch(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);

    koch(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);

    koch(n - 1, t, b);
}

int main()
{
    Point a, b;
    int n;
    cin >> n;

    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    printf("%.8f %.8f\n", a.x, a.y);

    koch(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n,m,k;
int a[maxn];
int b[maxn];

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

    cin>>n>>m>>k;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }
    for (int i=1; i<=m; i++) {
	cin>>b[i];
    }

    int ans = *min_element(a+1,a+1+n) + *min_element(b+1,b+1+m);

    while (k--) {
	int x, y, c;
	cin>>x>>y>>c;
	ans = min(ans, a[x]+b[y]-c);
    }

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


Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool CHMAX(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool CHMIN(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

  int ans = 0, tot = 0;
  REP(i,s.size()) {
    if (s[i] == 'A' ||
      s[i] == 'C' ||
      s[i] == 'G' ||
      s[i] == 'T'
    ) {
      tot++;
    } else {
      CHMAX(ans, tot);
      tot = 0;
    }
  }
  CHMAX(ans, tot);
  COUT(ans);
  return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(c) for c in input().split()]

#どうするか
#-1 -1  1
# 1 -1 -1
#-1  1 -1

#偶数個の数値を自由に反転できるとして見ていい

positive=[]
negative=[]
for a in A:
	if(a>=0):
		positive.append(a)
	else:
		negative.append(a)
if(len(negative)%2==0):#偶数個なら全部ひっくり返せばいい
	print(sum(positive)-sum(negative))
else:#奇数個なら, もっとも大きなもの以外をひっくり返す
	#あるいは, 最後にpositive最小とnegative最大をひっくり返すこともありうる	
	if(len(positive)==0):
		print(-sum(negative)+2*max(negative))
	
	else:
		max_nega=max(negative)
		min_posi=min(positive)
		if(-1*max_nega>min_posi):
			print(sum(positive)-sum(negative)-2*min_posi)
		else:	
			print(sum(positive)-sum(negative)+2*max_nega)







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

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

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

		if (A >= B) {
			B *= 2;
			continue;
		}

		if (B >= C) {
			C *= 2;
			continue;
		}
	}

	if (A < B&&B < C)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
int main(void)
{
	int a[200000],n,max1,max2;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		if(max1<a[i])
		{
			max2=max1;
			max1=a[i];
		}
		else if(max2<a[i])
		{
			max2=a[i];
		}
		else
		{
		}
	}
	for(int i=0;i<n;i++)
    {
		if(max1==a[i]) printf("%d\n",max2);
		else printf("%d\n",max1);
	}
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;

string sta = "abcdefghijklmnopqrstuvwxyz";

int stanum(char c){
	rep(i, sta.size()){
		if(c == sta[i]) return i;
	}
	return -1;
}

int main(){
	rep(i, 26){
		sta += sta[i]+'A'-'a';
	}


	while(1){
		int n;
		cin >> n;
		if(!n)break;
		vector<int> k(n);
		rep(i, n){
			cin >> k[i];
		}
		string s;
		cin >> s;
		rep(i, s.size()){
			s[i] = sta[(stanum(s[i])+sta.size()-k[i%k.size()])%sta.size()];
		}
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
public class Main {

  private static void solve() {
    int h1 = ni();
    int m1 = ni();
    int h2 = ni();
    int m2 = ni();
    int k = ni();
    int ret = h2 * 60 + m2 - h1 * 60 - m1 - k;
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36572
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    ll N, ans = 0;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    for (int i = 1; i < N; i++){
        if (A.at(i - 1) > A.at(i)){
            ans += A.at(i - 1) - A.at(i);
            A.at(i) = A.at(i - 1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4820
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

from collections import defaultdict
from collections import deque
import heapq

MOD = 998244353

def DD(arg): return defaultdict(arg)

def inv(n): return pow(n, MOD-2, MOD)

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

class NTT_convolution:
  def __init__(self, ROOT=3, MOD=998244353):
    self.ROOT = 3
    self.MOD = 998244353
    self.roots  = [pow(self.ROOT,(self.MOD-1)>>i,self.MOD) for i in range(24)] # 1 の 2^i 乗根
    self.iroots = [pow(x,self.MOD-2,self.MOD) for x in self.roots] # 1 の 2^i 乗根の逆元
 
  def untt(self,a,n):
    for i in range(n):
      m = 1<<(n-i-1)
      for s in range(1<<i):
        w_N = 1
        s *= m*2
        for p in range(m):
          a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m])%self.MOD, (a[s+p]-a[s+p+m])*w_N%self.MOD
          w_N = w_N*self.roots[n-i]%self.MOD
 
  def iuntt(self,a,n):
    for i in range(n):
      m = 1<<i
      for s in range(1<<(n-i-1)):
        w_N = 1
        s *= m*2
        for p in range(m):
          a[s+p], a[s+p+m] = (a[s+p]+a[s+p+m]*w_N)%self.MOD, (a[s+p]-a[s+p+m]*w_N)%self.MOD
          w_N = w_N*self.iroots[i+1]%self.MOD
      
    inv = pow((self.MOD+1)//2,n,self.MOD)
    for i in range(1<<n):
      a[i] = a[i]*inv%self.MOD
 
  def convolution(self,a,b):
    la = len(a)
    lb = len(b)
    deg = la+lb-2
    n = deg.bit_length()
    if min(la, lb) <= 50:
      if la < lb:
        la,lb = lb,la
        a,b = b,a
      res = [0]*(la+lb-1)
      for i in range(la):
        for j in range(lb):
          res[i+j] += a[i]*b[j]
          res[i+j] %= self.MOD
      return res
 
    N = 1<<n
    a += [0]*(N-len(a))
    b += [0]*(N-len(b))
    self.untt(a,n)
    self.untt(b,n)
    for i in range(N):
      a[i] = a[i]*b[i]%self.MOD
    self.iuntt(a,n)
    return a[:deg+1]

N = int(input())
NTT = NTT_convolution()

nokori = [1]
for n in range(1,2*N+10):
  nokori.append((nokori[-1]*(2*n-1)*(2*n)*inv(2)*inv(n))%MOD)

dic = DD(int)
for _ in range(N*2):
  dic[int(input())] += 1
A = [dic[k] for k in dic]
  
P = []
for a in A:
  temp = 1
  count = 0
  P.append([temp])
  while a >= 2:
    temp *= a*(a-1)//2
    temp %= MOD
    count += 1
    P[-1].append((temp*gyaku_kaijo(count))%MOD)
    a -= 2

Q = []
for i in range(len(P)):
  heapq.heappush(Q,(len(P[i]),i))

while len(Q)>1:
  _,p = heapq.heappop(Q)
  _,q = heapq.heappop(Q)
  temp = NTT.convolution(P[p], P[q])
  P.append(temp)
  heapq.heappush(Q,(len(temp),len(P)-1))
Q = list(P[-1])

ans = 0
M = len(Q)

def sign(x):
  if x%2: return -1
  else: return 1

for i in range(M):
  ans += sign(i) * Q[i] * nokori[N-i]
  ans %= MOD
  
print(ans)

Measured memory_bytes: 118472
import java.util.*;
public class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),z=s.nextInt(),w=s.nextInt(),a[]=new int[n--];
		Arrays.setAll(a,i->s.nextInt());
		System.out.println(n==0?Math.abs(a[0]-w):Math.max(Math.abs(a[n]-w),Math.abs(a[n-1]-a[n])));
	}
}

Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int x ,t;
  cin >> x >> t;
  cout << max(x - t,0) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, i, s=0, tmp;
	cin >> n;
	tmp=n;
	while (tmp!=0)
	{
		s += tmp % 10;
		tmp /= 10;
	}
	if (n % s == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)


H,W=map(int,input().split())
S=[]
for i in range(H):
    S.append(input())

def DFS(h,w,black,white,m):
    black,white=BorW(h,w,black,white)
    step=[[0,1],[0,-1],[1,0],[-1,0]]
    seen[h][w]=1
    for dh,dw in step:
        nh=h+dh
        nw=w+dw
        if 0<=nh<H and 0<=nw<W:
            if seen[nh][nw]==0 and m!=S[nh][nw]:
                seen[nh][nw]=1
                black,white=DFS(nh,nw,black,white,S[nh][nw])
    return black,white


def BorW(h,w,black,white):
    if S[h][w]=="#":
        black+=1
    else:
        white+=1
    return black,white


seen=[[0]*W for _ in range(H)]

L=[]
for h in range(H):
    for w in range(W):
        black=0
        white=0
        if seen[h][w]==0:
            black,white=DFS(h,w,black,white,S[h][w])
            L.append([black,white])
ans=0
for b,w in L:
     ans+=b*w

print(ans)

Measured memory_bytes: 232724
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] d = new int[7];
        int dice=1, i=0, ans=0, surface=0, right=0, left=0, top=0, bottom=0;
        
        for(i=0;i<6;i++)d[i+1] = sc.nextInt();
        
        String h = sc. next();
        
        for(i=0;i<h.length();i++){
            switch (h.substring(i,i+1)) {
            case "E":
                surface = d[4];
                d[4] = d[6]; d[6] = d[3]; d[3] = d[1]; d[1] = surface;
                break;
                
            case "W":
                surface = d[3];
                d[3] = d[6]; d[6] = d[4]; d[4] = d[1]; d[1] = surface; 
                break;
                
            case "S":
                surface = d[5];
                d[5] = d[6]; d[6] = d[2]; d[2] = d[1]; d[1] = surface; 
                break;
                
            case "N":
                surface = d[2];
                d[2] = d[6]; d[6] = d[5]; d[5] = d[1]; d[1] = surface; 
                break;
                
            }
        }
        System.out.println(d[1]);
    }
}


Measured memory_bytes: 26300
#include <stdio.h>

void swap(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

void ascend_order(int n, int s[]){
    int i, j;
    for (i = 0; i < n - 1; i++){
        for (j = 0; j < n - i - 1; j++){
            if (s[j] > s[j + 1])
                swap(&s[j], &s[j + 1]);
        }
    }
}

int main(void){
    int n, x;
    int m[99];
    int i;
    int ind;
    
    scanf("%d %d", &n, &x);
    for (i = 0; i < n; i++)
        scanf("%d", &m[i]);
    
    ascend_order(n, m);
    ind = x;
    for (i = 0; i < n; i ++)
        ind -= m[i];
    
    printf("%d \n", ind/m[0] + n);
    
    return 0;
}


Measured memory_bytes: 128
N, M = map(int,input().split())

reslist = []

if M == 0:
    if N == 1:
        print(0)
        exit(0)
    else:
        print('1' + '0'*(N-1))
        exit(0)

slist = [list(map(int,input().split())) for i in range(M)]

mlist = [-1 for i in range (N+1)]

for lis in slist:
    if mlist[lis[0]] != -1:
        if mlist[lis[0]] != lis[1]:
            print(-1)
            exit(0)
    else:
        mlist[lis[0]] = lis[1]

# print(mlist)



for j in range(1, N+1):
    # print(mlist[j])
    if mlist[j] == 0 and N > 1 and j == 1:
        print(-1)
        exit(0)
    if mlist[j] == -1:
        if j == 1:
            reslist.append(1)
        else:
            reslist.append(0)
    else:
        reslist.append(mlist[j])

# print(reslist)

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

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
using namespace std;
char ans[100010],spe[100010];
int n;
bool c(char l)
{
switch(l)
{
case 'o':return true;
case 'x':return false;
case 'S':return true;
case 'W':return false;
}
}
char c(bool l){return (l?'S':'W');}
char func(int i,int j)
{return (c((c(spe[i])==c(ans[i]))==(c(spe[j]))));}
bool comp(char f,char s)
{
int i;
spe[0]=f;spe[1]=s;
for(i=2;i<n;i++)
{spe[i]=func(i-1,i-2);}
return (func(n-1,n-2)==spe[0]&&func(0,n-1)==spe[1]);
}
int main()
{
cin>>n>>ans;
if(comp('S','S'))
{cout<<spe;return 0;}
if(comp('S','W'))
{cout<<spe;return 0;}
if(comp('W','S'))
{cout<<spe;return 0;}
if(comp('W','W'))
{cout<<spe;return 0;}
cout<<"-1";
return 0;
}


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

using namespace std;

int main(){

  int h,w;

  cin>>h>>w;

  vector<string> cond(h);

  for(int i=0;i<h;++i)
	cin>>cond[i];

  for(int i=0;i<h;++i){
	int c = 0;
	for(int j=0;j<w;++j){
	  if(cond[i][j]=='.' && c == 0)
		cout<<-1;
	  else if(cond[i][j]=='c'){
		cout<<0;
		c=1;
	  }
	  else if(cond[i][j]=='.' && c != 0){
		cout<<c;
		c++;
	  }
	  if(j != w-1)
		cout<<' ';
	}
	cout<<endl;
  }
}



Measured memory_bytes: 3156
#include <stdio.h>
int main(){
	int n,s,sub;
	int a,b,c,d,e,f,g,h,i;
	
	while(scanf("%d %d",&n, &s)!=EOF){
		if(n==0 &&s==0)		break;
		sub=0;
	
	if(n==1){
		for(a=0; a<=9; a++){
		if(s == a)	sub=1;
	}
	}

	else if(n==2){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				if(s == (a+b))	sub++;
			}
		}
	}

	else if(n==3){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					if(s == (a+b+c))	sub++;
				}
			}
		}
	}

	else if(n==4){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						if(s == (a+b+c+d))	sub++;
					}
				}
			}
		}
	}

	else if(n==5){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						for(e=d+1; e<=9; e++){
							if(s == (a+b+c+d+e))	sub++;
						}
					}
				}
			}
		}
	}

	else if(n==6){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						for(e=d+1; e<=9; e++){
							for(f=e+1; f<=9; f++){
								if(s == (a+b+c+d+e+f))	sub++;
							}
						}
					}
				}
			}
		}
	}

	else if(n==7){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						for(e=d+1; e<=9; e++){
							for(f=e+1; f<=9; f++){
								for(g=f+1; g<=9; g++){
									if(s == (a+b+c+d+e+f+g))	sub++;

								}
							}
						}
					}
				}
			}
		}
	}

	else if(n==8){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						for(e=d+1; e<=9; e++){
							for(f=e+1; f<=9; f++){
								for(g=f+1; g<=9; g++){
									for(h=g+1; h<=9; h++){
										if(s == (a+b+c+d+e+f+g+h))	sub++;

									}

								}
							}
						}
					}
				}
			}
		}
	}

	else if(n==9){
		for(a=0; a<=9; a++){
			for(b=a+1; b<=9; b++){
				for(c=b+1; c<=9; c++){
					for(d=c+1; d<=9; d++){
						for(e=d+1; e<=9; e++){
							for(f=e+1; f<=9; f++){
								for(g=f+1; g<=9; g++){
									for(h=g+1; h<=9; h++){
										for(i=h+1; i<=9; i++){
											if(s == (a+b+c+d+e+f+g+h+i))	sub++;
										}
									}

								}
							}
						}
					}
				}
			}
		}
	}
	printf("%d\n",sub);
	}
	
	return 0;
}



Measured memory_bytes: 1980
#include<stdio.h>

int main(){
  int a;
  int n,i;
  int flag = 0;

  scanf("%d", &n);

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

    if(a % 2 == 0){
      if(a % 3 != 0 && a % 5 != 0) flag = 1;
    }
  }

  if(flag == 1) printf("DENIED\n");

  else printf("APPROVED\n");

  return 0;
}


Measured memory_bytes: 128
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
ans = 1
n = 1
check = 1
city = [-1 for i in range(N+1)]
city[1] = 0
roop = 1
i = 0
while(check == 1):
  if i == K:
    check = 0
  else:
    n = A[n]
    i = i + 1 
    if city[n] == -1:
      city[n] = i
    else:
      roop = i - city[n]
      check = 0
roop_num = (K - i)%roop
for i in range(roop_num):
  n = A[n]
print(n)

Measured memory_bytes: 32372
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;

void solve(long long A, long long B) {
  cout << A / __gcd(A,B)*B << endl;
}

int main() {
  int a;
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  solve(A, B);
  return 0;
}


Measured memory_bytes: 256
public class Hello{
    
    public static void Main(){
        // Your code here!
        //startCode
        int[] data=new int[2];
        int[] data4=new int[2];
        int[] data5=new int[2];
        int cutNumber;
        string[] data2=new string[2];
        while(true){
            var datax=System.Console.ReadLine();
            data2=datax.Split(' ');
            data4[0]=int.Parse(data2[0]);
            data4[1]=int.Parse(data2[1]);
            if(data4[0]==0){
                break;
            }
            int[] data3=new int[data4[0]];
            for(int i=0;i<data4[0];i++){
                data3[i]=data4[0]-i;
            }
            cutNumber=data3[1];
            for(int i=0;i<data4[1];i++){
                var datax2=System.Console.ReadLine();
                data2=datax2.Split(' ');
                data5[0]=int.Parse(data2[0]);
                data5[1]=int.Parse(data2[1]);
                int[] data6=new int[data5[1]];
                for(int h=data5[0]-1;h<data5[0]+data5[1]-1;h++){
                    data6[h-data5[0]+1]=data3[h];
                }
                for(int h=data5[0]-2;h>=0;h--){
                    data3[h+data5[1]]=data3[h];
                }
                for(int h=0;h<data5[1];h++){
                    data3[h]=data6[h];
                }
            }
           System.Console.WriteLine(data3[0]);
            

        }
       
    }
}



Measured memory_bytes: 13904
#include<cstdio>
int digitsum(int n,int k=10){
	int ans=0;
	while(n>0){
		ans+=n%k;
		n/=k;
	}
	return ans;
}
int main(){
    int n;
    scanf("%d",&n);
    if(n%digitsum(n)==0)printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream> 
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
const int N = 50033;
long long a[N];
int len,n,k;
int size,ans1[N],ans2[N];
int main() {
	scanf("%d",&n);
	for (int i=1; i<=n; i++) scanf("%lld",&a[i]);
	int mx=-10000000,mn=10000000,p1=0,p2=0;
	for (int i=1; i<=n; i++) {
		if (a[i]>mx) {mx=a[i]; p1=i;}
		if (a[i]<mn) {mn=a[i]; p2=i;}
	}
	if (1LL*mx*mn<0) {
		if (mx>(-mn)) {
			rep(i,1,n) if (a[i]<0) {a[i]+=mx; ans1[++size]=p1; ans2[size]=i;}
			mn=0;
		}
		else {
			rep(i,1,n) if (a[i]>0) {a[i]+=mn; ans1[++size]=p2; ans2[size]=i;}
			mx=0;
		}
	}
	if (mx>=0&&mn>=0) {
		rep(i,2,n) if (a[i]<a[i-1]) {a[i]+=a[i-1]; if (a[i]>1e8) a[i]=1e8; ans1[++size]=i-1; ans2[size]=i;}
	}
	else {
		per(i,n-1,1) if (a[i]>a[i+1]) {a[i]+=a[i+1]; if (a[i]<-(1e8)) a[i]=-1e8; ans1[++size]=i+1; ans2[size]=i;}		
	}
	printf("%d\n",size); rep(i,1,size) printf("%d %d\n",ans1[i],ans2[i]);
	return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		B += A * 3;
		ans = B / 2;

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF INT_MAX
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll
#define P pair<int,int>

string alpha="abcdefghijklmnopqrstuvwxyz";
vector<int> cnt[26];
vector<int> cnt_t[26];

signed main(){
  string s,t;
  cin>>s>>t;
  set<char> s_char;
  for(int i=0; i<s.size(); i++){
    if(s[i]==t[i]){
      s_char.insert(s[i]);
    }
    for(int j=0; j<26; j++){
      if(s[i]==alpha[j]) cnt[j].push_back(i);
    }
  }
  
  for(int i=0; i<t.size(); i++){
    for(int j=0; j<26; j++){
      if(t[i]==alpha[j]) cnt_t[j].push_back(i);
    }
  }
  
  for(int i=0; i<26; i++){
    if(cnt_t[i].size()<2) continue;
    for(int j=1; j<cnt_t[i].size(); j++){
      if(s[cnt_t[i][0]]!=s[cnt_t[i][j]]){
        cout<<"No"<<en;
        RE;
      }
    }
  }
  
  for(int i=0; i<26; i++){
    if(cnt[i].size()<2) continue;
    for(int j=1; j<cnt[i].size(); j++){
      if(t[cnt[i][0]]!=t[cnt[i][j]]){
        cout<<"No"<<en;
        RE;
      }
    }
  }
  
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]){
      if(s_char.find(s[i])!=s_char.end()||s_char.find(t[i])!=s_char.end()){
        cout<<"No"<<en;
        RE;
      }
    }
  }
  cout<<"Yes"<<en;
}


Measured memory_bytes: 5108
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include<stdio.h>

using namespace std;

int main(void){
	int n; cin >> n;
	vector<int> a(n), b(n), c(n - 1);
	int ans;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> b[i];
	for (int i = 0; i < n-1; i++)cin >> c[i];
	ans=accumulate(b.begin(), b.end(), 0);
	//cout << ans;
	for (int i = 1; i < n; i++) {
		if (a[i] - 1 == a[i - 1]) ans += c[a[i-1]-1];
	}
	cout << ans;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define watch(x) cout<<(#x)<<" is "<<x<<endl;
#define ll long long int
#define pb push_back
#define in insert
#define mp make_pair
#define F first
#define S second
#define N 1000000
#define MOD 1000000007
#define PI acos(-1)
int main()
{
	IOS
	ll x;
	cin>>x;
	map<ll,ll> mp;
	for(ll a=-1000;a<=1000;a++)
	{
	mp[pow(a,5)]=a;
	}
	for(ll a=-1000;a<=1000;a++)
	{
		ll req=pow(a,5)-x;
		if(mp.find(req)!=mp.end()){
		cout<<a<<" "<<mp[req];
		return 0;}
	}
}

Measured memory_bytes: 4160
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<map>
#define MAX_N 100001
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;

struct edge{
  int from,to,cost;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;
typedef pair<int , int> P;
bool comp(const edge& e1, const edge& e2){
  return e1.cost < e2.cost;
}
struct moji{
  string red;
  string blue;
};

bool cmp(const moji& a,const moji& b){
  return a.red < b.blue;
}
typedef pair<string,string> PS;
int main()
{
  long long int c=0;
  int N;
  cin >> N;
  string s,r;
  map<PS, long long int> LM,RM;
  cin >> s;
  r = s.substr(N,2*N);
  reverse(r.begin(),r.end());
  s = s.substr(0,N);
  
  for(int i=0;i<pow(2,N);i++){
    PS d;
    REP(j,N)
      if(((i >> j) & 1) == 1)
        d.first.push_back(s[j]);
      else
        d.second.push_back(s[j]);
    LM[d]++;
  }
  for(int i=0;i<pow(2,N);i++){
    PS d;
    REP(j,N)
      if(((i >> j) & 1) == 1)
        d.first.push_back(r[j]);
      else
        d.second.push_back(r[j]);
    c += LM[d];
  }

  cout << c << endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 91904
/*
注意范围！
short范围：-32768~32767
unsigned short范围：0~65535
int范围：-2147483648~2147483647
uint范围：0~4294967295
INT范围：-9223372036854775808~9223372036854775807
UINT范围：0~18446744073709551615
float范围：-3.4e38～3.4e38，精度：6~7位
double范围：-1.7e308~1.7e308，精度：15~16位
ldouble范围：-1.2e4932~1.2e4932，精度：18~19位
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;

vector<int> aa[200007];
int n,m,a,b;

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&a,&b);
		aa[a].pb(b);
		aa[b].pb(a);
	}
	for(int i=0;i<SZ(aa[1]);i++)
	{
		int dis=aa[1][i];
		for(int j=0;j<SZ(aa[dis]);j++)
			if(aa[dis][j]==n)
				OVER("POSSIBLE");
	}
	OVER("IMPOSSIBLE");
}


Measured memory_bytes: 12144
// finish date: 2018/05/12
#include <bits/stdc++.h>


using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


struct Union_Find {
    vector<int> parent;
    vector<int> sizes;
    int setnum = 0;

    Union_Find(int n) : parent(n), sizes(n, 1) {
        rep(i, n) parent[i] = i;
        setnum = n;
    }

    int find(int x) {
        if (x == parent[x]) return x;
        return parent[x] = find(parent[x]);
    }

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

        if (x == y) return;

        if (sizes[x] < sizes[y]) swap(x, y);

        parent[y] = x;
        sizes[x] += sizes[y];
        setnum--;
    }

    bool isSame(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sizes[find(x)];
    }

};

int main() {
    int N, M;
    cin >> N >> M;
    map<int, int> mp1, mp2;
    vi p(N);
    rep(i, N) {
        cin >> p[i];
        mp1[p[i]] = i + 1;
        mp2[i + 1] = p[i];
    }
    int x, y;
    Union_Find uf(N+1);
    rep(i, M) {
        cin >> x >> y;
        uf.unite(x, y);
    }

    int c = 0;
    rep(i, N) {
        if (uf.isSame(i + 1, p[i])) c++;
    }
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 10752
#include <stdio.h>
#include <math.h>

int n, count = 0;
double rad = M_PI/3;

void draw(double x1, double y1, double x5, double y5, int count);

int main(){
  double x1 = 0.0, x2 = 100.0, x5, y5;

  scanf("%d", &n);
  printf("%f %f\n", x1, x1);

  if(n == 0){
    printf("%f %f\n", x2, x1);
  }
  else draw(x1, x1, x2, x1, count);

  return 0;
}

void draw(double x1, double y1, double x5, double y5, int count){
  double x2, y2, x3, y3, x4, y4;
  x2 = (2*x1+x5)/3.0;
  y2 = (2*y1+y5)/3.0;
  x4 = (x1+2*x5)/3.0;
  y4 = (y1+2*y5)/3.0;
  x3 = x2+(x4-x2)*cos(rad)-(y4-y2)*sin(rad);
  y3 = y2+(x4-x2)*sin(rad)+(y4-y2)*cos(rad);
  count++;

  if(count < n){
    draw(x1, y1, x2, y2, count);
    draw(x2, y2, x3, y3, count);
    draw(x3, y3, x4, y4, count);
    draw(x4, y4, x5, y5, count);
  }
  else{
    printf("%f %f\n", x2, y2);
    printf("%f %f\n", x3, y3);
    printf("%f %f\n", x4, y4);
    printf("%f %f\n", x5, y5);
  }
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
using namespace std;
int n,sum,maxn;
char s[105];
int main()
{
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I') sum++;
		else sum--;
		maxn=max(maxn,sum);
	}
	printf("%d\n",maxn);
	return 0;
}

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

int main() {
    int K,A,B;
    cin>>K>>A>>B;
    for (int i = A; i <= B; i++){
        if(i%K==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}

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

int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    bool flag = true;
    int num;

    for(int i = 0; i < (int)min(n,k); i++){
        if(s[i] != '1'){
            flag = false;
            num = s[i] - '0';
            break;
        }
    }

    if(flag){
        cout << 1 << endl;
    }else{
        cout << num << endl;
    }
}



Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
t = a[0] - min(a[0], x)
a[0] -= t
for i in range(1, n):
    if a[i] + a[i - 1] > x:
        diff = (a[i] + a[i - 1]) - x
        t += diff
        a[i] -= diff
print(t)

Measured memory_bytes: 14060
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}


void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL)root=i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2004
import scala.io.StdIn.readInt

object Main {
  def main(args:Array[String]) = {
    val w = { for(i <- 1 to 10) yield readInt }.sortWith( _ > _ ).take(3).sum
    val k = { for(i <- 1 to 10) yield readInt }.sortWith( _ > _ ).take(3).sum
    println(w + " " + k)
  }
}

Measured memory_bytes: 43912
M=10**9+7
n,k=map(int,input().split())
fac=[1]
for i in range(1,n+k+1):fac+=fac[-1]*i%M,
inv=[pow(fac[-1],M-2,M)]
for i in range(1,n+k+1)[::-1]:inv+=inv[-1]*i%M,
inv.reverse()
comb=lambda n,k:k<=n and fac[n]*inv[n-k]*inv[k]%M
for i in range(1,k+1):print(comb(n-k+1,i)*comb(k-1,i-1)%M)

Measured memory_bytes: 3572
#include<iostream>
using namespace std;
class Cube{
public:
int f[6];
Cube(){}
void roll_z(){ roll(1,2,4,3);}
void roll_y(){ roll(0,2,5,3);}
void roll_x(){ roll(0,1,5,4);}
void roll(int i,int j,int k,int l){
int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
}
};
bool eq(Cube c1,Cube c2){
for (int i=0;i<6;i++)
if(c1.f[i]!=c2.f[i])return false;
return true;
}
bool equal(Cube c1,Cube c2){
for(int i=0;i<6;i++){
for(int j=0;j<4;j++){
if(eq(c1,c2))return true;
c1.roll_z();
}
if(i%2==0)c1.roll_y();
else c1.roll_x();
}
return false;
}
int main(){
Cube c1,c2;
for(int i=0;i<6;i++)cin >>c1.f[i];
for(int i=0;i<6;i++)cin >>c2.f[i];
if(equal(c1,c2))cout <<"Yes" <<endl;
else cout <<"No" <<endl;
return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,c; cin>>a>>b>>c;
	if (c>=a&&c<=b) cout<<"Yes";
	else cout<<"No"<<endl;
	return 0;
}


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

main() {
    string s;
    cin>>s;
    int sum=0;
    for (char c:s) {
        sum=(sum+(int)(c-'0'))%9;
    }
    if (sum==0) {
        cout<<"Yes\n";
    } else {
        cout<<"No\n";
    }
}

Measured memory_bytes: 3688
import bisect
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
x = LI()
sx = [(i, x[i]) for i in range(n)]
sx = sorted(sx, key=lambda a: a[1])
mid_l = sx[n // 2 - 1][1]
mid_r = sx[n // 2][1]
# print(mid_l, mid_r)
sx = [(sx[i][0], i, sx[i][1]) for i in range(n)]
sx = sorted(sx, key=lambda a: a[0])
# print(sx)
for _, sort_i, elem in sx:
    if sort_i < n // 2:
        print(mid_r)
    else:
        print(mid_l)


Measured memory_bytes: 62908
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

  int ans = INF;
  REP(i,100001) {
    int S = 2*C*i+A*max(X-i,0)+B*max(Y-i,0);
    ans = min(ans,S);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
for e in sys.stdin:
 e=float(e)
 h=['light ','']
 a=h[e>91]+'heavy'if e>81 else h[e>75]+'middle'if e>69 else h[e>64]+'welter'if e>60 else'light'if e>57 else'feather'if e>54 else'bantam'if e>51 else h[e>48]+'fly'
 print(a)


Measured memory_bytes: 5580
#include <iostream>
using namespace std;
int main(){
  int a,v1,v2,sum[10];
  char c;
  while(cin >> a >> c){
    sum[0] = a;
    for(int i = 1 ; i < 10 ; i++ ){
      cin >> a >> c;
      sum[i] = a + sum[i - 1];
    }
    cin >> v1 >> c >> v2;
    
    double t = ((double)v1/(v1 + v2))*sum[9];
    for(int i = 0 ; i < 10 ; i++ ){
      if(t <= sum[i] ){
	cout << i + 1 << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
bool p(int a){
	if(a==1)
		return 0;
	for(int i=2;i*i<=a;i++)
		if(a%i==0)
			return 0;
	return 1;
}
int main(){
	int x;
	cin>>x;
	for(int i=x; ;i++)
		if(p(i)==1){ 
			cout<<i;
			return 0;
		} 
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int N, K;
int as[100000+10];

int main(void) {
  scanf("%d%d", &N, &K);
  REP(i, N) {
    scanf("%d", &as[i]);
  }
  int mini = 2e9;
  int last = 0;
  REP(i, N) {
    mini = min(mini, as[i]);
  }
  REP(i, N) {
    if(as[i] == mini) {
      last = i;
    }
  }
  int res = 0;
  REP(i, N) {
    if(as[i] != mini) {
      ++res;
      if(i < last) {
        bool exist = false;
        REP(j, K-1) {
          if(i+j >= N) {
            break;
          }
          if(as[i+j] == mini) {
            exist = true;
          } else {
            as[i+j] = mini;
          }
        }
        if(exist) {
          if(i+K-1 < N) {
            as[i+K-1] = mini;
          }
        }
      } else {
        REP(j, K-1) {
          if(i+j >= N) {
            break;
          }
          as[i+j] = mini;
        }
      }
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int taro_p = 0;
        int hanako_p = 0;
        int s = 0;
        for (int i = 0; i < n; i++) {
            String taro = sc.next();
            String hanako = sc.next();
            if (taro.length() == hanako.length()) { 
                s = taro.length();
            } else if (taro.length() < hanako.length()) {
                s = taro.length();
            } else {
                s = hanako.length();
            }
            for (int j = 0; j < s; j++) {
                if (taro.equals(hanako)) {
                    taro_p += 1;
                    hanako_p += 1;
                    break;
                } else if ((s - 1 == j && taro.charAt(j) == hanako.charAt(j) && taro.length() > hanako.length()) || taro.charAt(j) > hanako.charAt(j)) {
                    taro_p += 3;
                    break;
                } else if ((s - 1 == j &&  taro.charAt(j) == hanako.charAt(j) && taro.length() < hanako.length()) || taro.charAt(j) < hanako.charAt(j)) {
                    hanako_p += 3;
                    break;
                } else {
                   
                }
            }    
        }
        System.out.println(taro_p + " " + hanako_p);
    }
}

Measured memory_bytes: 29516
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;

        static void Solve()
        {
            string s = Console.ReadLine();
            var splits = s.Split(' ');
            var a = splits[0];
            var b = splits[1];
            var c = splits[2];
            string ans = a[a.Length - 1] == b[0] && b[b.Length - 1] == c[0] ? "YES" : "NO";
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

int main(){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if((abs(a - c) <= d) || ((abs(a - b) <= d) && (abs(b - c) <= d))) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

#define MAX 50

int main(){

	int N,K;
	int m,bi;
	int R;
	int p,q;
	int cnt=0;
	vector<int> e[MAX+1];
	vector<int> b;
	bool f[MAX+1];

	for(int i=0;i<=MAX;i++) f[i]=false;

	cin>>N>>K;
	for(int i=0;i<K;i++){
		cin>>m;
		for(int j=0;j<m;j++){
			cin>>bi;
			b.push_back(bi);
		}
		for(int j=0;j<b.size();j++){
			for(int k=0;k<b.size();k++){
				if(b[j]!=b[k]){
					e[b[j]].push_back(b[k]);
					e[b[k]].push_back(b[j]);
				}
			}
		}
		if(!b.empty()) b.clear();
	}

	cin>>R;

	for(int i=0;i<R;i++){
		cin>>p>>q;
		for(int i=0;i<e[p].size();i++){
			if(e[p][i]==q){
				f[p]=true;
				f[q]=true;
			}
		}
	}

	for(int i=1;i<=N;i++){
		if(f[i]==true) cnt++;
	}

	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 1252
#include<stdio.h>

int main(void){
	unsigned int i;
    unsigned long long int n;
	scanf("%llu", &n);
	
	if(0 < n && n < 21){
		for(i = n - 1; i > 1; i--) n*=i;
		printf("%llu\n", n);
	}

    return 0;
}

Measured memory_bytes: 0