akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  int n, k;
  scanf("%d %d", &n, &k);
  if (k == 1) printf("0\n");
  else printf("%d\n", n - k);
  return 0;
}

Measured memory_bytes: 256
from collections import deque,defaultdict

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

G = defaultdict(list)
for i in range(M):
    G[data[i][0]].append(data[i][1])
    G[data[i][1]].append(data[i][0])

D = [0]+[-1]*(N)

c = 0
for i in range(1,N+1):
    if D[i] != -1:
        continue
    else:
        q = deque([i])
        while q:
            n = q.pop()
            D[n] = 0
            for d in G[n]:
                if D[d] != -1:
                    continue
                else:
                    q.append(d)
        c += 1

print(c)

Measured memory_bytes: 89304
N = int(input())
arr = list(map(int,input().split()))

a=[]
b=[]
c=[]
for i in range(N):
    if arr[i]%4 == 0:
        a.append(arr[i])
    elif arr[i]%2 == 0:
        b.append(arr[i])
    else:
        c.append(arr[i])
if len(c) > len(a)+1:
    print('No')
elif len(c) < len(a) + 1:
    print('Yes')
elif len(b)%2 == 1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 14252
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();

        if (X < A) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }

}

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

using namespace std;

long int A,B,C,D;

int main(){
    
    cin >> A >> B >> C >> D;
    
    long int Ua = max(C, D);
    long int Ub = min(C, D);

    while (Ua % Ub != 0) {
        long int Uab = Ua - Ub;
        
        Ua = max(Ub, Uab);
        Ub = min(Ub, Uab);
        
        
        
    }
    
    long int CD = C*D/Ub;
    
    cout << B - A + 1 - ((B/C - (A-1)/C) + (B/D - (A-1)/D) - (B/CD - (A-1)/CD)) << endl;
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  
  I(N);
  FOR(i, 1, N+1) {
    ll cnt = N / i;
    ll sum = cnt * (cnt + 1) / 2;
    ret += sum * i;
  }

  P(ret);

}


Measured memory_bytes: 3620
# -*- coding: utf-8 -*-


def linear_search(S, T):
    count = 0
    for i in xrange(len(T)):
        if T[i] in S:
            count += 1
    return count

if __name__ == '__main__':
    n = input()
    S = map(int, raw_input().split())
    q = input()
    T = map(int, raw_input().split())

    print linear_search(S, T)

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll x;
    cin >> x;
    ll num = x%11;
    ll ans = (x/11)*2;
    if(num>6){
        ans+=2;
    }else if(num!=0){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int N;

const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x(x%mod) {}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};
mint MOD = mod;

vector<int>E[202020];
mint fact[202020], factinv[202020], dp1[202020], dp2[202020];
int cnt[202020];

mint modpow(mint a, ll n) {
	mint res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

void dfs1(int now,int p){
	mint ret = 1;
	ll c = 1;
	fore(x, E[now]) {
		if (x != p) {
			dfs1(x,now);
			c += cnt[x];
			ret *= dp1[x];
			ret *= factinv[cnt[x]];
		}
	}
	ret *= fact[c-1];
	dp1[now] = ret;
	cnt[now] = c;
}

void dfs2(int now,int p,mint mul) {
	mint ret = mul;
	fore(x, E[now]) {
		if (x != p) {
			ret *= dp1[x];
			ret *= factinv[cnt[x]];
		}
	}
	ret *= factinv[N-cnt[now]];
	fore(x, E[now]) {
		if (x != p) {
			mint temp = ret;
			temp *= modpow(dp1[x],mod-2);
			temp *= fact[cnt[x]];
			temp *= fact[N-1-cnt[x]];
			dfs2(x, now, temp);
		}
	}
	ret *= fact[N-1];
	dp2[now] = ret;
}


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

	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		E[a].pb(b);
		E[b].pb(a);
	}

	fact[0] = 1;
	for (ll i = 1; i < 202020; i++)fact[i] = fact[i - 1] * i;
	for (int i = 0; i < 202020; i++)factinv[i] = modpow(fact[i],mod-2);
	dfs1(0,-1);
	dfs2(0,-1,1);

	puts(dp1[0].x);
	for (int i = 1; i < N; i++)puts(dp2[i].x);

	return 0;
}

Measured memory_bytes: 21108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();

		sc.close();

		for(int i=0; i<str.length(); i++) {
			if(Character.isUpperCase(str.charAt(i))) {
				System.out.print(str.split("")[i].toLowerCase());
			} else {
				System.out.print(str.split("")[i].toUpperCase());
			}
		}
		System.out.println("");

	}

}



Measured memory_bytes: 68408
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    C=[]
    
    #連番無視
    for i in range(N):
        c=I()
        c-=1
        if C==[]:
            C.append(c)
        else:
            if C[-1]!=c:
                C.append(c)         
            
    """
    i番目の通り数をf(i)とする．
    今，i番目までを見てて，i番目と同じ数はj,kにあるとする．
    f(i)=
         f(i-1) #iを使わない
        +f(j-1) #i-jのみ
        +f(k-1) #i-kのみ
    かな，各色ごとに，f(j-1)+f(k-1)みたいなのをまとめておく
    """    
    S=[0]*(2*10**5 + 5)
    
    ans=1
    for c in C:
        temp=ans
        ans=(ans+S[c])%mod
        S[c]=(S[c]+temp)%mod
        
    print(ans)
        
        
        
        
    

main()


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

int main (){
  int N;
  cin >>N;
  int t=0;
  for (int i=1;i<3200;i++){
    if (N==i*(i-1)/2){t=i;break;}
  }
  if (t>0){
    cout << "Yes" << endl;
    cout << t << endl;
    for (int p=0;p<t;p++){
      cout << t-1;
      int i;
      for (i=1;i<=(t-1)/2;i++){
        int a=(i-1)*t+p+1;
        int b=(i-1)*t+(p+t-i)%t+1;
        cout<<" "<<a << " "<<b;
      }
      if (t%2==0){
        cout<<" "<<(i-1)*t+p%(t/2)+1;
      }
      cout <<endl;
    }
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    map<int, int> mp;
    cin >> n >> mp['A'] >> mp['B'] >> mp['C'];
    string s[n], ans = "";
    for(int i=0;i<n;i++) cin >> s[i];
    for(int i=0;i<n;i++){
    	string t = s[i];
    	if(mp[t[0]] == 0){
    		if(mp[t[1]] == 0){
    			cout << "No" << endl;
    			return 0;
    		}else{
    			mp[t[1]]--;
    			mp[t[0]]++;
    			ans += t[0];
    		}
    	}else{
    		if(mp[t[1]] == 0){
    			mp[t[0]]--;
    			mp[t[1]]++;
    			ans += t[1];
    		}else{
    			if(mp[t[0]] == 1 && mp[t[1]] == 1){
    				if(i == n - 1) ans += t[0];
    				else{
    					i++;
    					if(t == s[i]){
    						ans += t[0];
    						ans += t[1];
    					}else{
    						if(t[0] == s[i][0]) swap(t[0], t[1]), swap(s[i][0], s[i][1]);
    						else if(t[1] == s[i][0]) swap(s[i][0], s[i][1]);
    						else if(t[0] == s[i][1]) swap(t[0], t[1]);
    						mp[t[0]]--;
    						mp[s[i][0]]++;
    						ans += t[1];
    						ans += s[i][0];
    					}
    				}
    			}
    			else{
    				if(mp[t[0]] > mp[t[1]]){
    					mp[t[0]]--;
    					mp[t[1]]++;
    					ans += t[1];
    				}
    				else{
    					mp[t[1]]--;
    					mp[t[0]]++;
    					ans += t[0];
    				}
    			}
    		}
    	}
    }
    cout << "Yes" << endl;
    for(int i=0;i<n;i++){
    	cout << ans[i] << endl;
    }
    return 0;
}


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

vector<int> SCC(const vector<vector<int>> &graph, const vector<vector<int>> &rev) {
    int N = graph.size();
    vector<bool> visited(N);
    stack<int> vs;

    auto dfs = [&](auto &&dfs, int cur) -> void {
        visited[cur] = true;
        for(auto &to : graph[cur]) {
            if(!visited[to]) dfs(dfs, to);
        }
        vs.push(cur);
    };

    for(int i = 0; i < N; ++i) {
        if(!visited[i]) dfs(dfs, i);
    }

    visited.assign(N, false);
    int k = 0;
    vector<int> components(N);

    while(!vs.empty()) {
        int v = vs.top(); vs.pop();
        if(visited[v]) continue;

        auto dfs_rev = [&](auto &&dfs_rev, int cur) -> void {
            visited[cur] = true;
            for(auto &to : rev[cur]) {
                if(!visited[to]) dfs_rev(dfs_rev, to);
            }
            components[cur] = k;
        };

        dfs_rev(dfs_rev, v);
        k++;
    }

    return components;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> graph(N);
    vector<vector<int>> rev(N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        graph[a].emplace_back(b);
        rev[b].emplace_back(a);
    }
    auto scc = SCC(graph, rev);
    int Q; cin >> Q;
    while(Q--) {
        int u, v;
        cin >> u >> v;
        cout << (scc[u] == scc[v]) << '\n';
    }
    return 0;
}



Measured memory_bytes: 4472
import numpy as np
d=int(input())
c=list(map(int,input().split()))
TotalLoss=sum(c)
for i in range(26):
  c[i]=TotalLoss-c[i]
c=np.array(c)
s=[]
for i in range(d):
  si=np.array(list(map(int,input().split())))
  s=np.append(s,si)
ans=[]
for i in range(d):
  si=s[i]
  si-=c
  index=np.argmax(si)
  ans.append(index+1)
for i in range(d):
  print(ans[i])

Measured memory_bytes: 27460
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;
int main(){
  string s;cin>>s;
  bool ans=true;
  for(int i=1;i<4;i++){
    if(s[i-1]==s[i]){
      ans = false;
      break;
    }
  }
  cout<<(ans?"Good":"Bad")<<endl;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int cnt = 0;
  	if(a < 0) {
  		if(b >= 0)
      		cnt = a * -1;
  		else
      		cnt = b - a + 1;
	}
  	if(a <= 0 && b >= 0)
    	cout << "Zero" << endl;
	else {
    	if(cnt % 2)
        	cout << "Negative" << endl;
  		else
        	cout << "Positive" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
	char s[7];
	scanf("%s", s);
	if (s[2] == s[3] && s[4] == s[5])
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}


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

int main(){
    int h,w;
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                cout << "#";
            }
            cout << endl;
        
        }
        cout << endl;
    }
}


Measured memory_bytes: 3116
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

#[fastout]
fn main() {
  input! {
    a: i64,
    b: i64,
    n: i64,
  }
  let f = |x| a * x / b - a * (x / b);

  println!("{}", f(cmp::min(b - 1, n)));
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    long long int a;
    long double b;
    long long int fin;
    cin >> a >> b;
    
    b = b*100;
    b = b + 0.5;
    int tmpB = b;
    fin = a*tmpB/100;



    /*for(int i = 0; i < a; i++){
        res += b;
    }*/
    cout << fin << endl;
}

Measured memory_bytes: 3692
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import java.io._
// import java.util.ArrayDeque

object Main extends App {
  // val n = in.readInt
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = Integer.parseInt(in.readLine)

  case class edge(v:Int, d:Int)
  val tree = Array.fill(n)(mu.ListBuffer.empty[edge])

  Iterator.continually(in.readLine)
    .take(n-1)
    .map(_.split(" ").map(_.toInt))
    .foreach { case Array(v, u, d) =>
      new edge(u-1, d) +=: tree(v-1)
      new edge(v-1, d) +=: tree(u-1)
    }

  val colors = Array.ofDim[Int](n)
  val visit = Array.ofDim[Boolean](n)

  def dfs(v:Int, d:Int):Unit = {
    val stk = mu.Stack.empty[edge]
    // val stk = new ArrayDeque[edge]
    stk.push(new edge(v, d))

    while(!stk.isEmpty) {
      val v = stk.pop
      if(!visit(v.v)) {
        visit(v.v) = true
        colors(v.v) = v.d
        for(nv <- tree(v.v) if !visit(nv.v)){
          val d = (v.d + nv.d) % 2
          stk.push(new edge(nv.v, d))
        }
      }
    }
  }

  dfs(0,0)
  println(colors.mkString("\n"))
}

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

int revenue(int x, int y, int z){
  return 10000*x + 5000*y + 1000*z;
}

int main() {
  int N, Y,l=0,a,b, c,k;
  cin >> N >> Y ;
 
  for (int i = 0; i<=N;i++){
     if (l>= 1)
       break;
     for (int j = 0;j<=N;j++){
       if (l >=1)
         break;
       else {
       
           
           k = (Y - 10000*i - 5000*j)/1000; 
           if ( i + j + k== N && k >= 0){
           cout << i << " "<< j<<" "<<   k <<endl;
           l++;
           break;
          
          }
           else if (i ==N && j == N  ){
            cout << -1 <<" " <<  -1 <<" "<< -1 <<endl;
            break;
          }
           
        }
         
      }
    
    
  }
  
    
}
        

Measured memory_bytes: 256
package main
import . "fmt"
func main() {
  var n,m,x int
  var s string
  set := map[string]int{}
  Scan(&n)
  for i:=0;i<n;i++ {
    Scan(&s)
    if _,ok := set[s];ok {
      set[s]++
    } else {
      set[s] = 1
    }
  }
  Scan(&m)
  for i:=0;i<m;i++ {
    Scan(&s)
    if _,ok := set[s];ok {
      set[s]--
    } else {
      set[s] = -1
    }
  }
  x = 0
  for _,val := range set {
    if x < val { x = val }
  }
  Println(x)
}


Measured memory_bytes: 512
# 1st:0407,2nd-:0408

#ABC041-C
if False:
    N=int(input())
    A=[int(i) for i in input().split()]
    ans=[(i,a) for i,a in enumerate(A)]
    ans.sort(key=lambda x: x[1],reverse=True)
    for i in range(N): print(ans[i][0]+1)

#AGC017-A
if False:
    N,P=map(int,input().split())
    A=[int(i) for i in input().split()]
    flag=True # 偶数のみか
    for a in A:
        if a%2==1:
            flag=False
            break
    if flag:
        if P==0:
            print(2**N)
        else:
            print(0)
    else:
        print(2**(N-1))

#3rd: ABC155-A
if True:
    if len(set(input().split()))==2:
        print('Yes')
    else:
        print('No')
#4th
#5th

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
vector<int> G[100010];
int N, K;

int dfs(int v, int p) {
    int num;
    if (p == -1) num = K - 1;
    else num = K - 2;
    int case_num = 1;
    for(auto to : G[v]) {
        if (to == p) continue;
        case_num *= num;
        num--;
        case_num %= mod;
    }
    for(auto to: G[v]) {
        if (to == p) continue;
        case_num *= dfs(to, v);
        case_num %= mod;
    }
    return case_num;
}

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

    cin >> N >> K;
    rep(i, N - 1) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    cout << K * dfs(0, -1) % mod << endl;

    return 0;
}


Measured memory_bytes: 10368
#include <stdio.h>
int main(void){
    long a, b, c, k;
    scanf("%ld %ld %ld %ld", &a, &b, &c, &k);
    // printf("%d %d %d %d\n", a, b, c, k);
    if(a >= k) printf("%ld\n", k);
    else if(a + b >= k) printf("%ld\n", a);
    else printf("%ld\n", a-1*(k - a - b));
    return 0;
}

Measured memory_bytes: 1736
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
using namespace std;

int main() {
	int H, W, h, w;
	cin >> H >> W;
	cin >> h >> w;
	cout << (H*W) - (h*W) - (w*H) + (h*w);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;
set<int>s;
int a[maxn],b[maxn],cnt[maxn];
int main()
{
    int n;
    ll k;
    memset(cnt,0,sizeof(cnt));
    scanf("%d%lld",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        cnt[a[i]]+=b[i];
        s.insert(a[i]);
    }
    ll sum=0;int key;
    for(set<int>::iterator it=s.begin();it!=s.end();it++)
    {
        int t=*it;
        sum+=cnt[t];
        if(sum>=k)
        {
            key=t;
            break;
        }
    }
    printf("%d\n",key);

}


Measured memory_bytes: 4352
n = int(input())
cnt = 0
for i in range(n):
    num = int(input())
    judge = True
    if num == 2:
        pass
    elif num < 2 or num%2 == 0:
        judge = False
        pass
    else:
        j = 3
        while j <= num**0.5:
            if num%j == 0:
                judge = False
                break
            j += 2
    if judge == True:
        cnt += 1
print(cnt)


Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+9;
int main()
{
	char s[maxn];
	scanf("%s",s+1);
	int len=strlen(s+1);
	ll f[maxn]={1};
	ll ans=0,k=1,base=0;
	for(int i=len;i>=1;i--)
	{
		int num=s[i]-'0';
		base=(base+num*k)%2019;
		ans+=f[base];
		k=(k*10)%2019;
		f[base]++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 5524
from collections import defaultdict
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

def syori(instr):
    moji = defaultdict(list)
    for i, s in enumerate(instr):
        moji[s].append(i)
    #lis = list(moji.values())

    lisstrs = []
    for v in moji.values():
        lisstr = "@".join([str(i) for i in(v)])
        lisstrs.append(lisstr)
    st = set(lisstrs)
    #print(st)
    return (st)



stra = input()
strb = input()

aset  = syori(stra)
bset = syori(strb)

if aset == bset:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 21064
import sys
readline = sys.stdin.readline

N = int(readline().strip())
C = readline().strip()
c = []
for i in range(len(C)):
  c.append(C[i])

ans = 0
s = 0
e = len(c)-1
d = True
while s < e:
  si = s
  ei = e
  for i in range(si, ei):
    if c[i] == "R":
      s += 1
    else:
      break
  for j in range(ei, si, -1):
    if c[j] == "W":
      e -= 1
    else:
      break
  if s < e:
    c[s] = "R"
    c[e] = "W"
    ans += 1
print(ans)

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int a[511];

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	int x, y; char c;
	map <int, int, greater <int>> mp;
	while(cin >> x >> c >> y) {
		if(!x && !y) break;
		a[x] = y;
		mp[y] = 0;
	}
	int cnt = 0;
	for(auto &p : mp)
		p.second = ++ cnt;
	for(int q; cin >> q; )
		cout << mp[a[q]] << '\n';

	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
#define s second
#define nax (int)1e5+2
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n" 
#define INF (int)1e5
using namespace std;


int main(){
	int x,a;
	cin>>x>>a;
	if(x < a)
		cout<<0;
	else
		cout<<10;
	return 0;
}


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

	
typedef int Weight;
struct Edge {  //src:辺の始点,dst:辺の終点,weight:辺の重さ
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : //辺は重さが重いものを"小さい"と定義する
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
//引数 g:隣接リスト,r:最小全域木の始点
//戻値 total:最小全域木の重み,T:最小全域木の辺集合
pair<Weight, Edges> prim(const Graph &g, int r = 0) {
  int n = g.size();
  Edges T;
  Weight total = 0;
  vector<bool> visited(n);
  priority_queue<Edge> Q;
  Q.push( Edge(-1, r, 0) );    //始め、-1とrを結ぶ辺があると考える
  while (!Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (visited[e.dst]) continue;
    T.push_back(e);
    total += e.weight;
    visited[e.dst] = true;
    for(auto f=g[e.dst].begin();f!=g[e.dst].end();++f) if(!visited[f->dst]) Q.push(*f);
  }
  return pair<Weight, Edges>(total, T);
}

int main()
{ 
    while(true){
        int i, V, E;
        int s, t;
        Weight w;
        if(!(cin >> V >> E))break;
        Graph g(V);    //頂点数vの空隣接リストgを生成
        for(i=0; i<E; i++){
            cin >> s >> t >> w;
            g[s].push_back(Edge(s,t,w));    //隣接リストgにsからtに向かう重さwの辺を追加
            g[t].push_back(Edge(t,s,w));
        }
        // ...
        pair<Weight,Edges>ans=prim(g);    //ansにgに対しての最小全域木の重さと辺集合のpairが入る
        cout << ans.first << endl;
    }
  
    return 0;
}



Measured memory_bytes: 8704
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    int H,A;
    cin >> H >> A;
    if(H%A==0) cout << H/A << endl;
    else cout << H/A+1 << endl;
}

Measured memory_bytes: 256
ratings = [(400 * i - 1) for i in range(1, 9)]
present = [0 for i in range(1, 9)]
n = int(input())
a = list(map(int, input().split()))
hi = 0
for x in a:
	itr = 0
	while itr < len(ratings) and x > ratings[itr]:
		itr = itr + 1
	if (itr == len(ratings)):
		hi = hi + 1
	else:
		present[itr] = 1
sm = sum(present)
mn, mx = sm, sm + hi
if sm == 0:
	mn = 1
print("%d %d" % (mn, mx))


Measured memory_bytes: 3064
#include <stdio.h>

long N(long x){
  return (x+1)*(x+2)*(x+3)/6;
}

int main(){
  long n,m;
  while(~scanf("%ld",&n)){
    if (n > 2000)
      n = 4000 - n;
    if (n < 1001)
      printf("%d\n",N(n));
    else {
      m = n - 1000;
      printf("%ld\n", N(n)-(N(2*m)-m-1)/2);
    }
  }
  return 0;
}

Measured memory_bytes: 596
from itertools import product
N,K = list(map(int,input().split()))
D = list(map(int,input().split()))

D_ = [_ for _ in range(10) if _ not in D]
D_.sort()

break_flag=False
for s_ in D_:
    if break_flag:
        break
    elif s_ == 0:
        continue
    for p in product(D_,repeat=len(str(N))-1):
        ans=int(str(s_)+''.join(map(str,p)))
        if N <= ans:
            print(ans)
            break_flag=True
            break
            
if break_flag==False:
    for s_ in D_:
        if break_flag:
            break
        elif s_ == 0:
            continue
        for p in product(D_,repeat=len(str(N))):
            ans=int(str(s_)+''.join(map(str,p)))
            if N <= ans:
                print(ans)
                break_flag=True
                break

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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

int main(){

	int n = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		a[i] = nxt() - 1;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > i && a[a[i]] == i) {
			ans++;
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.io.*;
import java.lang.*;
class Main{
    public static void main(String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long x = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        long d = Long.parseLong(st.nextToken());

        long mov = Math.abs(x/d);

        if(mov >= k){
            if(x<0){
               System.out.println(Math.abs(x+k*d)); 
            }
            else{
                System.out.println(Math.abs(x-k*d));
            }
        }
        else if(mov < k){
            long num = k-mov;
            if(x<0){
                
                x = x+mov*d;
                if(num%2==1){
                    long dist  = Math.min(Math.abs(x-d),Math.abs(x+d));
                    System.out.println(dist);
                }
                else{
                    System.out.println(Math.abs(x));
                }

            }
            else{
                x = x-mov*d;
                //x = x+mov*d;
                if(num%2==1){
                    long dist  = Math.min(Math.abs(x-d),Math.abs(x+d));
                    System.out.println(dist);
                }
                else{
                    System.out.println(Math.abs(x));
                }
            }
        }
    }
}

Measured memory_bytes: 32620
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int n, v[21], c[21], ans = 0, g;

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

	cin >> n;
	for(int i = 1; i<=n; i++)
		cin >> v[i];

	for(int i = 1; i<=n; i++){
		cin >> c[i];
		g = v[i] - c[i];
		if(g > 0) ans += g;
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H")
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false)
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;

int math[100500]={0};

int Scan() {
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
///coding...................................

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

int main() {
    IOS;
    int t,m[2]={0},ans=0;
    cin>>t;
    for(int i=0;i<t;i++)
        cin>>math[i];
    sort(math,math+t,cmp);
    for(int i=0;i<t,ans<2;i++){
        if(math[i]==math[i+1])
        {m[ans++]=math[i];i++;}
    }
    if(m[0]&&m[1])
        cout<<LL(m[0])*LL(m[1])<<endl;
    else
        cout<<"0"<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(){
    string s, t, u; int a, b;
    cin >> s >> t >> a >> b >> u;
    if(u==s){a--;}
    else{b--;}
    cout << a << endl;
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long long A, T;
  cin >> T >> A;
  for (int i = 1; i < N; i ++) {
    long long t, a;
    cin >> t >> a;
    long long al = (T - 1) / t + 1;
    long long bt = (A - 1) / a + 1;
    long long k = max(al, bt);
    T = t * k;
    A = a * k;
  }
  cout << A + T << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5))
		System.out.println("Yes");
		else
		System.out.println("No");
		
	}
}

Measured memory_bytes: 35448
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=1;
  char s[LIMIT1][11];
  
  scanf("%lld",&n);
  rep(i,n) scanf("%s",s[i]);
  
  qsort(s,n,sizeof(s[0]),upchar);
  result=1;
  rep(i,n-1){
    if(strcmp(s[i],s[i+1])!=0) result++;
  }
  printf("%lld",result);
  return 0;
}



Measured memory_bytes: 5740
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    vi a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    int ans=0;
    rep(i,n)if((i+1)%m)ans+=a[n-i-1];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


int a,b, k;

int main(){
	cin >> a >> b >> k;
	int cnt = 0;
	for(int i = a; ; i--){
		if(a % i == 0 && b % i == 0) cnt++;
		if(cnt == k){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

bool vis[101010];
VI edges[101010];
ll ans[101010];
int cnt = 0;
map<PII,int> mp;
void dfs(int current, int x){
  vis[current] = true;
  int col = 1;
  for(int next :edges[current]){
    if(vis[next]) continue;
    if(x == col) col++;
    dfs(next,col);
    int l = min(next,current);
    int r = max(next,current);
    int idx = mp[PII(l,r)];
    ans[idx] = col;
    cnt = max(cnt,col);
    col++;
  }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  
  int a[n], b[n];
  
  rep(i,n-1){
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
    edges[b[i]].push_back(a[i]);
    edges[a[i]].push_back(b[i]);
    if(a[i] > b[i]) swap(a[i],b[i]);
    mp[PII(a[i],b[i])] = i;
  }

  
  memset(vis,false,sizeof(vis));
  dfs(0,0);

  cout << cnt << endl;
  rep(i,n-1){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 16512
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const H1 = readInt();
      const M1 = readInt();
      const H2 = readInt();
      const M2 = readInt();
      const K = readInt();
      
      int ans;
      ans -= H1 * 60 + M1;
      ans += H2 * 60 + M2;
      ans -= K;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}


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

#define ull unsigned long long
#define ll long long

int main(){
    ll n , k;
    cin >> n >> k;

    if(n < k){
        cout << min(n, k-n);
        return 0;
    }
    else{
        if(n%k == 0){
            cout << 0;
            return 0;
        }
        else{
            cout << min(n%k, abs(n%k - k));
            return 0;
        }
    }

    return 0;
}

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

//map<string,int> m;
set<string>m;
string s;
int main(){
	//cin.tie(0);
    //ios::sync_with_stdio(false);
    int n,k,a,b,c,d;
    scanf("%d",&n);
	for(int i=1;i<=n;i++){
		cin>>s;
		m.insert(s);
	} 
	int ans=0;
    for(set<string>::iterator it=m.begin();it!=m.end();it++){
    	ans++;
    }
    
    printf("%d",ans);
    return 0;
}




Measured memory_bytes: 19332
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
ll K;

int C[25];
int T[50005];

int main()
{
	int m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&C[i]);

	for(int i=0;i<=n;i++)T[i]=99999999;
	T[0] = 0;

	for(int i=1;i<=m;i++){
		for(int j=C[i];j<=n;j++){
			T[j] = min(T[j],T[j-C[i]]+1);
		}
	}

	printf("%d\n",T[n]);
	return 0;
}



Measured memory_bytes: 2896
#include<bits/stdc++.h>
using namespace std;
int h,w,n,num[100010];
int grid[112][112];

int main()
{
	int i,j;
	
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<112;i++)
	{
		for(j=0;j<112;j++)
		grid[i][j] = -1;
	}
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		grid[i][j] = 0;
	}
	
	for(i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
	}
	
	int state = 0;	//0=right	1=down		2=left		3=up
	int r=1,c=1,area=h*w,idx=1;
	for(i=1;i<=area;i++)
	{
	//	printf("pos [%d][%d]\n",r,c);
		grid[r][c] = idx;
		num[idx]--;
		if(num[idx]==0) idx++;
		if(state==0)
		{
			if(grid[r][c+1]==0)
			{
				c++;
			}
			else
			{
				state = 1;
				r++;
			}
		}
		else if(state==1)
		{
			if(grid[r+1][c]==0)
			{
				r++;
			}
			else
			{
				state = 2;
				c--;
			}
		}
		else if(state==2)
		{
			if(grid[r][c-1]==0)
			{
				c--;
			}
			else
			{
				state = 3;
				r--;
			}
		}
		else if(state==3)
		{
			if(grid[r-1][c]==0)
			{
				r--;
			}
			else
			{
				state = 0;
				c++;
			}
		}
	}
	
	
	
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
		{
			printf("%d ",grid[i][j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3860
N=int(input())
s=list(map(int,input().split(" ")))
co=0
i=0
while i<=N-3:
    if s[i]<s[i+1]<s[i+2] or s[i]>s[i+1]>s[i+2]:
        co+=1
    i+=1
print(co)

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


using LLint = long long int;


LLint gcd(LLint a, LLint b){
	return (b > 0) ? gcd(b, a%b) : a;
}


LLint lcm(LLint a, LLint b){
	return a / gcd(a, b) * b;
}


int main(){
	LLint a1, m1, a2, m2, a3, m3;
	
	while (cin >> a1 >> m1 >> a2 >> m2 >> a3 >> m3, a1||m1||a2||m2||a3||m3){
		LLint x = 1, y = 1, z = 1, a = 1, b = 1, c = 1;

		x = (x*a1) % m1;
		y = (y*a2) % m2;
		z = (z*a3) % m3;

		for (; x != 1; a++){ x = (x*a1) % m1; }
		for (; y != 1; b++){ y = (y*a2) % m2; }
		for (; z != 1; c++){ z = (z*a3) % m3; }

		LLint ans = lcm(lcm(a, b), c);
		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i < N;i++){
  	cin >> a.at(i);
  }
  //ここまででaiの入力
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end()); //aを大きい順に並べた
  int x = 0 ; //差の値xを設定
  
  for(int j = 0;j < N;j++){
  	if( j%2 == 0 ){
    	x += a.at(j);
    }
    if( j%2 == 1 ){
    	x -= a.at(j);
    }
  }
  cout << x << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void print(int x,int y)
{
	printf("%d %d\n",x,y);
}
int n;
int main()
{
	scanf("%d",&n);
	int m=1;
	while(m<n)m<<=1;
	if(n<3||m==n){printf("No\n");return 0;}
	printf("Yes\n");
	print(n+1,n+2);
	print(n+2,n+3);
	print(n+3,1);
	print(1,2);
	print(2,3);
	for(int i=4;i<n;i+=2)
	{
		print(1,i);
		print(i,n+i+1);
		print(1,i+1);
		print(i+1,i+n);
	}
	if(n%2==0)
	{
		for(int i=2;i<n;i++)
		if((n^i^1)<n)
		{
			print(n^i^1,n);
			print(i,2*n);
			break;
		}
	}
}

Measured memory_bytes: 2304
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
using namespace std;

int main() {
  string A;
  cin >> A;

  stack<int> s;
  stack<pair<int, int>> pairs;

  for(int i = 0; i < A.size(); i++) {
    if(A[i] == '\\') {
      s.push(i);
    } else if(A[i] == '/' && !s.empty()) {
      pairs.push(make_pair(s.top(), i));
      s.pop();
    }
  }

  if(pairs.size() == 0) {
    cout << 0 << endl << 0 << endl;
    return 0;
  }

  int sub = 0, leftest = pairs.top().first;
  vector<int> subs;

  for(auto t = pairs.top(); !pairs.empty(); pairs.pop()) {
    t = pairs.top();

    auto left = t.first, right = t.second;

    if(leftest <= left) {
      sub += right - left;
    } else {
      subs.push_back(sub);
      sub = right - left;
      leftest = left;
    }
  }
  if(sub) {
    subs.push_back(sub);
  }

  cout << accumulate(subs.begin(), subs.end(), 0) << endl;

  cout << subs.size() << " ";

  reverse(subs.begin(), subs.end());

  for(int i = 0; i < subs.size(); i++) {
    cout << subs[i] << (i + 1 == subs.size() ? '\n' : ' ');
  }
}

Measured memory_bytes: 3288
n = gets.to_i
tc, xc, yc = [0, 0, 0]

ans = "Yes"

n.times do |i|
  tn, xn, yn = gets.split.map(&:to_i)

  t = tn - tc
  x = (xn - xc).abs
  y = (yn - yc).abs

  if t < x + y || (t - (x + y)).odd?
    ans = "No"
    break
  end

  tc, xc, yc = tn, xn, yn
end

puts ans


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h1, m1, h2, m2, K;
    cin >> h1 >> m1 >> h2 >> m2 >> K;
    cout << (h2-h1)*60 + (m2-m1) - K << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int a,b,w;
  scanf("%d%d%d",&w,&a,&b);
  printf("%d",a>b?(a-b-w>0?a-b-w:0):(b-a-w>0?b-a-w:0));
}


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

struct hoge{
	double a[2],b[2],c[2];
};

void coll(double a,double b,double c,double a2,double b2,double c2){
	double x, y;
	x = (c * b2 - b * c2) / (a * b2 - b * a2);
	y = (c2 * a - c * a2) / (a * b2 - a2 * b);
	if(x == 0){
		x = 0.000;
	}
	if(y == 0){
		y = 0.000;
	}

	printf("%4.3f %4.3f\n", x, y);
}

int main()
{
	hoge date;

	while(cin >> date.a[0] >> date.b[0] >> date.c[0] >> 
		date.a[1] >> date.b[1] >> date.c[1])
	{
		coll(date.a[0], date.b[0], date.c[0], date.a[1], date.b[1], date.c[1]);
	}
	return 0;
}

Measured memory_bytes: 0
object Main extends App {
  val lines = scala.io.Source.stdin.getLines().toList

  // Q2
  import scala.util.Try
  lines.foreach { line =>
    val result = line.split("\\s+") match {
      case Array(a, "+", b) => Try(a.toInt + b.toInt).toOption
      case Array(a, "-", b) => Try(a.toInt - b.toInt).toOption
      case _ => None
    }
    result.foreach(println)
  }
}

Measured memory_bytes: 21828
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhilash Mandaliya
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader( inputStream );
        PrintWriter out = new PrintWriter( outputStream );
        TaskB solver = new TaskB();
        solver.solve( 1, in, out );
        out.close();
    }

    static class TaskB {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            String str = in.readString();
            out.println( ( str.charAt( 0 ) ) + "" + ( ( str.length() - 2 ) ) + "" + ( str.charAt( str.length() - 1 ) ) );
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader (InputStream st) {
            this.stream = st;
        }

        public int read () {
            if ( snumChars == - 1 )
                throw new InputMismatchException();
            if ( curChar >= snumChars ) {
                curChar = 0;
                try {
                    snumChars = stream.read( buf );
                } catch ( IOException e ) {
                    throw new InputMismatchException();
                }
                if ( snumChars <= 0 )
                    return - 1;
            }
            return buf[curChar++];
        }

        public String readString () {
            int c = read();
            while ( isSpaceChar( c ) ) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint( c );
                c = read();
            } while ( ! isSpaceChar( c ) );
            return res.toString();
        }

        public boolean isSpaceChar (int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == - 1;
        }

    }
}



Measured memory_bytes: 20692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll a[2];
    f(i,0,2)cin>>a[i];
    sort(a,a+2);
    if(a[0]==1 && a[1]==2)cout<<3;
    else if(a[0]==1 && a[1]==3)cout<<2;
    else cout<<1;
    return 0;
}   

Measured memory_bytes: 256