akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3


def judge(s):
    for i, c in enumerate(s):
        if i % 2 == 0 and c == "L" or i % 2 == 1 and c == "R":
            return False
    return True


def main():
    s = input()
    print("Yes" if judge(s) else "No")


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int a, b; cin >> a >> b;
    if(a >= 10 ||b >= 10){
        cout << -1; return 0;
    }
    else cout <<a*b;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int p;
int fact[3005];
int factInv[3005];
int res[3005];
int coef[3005];

int power(int base, int e){
    int res = 1;
    while (e > 0){
        if (e % 2) res = res * base % p;
        base = base * base % p;
        e /= 2;
    }
    return res;
}

void generate(){
    fact[0]=1;
    for (int i=1; i<=p-1; i++) fact[i] = fact[i-1] * i % p;
    for (int i=0; i<=p-1; i++) factInv[i] = power(fact[i], p-2);
}

int comb(int a, int b){
    return (fact[a]*factInv[a-b])%p*factInv[b]%p;
}

int main() {
    cin >> p;
    generate();
    for (int i=0; i<p; i++){
        scanf("%d", &res[i]);
    }
    for (int i=0; i<p; i++){
        if (res[i]) {
            for (int j=0; j<p; j++){
                coef[p-1-j] += p-(comb(p-1, j) * power(-i, j) % p);
                coef[p-1-j] %= p;
            }
            coef[0] += 1;
            coef[0] %= p;
        }
    }
    for (int i=0; i<p; i++) {
        printf("%d ", coef[i]);
    }
    cout << endl;
//    for (int i=0; i<p; i++) cout << fact[i] << " ";
//    cout << endl;
//    for (int i=0; i<p; i++) cout << factInv[i] << " ";
//    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL x;

int main()
{
	FIO;
	cin >> x;
	cout << (x ^ 1) << endl;
}

Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string ans = "yes";
    for (int i = 0; i < s.size(); ++i) {
        if (count(s.begin(), s.end(), s[i]) != 1) {
            ans = "no";
            break;
        }
    }
    cout << ans << endl;

    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 c = sc.nextInt();

		if (a == b) {
			if (a == c) {
				System.out.println(1);
			} else {
				System.out.println(2);
			}
		} else {
			if (a == c) {
				System.out.println(2);
			} else if (b == c) {
				System.out.println(2);
			} else {
				System.out.println(3);
			}
		}
	}

}


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

#include <vector>
using namespace std;


int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	
	for(unsigned int i = 0; i < s.size() - 1 ; i++){
		if(s[i] == s[i + 1]){
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
			}
	}	
	
		for(unsigned int i = 0; i < s.size() - 2 ; i++){
			if(s[i] == s[i + 2]){
				cout << i  + 1 << " " << i + 3 << endl;
				return 0;
				}
			}
	
	
	cout << -1 << " " << -1 << endl;
	
	
	return 0;
}


Measured memory_bytes: 512
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

if 'LOCAL' in os.environ:
    N = 2* 10** 5
    Q = 2 * 10 ** 5
    AB = [[i, i + 1] for i in range(1, N)]
    PX = [[i, 10] for i in range(Q)]
else:
    N, Q = LI()
    AB = []
    PX = []
    for i in range(N-1):
        AB.append(LI())

    for i in range(Q):
        PX.append(LI())


"""
そもそも各頂点の部分木をdictに入れましょうか？
参照するような形で。
2には3
3には4,5
4,5はNoneだと、参照しやすいか？

カウントを若い順にやっていく
"""
AB = sorted(AB, key=lambda x: x[0])
perr('AB')
perr(AB)
d = {}
for p, x in PX:
    if p not in d.keys():
        d[p] = 0
    d[p] += x
for a, b in AB:
    if b not in d.keys():
        d[b] = 0
    if a not in d.keys():
        d[a] = 0
    d[b] += d[a]
for i in range(1, N+1):
    print(d[i], end=' ')


Measured memory_bytes: 109072
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    auto a = vector<vector<int>>(3, vector<int>(N));
    REP(i, N) { cin >> a[0][i] >> a[1][i] >> a[2][i]; }

    auto dp  = vector<vector<int>>(3, vector<int>(N));
    dp[0][0] = a[0][0];
    dp[1][0] = a[1][0];
    dp[2][0] = a[2][0];

    FOR(i, 1, N) {
        REP(pre, 3) {
            REP(now, 3) {
                if (pre != now) {
                    chmax(dp[now][i], dp[pre][i - 1] + a[now][i]);
                }
            }
        }
    }

    int ans = max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1]));
    std::cout << ans << '\n';

    return 0;
}

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

using namespace std;

int main(){
    string N;
    cin >> N;
    int sum = 0;
    for(auto c : N) sum += c - '0';
    cout << max(sum, (int)((N.length() - 1)*9 + N[0] - '1')) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, a[N];

int main() {
    scanf("%d", &n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if (a[i] == i) continue;
        else ans++;
    }
    if (ans == 2 || ans == 0) printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

## a, bを無向辺として，隣接リストを作成
N = int(input())
a = [0] + list(map(int, input().split()))
al = [[] for i in range(N+1)]

for i in range(N-1):
    c, d = list(map(int, input().split()))
    al[c].append(d)
    al[d].append(c)

visited = [0 for i in range(N+1)]

LIS = [a[1]]
ans = [0 for i in range(N+1)]
ans[1] = 1

def dfs_rec(u):
    x = a[u]
    if x > LIS[-1]:
        pre_idx = len(LIS)
        pre_v = INF
        LIS.append(x)
    else:
        pre_idx = bisect.bisect_left(LIS, x)
        pre_v = LIS[pre_idx]
        LIS[bisect.bisect_left(LIS, x)] = x

    ans[u] = len(LIS)

    visited[u] = 1
    for v in al[u]:
        if visited[v] == 0:
            dfs_rec(v)

    if pre_v == INF:
        LIS.pop()
    else:
        LIS[pre_idx] = pre_v

dfs_rec(1)

for i in range(1,N+1):
    print(ans[i])





Measured memory_bytes: 363148
card = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
alice, bob = map(int, input().split())
if card.index(alice) > card.index(bob):
    print('Alice')
elif card.index(alice) < card.index(bob):
    print('Bob')
else:
    print('Draw')


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

typedef long long int lli;
typedef pair<int, int> ii;

const int N = 1e5;
const int MOD = 1e9+7;
vector<vector<int>> adjList(N);

int n, k;

lli paintChildren(int u, int par) {
	lli ans = 1;
	bool parFlag = false;
	for(int i=0; i<adjList[u].size(); i++) {
		if(adjList[u][i] == par) {parFlag = true; continue;}
		ans *= (k- (parFlag? 1:2) -i);
		ans %= MOD;
		ans *= paintChildren(adjList[u][i], u);
		ans %= MOD;
	}
	return ans;
}

lli paintChildrenRoot(int u) {
	lli ans = 1;
	for(int i=0; i<adjList[u].size(); i++) {
		ans *= (k-1-i);
		ans %= MOD;
		ans *= paintChildren(adjList[u][i], u);
		ans %= MOD;
	}
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> k;
	
	int a, b;
	for(int i = 0; i < n-1; i++) {
		cin >> a >> b;
		a--; b--;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
	}

	lli ans = k*paintChildrenRoot(0);
	ans %= MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11648
x = int(input()) # 素数
ans = -1
if x == 2: ans = 2
for i in range(x, x+10**5+1):
    f = True
    for j in range(2, int(x**0.5)):
        if i%j==0:
            f = False
            break
    if f:
        ans = i
        break
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int a[N],b[N],c[N];
int main(){
    int n;
    cin>>n;
    int minn=0x3f3f3f3f;
    int id=0;
    int sum1=0,sum2=0;
    long long  ans=0;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
        if(a[i]>0) sum1++;
        if(a[i]<0) sum2++;
        ans+=abs(a[i]);
        minn=min(abs(a[i]),minn);
    }
    // printf("%d %d %d\n",sum1,sum2,ans);
    if(sum2%2==0) cout<<ans<<endl;
    else cout<<ans-2*minn<<endl;
    //system("pause");
}


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

int main(void){
  int antena[5];
  int k, cnt = 0;
  for(int i = 0; i < 5; i++)
    cin >> antena[i];
  cin >> k;
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      if(antena[i] < antena[j] && antena[j] - antena[i] <= k)
      cnt++;
    }
  }
  if(cnt == 10) cout << "Yay!" << "\n";
  else cout << ":(" << "\n";
  return 0;
}


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

namespace ALDS1_1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var values = new List<int>();

            var n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                values.Add(int.Parse(Console.ReadLine()));
            }

            int minv = values[0];
            int maxv = values[1] - values[0];

            for (int j = 1; j < n; j++)
            {
                maxv = Math.Max(maxv,values[j]-minv);
                minv = Math.Min(minv,values[j]);
            }
            Console.WriteLine(maxv);
        }
    }
}



Measured memory_bytes: 21424
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"

#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define LINF ((ll)1 << 60)
#define INF (1 << 28)
template<typename T>
void chmax(T& a, T b) {
        if (a < b) a = b;
}
template<typename T>
void chmin(T& a,T b) {
        if (a > b) a = b;
}
//.....................
ull mod = (int)1e9 + 7;
const int MAX = (int)2e5 + 5;

ll N;
vector<ll> a;
ll res;

void solve() {
        cin >> N;
        a.resize(N);
        rep(i, N) cin >> a[i];
        rep(i, N) {
                int end_id = N;
                REP(j, i, N) {
                        if (a[j] == 0) {
                                end_id = j;
                                break;
                        }
                }
                res += accumulate(a.begin() + i, a.begin() + end_id, (ll)0) / 2;
                i = end_id;
        }
        cout << res << endl;
}

signed main() {
        int T = 1;
        cout << fixed << setprecision(20);
        rep(i, T) {
                solve();
        }
        return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MX=2e5+9;
ll n,x;
map<ll,ll>m;
vector<pair<ll,ll> > v;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%lld",&x);m[x]++;
    }
    for(auto pp:m){
        if(pp.second==1)continue;
        v.push_back({pp.first,pp.second});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    ll h=-1,w=-1;
    for(auto &pp:v){
        if(pp.second>=2&&h==-1){
            h=pp.first;
            pp.second-=2;
        }
        if(pp.second>=2&&w==-1){
            w=pp.first;
            pp.second-=2;
        }
        if(w!=-1&&h!=-1)break;
    }
    if(w==-1||h==-1)puts("0");
    else cout<<w*h<<endl;
}


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

int s1[2000], s2[2000];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)scanf("%d", &s1[i + 1]);
		rep(i, m)scanf("%d", &s2[i + 1]);
		for (int i = 1; i <= n; i++)s1[i] += s1[i - 1];
		for (int i = 1; i <= m; i++)s2[i] += s2[i - 1];
		int cnt = 0;
		unordered_map<int, int>mp1, mp2;
		rep(i, n + 1)rep(j, i)mp1[s1[i] - s1[j]]++;
		rep(i, m + 1)rep(j, i)mp2[s2[i] - s2[j]]++;
		for (auto p : mp1) {
			cnt += p.second*mp2[p.first];
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 31932
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0;i<N;i++) cin >> h[i];
  vector<int> dp(N,1000000010);
  dp[0]=0;
  for(int i=1;i<N;i++){
    for(int j=max(0,i-K);j<i;j++){
      dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
    }
    //cout << dp [i] << " ";
  }

  cout << dp[N-1] << endl;

  return 0;
}


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

vector<int> winlist[100005];

int func(int node){
    if (winlist[node].size()==0){
        return 0;
    }
    else{
        vector<int> v;
        for (int x : winlist[node]){
            v.push_back(func(x));
        }
        sort(v.begin(),v.end());
        int ans = 0;
        for (int x = v.size(); x>0; x--){
            ans = max(ans,x+v[v.size()-x]);
        }
        return ans;
    }
}

int main(){
int n;
scanf("%d",&n);
for (int x = 2; x<=n; x++){
    int a;
    scanf("%d",&a);
    winlist[a].push_back(x);
}
printf("%d",func(1));
}


Measured memory_bytes: 13568
N=int(input())
A=[0]*N
B=list(map(int,input().split()))
A[0]=B[0]
for i in range(N-1):
    if i==0:
        continue
    A[i]=min(B[i-1],B[i])
A[N-1]=B[N-2]
print(sum(A))

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

using namespace std;

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

char direction[4] = {'U', 'R', 'D', 'L'};
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
char A[11][11];
bool B[11][11];
int H, W;
string ans;
int sum = 0;
bool dfs(int x, int y, int cnt, int dir) {
    // cout << x << " " << y << " " << direction[dir] << endl;
    B[x][y] = false;
    if (cnt == sum) {
        ans += direction[dir];
        return true;
    } else {
        REP(i, 3) {
            int nd = (dir - 1 + i + 4) % 4;
            int nx = x;
            int ny = y;
            while (true) {
                nx += dx[nd];
                ny += dy[nd];
                if (nx < 0 || nx >= H || ny < 0 || ny >= W) break;
                if (B[nx][ny]) {
                    if (dfs(nx, ny, cnt + 1, nd)) {
                        ans += direction[dir];
                        return true;
                    };
                    break;
                }
            }
        }
    }
    B[x][y] = true;
    return false;
}
bool solve() {
    cin >> H >> W;
    int sx = 0, sy = 0;
    int sd = 0;
    REP(i, H) {
        REP(j, W) {
            cin >> A[i][j];
            if (A[i][j] == 'o') {
                B[i][j] = true;
                sum++;
            } else
                B[i][j] = false;
            REP(k, 4) {
                if (A[i][j] == direction[k]) {
                    sd = k;
                    sx = i, sy = j;
                }
            }
        }
    }
    dfs(sx, sy, 0, sd);
    reverse(ans.begin(), ans.end());
    FOR(i, 1, ans.size()) cout << ans[i];
    cout << endl;
}
signed main() {
    // while (solve())
    //     ;
    solve();
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, n, i, j;
  a=0;
  b=0;
  cin >> n;
  vector<int> card(100);
  for(i=0;i<n;i++) {
    cin >> card.at(i);
  }
  for(i=0;i<n;i++) {
    for(j=0;j<n;j++) {
      if (card.at(i) > card.at(j)) {
        b=card.at(i);
        card.at(i) = card.at(j);
        card.at(j) = b;
      }
    }
  }
  for(i=0;i<n;i+=2) {
   a += card.at(i)-card.at(i+1);
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char s[100010];
	while(scanf("%s",s)!=EOF)
	{
		int n,ans;
		ans=0;
		n=strlen(s);
		for(int i=1;i<n;i++)
		{
			if(s[i]!=s[i-1])
				ans++;
		}
		cout<<ans<<endl;
	}
return 0;
}


Measured memory_bytes: 384
//00:10
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
#define ll long long
const ll INF=1e18;
ll DA[N],DB[N];
int Ord[N];
bool cmp(int a,int b)
{
	return DA[a]+DB[a]<DA[b]+DB[b];
}
struct Edge
{
	int v,w[2];
};
vector<Edge>V[N];
struct T
{
	int id;ll sum;
	bool operator<(T b)const
	{
		return sum>b.sum;
	}
};
priority_queue<T>Q;
int n,m;
void Dij(ll*sp,int s,int flag)
{
	for(int i=1;i<=n;i++)sp[i]=INF;
	sp[s]=0;Q.push({s,0});
	while(!Q.empty()){
		T p=Q.top();Q.pop();
		if(p.sum>sp[p.id])continue;
		for(auto k:V[p.id]){
			if(sp[p.id]+k.w[flag]<sp[k.v]){
				sp[k.v]=sp[p.id]+k.w[flag];
				Q.push({k.v,sp[k.v]});
			}
		}
	}
}
bool vis[N];
const ll Cost=1e15;
int main()
{
	//freopen("/home/zz7/CFInput","r",stdin);
	int s,t;scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=0;i<m;i++){
		int u,v,a,b;
		scanf("%d%d%d%d",&u,&v,&a,&b);
		V[u].push_back({v,a,b});
		V[v].push_back({u,a,b});
	}
	Dij(DA,s,0);
	Dij(DB,t,1);
	for(int i=0;i<n;i++)Ord[i]=i+1;
	sort(Ord,Ord+n,cmp);
	int j=0;
	for(int i=0;i<n;i++){
		vis[i]=true;
		while(vis[Ord[j]])j++;
		cout<<Cost-(DA[Ord[j]]+DB[Ord[j]])<<'\n';
	}
}



Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
typedef long long ll;
using namespace std;
using Graph = vector<vector<pair <int, ll>>>;

int col[100000];

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph &G, int v, ll dist)
{
    seen[v] = true; 
    for (auto next_v : G[v]){
      if (seen[next_v.first])  continue;
      if((dist + next_v.second)%2==1) col[next_v.first]=1;
      dfs(G, next_v.first, dist + next_v.second);
    }
}
int main(){
  int n;
  cin >> n;
  seen.assign(n,false);
  Graph G(n);
  REP(i,n-1){
    int u,v;
    ll w;
    cin >> u >> v >> w;
    u--,v--;
    G[u].push_back(make_pair(v,w));
    G[v].push_back(make_pair(u,w));
  }
  dfs(G, 0, 0);
  REP(i,n) cout << col[i] << '\n';
  return 0;
 
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count1=0,count2=0;
  for (int i=0;i<N;i++){
    if (S[i]=='('){
      count1++;
    }
    else {
      if (count1>0){
        count1--;
      }
      else {
        count2++;
      }
    }
  }
  string ans="";
  for (int i=0;i<count2;i++){
    ans+='(';
  }
  ans+=S;
  for (int i=0;i<count1;i++){
    ans+=')';
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  string S; cin>>S;
  int L=0;
  for(int i=0; i<S.size()-2; i++){
    if(S.at(i)=='A'&&S.at(i+1)=='B'&&S.at(i+2)=='C')
      L++;
    else continue;
  }
  cout<<L<<endl;
  
}


Measured memory_bytes: 3604
N = int(input())
A = list(map(int,input().split()))



NumValid = [True] * (N+1)
ans = []
NumAns = [0] * (N+1)


for i in reversed(range(1,N+1)):
    j = 2 * i
    tmp = 0
    while j < N+1:
        tmp += NumAns[j]
        j += i
        
    if tmp % 2 == 0:
        if A[i-1] == 0:
            NumAns[i] = 0
        else:
            NumAns[i] = 1
            ans.append(i)
    else:
        if A[i-1] == 0:
            NumAns[i] = 1
            ans.append(i)
        else:
            NumAns[i] = 0
        
print(len(ans))
print(' '.join(map(str,ans)))

Measured memory_bytes: 21236
#include<bits/stdc++.h>
#define dd(x) cout<<#x<<" = "<<x<<" "
#define de(x) cout<<#x<<" = "<<x<<endl
#define sz(x) int(x.size())
#define All(x) x.begin(),x.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef priority_queue<int> pq;
const int maxn=1e5+10,mod=1e9+7,INF=0x3f3f3f3f;
int a[maxn];
bool check(int n){
	for (int i=2;i<=n;++i)
		if (a[i]-a[i-1]!=1)
			return 0;
	return 1;
}
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;++i)
		cin>>a[i];
	if (check(n)){
		cout<<"YES";
		return 0;
	}
	for (int i=1;i<=n;++i)
		for (int j=i+1;j<=n;++j){
			swap(a[i],a[j]);
			if (check(n)){
				cout<<"YES";
				return 0;
			}
			swap(a[i],a[j]);
		}
	cout<<"NO";
	return 0;
}

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

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<ll> l(N+1);
    l[0]=2;
    l[1]=1;
    for(int i=2;i<=N;i++){
        l[i]=l[i-1]+l[i-2];
    }
    cout << l[N] << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int s_A=0,s_B=0;
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    rep(i,a.size()){
        if(i%2==0)s_A+=a[i];
        else s_B+=a[i];
    }
    cout << s_A-s_B << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
i = sys.stdin.read().split('\n')[:-1]
s = i[0]
a = ['', '']
r = 0
for l in i[2:]:
    if l[0] == '1':
        r ^= 1
    else:
        t, f, c = l.split()
        a[0 if f == '21'[r] else 1] += c 
if r:
    print(a[0][::-1] + s[::-1] + a[1])
else:
    print(a[1][::-1] + s + a[0])

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

using namespace std;


using ll = long long;


const int MAX = 680000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
int combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 

void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

void Solve(){
  int x,y;
    scanf("%d%d",&x,&y);

  int n=(x+y)/3;//何回移動するか
  
  if(2*n<x||2*n<y||(x+y)%3!=0){
    cout<<0<<endl;
    return;
  }
  
  comuse;
  printf("%d\n",combi(n,2*n-x));
}

Measured memory_bytes: 16256
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    la = list(map(int, input().split()))
    lb = list(map(int, input().split()))
    lc = list(map(int, input().split()))
    
    la.sort()
    lb.sort()
    lc.sort()

    ans = 0
    for b in lb:
        idxa = bisect.bisect_left(la, b)
        idxc = bisect.bisect_right(lc, b)
        if idxa > 0 and idxc < n:
            ans += idxa * (n - idxc)
    print(ans) 

if __name__ == '__main__':
    main()

Measured memory_bytes: 118692
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const long long INF = 1LL << 60;
typedef long long ll;

int main()
{
	int H, W;
	cin >> H >> W;
	char table[120][120];

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> table[i][j];
		}
	}

	vector<int> H_zip;
	vector<int> W_zip;

	for (int i = 0; i < H; i++)
	{
		int flag = 0;

		for (int j = 0; j < W; j++)
		{
			if (table[i][j] == '#') {
				flag = 1;
				//cout << "hi" << endl;
				break;
			}
		}
		if (flag)
		{
			H_zip.push_back(i);
		}
	}

	for (int i = 0; i < W; i++)
	{
		int flag = 0;
		for (int j = 0; j < H; j++)
		{
			if (table[j][i] == '#') {
				flag = 1;
				//cout << "hi" << endl;
				break;
			}
		}
		if (flag)
		{
			W_zip.push_back(i);
		}
	}

	
	for (int i = 0; i < H_zip.size(); i++)
	{
		for (int j = 0; j < W_zip.size(); j++)
		{
			int x = H_zip[i];
			int y = W_zip[j];
			cout << table[x][y];
		}
		cout << endl;
	}
	\
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n, k; cin >> n >> k;
    long long ar[n+5] = {};
    for(int i = 1; i <= n; i++)
    {
        cin >> ar[i];
    }
    vector<unsigned long long>v;
    long long ans = 1;
    for(int i = 1; i <= k; i++)
    {
        ans += ar[i];
    }
    v.push_back(ans);
    int pos = 1;
    for(int i = k+1; i <= n; i++)
    {
        ans -= ar[pos];
        ans += ar[i];
        pos++;
        v.push_back(ans);
    }
    for(int i = 0; i < v.size()-1; i++)
    {
        if(v[i] < v[i+1])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6920
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=4e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=998244353;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}
char a[10005];

int main()
{
    scanf("%s",a);
    int len=strlen(a);
    a[len-8]='\0';
    printf("%s\n",a);
    return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

import fractions

n, x = map(int, input().split())
a = [abs(int(i) - x) for i in input().split()]

a.sort()

res = 0
for val in a:
    if res == 0:
        res = val
    else:
        res = fractions.gcd(res, val)
        if res == 1:
            break

print(res)


Measured memory_bytes: 16240
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[100001] = {}, b[100001] = {};
  int amax = 0, bmax = 0;
  REP(i, n){
    int x;
    cin >> x;
    if(i % 2 == 0){
      a[x]++;
      if(a[x] > a[amax])amax = x;
    }else{
      b[x]++;
      if(b[x] > b[bmax])bmax = x;
    }
  }
  int ans;
  if(amax != bmax){
    ans = n - a[amax] - b[bmax];
  }else{
    int asec = 0, bsec = 0;
    FOR(i, 1, 100001){
      if(i != amax && a[i] > a[asec])asec = i;
      if(i != bmax && b[i] > b[bsec])bsec = i;
    }
    ans = n - max(a[amax] + b[bsec], a[asec] + b[bmax]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main( void )
{
	int n;
	while(cin >> n, n) {
		int Max = 0, Min = 1001, Sum = 0;
		int i=n;
		while(i--) {
			int s;
			cin >> s;
			Sum += s;
			if(Max < s) Max = s;
			if(Min > s) Min = s;
		}
		int ave = (Sum - Max - Min) / (n - 2);
		cout << ave << endl;

	}
	return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())


signed main(){

	lli n;
	cin>>n;

	map<lli,vector<lli>> d;

	REP(i,0,n-1){
		lli a,b;
		cin>>a>>b;
		a--,b--;

		d[a].push_back(b);
		d[b].push_back(a);
	}

	lli data[100100];
	REP(i,0,100100)data[i]=0;

	queue<lli> f,s;
	f.push(0);
	s.push(n-1);

	data[0]=1;
	data[n-1]=1;

	lli fBreak=2;
	lli sBreak=2;
	lli fCnt=0;
	lli sCnt=0;
	while(f.size()!=0 || s.size()!=0){
		
		while(f.size()!=0){
			lli top = f.front();
			if(data[top]==fBreak)break;
			f.pop();
			fCnt++;

			for(auto e:d[top]){
				if(data[e]!=0)continue;

				data[e]=data[top]+1;
				f.push(e);
			}
		}
		fBreak++;

		while(s.size()!=0){
			lli top = s.front();
			if(data[top]==sBreak)break;
			s.pop();
			sCnt++;

			for(auto e:d[top]){
				if(data[e]!=0)continue;

				data[e]=data[top]+1;
				s.push(e);
			}
		}
		sBreak++;
	}

	if(fCnt>sCnt)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;

	return 0;
}

Measured memory_bytes: 12416
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[100001] = { 0 };
	long long int k;
	int len, l;

	scanf("%s", &s);
	scanf("%lld", &k);
	len = strlen(s);
	
	for (int i = 0; i < len - 1; i++) {
		if ((s[i] + k > 'z') && (s[i] != 'a')) {
			k = k - ('z' - s[i]) - 1;
			s[i] = 'a';
			if (k <= 0) break;
		}
	}

	l = k % 26;
	while (l > 0) {
		if (s[len - 1] + l > 'z') {
			l = l - ('z' - s[len - 1]) - 1;
			s[len - 1] = 'a';
		}
		else {
			s[len - 1] += l;
			l = 0;
		}
	}

	printf("%s\n", s);

	return 0;
}

Measured memory_bytes: 384
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 47356
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int[] a = new int[x];
        for(int i = 0; i < a.length; i++){
            a[i] = sc.nextInt();
        }
        build(a);
        for(int i = 1; i < a.length; i++){
            int v = a[i];
            int j = i-1;
            while(j >=0 && a[j] > v){
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = v;
            build(a);
        }
    }
    
    public static void build(int[] a){
        StringBuilder out = new StringBuilder();
        for(int i = 0; i < a.length; i++){
            out.append(a[i]);
            if(i < a.length-1){
                out.append(" ");
            }
        }
        out.append("\n");
        System.out.print(out.toString());
    }
}

Measured memory_bytes: 27996
def slove():
    import sys
    input = sys.stdin.readline
    l, k = list(map(int, input().rstrip('\n').split()))
    ab = [list(map(int, input().rstrip('\n').split())) for _ in range(l)]
    ab.sort()
    cnt = 0
    for a, b in ab:
        cnt += b
        if cnt >= k:
            print(a)
            exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 56540
h, w, n = map(int, input().split())
d = dict()
ans = [0] * 10
for _ in range(n):
    a, b = map(int, input().split())
    for i in range(-1, 2):
        for j in range(-1, 2):
            x, y = a + i, b + j
            if 1 < x < h and 1 < y < w:
                k = x * w + y
                if not k in d:
                    d[k] = 1
                    ans[1] += 1
                else:
                    ans[d[k]] -= 1
                    ans[d[k] + 1] += 1
                    d[k] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans)
for i in ans:
    print(i)

Measured memory_bytes: 193212
// C++ program of a space optimized DP solution for 
// 0-1 knapsack problem. 
#include<bits/stdc++.h> 
#define ll long long int
#define mod 1000000007
using namespace std; 

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

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

// Driver program to test the cases 
int main() 
{ 
	ll r,c,i,j;
    cin >> r >> c;
    char a[r+1][c+1];
    ll dp[r+1][c+1];
    
    for(i=1;i<=r;i++){
        for(j=1;j<=c;j++) {
            cin >> a[i][j];
            dp[i][j] = 0;
        }
    }
    
    dp[1][1] = 1;
    
    for(i=2;i<=r;i++)
    {
       if(a[i][1] != '#') {
       dp[i][1] = dp[i-1][1];
       }
    }
    for(i=2;i<=c;i++)
    {
       if(a[1][i] != '#') 
       dp[1][i] = dp[1][i-1]; 
    }
    
    for(i=2;i<=r;i++){
        for(j=2;j<=c;j++) {
            if(a[i][j] != '#') {
                dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod;
            }
        }
    }
    
    cout << dp[r][c];
	
	
    
} 


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


int main() {
long N,K;
cin>>N>>K;
if(K%2==1){
  cout<<long(pow(N/K,3))<<endl;
}
else{
  long h=N/(K/2);
  long m=N/K;
  h-=m;
  cout<<long(pow(h,3)+pow(m,3))<<endl;
}

}


Measured memory_bytes: 4020
N=int(input())
H=list(map(int, input().split()))
Max=0
count=0
index=0
for i in range(1,N):
  if H[index] >= H[i]:
    count+=1
    index+=1
  else:
    count=0;
    index = i
  if Max < count:
    Max = count
print(Max)

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>

using namespace std;

bool check[109];
int d[109], f[109];
int n, t=0;
vector<int> G[109];

void dfs(int n){
  check[n] = true;
  d[n] = ++t;
  for(int i=0;i<G[n].size();i++){
    if(!check[G[n][i]])dfs(G[n][i]);
  }
  f[n] = ++t;
}

int main(){
  memset(check, false, sizeof(check));
  cin >> n;
  for(int i=0;i<n;i++){
    int u, k, v;
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> v;
      G[u].push_back(v);
      sort(G[u].begin(), G[u].end());
    }
  }
  for(int i=1;i<=n;i++){
    if(!check[i])dfs(i);
  }
  for(int i=1;i<=n;i++)cout << i << ' ' <<  d[i] << ' ' << f[i] << endl;
}


Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int h[21];
    for (int i = 0; i < n;i++){
        cin >> h[i];
    }
    int tmp = h[0];
    int ans = 0;
    for (int i = 0; i < n;i++){
        if(tmp<=h[i]){
            ans++;
            tmp = h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(void){
    long long a, b, k;
    std::cin >> a >> b >> k;
    if(a >= k){
	a -= k;
	std::cout << a << " " << b << std::endl;
	return 0;
    }else{
	k = k - a;
	a = 0;
	if(b >= k){
	    b -= k;
	    std::cout << a << " " << b << std::endl;
	}else{
	    std::cout << a << " " << 0 << std::endl;
	}
    }
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main() {
	string s;
	cin >> s;
	if(s=="RRR") cout << 3 <<endl;
	else if(s=="RRS" || s == "SRR") cout << 2 <<endl;
	else if(s=="SSS") cout << 0 <<endl;
	else cout << 1 << endl;
	return 0;
}

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

using namespace std;

int cost[100005];
int dp[100005];

int main(){
    ios::sync_with_stdio(0); cin.tie();
     
    int N, a,k;
    cin >> N >>k;
    for(int i = 0 ;i < N+1 ; i++) dp[i] = 1000000002; //set value
    for(int i=0;i<N;i++){
        cin >> a;
        cost[i] = a;
    }
    dp[0] = 0;
    
    for(int i = 1 ; i < N ; i++){
        for(int j = 1; j < k+1 ; j++){
            
            if( i - j >= 0 ) {
              dp[i] = min( dp[i], dp[i-j] + abs(cost[i] - cost[i-j])); 
                              }
            else
                break;
            
            
        }
    }
    cout << dp[N-1];
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(all(s));
	rep(i, n) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >>  a >> b;
  if(a<6){
    c=0;
  }else if(a>12){
    c = b;
  }else{
    c = b/2;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

signed main(){
	int a,b;
	cin>>a>>b;
	if(b!=1)cout<<(a-b)<<endl;
	else cout<<(0)<<endl;
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, K = gets_i_list
a_list = gets_i_list

type_count = a_list.uniq.size

# 配列に出現する数値をカウント
# {1=>3, 2=>1, 3=>2}
count_hash = a_list.group_by(&:itself).map{|k,v| [k, v.count] }.to_h

if type_count <= K
  puts 0
  exit
end

count_list = count_hash.values.sort
total = 0
(type_count - K).times do
  total += count_list.shift
end

puts total


Measured memory_bytes: 70232
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

using int64 = long long;

int main() {
  int64 n;
  cin >> n;
  vector<int64> A(n);
  for (int64& a : A)
    cin >> a;

  int64 left = 0;
  int64 right = 0;
  for (int64 i = 0, j = n - 1; i <= j;) {
    if (left < right) {
      left += A[i++];
    } else {
      right += A[j--];
    }
  }
  cout << abs(left - right) << "\n";

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int main(void){
	int a,b,c,d,e,check;
	int *Ans,*da,*db,*dc;
	while(1){
	scanf("%d %d %d",&a,&b,&c);
	if(a==0 && b==0 && c==0)break;
	Ans=(int*)malloc(sizeof(int)*(a+b+c+1));
	for(e=1;e<=a+b+c;e++){
		Ans[e]=2;
	}
	scanf("%d",&d);
	da=(int*)malloc(sizeof(int)*(d));
	db=(int*)malloc(sizeof(int)*(d));
	dc=(int*)malloc(sizeof(int)*(d));
	for(e=0;e<d;e++){
		scanf("%d %d %d %d",&da[e],&db[e],&dc[e],&check);
		if(check==1)Ans[da[e]]=1,Ans[db[e]]=1,Ans[dc[e]]=1;
	}
	back:
	for(e=0;e<d;e++){
		   check=0;
		   if(Ans[da[e]]==1)check+=1;
		   if(Ans[db[e]]==1)check+=1;
		   if(Ans[dc[e]]==1)check+=1;
		   if(check==2){
		   	 if(Ans[da[e]]==2){
			 	Ans[da[e]]=0;
				goto back;
			 }
		  	 if(Ans[db[e]]==2){
			 	Ans[db[e]]=0;
				goto back;
			 }
		 	 if(Ans[dc[e]]==2){
			 	Ans[dc[e]]=0;
				goto back;
		   	 }
		}
	}
	free(da);
	free(db);
	free(dc);
	for(e=1;e<=a+b+c;e++){
		printf("%d\n",Ans[e]);
	}
	}
	return 0;
} 

Measured memory_bytes: 0
from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

S = [[False]*W for _ in range(H)]
for h in range(H):
    s = input()
    for w in range(W):
        if s[w] == ".":
            S[h][w] = True
d = [[10**9]*W for _ in range(H)]
d[Ch-1][Cw-1] = 0

D = deque([(Ch-1, Cw-1, 0)])
while D:
    h, w, c = deque.popleft(D)
    if c > d[h][w]:
        continue
    # 歩いて移動
    # 上
    if h > 0:
        if S[h-1][w] and c < d[h-1][w]:
            d[h-1][w] = c
            deque.appendleft(D, (h-1, w, c))
    # 下
    if h < H-1:
        if S[h+1][w] and c < d[h+1][w]:
            d[h+1][w] = c
            deque.appendleft(D, (h+1, w, c))
    # 左
    if w > 0:
        if S[h][w-1] and c < d[h][w-1]:
            d[h][w-1] = c
            deque.appendleft(D, (h, w-1, c))
    # 右
    if w < W-1:
        if S[h][w+1] and c < d[h][w+1]:
            d[h][w+1] = c
            deque.appendleft(D, (h, w+1, c))
    # ワープで移動
    for hh in range(max(0, h-2), min(H-1, h+2)+1):
        for ww in range(max(0, w-2), min(W-1, w+2)+1):
            if S[hh][ww] and d[hh][ww] > c+1:
                d[hh][ww] = c+1
                deque.append(D, (hh, ww, c+1))
if d[Dh-1][Dw-1] == 10**9:
    print(-1)
else:
    print(d[Dh-1][Dw-1])




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i, N) cin >> d[i];

    ll res = 0;
    sort(d.begin(), d.end());
    REP(K, 101010){
    	ll x = d.end() - lower_bound(d.begin(), d.end(), K);
    	ll y = N - x;
    	if(x == y) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String sArray[] = new String[4];

		sArray = S.split("");

		if (sArray[0].equals(sArray[1]) || sArray[1].equals(sArray[2]) || sArray[2].equals(sArray[3])) {
			System.out.println("Bad");
		} else {
			System.out.println("Good");
		}
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
const int inf=1e4+5;
typedef long long ll;
string a,b,c;
int len1,len2;
int dp[inf][inf];
bool vis[inf][inf];
void str(int i,int j)
{
    if(a[i]=='\0' || b[j]=='\0'){
        cout<<c<<endl;
        return;
    }
    if(a[i]==b[j]){
        c+=a[i];
        str(i+1,j+1);
    }
    else{
    if(dp[i+1][j]>dp[i][j+1]){
        str(i+1,j);
    }
    else{
        str(i,j+1);
    }
    }
}
int solve(int i,int j)
{
    if(a[i]=='\0' || b[j]=='\0'){
        return 0;
    }
    if(vis[i][j]) return dp[i][j];
    int ans=0;
    if(a[i]==b[j]){
        ans=1+solve(i+1,j+1);
    }
    else{
        int val1=solve(i+1,j);
        int val2=solve(i,j+1);
        ans=max(val1,val2);
    }
    vis[i][j]=1;
    dp[i][j]=ans;
    return dp[i][j];
    //return c;
}
int main()
{
    cin>>a>>b;

    int k=solve(0,0);
    str(0,0);
   // cout<<c<<endl;
}


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

int f(int X) {
  int sum = 0;
  while(true) {
    sum += X % 10;
    X /= 10;
    if(X == 0) {
      break;
    }
  }
  return sum;
}

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

  if(N % f(N) == 0) cout << "Yes";
  else cout << "No";

  cout << endl;
}

Measured memory_bytes: 256
a = []
b = []
for i in range(0,10):
    n = int(input())
    a.append(n)
    a.sort()
    W = a[7:10]
for i in range(10,20):
    n = int(input())
    b.append(n)
    b.sort()
    c = b[7:10]
print(sum(W),sum(c))


Measured memory_bytes: 5596
N=int(input())
T=[]
for i in range(N):
    t=int(input())
    T.append(t)
    
ans=T[0]
def LCM(a,b):
    A=max(a,b)
    B=min(a,b)
    while A%B!=0:
        A,B=B,A%B
    #print(a,b,A,B)
    return a*b//B

for i in range(1,N):
    ans=LCM(ans,T[i])
print(ans)

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[][] d = new int[31][10000];
		int[] idx = new int[31];
		while(true){
			String[] tmp = stdIn.next().split(",");
			int num = Integer.parseInt(tmp[0]);
			int ans = Integer.parseInt(tmp[1]);
			if((num|ans)==0){
				break;
			}
			d[ans][idx[ans]++] =num;
		}
		while(stdIn.hasNext()){
			int call = stdIn.nextInt();
			int rank = 0;
			LOOP : {
				for(int i=30;i>=0;i--){
					if(idx[i]>0){
						rank++;
					}
					for(int j=0;j<idx[i];j++){
						if(call==d[i][j]){
							System.out.println(rank);
							break LOOP;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 14000