akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int A = V[0], P = V[1];
            Console.WriteLine((A * 3 + P) / 2);
        }
    }
}


Measured memory_bytes: 13140
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N, X;
int L[MAX_N];

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

  cin >> N >> X;
  rep(i, N) cin >> L[i];

  int ans = 1;
  int sum = 0;
  rep(i, N) {
    sum += L[i];
    if (sum <= X) {
      ++ans;
    } else {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
str1 = input();
str2 = str1.split(" ")
n = int(str2[0])
m = int(str2[1])
xcap = int(str2[2])
ycap = int(str2[3])

strx = input()
stry = input()
strx2 = strx.split(" ")
stry2 = stry.split(" ")
for i in range(n):
    strx2[i] = int(strx2[i])

for i in range(m):
    stry2[i] = int(stry2[i])

if max(max(strx2),xcap) < min(min(stry2), ycap):
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define  Rep(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) Rep(i,0,(n))
#define  all(a) begin(a),end(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
 
int main()
{
    char c;
    cin>>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel\n";
    else cout<<"consonant\n";
        
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <algorithm>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;


// sortの仕方
// 	■ string s の場合
// 	昇順: sort(s.begin(), s.end())
// 	降順: sort(s.rbegin(), s.rend())
//
// 	■ ll a[N] の場合
// 	昇順: sort(a, a+N)
// 	降順: 不明


// int alph2int(char character) {
//     int x = character - 'a';
//     return x;
// }


// ll my_gcd(ll a, ll b){
// 	return (b==0) ? a : my_gcd(b, a%b);
// }


//  ll my_lcm(ll a, ll b){
//  	return a*b / my_gcd(a,b);
//  }


// ll factorial(ll a){
// 	ll ans = 1;
// 	for(ll i=a; i>0; i--){
// 		ans *= i;
// 	}
// 	return ans;
// }

int main(int argc, char *argv[]){
    int N;
    cin >> N;
    string W[N];
    for(int i=0; i<N; i++){
        cin >> W[i];
    }

    for(int i=1; i<N; i++){
        if(W[i-1][W[i-1].length()-1] != W[i][0]){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i == j){
                continue;
            }
            if(W[i] == W[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 768
n,m = map(int,input().split())
ans = [i+1 for i in range(n+1)]
l = []
r = []
for i in range(m):
    l1,r1 = map(int,input().split())
    l.append(l1)
    r.append(r1)
    
left = max(l)
right = min(r)
print(len(ans[left:right+1]))

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

int solve(int a[],int b[],int c[],int n){
   int dp[n][3];
   dp[0][0]=a[0];
   dp[0][1]=b[0];
   dp[0][2]=c[0];
   for(int i=1;i<n;i++){
      dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
   }
   return max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
int main(){
   int n;cin>>n;
   int a[n],b[n],c[n];
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i]>>c[i];
   }
   cout<<solve(a,b,c,n)<<endl;
}

Measured memory_bytes: 5932
class Graph():
    def __init__(self):
        self.adjacency_dict={}
    def add_vertex(self, v):
        self.adjacency_dict[v] = []
    def add_edge(self, v1, v2):
        """ ノード同士をつなぐ。"""
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)
    def print_graph(self):
        print(self.adjacency_dict)

graph=Graph()
n,m=map(int,input().split())
h=list(map(int,input().split()))
good=[1]*n
for i in range(n):
    graph.add_vertex(i+1)
for i in range(m):
    a,b=map(int,input().split())
    graph.add_edge(a,b)
for i in range(n):
    if good[i]==1:
        for j in graph.adjacency_dict[i+1]:
            if h[i]>h[j-1]:
                good[j-1]=0
            elif h[i]<h[j-1]:
                good[i]=0
            else:
                good[i]=0
                good[j-1]=0
ans=0
for i in range(n):
    if good[i]==1:
        ans+=1
print(ans)

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (long long i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second

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

int n,m;
vector<int> v[501];
set<int> st,ss;

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

    while(true) {
	cin>>n>>m;
	if(n==0&m==0) break;
	REP(i,501) v[i].clear();
	st.clear();ss.clear();
	REP(i,m) {
		int a,b;
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	st.insert(1);
	REP(i,v[1].size()) {
		st.insert(v[1][i]);
	}
	for(auto x:st) {
		REP(i,v[x].size()) {
			ss.insert(v[x][i]);
		}
	}
	for(auto x:st) {
		ss.insert(x);
	}
	cout<<ss.size()-1<<endl;
    }

	return 0;
}



Measured memory_bytes: 3328
let N = readLine()!.characters.split(" ").map{Int(String($0))!}[1]
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}+[N]).sort()
let d = (1..<x.count).map{x[$0]-x[$0-1]}
var ans = 0
for i in d {
    var (a, b) = (i, ans)
    while b > 0 {
        (a, b) = (b, a%b)
    }
    ans = a
}
print(ans)

Measured memory_bytes: 7228
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int s[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  REP(i,N) cin >> s[i];
  int ans = 0;
  for (int c = 1; c < N-1; c++) {
    int sum = 0;
    set<int> st;
    st.insert(0);
    st.insert(N-1);
    for (int k = 1; k*c < N-1; k++) {
      if (st.count((N-1)-k*c)) break;
      else st.insert((N-1)-k*c);
      if (st.count(k*c)) break;
      else st.insert(k*c);
      if ((N-1)-k*c-c <= 0) break;
      sum += s[(N-1)-k*c]+s[k*c];
      CHMAX(ans,sum);
    }
  }
  cout << ans << endl;

  return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	string s; cin >> s;
	ll K; cin >> K;
	ll N = (ll)s.size();
	vector<ll> diff(N);

	REP(i, N)
	{
		if (s[i] == 'a') diff[i] = 0;
		else
			diff[i] = 26 - abs('a' - s[i]);
		// std::cout << diff[i] << std::endl;
	}

	string res;
	REP(i, N)
	{
		if (diff[i] <= K)
		{
			res += 'a';
			K -= diff[i];
		}
		else
		{
			res += s[i];
		}
	}

	if (K > 0)
	{
		res.back() += (K % 26);
	}
	std::cout << res << std::endl;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int MAX = 1 << 18;
const int K = 4;

int dp[MAX][K];

void upd(int& x, int val)
{
	x = max(x, val);
}

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int n = SZ(s);
	FOR(i, 0, MAX)
		FOR(j, 0, K)
			dp[i][j] = -INF;
	FOR(i, 0, K)
		dp[i][i] = 1;
	FOR(i, 0, n)
		FOR(j, 0, K)
		{
			if(dp[i][j] >= 0 && i + j + 1 < n)
			{
				bool ok = false;
				FOR(k, i - j, i + 1)
					ok |= s[k] != s[k + j + 1];
				if(ok)
					upd(dp[i + j + 1][j], dp[i][j] + 1);
			}
			FOR(k, 0, K)
				if(k != j && i + k + 1 < n)
					upd(dp[i + k + 1][k], dp[i][j] + 1);
		}
	int ans = 0;
	FOR(i, 0, K)
		upd(ans, dp[n - 1][i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 4612
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

Satisfaction=0
for i in range(N):
    Satisfaction+=B[i]
    if i<=N-2 and A[i]+1==A[i+1]:
        Satisfaction+=C[A[i]-1]

print(Satisfaction)

Measured memory_bytes: 3064
use std::io;
use std::str::FromStr;

fn main(){
    let mut buf = String::new();
    let _ = io::stdin().read_line(&mut buf);

    let sec : i64 = i64::from_str(buf.trim()).unwrap();
    let h = sec/60/60;
    let m = sec/60 - h*60;
    let s = sec%60;

    println!("{}:{}:{}", h, m, s);
}



Measured memory_bytes: 5028
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

k = INT()
l = len(str(k))
if k % 2 == 0:
    print(-1)
    exit()
dp = [-1 for _ in range(10 ** 6 + 100)]
for i in range(10 ** 6 + 100):
    if l > i + 1:
        continue
    elif l == i + 1:
        num = 0
        for _ in range(i):
            num *= 10
            num += 7
        if k > num:
            continue
    if dp[i - 1] == -1:
        num = 0
        for _ in range(i):
            num *= 10
            num += 7
        dp[i] = num % k
    else:
        dp[i] = (dp[i - 1] * 10 + 7) % k
    if dp[i] == 0:
        print(i)
        exit()
print(-1)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int r,g,b;
  cin >> r >> g >> b;
  int res = r*100 + g*10+b;
  if(res % 4 == 0)cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;
}


Measured memory_bytes: 256
strtick = input()
inttick = [int(i) for i in strtick]

for i in range(2**3):
  ans = inttick[0]
  op = ["-"]*3 
  for j in range(3):
    if (i >> j) & 1:
      ans += inttick[j+1]
      op[j] = "+"
    else:
      ans -= inttick[j+1]
#  print(i, ans, op)
  if ans == 7:
    print(inttick[0], op[0], inttick[1], op[1], inttick[2], op[2], inttick[3], "=7", sep="")
    exit()

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAX_N = 100005;

int n;
ll a[MAX_N];
ll b[MAX_N];
ll c[MAX_N];
bool changed[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	ll aSum = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		aSum += a[i];
	}
	for (int i = 0; i < n; i++)
		cin >> b[i];

	ll cSum = 0;
	set<pair<ll, int>, greater<pair<ll, int>>> s;
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= b[i])
		{
			cSum += a[i];
			c[i] = a[i];
			s.emplace(a[i] - b[i], i);
		}
		else
		{
			cSum += b[i];
			c[i] = b[i];
			changed[i] = true;
		}
	}

	while (cSum > aSum && !s.empty())
	{
		ll diff = s.begin()->first;
		int pos = s.begin()->second;
		s.erase(s.begin());
		if (cSum - diff < aSum)
			diff = cSum - aSum;
		if (diff == 0)
			continue;
		c[pos] -= diff;
		changed[pos] = true;
		cSum -= diff;
	}

	if (cSum != aSum)
		cout << "-1" << endl;
	else
	{
		int cnt = 0;
		for (int i = 0; i < n; i++)
			if (changed[i])
				cnt++;
		cout << cnt << endl;
	}
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int n){
    for(int i=0; i<n-1; i++){
        for(int j=n-1; j>=i; j--){
            if(A[j].value < A[j-1].value){
                //swap(A[j].value, A[j-1].value);
                Card t = A[j];
                A[j]=A[j-1];
                A[j-1] = t;
            }
        }
    }
}

void selection(struct Card A[], int n){
    for(int i=0; i<n; i++){
        int minj = i;
        for(int j=i; j<n; j++)
            if(A[j].value < A[minj].value) minj = j;
        //swap(A[i].value, A[minj].value);
        Card t = A[i]; A[i]=A[minj]; A[minj]=t;
    }
}

void print(struct Card A[], int n){
    for(int i=0; i<n; i++){
        if(i) cout << ' ';
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int n){
    for(int i=0; i<n; i++){
        if(C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int n;
    char ch;
    
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for(int i=0; i<n; i++) C2[i] = C1[i];
    
    bubble(C1, n);
    selection (C2, n);
    
    print(C1, n);
    cout << "Stable" << endl;
    print(C2, n);
    if(isStable(C1, C2, n)){
        cout << "Stable" << endl;
    }else{
        cout << "Not stable" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3100
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define INF 1<<29
#define R 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion 

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

	int n;
	st s;
	cin >> n >> s;
	map<char, int>m;
	f(i, 0, n) {
		m[s[i]]++;
	}
	int ans = 1;
	for (char c = 'a'; c <= 'z'; c++) {
		if (m[c] != 0) {
			ans *= (m[c] + 1);
			ans %= R;
		}
	}
	cout << ans - 1;
	return 0;
}

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

using namespace std;

using ll = long long;

int main()
{
    string s;
    cin >> s;
    
    int a[4];
    for(int i = 0; i < 4; i ++) {
        a[i] = s[i] - '0';
    }
    int p = a[0] + a[1] + a[2] + a[3];
    int r = a[0] - a[1] - a[2] - a[3];
    int u = a[0] + a[1] + a[2] - a[3];
    int v = a[0] + a[1] - a[2] + a[3];
    int w = a[0] - a[1] + a[2] + a[3];
    int x = a[0] + a[1] - a[2] - a[3];
    int y = a[0] - a[1] + a[2] - a[3];
    int z = a[0] - a[1] - a[2] + a[3];
    
    string s1 = "";
    if(p == 7) {
        s1 += '+';
        s1 += '+';
        s1 += '+';
    }
    else if(r == 7) {
        s1 += '-';
        s1 += '-';
        s1 += '-';
    }
    else if(u == 7) {
        s1 += '+';
        s1 += '+';
        s1 += '-';
    }
    else if(v == 7) {
        s1 += '+';
        s1 += '-';
        s1 += '+';
    }
    else if(w == 7) {
        s1 += '-';
        s1 += '+';
        s1 += '+';
    }
    else if(x == 7) {
        s1 += '+';
        s1 += '-';
        s1 += '-';
    }
    else if(y == 7) {
        s1 += '-';
        s1 += '+';
        s1 += '-';
    }
    else if(z == 7) {
        s1 += '-';
        s1 += '-';
        s1 += '+';
    }
    for(int i = 0; i < 4; i ++) {
        if(i < 3) {
            cout << a[i] << s1[i];
        }
        else {
            cout << a[i] << "=7" ;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())

F = [[1 for _ in range(W)] for _ in range(H)]

for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(H):
            for j in range(x):
                F[i][j] = 0
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                F[i][j] = 0
    elif a == 3:
        for i in range(y):
            for j in range(W):
                F[i][j] = 0
    elif a == 4:
        for i in range(y, H):
            for j in range(W):
                F[i][j] = 0

print(sum(sum(f) for f in F))


Measured memory_bytes: 3064
#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
    int n,a[100],i,j,flag,s=0;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    for(j=0;j<n;j++)
    {
        flag=0;
        for(i=0;i<j;i++)
        {
            if(a[i]>a[j])
            {flag=1;break;}
        }
        if(flag==0)
            s++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	string n;  cin >> n;
	long sum = 0;
	for(auto ni : n){
		sum += (long)(ni - '0');
	}
	string ans = "Yes";
	if(sum % 9)  ans = "No";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3732
N, M = map(int, input().split())
li_l = []
li_r = []
for i in range(M):
    L, R = map(int, input().split())
    li_l.append(L)
    li_r.append(R)
largest_L = max(li_l)
smallest_R = min(li_r)
cards = smallest_R - largest_L + 1
if cards > 0 :
    print(cards)
else:
    print(0)

Measured memory_bytes: 11016
N,M = map(int,input().split())
L = [[0,0] for _ in range(N)]

for _ in range(M):
  x = input().split()
  p = int(x[0])
  S = x[1]
  if S == "AC":
    L[p-1][0] = 1
  elif L[p-1][0] == 0:
    L[p-1][1] +=1

ac = 0
wa = 0
for i in range(N):
    x = L[i][0]
    y = L[i][1]
    if x == 1:
        ac +=1
        wa +=y
        
print(ac,wa)

Measured memory_bytes: 13172
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;



int main(){
  ll n;
  cin>>n;
  vector<pair<ll,ll>> ab(n);

  rep(i,n){
    cin>>ab[i].second>>ab[i].first;// 必要時間，締め切り
  }
  sort(ab.begin(),ab.end());//締め切り順に並べる

  ll time=0;

  rep(i,n){
    time+=ab[i].second;
    //cout<<time<<" "<<ab[i].first<<endl;
    if(time>ab[i].first){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;



}


Measured memory_bytes: 6420
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int dp[19][2][2];long long d;
long long mi[19];
int Get(int i)
{
	return (int)((d/mi[i-1])%10);
}
int DP(int i,int len,int ty1,int ty2)//前i要(进1/不进位)给前i-1，后i已经被后i-1(进1/不进位) 
{
	if(dp[i][ty1][ty2]!=-1)return dp[i][ty1][ty2];
	if(i==len/2+1)
	{
		if(len%2==0)
		{
			if(ty1==ty2)return 1;
			else return 0;
		}
		else
		{
			//第i位的数+d的第i位+ty2=10*ty1+第i位的数
			if(Get(i)+ty2==10*ty1)return len==1?9:10;
			else return 0;
		}
	}
	int res=0;int j=len-i+1;
	for(int x=0;x<=9;x++)
	for(int y=0;y<=9;y++)//从前往后数第i位填x，len-i+1位填y 
	{
		if(i==1&&x==0)continue;
		if((y+ty2+Get(i)==x||y+ty2+Get(i)==x+10)&&(((x+Get(j))%10==y&&(x+Get(j))/10==ty1)||(((x+Get(j)+1)%10==y&&(x+Get(j)+1)/10==ty1))))
		{
			int _ty2=(y+ty2+Get(i))/10,_ty1;
			if((x+Get(j))%10==y&&(x+Get(j))/10==ty1)_ty1=0;else _ty1=1;
//			cout<<len<<" "<<i<<" "<<x<<" "<<y<<" "<<_ty1<<" "<<_ty2<<endl;
			res+=DP(i+1,len,_ty1,_ty2);
		}
	}
	return dp[i][ty1][ty2]=res;
}
int main()
{
	mi[0]=1;
	for(int i=1;i<18;i++)mi[i]=mi[i-1]*10;int len=0;
	scanf("%lld",&d);int ans=0;for(int t=d;t;t/=10)len++;//cout<<len<<endl;
	for(int i=len;i<=18;i++)memset(dp,-1,sizeof(dp)),ans+=DP(1,i,0,0);
	printf("%d",ans);
}
//dp[i][0/1][0/1]表示前i个数，前i被前i-1给(进1/不进位)，后i(进1/不进位)给后i+1  的方案数 

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

int main(){
  int n;
  int x[8], y[8];
  double sum=0, av;
  int count = 0;
  
  cin >> n;
  
  for(int i=0;i<n;i++){
    cin >> x[i] >> y[i];
  }

  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum += sqrt(pow((double)x[i]-x[j], 2)+pow(y[i]-y[j], 2));
      //cout << sqrt(pow(x[i]-x[j], 2)+pow(y[i]-y[j], 2)) << endl;
      count ++;
  }}
  av = sum/count*(n-1);
  //cout << sum << "sum" << endl;
  //cout << count << "count" << endl;
  //cout << av;
  printf("%f", av);
  return 0;
}

Measured memory_bytes: 256
s=input()
t=input()

min=len(t)
m=len(s)-len(t)
if m == 0:
    m = 1
for n in range(m):
    x=0
    for i in range(len(t)):
        if t[i] != s[n+i]:
            x=x+1

    if x<min:
        min = x
print(min)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int a, b, c;
    
    cin >> a >> b >> c;
    
    if(a==b&&b==c){
        
        cout << "No" << endl;
        return 0;
        
    } else if(a!=b&&b!=c&&c!=a){
        
        cout << "No" << endl;
        return 0;
        
    }
    
    cout << "Yes" << endl;
    
    return 0;
    
}

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

using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;

  cout << static_cast<char>(a.front()-32) << static_cast<char>(b.front()-32) << static_cast<char>(c.front()-32) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <map>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);

ll solve(){
	int h,w,k,ans=0;
	cin>>h>>w>>k;
	string s[h];
	for(string &i:s) cin>>i;
	int tot=0;
	for(string &i:s) for(char c:i) if(c == '#') tot++;	
	const int R=(1<<h),C=(1<<w);
	for(int i=0;i<R;i++){
		for(int j=0;j<C;j++){
			int rm=0;
			for(int r=0;r<h;r++) if((1<<r) & i) for(int c=0;c<w;c++) rm+=(s[r][c] == '#');
			for(int c=0;c<w;c++) if((1<<c) & j) for(int r=0;r<h;r++) rm+=(s[r][c] == '#' && !((1<<r) & i));
			ans+=(tot-rm == k);
		}
	}
	return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 3600
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll f[100010];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね

/*
    f[0]=1;
    rep2(i,200005){
        f[i]=f[i-1]*i;
        f[i]%=mod;
    }
*/

ll a[100005];
vector<ll> b;
ll A[100005];

int main(){
    f[0]=1;
    rep2(i,100005){
        f[i]=f[i-1]*i;
        f[i]%=mod;
    }
    ll n,k;
    cin >> n>>k;
    rep(i,n){
        cin >> a[i];
        //a[i]%=mod;
        b.push_back(a[i]);
    }
    sort(b.begin(),b.end());
    rep(i,n){
        
        A[i]=b[i];
        //cerr<<A[i]<<' ';
    }
    ll ans=0;
    rep(i,n){
        ans+=A[n-1-i]*comb(n-1-i,k-1)%mod;
        ans%=mod;
        //cerr<<ans<<endl;
    }
    rep(i,n){
        
        ans+=mod-A[i]*comb(n-i-1,k-1)%mod;
        
        ans%=mod;
        //cerr<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3448
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {
        
        int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int A = a[0];
        int B = a[1];
        int K = a[2];
        var list1 = new List<int>();
        var list2 = new List<int>();
        for(int i = 1; i <= A; i++)
        {
            if(A % i == 0)
            {
                list1.Add(i);
            }
        }
        
        for(int i = 0; i < list1.Count; i++)
        {
            if(B % list1[i] == 0)
            {
                list2.Add(list1[i]);
            }
        }
        
        list2.Sort();
        Console.WriteLine(list2[list2.Count - K]);
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
typedef long long LL;
const int N = 500003, mod = 998244353;
int n, m, ans, tmp, fac[N], inv[N];
inline int kasumi(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) res = (LL) res * a % mod;
		a = (LL) a * a % mod;
		b >>= 1;
	}
	return res;
}
inline void init(){
	fac[0] = 1;
	for(Rint i = 1;i <= m;i ++) fac[i] = (LL) i * fac[i - 1] % mod;
	inv[m] = kasumi(fac[m], mod - 2);
	for(Rint i = m;i;i --) inv[i - 1] = (LL) i * inv[i] % mod;
}
inline int C(int n, int m){
	return (LL) fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main(){
	scanf("%d%d", &n, &m);
	if(n > m) swap(n, m);
	init();
	for(Rint i = 0;i <= n;i ++){
		tmp = (LL) C(n, i) * C(m, i) % mod * fac[i] % mod * kasumi(m + 1, n - i) % mod * kasumi(n + 1, m - i) % mod;
		if(i & 1) ans = (ans + mod - tmp) % mod;
		else ans = (ans + tmp) % mod;
	}
	printf("%d", ans);
}

Measured memory_bytes: 4096
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

llong ctoi(char c) {
    switch (c) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
};

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

    string K;
    llong D;
    cin >> K >> D;

    llong maxDigit = K.length();

    vvecllong dpAll(maxDigit + 1, vecllong(D, 0));  // dpAll[digit][mod] = すべて
    vvecllong dpSub(maxDigit + 1, vecllong(D, 0));  // dpSub[digit][mod] = K以下
    dpAll[0][0] = 1;
    dpSub[0][0] = 1;

    FORS(digit, 1, maxDigit + 1) {
        FOR(mod, D) {
            FOR(add, 10) {
                llong d = (mod - add) % D;
                if(d < 0) d += D;
                dpAll[digit][mod] = (dpAll[digit][mod] + dpAll[digit - 1][d]) % MOD;

                if(add < ctoi(K[maxDigit - digit])) {
                    dpSub[digit][mod] = (dpSub[digit][mod] + dpAll[digit - 1][d]) % MOD;
                } else if (add == ctoi(K[maxDigit - digit])) {
                    dpSub[digit][mod] = (dpSub[digit][mod] + dpSub[digit - 1][d]) % MOD;
                }
            }
        }
    }

    llong ans = (dpSub[maxDigit][0] - 1) % MOD;
    if(ans < 0) ans += MOD;
    cout << ans << endl;

    return 0;
}

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

int main() {
  int x,y;
  while(cin >> x >> y && x) {
    x%=y;
    unordered_map<int,int> m;
    int i;
    for(i=0; i<1000000; i++) {
      if(!x) break;
      if(m.count(x)) {
        cout << m[x] << " " << i-m[x] << endl;
        goto next;
      }
      m[x]=i;
      x*=10;
      x%=y;
    }
    cout << i << " " << 0 << endl;
    next:;
  }
  return 0;
}


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

int main() {
     int n , arr[4] = {0} ;

     string s , arr_st[4]= { "AC", "WA", "TLE", "RE"} ;

     cin >> n ;

     while(n--){

          cin >> s ;
          for(int i =0 ; i < 4 ; i++){

               if(s == arr_st[i])arr[i]++ ;
          }

     }
     for(int j =0 ; j < 4 ; j++){

          cout << arr_st[j] << " x " << arr[j] << endl ;
     }
}


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

int main() {
	UL E, Y; cin >> E >> Y;
	if (E == 0) {
		if (1868 <= Y && Y <= 1911) { cout << "M" << Y - 1867; }
		else if (Y <= 1925) { cout << "T" << Y - 1911; }
		else if (Y <= 1988) { cout << "S" << Y - 1925; }
		else if (Y <= 2016) { cout << "H" << Y - 1988; }
	}
	else if (E == 1)
		cout << Y + 1867;
	else if (E == 2)
		cout << Y + 1911;
	else if (E == 3)
		cout << Y + 1925;
	else if (E == 4)
		cout << Y + 1988;
	cout << endl;
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    vi a(3);
    cin >> a;
    sort(ALL(a));
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
        cout << "YES" << endl;
    } else
        cout << "NO" << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

//link: https://atcoder.jp/contests/arc103/tasks/arc103_a

vector <int> e;
vector <int> o;
map <int, int> mpe;
map <int, int> mpo;
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	bool can = true;
	int n; cin >> n;
	for(int i = 0; i < n; ++i) {
		int x; cin >> x;
		if (i % 2 == 0) o.pb(x);
		else e.pb(x);
	}
	// find the top 2 modes
	for(auto it:e) {
		++mpe[it];
	}
	vector <pii> MPE; // convert to vector for sorting
	for(auto it:mpe) {
		MPE.pb(it);
	}
	sort(all(MPE), [] (pii i, pii j) {
		return i.second > j.second;
	});
	int e1 = MPE[0].first;
	int e2 = MPE[1].first;
	cerr << e1 << ' ' << e2 << '\n';
	// repeat!!
	for(auto it:o) {
		++mpo[it];
	}
	vector <pii> MPO;
	for(auto it:mpo) {
		MPO.pb(it);
	}
	sort(all(MPO), [] (pii &i, pii &j) {
		return i.second > j.second;
	});
	int o1 = MPO[0].first;
	int o2 = MPO[1].first;
	cerr << o1 << ' ' << o2 << '\n';

	if (e1 != o1) {
		// assert(0);
		int count = 0;
		for(auto it:e) {
			if (it != e1) ++count;
		}
		for(auto it:o) {
			if (it != o1) ++count;
		}
		cout << count;
		time;
	}

	// find the number of changes required for first type
	int count = 0;
	for(auto it:e) {
		if (it != e1) ++count;
	}
	for(auto it:o) {
		if (it != o2) ++count;
	}
	// second type
	int sum = 0;
	for(auto it:e) {
		if (it != e2) ++sum;
	}
	for(auto it:o) {
		if (it != o1) ++sum;
	}
	cout << min(count, sum);
}

Measured memory_bytes: 12628
import scala.language.implicitConversions
object Main extends App {
  val n = io.StdIn.readInt()
  println(phi(n))

  def phi(n: Int): BigInt =
    if (isPrime(n)) n-1
    else {
      implicit def int2rational(x: Int) = Rational(x,1)
      val pfs = primeFactors(n)
      val x = pfs.foldLeft(n: Rational)((acc, e) => acc * (1 - Rational(1,e)))
      x.toInt
    }
  def primeFactors(n: Int): Seq[Int] = {
    if (n == 1) Seq()
    else if (isPrime(n)) Seq(n)
    else {
      var x = n
      val p = rho(n)
      if (isPrime(p)) {
        while(x % p == 0) x /= p
        p +: primeFactors(x)
      }
      else {
        val ps = primeFactors(p)
        ps foreach (p => while(x % p == 0) x /= p)
        ps ++ primeFactors(x)
      }
    }
  }
  def rho(n: Int): Int = {
    def f(x: Int, c: Int): Int = (x * x + c) % n
    def loop(x: Int, y: Int, d: Int, c: Int = 1): Int =
      if (d != 1) {
        if (d == n) loop(2,2,1,c+1)
        else d
      }
      else {
        val a = f(x, c)
        val b = f(f(y, c), c)
        loop(a, b, gcd(Math.abs(a-b), n), c)
      }
    if (n % 2 == 0) 2
    else loop(2,2,1)
  }
  def gcd(x: Int, y: Int): Int = {
    if (x < y) gcd(y, x)
    else {
      if (y > 0) {
        val r = x % y
        gcd(y, r)
      } else x
    }
  }
  def isPrime(n: Int): Boolean = Primes.miller_rabin_test(n)
  object Primes {
    private def mod_exp(x: BigInt, n: Int, m: Int): BigInt = {
      def loop(x: BigInt, n: Int, acc: BigInt): BigInt = {
        if (n == 0) acc
        else loop (
          (x * x) % m,
          n >> 1,
          if ((n & 1) == 1) (acc * x) % m else acc
        )
      }
      loop(x,n,1)
    }
    private def div_pow_2(d: Int, s: Int = 0): (Int, Int) ={
      if ((d % 2) != 0) (d,s)
      else div_pow_2(d/2, s+1)
    }

    private def miller_rabin(n: Int, a: Int): Boolean = {
      val (d,s): (Int, Int) = div_pow_2(n-1)
      val a_exp_d: BigInt = mod_exp(a,d,n)
      def double(x: BigInt): BigInt = mod_exp(x,2,n)
      def loop(e: BigInt, i: Int): Boolean = {
        if (i == 0) false
        else if (e == n-1) true
        else loop(double(e), i-1)
      }
      a_exp_d == 1 || loop(a_exp_d, s)
    }
    def miller_rabin_test(n: Int, k: Int = 20): Boolean = {
      def loop(i: Int): Boolean = {
        if (i == 0) true
        else {
          val a = scala.util.Random.nextInt(n-1)+1
          if (miller_rabin(n,a)) loop(i-1)
          else false
        }
      }
      if (n < 2) false
      else loop(k)
    }
  }
  case class Rational(numerator: BigInt, denominator: BigInt) {
    private def gcd(x: BigInt, y: BigInt): BigInt = {
      if (x < y) gcd(y, x)
      else {
        if (y > 0) {
          val r = x % y
          gcd(y, r)
        } else x
      }
    }
    val g = gcd(numerator, denominator)
    val n = numerator/g
    val d = denominator/g

    def -(that: Rational): Rational = Rational(n * that.d - that.n * d, d * that.d)
    def *(that: Rational): Rational = Rational(n * that.n, d * that.d)
    def toInt: BigInt = n / d
  }
}

Measured memory_bytes: 44572
N = gets.to_i
F = (0...N).map{
  gets.chomp.split.join.to_i(2)
}
P = (0...N).map{
  gets.split.map(&:to_i)
}

h = (0...1024).map{ |b| b.to_s(2).count("1") }

p (1...(1 << 10)).map{ |b|
  F.map.with_index{ |f,i|
    #p [b, f, f & b, (f & b).to_s(2), (f & b).to_s(2).count("1")]
    P[i][h[f & b]]
  }.inject(:+)
}.max


Measured memory_bytes: 2428
#include <stdio.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
//	
	int n, R;
	scanf("%d %d", &n, &R);
	if (n < 10)
	{
		R = R + 100 * (10 - n);
	}
	printf("%d", R);
	return 0;
}

Measured memory_bytes: 1720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


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


        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String word = br.readLine();
        word = word + word;
        String key = br.readLine();
        boolean result = false;

        for(int i = 0; i< word.length();){
        	int index = word.indexOf(key.charAt(0), i);
        	if(index == -1 || result || index + key.length() >  word.length()) break;

        	for(int j = 0; j < key.length();j++){
        		if(word.charAt(j + index)!=key.charAt(j)){
        			i = index + 1;
        			break;
        		}
        		if(j == key.length() -1){
        			result = true;
        			break;
        		}
        	}
        }

        if(result){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 24460
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n;
double p[3000];
double dp[3010][3010];

signed main(){
    I(n);
    REP(i,n) cin >> p[i];
    dp[1][1] = 1;
    REP(nv,n){
        int i = nv+3;
        FOR(x,1,i){
            int y = i-x;
            dp[x][y] = dp[x-1][y] * p[nv] + dp[x][y-1] * (1. - p[nv]);
        }
    }
    double ret = 0;
    int in = n+2;
    FOR(x,1,in){
        int y = in-x;
        if( x < y) continue;
        ret += dp[x][y];
    }
    printf("%.13f\n",ret);
}

Measured memory_bytes: 70016
import java.util.Scanner

import scala.util.Sorting

object Main {
  def solve(a: Array[Int]) = {
    Sorting.quickSort(a)
    val n = a.last
    val mid = n / 2
    val p = lowerBound(a, mid)
    val p2 = math.max(0, p - 1)
    val r =
      if (a(p) == n) a(p2)
      else if (a(p2) == n) a(p)
      else if (math.abs(2 * a(p) - n) > math.abs(2 * a(p2) - n)) a(p2) else a(p)
    (n, r)
  }

  def lowerBound(as: Array[Int], x: Int): Int = {
    def step(l: Int, h: Int): Int = h - l match {
      case 1 => h
      case _ =>
        val mid = l + (h - l) / 2
        if (as(mid) > x) {
          step(l, mid)
        } else {
          step(mid, h)
        }
    }
    step(-1, as.length)
  }

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N = sc.nextInt()
    val as = Array.fill(N)(sc.nextInt())
    val (n, r) = solve(as)
    println(s"$n $r")
  }
}


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


int main() {

    int k;
    cin >> k;
    if (k % 2 == 0) cout << k/2 * k/2 << endl;
    else cout << (k-1)/2 * (k - (k-1)/2) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a= sc.next();
		String b="";
		int c= a.length();
		for(int i=0; i<c; i++) {
			b+="x";
		}
		System.out.println(b);
	}
}
	

Measured memory_bytes: 23380
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  int h, w; cin >> h >> w;
  bool mat[h][w];

  rep(i, h) {
    string s; cin >> s;
    rep(j, w) {
      mat[i][j] = (s.at(j) == '.');
    }
  }

  vector<bool> skiph(h);
  rep(i, h) {
    skiph.at(i) = true;
    rep(j, w) {
      skiph.at(i) = skiph.at(i) && mat[i][j];
    }
  }
  vector<bool> skipw(w);
  rep(j, w) {
    skipw.at(j) = true;
    rep(i, h) {
      skipw.at(j) = skipw.at(j) && mat[i][j];
    }
  }  

  rep(i, h) {
    if (skiph.at(i)) continue;
    rep(j, w) {
      if (skipw.at(j)) continue;
      cout << (mat[i][j] ? '.' : '#');
    }
    cout << endl;
  }
}

Measured memory_bytes: 256