akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);

	int x = stdIn.nextInt();

	int y = stdIn.nextInt();
	
	int z = stdIn.nextInt();
	int temp;

	if(x > y ){
	    temp = x;
	    x = y;
	    y = temp;
	}
        if(x > z ){
	    temp = x;
	    x = z;
	    z = temp;
	}
	if(y > z ){
	    temp = z;
	    z = y;
	    y = temp;
	}
	System.out.printf("%d %d %d\n",x,y,z);
    }
}

Measured memory_bytes: 17168
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

n,x = map(int,input().split())
s = list(map(int,input().split()))

for i in range(n):
    s[i]-=x
ans=s[0]
for i in range(n-1):
    ans=gcd(ans,s[i+1])

if(ans<0):
    ans=-ans
    

print(ans)

Measured memory_bytes: 14224
#include <stdio.h>

#define MAX 50

int main(void)
{
  int N, v[MAX];
  int i,j;
  double sum=0;

  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&v[i]);

  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(v[j-1] > v[j]){
        int tmp = v[j-1];
        v[j-1] = v[j];
        v[j] = tmp;
      }
    }
  }

  sum = v[0];
  for(i=1;i<N;i++){
    sum += v[i];
    sum /= 2;
  }
  printf("%lf\n",sum);


  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <ctype.h>

struct kouzoutai0048
{
	double weight;
	char c[101];
};
typedef struct kouzoutai0048 k0048;

int main()
{
	int i=0;
	int count;
	int ret;
	k0048 data[100];
	while(1){
		ret=scanf("%lf", &data[i].weight);
		if(ret==EOF){
			break;
		}
		if(data[i].weight<=48.00){
			strcpy(data[i].c, "light fly");
		}
		else if(data[i].weight<=51.00){
			strcpy(data[i].c, "fly");
		}
		else if(data[i].weight<=54.00){
			strcpy(data[i].c, "bantam");
		}
		else if(data[i].weight<=57.00){
			strcpy(data[i].c, "feather");
		}
		else if(data[i].weight<=60.00){
			strcpy(data[i].c, "light");
		}
		else if(data[i].weight<=64.00){
			strcpy(data[i].c, "light welter");
		}
		else if(data[i].weight<=69.00){
			strcpy(data[i].c, "welter");
		}
		else if(data[i].weight<=75.00){
			strcpy(data[i].c, "light middle");
		}
		else if(data[i].weight<=81.00){
			strcpy(data[i].c, "middle");
		}
		else if(data[i].weight<=91.00){
			strcpy(data[i].c, "light heavy");
		}
		else{
			strcpy(data[i].c, "heavy");
		}
		i++;
	}
	count=i;
	for(i=0; i<count; i++){
		puts(data[i].c);
	}
	return 0;
}

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

int main()
{
    char str[1001];
    char order[8];
    char p[1001];
    char tmp;
    int q, a, b, i, j, k;
    
    scanf("%s", str);
    scanf("%d", &q);
    
    for(i=0; i<q; i++){
        scanf("%s", order);
        scanf("%d%d", &a, &b);
        
        if(strcmp(order, "print")==0){
            for(j=a; j<=b; j++) printf("%c", str[j]);
            printf("\n");
        }
        
        else if(strcmp(order, "reverse")==0){
            for(j=a, k=b; j<=k; j++, k--){
                tmp = str[j];
                str[j] = str[k];
                str[k] = tmp;
            }
        }
        
        else if(strcmp(order, "replace")==0){
            scanf("%s", p);
            for(j=a; j<=b; j++) str[j] = p[j-a];
        }
    }
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int A[N];
    unordered_map<int, ll> um;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (um.find(A[i]) == um.end()) {
            um[A[i]] = 1;
        } else {
            um[A[i]]++;
        }
    }
    ll sum = 0;
    for (auto p : um) {
        sum += p.second * (p.second - 1) / 2;
    }
    for (int a : A) {
        cout << sum - um[a] + 1 << "\n";
    }
}


Measured memory_bytes: 8392
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 100050
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n,a[3],dp[N][3];

int main(){

	fastio;
	fill(dp,0);
	cin >> n;
	for(int i = 1; i <= n; ++i){
		FER(j,0,3) cin >> a[j];
		FER(j,0,3) FER(k,0,3) if(j != k) dp[i][j] = max(dp[i][j],dp[i-1][k] + a[j]);
	}
	cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
	return 0;
}


Measured memory_bytes: 1408
n, a, b = map(int, input().split(' '))
x = list(map(int, input().split(' ')))

result = 0
for i in range(1, n):
    L = x[i] - x[i-1]
    if a*L < b:
        result += a*L
    else:
        result += b
print(result)

Measured memory_bytes: 14252
H, W = map(int, input().split())
a_list = [list(input()) for _ in range(H)]
dot_cnt = [sum([a == '.' for a in a_col]) for a_col in a_list]
exist_idx = [i for i, num in enumerate(dot_cnt) if num != W]
st = set(range(W))
for i in exist_idx:
    dot_idx = [i for i, a in enumerate(a_list[i]) if a == '.']
    st = st & set(dot_idx)
for i in exist_idx:
    print(''.join([a for i, a in enumerate(a_list[i]) if i not in st]))


Measured memory_bytes: 9236
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
#include<set>
using namespace std;
typedef long long ll;
const int NMmax = 1e5;
const ll INF = 1e17;
int N, M;
int U[NMmax], V[NMmax];
ll S[NMmax];

void dfs(int v, vector<ll> &x, vector<bool> &z, vector<vector<pair<int, ll> > > &g){
	for(int i=0; i<g[v].size(); i++){
		int u = g[v][i].first;
		ll s = g[v][i].second;
		if(x[u]==INF){
			x[u] = s-x[v];
			z[u] = !z[v];
			dfs(u, x, z, g);
		}
	}
}

void f(ll x0, vector<ll> &x, vector<bool> &z, vector<vector<pair<int, ll> > > &g){
	x = vector<ll>(N, INF);
	z = vector<bool>(N);
	x[0] = x0;
	dfs(0, x, z, g);
}

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> U[i] >> V[i] >> S[i];
		U[i]--; V[i]--;
	}

	vector<vector<pair<int, ll> > > graph(N);
	for(int i=0; i<M; i++){
		graph[U[i]].push_back(make_pair(V[i], S[i]));
		graph[V[i]].push_back(make_pair(U[i], S[i]));
	}

	vector<ll> x;
	vector<bool> z;
	set<ll> s;
	f(0, x, z, graph);
	for(int i=0; i<M; i++){
		if(z[U[i]]==z[V[i]]){
			ll x0 = (S[i]-x[U[i]]-x[V[i]])/2;
			s.insert(z[U[i]] ? -x0 : x0);
		}
	}
	if(s.size() > 1){
		cout << 0 << endl;
		return 0;
	}
	else if(s.size() == 1){
		//for(int i=0; i<N; i++) cout << z[i] << " " << x[i] << endl;
		ll x0 = *s.begin();
		f(x0, x, z, graph);
		bool ok=true;
		for(int i=0; i<N; i++){
			ok = ok && x[i] > 0;
		}
		for(int i=0; i<M; i++){
			ok = ok && (x[U[i]] + x[V[i]] == S[i]);
		}
		cout << (ok ? 1 : 0) << endl;
		return 0;
	}
	bool ok = true;
	for(int i=0; i<M; i++){
		ok = ok && (x[U[i]]+x[V[i]]==S[i]);
	}
	if(!ok){
		cout << 0 << endl;
		return 0;
	}

	ll lb=1, ub=INF;
	for(int i=0; i<N; i++){
		if(z[i]){
			ub = min(ub, x[i]-1);
		}
		else{
			lb = max(lb, -x[i]+1);
		}
	}
	cout << max(0LL, ub-lb+1) << endl;
	return 0;
}


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


int main(){
  int n;
  string s;
  cin >> n >> s;
  map<pair<string,string>,ll> mp;
  ll res = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    string blue, red;
    for (int i = 0; i < n; i++) {
      if (bit & (1<<i)) blue += s[i];
      else red += s[i];
    }
    mp[{blue,red}]++;
  }
  reverse(s.begin(), s.end());
  for (int bit = 0; bit < (1 << n); bit++) {
    string blue, red;
    for (int i = 0; i < n; i++) {
      if (bit & (1<<i)) blue += s[i];
      else red += s[i];
    }
    res += mp[{red,blue}];
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 91904
#include <stdio.h>

int euclid(int a, int b){
  int r = a%b;
  if(r == 0) return b;
  else euclid(b,a%b);
}

int main(){
  int a,b,gcd;

  scanf("%d%d",&a,&b);

  if(a >= b) gcd = euclid(a,b);
  else gcd = euclid(b,a);

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

  return 0;
}

Measured memory_bytes: 592
H, W = map(int,input().split())
s = []
rc = [[[None]*W for _ in range(H)] for _ in range(2)]
for _ in range(H):
    s.append(list(input()))
for j in range(H):
    l = s[j]
    for i in range(W):
        if l[i] == "#":
            rc[0][j][i] = 0
        elif i > 0:
            rc[0][j][i] = rc[0][j][i-1] + 1
        else:
            rc[0][j][i] = 1
    for i in range(W-1, -1, -1):
        if l[i] == "#":
            continue
        elif i < W-1:
            rc[0][j][i] = max(rc[0][j][i+1], rc[0][j][i])
for i in range(W):
    for j in range(H):
        if s[j][i] == "#":
            rc[1][j][i] = 0
        elif j > 0:
            rc[1][j][i] = rc[1][j-1][i] + 1
        else:
            rc[1][j][i] = 1
    for j in range(H-1, -1, -1):
        if s[j][i] == "#":
            continue
        elif j < H-1:
            rc[1][j][i] = max(rc[1][j+1][i], rc[1][j][i])
ans = 0
for j in range(H):
    for i in range(W):
        ans = max(rc[0][j][i] + rc[1][j][i] - 1, ans)
print(ans)

Measured memory_bytes: 326056
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		Integer[] a = new Integer[n];
		Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
		int count = 0;
		for(int i=0; i<n; i++){
			if(i % 2 == 0 && a[i] % 2 != 0) count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35600
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0,g=0,h=0, count = 0;
	char ac,uc[100000];
	string manji,gage;
	cin >> a>>b>>c;
	if ((b * 10 + c) % 4 == 0) {
		cout << "YES" << endl;
	}
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 300, M = N * N, INF = 0x3f3f3f3f;

struct E {
	int i, j, w;
} ee[M];

int aa[N][N], dd[N][N];

int main() {
	int n; cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++) {
			int w; cin >> w;
			aa[i][j] = dd[i][j] = w;
			auto &e = ee[m++];
			e.i = i;
			e.j = j;
			e.w = w;
		}
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			if (aa[i][j] != dd[i][j]) {
				cout << "-1\n";
				return 0;
			}
	sort(ee, ee + m, [] (auto &e, auto &f) { return e.w < f.w; });
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			dd[i][j] = INF;
	long long ans = 0;
	for (int h = 0; h < m; h++) {
		auto &e = ee[h];
		int i = e.i, j = e.j, w = e.w;
		int d = dd[i][j];
		for (int k = 0; k < n; k++)
			d = min(d, dd[i][k] + dd[k][j]);
		if (d > w) {
			d = w;
			ans += w;
		}
		dd[i][j] = dd[j][i] = d;
		for (int k = 0; k < n; k++) {
			dd[i][k] = dd[k][i] = min(dd[i][k], d + dd[j][k]);
			dd[j][k] = dd[k][j] = min(dd[j][k], d + dd[i][k]);
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 5392
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let mut total: usize = 0;
    for n_i in 1..n+1 {
        if (n_i % 3 != 0) & (n_i % 5 != 0) {
            total += n_i;
        }
    }
    println!("{}", total);
}




Measured memory_bytes: 2104
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		String line = readLine();
		for (int i = 0; i < line.length(); i += 2) {
			p(line.charAt(i));
		}
		pln("");
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 23124
import Control.Applicative
import Control.Monad
import Data.List
import Data.Function (on, fix)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n <$> f >>= putStrLn
    main
  where
    f = map head <$> words <$> getLine

solve :: Int -> [Char] -> String
solve n vs = f 1 (zip ['A' .. 'Z'] (repeat 0)) vs
  where
    f i sb [] = "TIE"
    f i sb (c:cs) = let (as, (x,y):bs) = break ((==c).fst) sb
                        sb'@((w,p1):(_,p2):_) = sortBy (flip compare `on` snd) $ as ++ (x, y+1) : bs
                    in if p1 > p2 + n - i
                       then w : ' ' : show i
                       else f (i + 1) sb' cs



Measured memory_bytes: 4180
from collections import deque
import sys
input = sys.stdin.readline
MOD = 10**9+7

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)

dq = deque([0])
ans = K
check = [True]*N
check[0] = False
while dq:
    p = dq.popleft()
    if p == 0:
        cand = K-1
    else:
        cand = K-2
    for i in A[p]:
        if check[i]:
            check[i] = False
            ans = (ans*cand)%MOD
            cand -= 1
            dq.append(i)

print(ans)


Measured memory_bytes: 61616
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n; cin >> n;
    vector<ll> sum(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> sum[i + 1];
        sum[i + 1] += sum[i];
    }
    ll ans = infl;
    for (int i = 1; i <= n - 1; ++i) {
        ans = min(ans, abs(sum[i] - (sum[n] - sum[i])));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(0,A+1):
    for j in range(0,B+1):
        for k in range(0,C+1):
            if 500 * i + 100 * j + 50 * k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N, M;
    cin >> N >> M;
    vector<ll> answer(N, -1);
    bool can_make = true;
    for (int i = 0; i < M; i++)
    {
        ll s, c;
        cin >> s >> c;
        s--;
        if (answer[s] == -1 || answer[s] == c)
        {
            answer[s] = c;
        }
        else
        {
            can_make = false;
        }
    }
    if (!can_make || (answer[0] == 0 && N != 1))
    {
        cout << -1 << endl;
    }
    else
    {
        if (N == 1)
        {
            if (answer[0] == -1)
            {
                cout << 0 << endl;
            }
            else
            {
                cout << answer[0] << endl;
            }
        }
        else
        {
            for (int i = 0; i < N; i++)
            {
                if (i == 0)
                {
                    if (answer[i] == -1)
                    {
                        cout << 1;
                    }
                    else
                    {
                        cout << answer[i];
                    }
                }
                else
                {
                    if (answer[i] == -1)
                    {
                        cout << 0;
                    }
                    else
                    {
                        cout << answer[i];
                    }
                }
            }
            cout << endl;
        }
    }
    return 0;
}

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

int main(){
	int a, b, c;
	while(scanf(" %d %d %d", &a, &b, &c) != EOF){
		int now=a+b, count=0;
		
		for(int i=1; i<=10; i++){
			if(i==a || i==b || i==c) continue;
			else{
				if(now+i<=20) count++;	
			}
		}

		if(count>=4) printf("YES\n");
		else printf("NO\n");

	}

	return 0;
}

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

using namespace std;

int main(){
  int n,k,ans=0,tmp;
  scanf("%d %d",&n,&k);
  
  for(int i=0;i<n;i++){
    scanf("%d",&tmp);
    ans+=2*min(tmp,k-tmp);
  }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define kk long long
using namespace std; 
 
int main() 
{ 
	
	
	kk i,j,n,m,a;
	cin>>n>>m;
	
	kk ara[n];
	for(i=0;i<n;i++)
	{
		cin>>ara[i];
		
	      
			}
			if(m>=n)
			{
				cout<<"0";
				return 0;
			}
		   sort(ara,ara+n);
			a=n-m;
			kk sum=0;
			for(i=0;i<a;i++)
			{
				sum+=ara[i];
			}
			
		 cout<<sum<<endl;
	  
	return 0; 
} 

// This is code is contributed by rathbhupendra 


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

const int mod = 1e9 + 7;

int main(int argc, char* argv[])
{
  using std::cin;
  using std::cout;
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;
  std::string s;
  cin >> s;

  std::map<char, int> cnt;
  for (char c : s) cnt[c]++;

  long long res = 1;
  for (auto& entry : cnt)
  {
    res *= (entry.second + 1);
    res %= mod;
  }
  res = (res - 1 + mod) % mod;
  cout << res << "\n";

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define N 200005
using namespace std;
string s[N];
int ch[1000005][26],val[1000005][26],sz,k,n;
bool has[30];
long long ans;
char buf[1000005];
bool cmp(const string &s1,const string &s2)
{
	return s1.size()>s2.size();
}
void query(int i,int p)
{
//	cout<<"k:"<<k<<endl;
	if(i==s[k].size()-1)
		{ans+=val[p][s[k][i]-'a'];/*cout<<"ans:"<<ans<<endl;*/return;}
	if(!ch[p][s[k][i]-'a'])
		return;
	query(i+1,ch[p][s[k][i]-'a']);
}
void update(int i,int p)
{
//	cout<<"k:"<<k<<endl;
	if(i==s[k].size())
	{
		has[s[k][i-1]-'a']=1;
		return;
	}
	if(!ch[p][s[k][i]-'a'])ch[p][s[k][i]-'a']=++sz;
	update(i+1,ch[p][s[k][i]-'a']);
	
	for(int j=0;j<26;++j)val[p][j]+=has[j];/*,cout<<(char)(j+'a')<<':'<<val[p][j]<<endl;*/
//	puts("---");
	if(i)has[s[k][i-1]-'a']=1;
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;++i)
	{
		scanf("%s",buf);
		s[i]=buf;
		reverse(s[i].begin(),s[i].end());
	}
	sort(s,s+n,cmp);
//	for(int i=0;i<n;++i)cout<<s[i]<<endl;
	for(int i=0;i<n;++i)
	{
		k=i;
		for(int j=0;j<30;++j)has[j]=0;
		query(0,0);
		update(0,0);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 242200
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int min(int a,int b){
    return (a<b) ? a : b ;
}

int max(int a,int b){
    return (a<b) ? b : a ;
}

int main() {

    int k,a,b ;
    cin >>k>>a>>b  ;

   for(int i=a;i<=b;i++){
       if(i%k==0){
           cout << "OK" << endl ;
           return 0 ;
       }
   }

    cout << "NG" << endl  ;

 return 0 ;
}  


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <string>
#include <math.h>
using namespace std;

int main(){
    string s;
    cin>>s;;
    vector<string>a(50000,"zzzzzz");
    int k;
    cin>>k;
    for(int i=1;i<=5&&i<=s.size();i++){
        for(int j=0;j<s.size()-i+1;j++){
            a[j+(i-1)*10000]=s.substr(j,i);
        }
    }
    sort(a.begin(),a.end());
    int j=1;
    int i=0;
    while(j<k){
        if(a[i]!=a[i+1]){
            j++;
        }
        i++;
    }
    cout<<a[i]<<endl;
    return 0;
}


Measured memory_bytes: 4752
s = input()
n = len(s)
result = [0 for _ in range(n)]
start = 0
c = 'R'
for i in range(1, n):
  if s[i] != c:
    if c == 'R':
      result[i - 1] += (i - start) // 2 + (i - start) % 2
      result[i] += (i - start) // 2
      c = 'L'
    else:
      result[start] += (i - start) // 2 + (i - start) % 2
      result[start - 1] += (i - start) // 2
      c = 'R'
    start = i
result[start] += (n - start) // 2 + (n - start) % 2
result[start - 1] += (n - start) // 2
print(*result)


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

using namespace std;

#define all(v)   v.begin(), v.end()
#define pb       push_back
#define sz(x)    (int) (x.size())
#define endl "\n"
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE


typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


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

    ll n; cin >> n;
    ll a[n + 2] = {};
    ll sum = 0;
    for(ll j = 1; j <= n; j++){
       ll k = j;
       while(k <= n){
            a[k]++;
            k += j;
       }
    }
    for(int i = 1; i <= n; i++)
        sum += i*a[i];
    cout << sum;
    return 0;
}


Measured memory_bytes: 81764
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int N = p[0];
		int K = p[1];
		var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Array.Sort(l);
		Array.Reverse(l);
		long ans = 0;
        for(int i = 0; i < K; i++)
		{
			ans += l[i];
		}
		Console.WriteLine(ans);

		Console.Out.Flush();
	}
}

Measured memory_bytes: 13396
main :: IO ()
main = do
  n <- readLn
  an <- map (read :: String -> Int) . words <$> getLine
  print $ ans n 1 an

ans :: Int -> Int -> [Int] -> Int
ans n k [] = if k == 1 then -1 else n-k+1
ans n k (a:an) = if a == k then ans n (k+1) an else ans n k an

Measured memory_bytes: 62076
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

// aを決定したとき、bの個数をカウントする
int count_b(int n, int a) {
	if (a % 10 == 0) return 0;
	int a_top, a_lst; // 先頭の桁, 末尾の桁
	a_lst = a % 10;
	while (a > 9)
		a /= 10;
	a_top = a;
	int res = (a_top == a_lst) ? 1 : 0;
	for (int i = 0;; ++i) { // 間の桁数ごとにカウント
		// b_mn = a_lst 0 0 0 ... 0 a_top
		// b_mx = a_lst 9 9 9 ... 9 a_top
		int b_mn = a_lst, b_mx = a_lst;
		for (int ii = 0; ii < i + 1; ++ii) {
			b_mn *= 10; b_mx = 10 * b_mx + 9;
		}
		b_mn += a_top;
		b_mx += (a_top - 9);
		if (b_mn > n) break;
		else if (b_mx <= n) res += (b_mx / 10 - b_mn / 10 + 1);
		else {
			b_mx = (n % 10 >= a_top) ? n : (n - 10);
			res += (b_mx / 10 - b_mn / 10 + 1);
		}
	}
	return res;
}

signed main() {
	int n; cin >> n;
	int ans = 0;
	for (int a = 1; a <= n; ++a)
		ans += count_b(n, a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int max = 0;
		int cur = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
				cur++;
			} else {
				if (cur > max) {
					max = cur;
				}
				cur = 0;
			}
		}
		if (cur > max) {
			max = cur;
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23252
#include <stdio.h>

int main() {
    char s[100];
    scanf("%s", s);

    int ans=0;
    for (int i = 0; i < 4 ; ++i) {
        if(s[i]=='+'){
            ans += 1;
        }else if(s[i]=='-'){
            ans -= 1;
        }
    }
    printf("%d", ans);
    return 0;
}

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

int main(){
  int n, m, x;
  cin>>n >>m >>x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++)cin>>a[i][j];
  }
  int ans=1200010;
  int all=1<<n;
  for(int mask=0;mask<all;mask++){
    vector<int> level(m);
    int cost=0;
    for(int i=0;i<n;i++){
      if((mask>>i)&1){
        cost+=c[i];
        for(int j=0;j<m;j++){
          level[j]+=a[i][j];
        }
      }
    }
    bool ok=true;
    for(int i=0;i<m;i++){
      if(level[i]<x)ok=false;
    }
    if(ok)ans=min(ans, cost);
  }
  if(ans==1200010)cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.ParseException;

public class Main {
	public static void main(String[] args) throws IOException, ParseException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	final double A = Double.parseDouble(str.split(" ")[0]);
    	final double B = Double.parseDouble(str.split(" ")[1]);

   		System.out.println(A / B);
	}
}


Measured memory_bytes: 23252
unittest
{
	assert( [ "123456789" ].solve == "Yes" );
	assert( [ "0" ].solve == "Yes" );
	assert( [ "31415926535897932384626433832795028841971693993751058209749445923078164062862089986280" ].solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.map!( ( a ) => ( a - '0' ).to!( long ) );
	
	return ( n.sum % 9 == 0 ) ? "Yes" : "No";
}


Measured memory_bytes: 2984
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,W;
      cin>>n>>W;
      vector<int>dp(100001,INF);
      dp[0]=0;
      for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            vector<int>temp(100001,INF);
            for(int j=y;j<=100000;j++){
                  temp[j]=min(temp[j],dp[j-y]+x);
            }
            for(int j=0;j<=100000;j++)dp[j]=min(dp[j],temp[j]);
      }
      int ans=0;
      for(int i=0;i<=100000;i++){
            if(dp[i]<=W)ans=i;
      }
      cout<<ans;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

struct ei{
    string ans;
    int len;
    int c;
    ei(int len,int c):len(len),c(c){}

    void add(char x,int t){
        if(t<=c){
            c-=t;
            return;
        }
        t-=c;
        c=0;
        for(int i=0;i<t&&ans.size()<len;i++){
            ans+=x;
        }
    }
    void add(int a,int b,int t){
        int tmp=c/(a+b);
        chmin(tmp,t);
        c-=tmp*(a+b);
        t-=tmp;
        for(int i=0;i<t&&ans.size()<len;i++){
            add('A',a);
            add('B',b);
        }
    }
};

string solve(int a,int b,int c,int d){
    int k=(a+b)/(b+1);

    ei ans(d-c,c);



    if(a>=k*b){
        ans.add(k,1,b);
        a-=k*b;
        b=0;

        ans.add('A',a);
        return ans.ans;
    }



    int lb=0,ub=1<<30;
    while(ub-lb>1){
        int mid=(ub+lb)/2;

        int aa=a-mid*k;
        int bb=b-mid;

        if(aa>=0&&bb>=0&&aa*k>=bb)lb=mid;
        else ub=mid;
    }
    ans.add(k,1,lb);
    a-=lb*k;
    b-=lb;


    int x=max((b+k-1)/k,a+1-k);

    if(x){
        ans.add('A',a-x+1);
        a=x-1;

        if((x-1)*k+1>=b){
            ans.add('B',1);
            b--;
        }
        else{
            ans.add('B',b-(x-1)*k);
            b=(x-1)*k;
        }
        x--;
    }


    lb=0,ub=1<<30;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        int aa=a-mid;
        int bb=b-mid;

        if(aa>=0&&bb>=0&&aa*k>=bb)lb=mid;
        else ub=mid;
    }
    ans.add(1,1,lb);
    a-=lb;b-=lb;

    if(a){
        ans.add('A',1);
        a--;

        if(a*k+1>=b){
            ans.add('B',1);
            b--;
        }
        else{
            ans.add('B',b-a*k);
            b=a*k;
        }
    }

    ans.add(1,k,a);
    return ans.ans;
}

signed main(){
    int Q;cin>>Q;
    while(Q--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        c--;

        if(a>=b){
            cout<<solve(a,b,c,d)<<endl;
        }
        else{
            string s=solve(b,a,a+b-d,a+b-c);
            reverse(all(s));
            rep(i,s.size()){
                if(s[i]=='A')s[i]++;
                else s[i]--;
            }
            cout<<s<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    int n;
    cin >> n;
    vector<ll> vec(n);
    vector<ll> num;
    vector<ll> num2(int(1e6+5));
    fill(All(num2),0);
    rep(i,1e6+5) num.push_back(0);
    rep(i,n){
        cin >> vec[i];
        num[vec[i]]++;
        num2[vec[i]]++;
    }
    int ans = 0;
    sort(All(vec));
    rep(j,n){
        ll now = vec[j];
        if(j!=0){
            if(now==vec[j-1]) continue;
        }
        if(num[now]>=2) num2[now]=0;
        for(int i = 2*now;i<1e6+3;i+=now){
            if(num[i]!=0){
                num2[i]=0;
            }
        }
    }
    rep(i,1e6+5){
        ans+=num2[i];
    }
    cout << ans << endl;
    /*vector<ll> left(n+1);
    vector<ll> right(n+1);
    left[0]=1;
    rep(i,n){
        left[i+1]=lcm(left[i],vec[i]);
        if(left[i+1]>1e6) left[i+1]=-1;
    }
    right[n]=1;
    for(int i = n-1;i>=0;i--){
        right[i]=lcm(right[i+1],vec[i]);
        if(right[i]>1e6) right[i+1]=-1;
    }
    int ans = 0;
    rep(i,n){
        ll now_lcm = lcm(left[i],right[i+1]);
        if(now_lcm!=-1){
            if(ans%now_lcm)
        }
    }*/
    

}

Measured memory_bytes: 20972
a, b, k = list(map(int, input().split()))

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 0:
            tmp = a
            a -= a//2
            b += tmp//2
        else:
            a -= 1
            tmp = a
            a -= a//2
            b += tmp//2
    else:
        if b % 2 == 0:
            tmp = b
            b -= b//2
            a += tmp//2
        else:
            b -= 1
            tmp = b
            b -= b//2
            a += tmp//2

print(a, b)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for(int i=0;i<n-2;i++){
            String sub = s.substring(i,i+3);
            if(sub.equals("ABC"))count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, M;
int DP[1 << 12];

int main() {
	cin >> N >> M;
	for (int i = 0; i < (1 << N); ++i) {
		DP[i] = mod;
	}
	while (M--) {
		int a, b;
		cin >> a >> b;
		int t = 0;
		for (int i = 0; i < b; ++i) {
			int c;
			cin >> c;
			t += (1 << c - 1);
		}
		DP[t] = min(DP[t], a);
	}
	for (int i = 1; i < (1 << N); ++i) {
		for (int j = 1; j < i; ++j) {
			DP[i | j] = min(DP[i | j], DP[i] + DP[j]);
		}
	}
	if (DP[(1 << N) - 1] == mod) {
		cout << -1 << endl;
		return 0;
	}
	cout << DP[(1 << N) - 1] << endl;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
// using P = std::tuple<int,int>;

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

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

    int A, B, C, D, P;
    std::cin >> A >> B >> C >> D >> P;

    int res = min(A * P, B + max(P - C, 0) * D);
    std::cout << res << std::endl;
}



Measured memory_bytes: 3168
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	map<string, int>A;
	cin >> Q;
	rep(i, Q) {
		ll a;
		cin >> a ;
		if (a==0) {
			string key;
			int x;
			cin >> key >> x;
			A[key] = x;
		}
		else if(a==1){
			string key;
			cin >> key;
			cout << A[key] << endl;
		}
		else {
			string key;
			cin >> key;
			A.erase(key);
		}
	}
	return 0;
}


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

int main(){
  int k;
  cin >> k;
  queue<long long> lun;
  for(int i=1;i<10;i++){
    lun.push(i);
  }
  for(int i=1;i<k;i++){
    long long x=lun.front();
    lun.pop();
    if(x%10!=0) lun.push(x*10+x%10-1);
    lun.push(x*10+x%10);
    if(x%10!=9) lun.push(x*10+x%10+1);
  }
  cout << lun.front() << endl;
}

Measured memory_bytes: 1792
S = input().rstrip()
front = int(S[0:2])
back = int(S[2:4])

if 1 <= front <= 12:
    if 1 <= back <= 12:
        print('AMBIGUOUS')
    elif 0 <= back:
        print('MMYY')
    else:
        print('NA')
else:
    if 0 <= front and 1 <= back <= 12:
        print('YYMM')
    else:
        print('NA')

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

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

    int a[4] = {};
    int face = 0;

    int ans = 0;
    bool right = false;
    for(char c : s){
        if(face == 0 && c == 'R')   right = true;
        else if(face == 0 && c == 'L')  right = false;
        if(c == 'R')    face = (face+1)%4;
        else            face = (face-1+4)%4;
        a[face]++;
        if(face == 0){
            if(c == 'R' && right && a[1] > 0 && a[2] > 0 && a[3] > 0)    ans++;
            memset(a, 0, sizeof(a));
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3224
import java.lang.StringBuilder

fun main(args:Array<String>){
    val n=readInt()
    val list=(1..n).map{readLine()!!}
    val map=list.groupBy { it }.map{it.key to it.value.size}
    val max=map.maxBy { it.second }!!.second

    val answer=StringBuilder()
    val sorted=map.filter{it.second==max}.map{it.first}.sorted()
    for(it in sorted){
        answer.appendln(it)
    }
    print(answer)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 112740
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int x;
  scanf("%d", &x);
  long ans = 0;
  ans += 1000 * (x/500);
  x %= 500;
  ans += 5 * (x/5);
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 128
def main():
    n = int(input())
    ss = [input() for _ in range(n)]
    m = int(input())
    ts = [input() for _ in range(m)]

    fruits = list(set(ss))
    ans = 0
    for fruit in fruits:
        money = 0
        money += ss.count(fruit)
        money -= ts.count(fruit)
        ans = max(ans, money)
    print(ans)


if __name__ == "__main__":
    main()


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

int n,L,dp[1<<18][19],p[1<<18];
string s;
inline int F(int a,int b){
  if(a>b) swap(a,b);
  return (s[b-a-1]=='0'?a:b);
}
int g(int S,int W){
  if(!W)return p[S];
  if(~dp[S][W])return dp[S][W];
  return dp[S][W]=F(g(S,W-1),g((S+(1<<(W-1)))%L,W-1));
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n>>s;
  for(int i=0;i<(L=1<<n);i++)cin>>p[i];
  for(int i=0;i<L;i++)cout<<g(i,n)<<endl;
}



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

using namespace std;

class Inverse {
private:
  long long mod;
	vector<long long> inv;
  
public:
  Inverse() {}
  
	Inverse(long long mod, long long n = 1000000) : mod(mod) {
    inv = vector<long long>(n, 1);
    for (int i = 2; i < n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  }
  
	long long operator()(long long a) const {
		if (a < (int)inv.size()) return inv[a];
		long long b = mod, x = 1, y = 0;
		while (b) {
			long long t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return (x %= mod) < 0 ? x + mod : x;
	}
};

class Mint {
private:
  static long long mod;
  static Inverse inverse;
  long long val;
	
public:
	Mint() {}

	Mint(const long long& val) {
    this->val = val % mod;
    if (this->val < 0) this->val += mod;
  }

  static void setMod(const long long& m) {
    mod = m;
    inverse = Inverse(m);
  }
	
	Mint operator+=(const Mint& m) {
		val += m.val;
		if (val >= mod) val -= mod;
		return *this;
	}
  
	Mint operator-=(const Mint& m) {
		val -= m.val;
		if (val < 0) val += mod;
		return *this;
	}
  
	Mint operator*=(const Mint& m) {
		val *= m.val;
		val %= mod;
		return *this;
	}
  
	Mint operator/=(const Mint& m) {
		val *= inverse(m.val);
		val %= mod;
		return *this;
	}
	
	Mint operator+(const Mint& m) const {
		Mint res = *this;
		res += m;
		return res;
	}
	
	Mint operator-(const Mint& m) const {
		Mint res = *this;
		res -= m;
		return res;
	}
	
	Mint operator*(const Mint& m) const {
		Mint res = *this;
		res *= m;
		return res;
	}
	
	Mint operator/(const Mint& m) const {
		Mint res = *this;
		res /= m;
		return res;
	}
	
	Mint operator++() {return val += 1;}
	
	operator long long() {
		return val;
	}

  Mint identity() const {
    return 1;
  }
};

long long Mint::mod = 1000000007;
Inverse Mint::inverse(1000000007);

ostream& operator<<(ostream& os, Mint a) {
	os << (long long)a;
	return os;
}

istream& operator>>(istream& is, Mint& a) {
	long long n;
	is >> n;
	a = n;
	return is;
}

template<typename T> T pow(T& m, long long n) {
  if (n == 0) {
    return m.identity();
  } else if (n < 0) {
    return m.identity() / pow(m, -n);
  }
  T mm = pow(m, n / 2);
  mm *= mm;
  if (n % 2) mm *= m;
  return mm;
}

int main() {
  Mint m;
  int n;
  cin >> m >> n;
  cout << pow(m, n) << endl;
}

Measured memory_bytes: 8984
#include <iostream>
#include <cstdio>
#include <cmath>

int main() {
  double x1, x2;
  double y1, y2;
  std::cin >> x1 >> y1 >> x2 >> y2;

  double distance;
  distance = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  printf("%.4f\n", distance);

  return 0;
}

Measured memory_bytes: 3152
#include <stdio.h>
int main(void){
   int a,b;
   double f;
   
   scanf("%d %d", &a, &b);
   
   int d = a / b;
   int r = a % b;
   f = (double) a / b;
   
   printf("%d %d %f\n", d, r, f);
   return 0;
    
}



Measured memory_bytes: 2084
#include<stdio.h>
int main(){
  	int a[6],i;
  	for(i=1;i<=5;i++){
      scanf("%d",&a[i]);
    }
  for(i=1;i<=5;i++)
    if(a[i]==0){
      printf("%d",i);
  		break;
    }
  return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  int num = 100 * r + 10 * g + b;
  if (num % 4 == 0){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::marker::*;
use proconio::*;

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize, K: usize,
        mut p: [usize; N],
    }
    p.sort();
    println!("{}", (0..K).map(|x| p[x]).sum::<usize>());
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<lli,lli> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1e9+7;
const int maxn = 1e5+5;
char a[10][10];
char b[10][10];
int main(){__
	int h,w,k;
	cin >> h >> w >> k;
	int ans =0;
	int tot =0;
	for(int i=0; i < h; i++){
		for(int j=0; j < w; j++){
			cin >> a[i][j];
			if(a[i][i] == '#') tot++;
		}
	}
	
	for(int i=0; i < h; i++){
		for(int j=0; j < w; j++){
			b[i][j] = a[i][j];
		}
	}
	for(int n=0; n < (1<<h); n++){
		for(int m=0; m < (1<<w); m++){

			for(int i=0; i < h; i++){
				if(n & (1<<i)){
					for(int x=0; x < w; x++){
						b[i][x] = 'r';
					}
				}
			}

			for(int j=0; j < w; j++){
				if(m & (1 << j)){
					for(int x=0; x < h; x++){
						b[x][j] = 'r';
					}
				}
			}

			//todo
			int res =0;
			for(int i=0; i < h; i++){
				for(int j=0; j < w; j++){
					if(b[i][j] == '#') res++;
				}
			}
			if(res == k) ans++;

			for(int i=0; i< h; i++){
				for(int j=0; j < w; j++){
					b[i][j] = a[i][j];
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll k,a,b;cin>>k>>a>>b;
  string ans="NG";
  for(ll i=a;i<=b;i++)if(i%k==0)ans="OK";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<set>
#include<string>
#include<vector>
#include<map>

using namespace std;

using P = pair<int, int>;

int main(void){
    int N, M;
    cin >> N >> M;
    int n = N-1;
    set<P> v;
    vector<int> fromN;
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        v.insert(P(a,b));
        //v.insert(P(b,a));
        //if(a == n) fromN.push_back(b);
        if(b == n) fromN.push_back(a);
    }

    for(auto t : fromN){
        if(v.count(P(0, t))){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}

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

namespace abc129_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var m = CIn.ReadInt();
      var a = new HashSet<int>(CIn.ReadIntArray(m));

      var mod = 1000000007;

      var dp = new int[n + 1];

      dp[n] = 1;

      for (var i = n - 1; i >= 0; i--)
      {
        if (a.Contains(i)) continue;

        dp[i] = i == n - 1 ? dp[i + 1] : (dp[i + 1] + dp[i + 2]) % mod;
      }

      Console.WriteLine(dp[0]);
    }
  }


  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

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

using namespace std;

int main(){
  string str;
  char code[6][5] = {{'a', 'b', 'c', 'd', 'e'},
                     {'f', 'g', 'h', 'i', 'j'},
                     {'k', 'l', 'm', 'n', 'o'},
                     {'p', 'q', 'r', 's', 't'},
                     {'u', 'v', 'w', 'x', 'y'},
                     {'z', '.', '?', '!', ' '}};
  while(cin >> str){
    if(str.size() % 2){
      cout << "NA\n";
      continue;
    }
    string ans = "";
    for(int i = 0; i < str.size(); i += 2){
      if(str[i] < '1' || '6' < str[i] || str[i + 1] < '1' || '5' < str[i + 1]){
        ans = "NA";
        break;
      }
      ans += code[str[i] - '1'][str[i + 1] - '1'];
    }
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 1180
#include<stdio.h>

int main(){
	
	int N,Y,i,j,count=0;
	
	scanf("%d",&N);
	scanf("%d",&Y);
	
	for(i=0;i<N+1;i++){
		for(j=0;j<N+1-i;j++){
			if(10000*i+5000*j+1000*(N-i-j)==Y){
				printf("\n%d %d %d\n\n",i,j,N-i-j);
				count++;
				break;
			}
		}
		if(count!=0){
			break;
		}
		
	}
	
	
	if(count==0){
		printf("\n-1 -1 -1\n\n");
	}
	
	
	return 0;
}

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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _reps, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll n[4];	cin >> n[0] >> n[1] >> n[2] >> n[3];

	cout << max({n[0]*n[2], n[0]*n[3], n[1]*n[2], n[1]*n[3]});

	return 0;
}


Measured memory_bytes: 3644