akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

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

    long int a[N];

    for(long int i=0;i<N;i++)cin>>a[i];
    
    int x[N],M=0;
    
    for(long int i=N;i>0;i--){
        int n=0;
        for(long int j=2;j*i<=N;j++){
            n+=x[i*j-1];
        }
        if(n%2==a[i-1])x[i-1]=0;
        else {
            x[i-1]=1;
            M++;
        }
    }
    

    cout<<M<<'\n';
    for(long int i=0;i<N;i++){
        if(x[i]==1)cout<<i+1<<'\n';
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

bool find(int j, vector<vi>& g, vi& btoa, vi& vis) {
	if (btoa[j] == -1) return 1;
	vis[j] = 1; int di = btoa[j];
	trav(e, g[di])
		if (!vis[e] && find(e, g, btoa, vis)) {
			btoa[e] = di;
			return 1;
		}
	return 0;
}
int dfsMatching(vector<vi>& g, vi& btoa) {
	vi vis;
	rep(i,0,sz(g)) {
		vis.assign(sz(btoa), 0);
		trav(j,g[i])
			if (find(j, g, btoa, vis)) {
				btoa[j] = i;
				break;
			}
	}
	return sz(btoa) - (int)count(all(btoa), -1);
}

int n, m;

vector<vi> step1(vector<vi> &as){
	vector<vi> bs(n, vi(m));
	vector<vector<vi>> lists(n, vector<vi>(n));
	rep(i,0,n) rep(j,0,m)
		lists[i][ (as[i][j]-1)/m ].push_back(j);
	rep(c,0,m){
		vector<vi> g(n);
		rep(l,0,n) rep(r,0,n)
			if(!lists[r][l].empty())
				g[l].push_back(r);
		vi btoa(n, -1);
		dfsMatching(g, btoa);
		rep(r,0,n){
			int l = btoa[r];
			int j = lists[r][l].back();
			lists[r][l].pop_back();
			bs[r][c] = as[r][j];
		}
	}
	return bs;
}

vector<vi> step2(vector<vi> &bs){
	vector<vi> cs(n, vi(m));
	rep(i,0,n) rep(j,0,m){
		int r = (bs[i][j]-1) / m;
		cs[r][j] = bs[i][j];
	}
	return cs;
}

void skriv(vector<vi> &xs){
	trav(v, xs){
		trav(x, v) cout << x << ' ';
		cout << endl;
	}
}

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

	cin >> n >> m;

	vector<vi> as(n, vi(m));
	trav(v, as) trav(x, v) cin >> x;

	vector<vi> bs = step1(as);
	vector<vi> cs = step2(bs);
	skriv(bs);
	puts("");
	skriv(cs);
}


Measured memory_bytes: 896
#include<iostream>
#include<unordered_map>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int n, k;
int a[200005];
map<int, int>M;
vector<int>V;
vector<pair<int, int>> vec;

void input(){
  cin >> n >> k;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    M[a[i]]++;
  }
}

void count(){
  
  map<int, int> :: iterator it2;
  for (it2=M.begin(); it2!=M.end(); it2++){
    vec.push_back(make_pair(it2->second, it2->first));
    //cout << it2->second << endl;
  }
  sort(vec.begin(), vec.end());
}

int solve(){
  if(vec.size() < k){
    //cout << 0 << endl;
    return 0;
  }else{
    int ans = 0;
    for(int i = 0; i < vec.size() - k; ++i){
      ans += vec[i].first;
    }
    return ans;
  }
  
}

int main(){
  input();
  count();
  cout << solve() << endl;
}

Measured memory_bytes: 12536
#include "bits/stdc++.h"
using namespace std;

int main() {
	int x = 0;
	string a;
	cin >> a;
	x += a.at(0) - 48;
	x += a.at(1) - 48;
	x += a.at(2) - 48;
	cout << x << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let n=read();
    let mut v: Vec<i64> = Vec::new();
    for i in 0..n{
        let k:i64=read();
        v.push(k);
    }
    v.sort();
    let mut sum:i64=0;
    for i in 0..n-1{
        sum+=v[i];
    }
    if(v[n-1]>=sum){
        println!("No");
    }else{
        println!("Yes");
    }
}

Measured memory_bytes: 2124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int d = 0; d < W; d++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}


Measured memory_bytes: 34860
//AOJ 0200
//菴ソ縺?婿繧ゅｏ縺九ｉ縺ェ縺?¥縺帙↓include縺励∪縺上ｋ莠コ髢薙?繧ッ繧コ
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<deque>
using namespace std;
#define INF 1 << 20
#define MAX_B 101

int a, b, i, j, k, money[MAX_B][MAX_B], time[MAX_B][MAX_B], n, m, c, d;
bool judge;
stack<int> left, right;


int main(){
  while(1){
    scanf("%d %d", &n, &m);
    if(n == 0 && m == 0) return 0;
    for(i = 1; i <= m; i++){
      for(j = 1; j <= m; j++){
	money[i][j] = INF;
	time[i][j] = INF;
      }
    }
    for(i = 1; i <= m; i++){
      money[i][i] = 0;
      time[i][i] = 0;
    }
    for(i = 0; i < n; i++){
      scanf("%d %d %d %d", &a, &b, &c, &d);
      money[a][b] = c;
      money[b][a] = c;
      time[a][b] = d;
      time[b][a] = d;
    }
    scanf("%d", &a);
    for(i = 1; i <= m; i++){
      for(j = 1; j <= m; j++){
	for(k = 1; k <= m; k++){
	  if(money[j][k] > money[j][i] + money[i][k]){
	    money[j][k] = money[j][i] + money[i][k];
	    money[k][j] = money[j][i] + money[i][k];
	  }
	  if(time[j][k] > time[j][i] + time[i][k]){
	    time[j][k] = time[j][i] + time[i][k];
	    time[k][j] = time[j][i] + time[i][k];
	  }
	}
      }
    }
    for(i = 0; i < a; i++){
      scanf("%d %d %d", &b, &c, &d);
      if(d == 1)
	printf("%d\n", time[b][c]);
      if(d == 0)
	printf("%d\n", money[b][c]);
    }
  }
  return 0;
}

Measured memory_bytes: 1116
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <iterator>
#include <utility>
#include <iomanip>
#include <stack>
#include<bitset>
#include <cmath>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > >pq;
vector<ll>adj[1000005];
ll expo(ll b,ll n,ll m)
{
 ll r,p;
	p=1;
	 b=b%m;
	while(n>0)
	{ 
		r=n%2;
		if(r==1)
		   p=((p)*(b))%m;
		b=((b)*(b))%m; 
		n=n/2;		
	}
 return (p%m);
}
ll divide1(ll a,ll b,ll m)
	{ ll r,p,n;
			p=a%m;
				n=m-2;
				while(n>0){
						 r=n%2;
						if(r==1)
							p=((p%m)*(b%m))%m;
						b=((b%m)*(b%m))%m; 
						n=n/2;	
					}
	return (p%m); }
char c[1000002];
int main(int argc, char const *argv[])
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL),cout.tie(NULL);
	ll n,w=0, ans,r=0,f;
	cin>>n;
	f = n;
	for (int i = 0; i < n; ++i)
	{
		cin>>c[i];
		if (c[i]=='W'){
			w++;
		}
		if(c[i]=='R'){
			r++;
		}
	}
	ans = min(w,r);
	ll r1=r;
	for (int i = 0; i < r1; ++i)
	{
		r -= (c[i]=='R');
	}
	cout<<min(ans, r)<<endl;
	return 0;
}


Measured memory_bytes: 27236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	 int n,m,i,j,k,a,b,s;
	 double ave;
	 while(scanf("%d %d",&a,&b)!=EOF)
	 {
	 	ave=(a+b)/2.0;
	 	printf("%d\n",(int)(ave+0.5));
	 }
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi p(n);
    rep(i,0,n)cin>>p[i];
    vi tomodify;
    rep(i,0,n){
        if(p[i]==i+1){
            tomodify.push_back(i);
        }
    }
    int cnt=0;
    for(int i=0;i<tomodify.size();i++){
        if(i+1<tomodify.size()){
            if(tomodify[i+1]-tomodify[i]==1){
                cnt++;
                i++;
            }
            else{
                cnt++;
            }
        }
        else {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 1276
import java.util.Scanner;

public class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H == 0 && W == 0) break;
            for(int i = 1 ; i <= H ; i++){
                if(i % 2 != 0){
                    for(int j = 1 ; j <= W ; j++){
                        if(j % 2 != 0)  System.out.print("#");
                        else System.out.print(".");
                    }
                    System.out.println();
                }else{
                    for(int j = 1 ; j <= W ; j++){
                        if(j % 2 != 0)  System.out.print(".");
                        else System.out.print("#");
                    }
                    System.out.println();
                }
            }
            System.out.println();
        }
        
    }
}


Measured memory_bytes: 37572
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;++i)
#define INF 1e9
typedef long long llong;
using namespace std;

int n,a,b,c;
int l[8];

int dfs(int cnt,int an,int bn,int cn){
	if(cnt==n){
		if(an==0||bn==0||cn==0) return INF;//例外処理.
		else return abs(a-an)+abs(b-bn)+abs(c-cn)-30;//-30はa,b,cそれぞれの初めの余分なMPの調整.
	}
	
	int ret0=dfs(cnt+1,an,bn,cn);//l[cnt]を使わない場合.
	int ret1=dfs(cnt+1,an+l[cnt],bn,cn)+10;//aの材料に使う場合(+10MP).
	int ret2=dfs(cnt+1,an,bn+l[cnt],cn)+10;//bの材料に使う場合(+10MP).
	int ret3=dfs(cnt+1,an,bn,cn+l[cnt])+10;//cの材料に使う場合(+10MP).
	
	return min({ret0,ret1,ret2,ret3});//retのうちの最小値.
}

int main(){
	cin>>n>>a>>b>>c;
	REP(i,n) cin>>l[i];
	
	cout<<dfs(0,0,0,0)<<endl;
}//解答解説参考.

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;
  for(v=0;v < n; v++){
    if(M[u][v] == 0)continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;
  for(u = 0 ; u < n ; u++)color[u] = WHITE;
  tt = 0 ;
  for(u = 0 ; u < n ; u++){
    if(color[u] == WHITE)dfs_visit(u);
  }
  for(u = 0 ; u < n ; u++){
    printf("%d %d %d\n",u + 1 ,d[u],f[u]);
  }
}

int main(){
  int u, v, k, i,j;

  scanf("%d",&n);
  for(i=0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++)M[i][j] = 0 ;
  }
  for(i = 0; i < n ; i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  dfs();

  return 0;

}



Measured memory_bytes: 2052
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
A=list(map(int,input().split()))
s="APPROVED"
for i in range(n):
    if(A[i]%2==0):
        if not (A[i]%3==0 or A[i]%5==0):
            s="DENIED"
            break
            
print(s)

Measured memory_bytes: 3060
from sys import stdin



############################################
#from sys import stdin
import numpy as np

# read data for n sequences.
input = stdin.readline().split()
m = int(input[0])
n = int(input[1])
#n = int(stdin.readline().split()[1])
data = np.zeros(n)
d = stdin.readline().split()
for i,x in enumerate(d):
    data[i] = int(x)
data = sorted(data)

dif = np.zeros(len(data)-1)
for x in range(0, len(data)-1):
    dif[x] = data[x+1]-data[x]

out = 0

# split in m data.
#print(data)
dif = np.zeros(len(data)-1)
for x in range(0, len(data)-1):
    dif[x] = data[x+1]-data[x]
out = sum(sorted(dif, reverse=True)[m-1:])

            

print(int(out))
            

Measured memory_bytes: 27104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<ll>());
  vl x(2);
  int j = 0;
  rep(i, n - 1) {
    if(a[i] != a[i + 1]) continue;
    x[j] = a[i];
    i++;
    j++;
    if(j == 2) break;
  }
  cout << x[0] * x[1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  sort(V.begin(),V.end());
  int A=1;
  
  for(int i=0;i<N-1;i++){
    if(V.at(i)<V.at(i+1)){
      A++;
    }
  }
  cout << A <<endl;
}

Measured memory_bytes: 3592
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
use std::str::FromStr;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// N M
// input! {
//     N: i32,
//     M: i32,
// }

// N
// a1, ..., aN
// input! {
//     N: i32,
//     A: [i32, N],
// }

// H W
// a11 ... a1W
// ...
// aH1 ... aHW
// input! {
//     H: i32,
//     W: i32,
//     A: [[i32, W], H],
// }

// S
// input! {
//     S: chars,
// }

fn main() {
    input! {
        N: usize,
        S: chars,
        K: usize,
    };

    let sk = S[K - 1];
    let mut ans = vec![];

    for s in S {
        if s == sk {
            ans.push({s});
        } else {
            ans.push({'*'});
        }
    }
    println!("{}", ans.into_iter().collect::<String>());
}


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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  rep(i,n) {
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());
  string a = s[0];
  ll count = 0;
  vector<ll> q;
  rep(i,n) {
    if(a == s[i]) count++;
    else {
      q.push_back(count);
      count = 1;
      a = s[i];
    }
  }
  q.push_back(count);
  rep(i,q.size()) {
    ll c = q[i];
    ans += c*(c-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8444
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
A = list(map(int, readline().split()))
A.sort(reverse=True)

alice = bob = 0

for i, num in enumerate(A):
    if i % 2 == 0:
        alice += num
    else:
        bob += num

print(alice - bob)


Measured memory_bytes: 2940
//AnkitCode99 here....
#include<bits/stdc++.h>
#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define mp make_pair
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)
using namespace std;

const ll sz=100005;
const ll szz=1000006;

ll n,k;
ll ar[sz],cache[sz];

// TOP - DOWN Approach

ll dp(ll idx)
{
    if(idx>n)
        return ll(1e9);

    if(idx==n)
        return 0;

    if(cache[idx]!=-1)
        return cache[idx];
    
    ll mini=inf;
    for(ll i=1;i<=k and i+idx<=n;i++)
    {
        mini=min(mini,abs(ar[idx]-ar[idx+i])+dp(idx+i) );
    }
    // cout<<idx<<" "<<mini<<endl;
    cache[idx]=mini;
    // cache[idx]=min(abs(ar[idx]-ar[idx+1])+dp(idx+1),abs(ar[idx]-ar[idx+2])+dp(idx+2));
    return cache[idx];
}

int main()
{
    fast;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("op.txt","w",stdout);
    // #endif

    cin>>n>>k;
    memset(cache,-1,sizeof cache);
    rep(i,1,n+1)
    {
        cin>>ar[i];
    }    
    
    cout<<dp(1)<<endl;

    // rep(i,1,n+1)
    //     cout<<cache[i]<<" ";
}//Goodbye...

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin >> k;
	unsigned long long cnt=0;
	for(int a=1;a<=k;a++){
		for(int b=1;b<=k;b++){
			for(int c=1;c<=k;c++)cnt+=__gcd(__gcd(a,b),c);
		}
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll r,g; cin >> r >> g;
  cout << 2*g - r << endl;
}

Measured memory_bytes: 3624
// #include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}
  
int main(){
    int t=1;
    // read(t);
    while(t--){
        string s;
        cin>>s;
        ll ans=0;
        for(auto tmp:s){
            ans+=tmp-48;
        }
        puts(ans%9?"No":"Yes");
    }
    return 0;
}

Measured memory_bytes: 3364
import itertools

s=list(input())
n=len(s)-1
ans=0

for lst in itertools.product(range(2),repeat=n):
  x=s[0]
  for i in range(n):
    if lst[i]==0:
      x+=s[i+1]
    else:
      x=int(x)
      ans+=x
      x=s[i+1]
    
  x=int(x)
  ans+=x
      
print(ans)

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


int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==5&&b==5&&c==7) cout<<"YES"<<endl;
  else if(a==5&&b==7&&c==5) cout<<"YES"<<endl;
  else if(a==7&&b==5&&c==5) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <unordered_set>
#include <unordered_map>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
  int N;
  int minusCnt = 0;
  ll minabs = INT_MAX;
  cin >> N;
  ll total = 0;
  for (int i = 0; i < N; i++) {
    ll A;
    cin >> A;
    if (A < 0) minusCnt++;
    minabs = min(minabs, abs(A));
    total += abs(A);
  }
  if (minusCnt & 1) {
    total -= 2 * minabs;
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 384
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])

  let sum = 0
  for (let i = 0; i < N; i++) {
    const [price, currency] = input[i + 1].split(' ')
    if (currency === 'BTC') {
      sum += parseFloat(price) * 380000
    } else {
      sum += parseFloat(price)
    }
  }

  console.log(sum)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30424
//
// Created by たかえすみずき on 2017/07/15.
//

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

ll abs1(ll num){
    if(num >= 0) return num;
    else return -num;
}

int main() {
    int n;
    cin >> n;
    vector<ll> sumarr;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            ll tmp;
            cin >> tmp;
            sumarr.push_back(tmp);
        } else {
            ll tmp;
            cin >> tmp;
            sumarr.push_back(sumarr[sumarr.size() - 1] + tmp);
        }
    }
    ll sum = sumarr[sumarr.size() - 1];
    ll min = 5000000000000000;

    for(int i = 0; i + 1 < sumarr.size(); i++){
        if(min > abs1(sum - 2 * sumarr[i])){
            min = abs1(sum - 2 * sumarr[i]);
        }
    }
    cout << min << endl;
}


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

int main(){
	int n, m, A[100][100], b[100], c[100];

	cin >> n >> m;
	for ( int i = 0; i < n; i++ )
	for ( int j = 0; j < m; j++ ) cin >> A[i][j];
	for ( int i = 0; i < m; i++ ) cin >> b[i];

	for ( int i = 0; i < n; i++ ){
		c[i] = 0;
		for ( int j = 0; j < m; j++ ){
			c[i] += A[i][j]*b[j];	
		}
	}
	
	for ( int i = 0; i < n; i++ ) cout << c[i] << endl;

	return 0;
}


Measured memory_bytes: 3136
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template<class S,class T>
string to_string(pair<S,T> p){
	return "{"+to_string(p.first)+","+to_string(p.second)+"}";
}

template <class T>
string to_string(unordered_set<T> s){
	string ret="{";
	for(T t:s)ret+=to_string(t)+",";
	ret+="}";
	return ret;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
	cin.tie(0);
	int H,W,A,B;
	cin>>H>>W>>A>>B;
	if(A*2>W||B*2>H){
		print("No");
		return 0;
	}
	FOR(i,H){
		FOR(j,W){
			if((i<B)^(j<A)){
				cout<<0;
			}else{
				cout<<1;
			}
		}
		cout<<"\n";
	}
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using i64 = long long;

constexpr i64 mod = 1000000007;
std::string l, r;
i64 dp[61][2][2][2];

// l <= x, y <= r, MSB is fixed
i64 rec(int p, int a, int b, int c) {
    if (!p) return 1;
    if (dp[p][a][b][c] >= 0) return dp[p][a][b][c];

    i64 ret = 0;
    if (a || l[60 - p] == '0') {
        ret = (ret + rec(p - 1, a, r[60 - p] == '1' || b, c)) % mod;
    }
    if (b || r[60 - p] == '1') {
        ret = (ret + rec(p - 1, l[60 - p] == '0' || a, b, 1)) % mod;
    }
    if (c && (l[60 - p] == '0' || a) && (r[60 - p] == '1' || b)) {
        ret = (ret + rec(p - 1, a, b, c)) % mod;
    }
    return dp[p][a][b][c] = ret;
}

int main() {
    i64 ll, rr;
    std::cin >> ll >> rr;
    for (i64 i = 59; i >= 0; --i) l += '0' + ((ll >> i) & 1);
    for (i64 i = 59; i >= 0; --i) r += '0' + ((rr >> i) & 1);
    for (auto &w : dp) for (auto &x : w) for (auto &y : x) for (auto &z : y) z = -1;
    std::cout << rec(60, 0, 0, 0) << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> a(n + 1);
    rep(i, n + 1)a[i] = i;
    vector<ll> a_sum(n + 2);
    a_sum[0] = 0;
    _rep(i, 1, n + 2){
        a_sum[i] = a_sum[i - 1] + a[i - 1];
        //cout << a_sum[i] << endl;
    }

    ll ans = 0;
    rep(i, n - k + 2){
        ans += (a_sum[n + 1] - a_sum[(n + 1 - k) - i]) - a_sum[k + i] + 1;    
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6340
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC200420
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] hwd = ReadInts();
            int h = hwd[0];
            int w = hwd[1];
            int d = hwd[2];
            bool[,] grid = new bool[h, w];
            for (int i = 0; i < h; i++)
            {
                string s = Read();
                for (int j = 0; j < w; j++)
                {
                    grid[i, j] = s[j] == '.';
                }
            }

            int res = 0;
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j + d - 1 < w; j++)
                {
                    bool ok = true;
                    for(int k = 0; k < d; k++)
                    {
                        if (grid[i, j + k])
                        {
                            continue;
                        }

                        ok = false;
                        break;
                    }
                    if (ok)
                    {
                        res++;
                    }
                }
            }
            for (int i = 0; i + d - 1 < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    bool ok = true;
                    for(int k = 0; k < d; k++)
                    {
                        if (grid[i + k, j])
                        {
                            continue;
                        }

                        ok = false;
                        break;
                    }
                    if (ok)
                    {
                        res++;
                    }
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        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); }
    }
}



Measured memory_bytes: 17884
N = int(input())
S = list(map(int,input().split()))
Q = int(input())
T = list(map(int,input().split()))

def binary_searach(A, key):   
    left = 0
    right = len(A)
    while(left < right):
        mid = int((left + right) / 2 )
        if A[mid] == key:
            return mid
        elif A[mid] > key:
            right = mid
        else:
            left = mid + 1
    return None

count = 0
for i in T:
    num = binary_searach(S, i)
    if num is not None:
        count += 1
print(count)


Measured memory_bytes: 16716
#include <stdio.h>


int main(void)
{
  int a[150]={0};

  char c;

  for (; c != '\n';) {
    scanf("%c", &c);
    if (a[c] == 0){
      a[c]++;
    }
  }

  char ans;
  int ans_n=0;

  for (int i = 'z'; i >= 'a'; i--) {
    if (a[i] == 0) {
      ans = i;
      ans_n++;
    }
  }

  if (ans_n == 0) {
    printf("None\n");
  } else {
    printf("%c\n", ans);
  }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t;
	cin>>n;
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		ans+=(n-1)/i;
	}
	cout<<ans;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstring>

using namespace std;

struct Data{
	int len;
	char data;
};

int n, i=0;
Data val[50];

int solve(){
	int ans, depth = val[i].len;
	char c=val[i++].data;
	if(c=='+')ans=0;
	else if(c=='*') ans=1;

	while(i<n && val[i].len > depth){
		if(isdigit(val[i].data)){
			if(c=='+')ans+=val[i++].data-'0';
			else if(c=='*') ans*=val[i++].data-'0';
		} else{
			if(c=='+')ans+=solve();
			else if(c=='*') ans*=solve();
		}
	}
	return ans;
}

int main(){
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0; i<n; i++){
			val[i].len = 0;
			val[i].data = '\0';
		}
		char tmp[50];
		for(int i=0; i<n; i++){
			cin >> tmp;
			val[i].len = strlen(tmp);
			val[i].data= tmp[strlen(tmp)-1];
		}
		i=0;
		if(n==1) cout << val[i].data << endl;
		else cout << solve() << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
N,W = map(int,input().split())
wv = []
for i in range(N):
  wv.append(list(map(int,input().split())))
dp = []
for i in range(N+1):
  dp.append([0 for _ in range(W+1)])
for i in range(N-1,-1,-1):
  for j in range(0,W+1):
    if j < wv[i][0]:
      dp[i][j] = dp[i+1][j]
    else:
      dp[i][j] = max(dp[i+1][j],dp[i+1][j-wv[i][0]]+wv[i][1])
print(dp[0][W])

Measured memory_bytes: 171528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int f = scan.nextInt();
		int r = scan.nextInt();
		
		while(m != -1 || f != -1 || r != -1 ) {
			if(m == -1 || f == -1) {
				System.out.println("F");
			} else {
			int S = m + f;
			if(S >= 80) {
				System.out.println("A");
			} else if(S >= 65 && S < 80) {
				System.out.println("B");
			} else if(S >= 50 && S < 65) {
				System.out.println("C");
			} else if (S < 30) {
				System.out.println("F");
			} else {
			    if(r >= 50) {
			    	System.out.println("C");
			    } else {
			    	System.out.println("D");
			    }
			}
					}
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
		}
	}
}

Measured memory_bytes: 26324
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b)swap(a,b);
	if((b-a)%2==0)printf("%lld\n",(b-a)/2);
	else
	{
		ll ans=min(b-1,n-a);
		ans=min(ans,a+(b-a-1)/2);
		ans=min(ans,n-b+1+(b-a-1)/2);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

double compute_prob(double *p, size_t n) {
    double fX[n+1], res = 0.0;
    fX[0] = 1 - p[0];
    fX[1] = p[0];
    size_t i, x;
    for (x = 2 ; x<=n ; x++) fX[x] = 0.0;
    for (i = 1 ; i<n ; i++) {
        for (x = i+1 ; x ; x--) {
            fX[x] = fX[x]*(1-p[i]) + fX[x-1]*p[i];
        }
        fX[0] *= 1-p[i];
    }
    for (x = n/2+1 ; x<=n ; x++) res += fX[x];
    return res;
}

int main() {
    unsigned N;
    scanf("%u", &N);
    double p[N];
    for (unsigned i = 0 ; i<N ; i++) scanf("%lf", p+i);
    printf("%.10f", compute_prob(p, N));
    return 0;
}


Measured memory_bytes: 384
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
    long long a;
    cin>>a;
    string s;
    cin>>s;
    vector<long long> vec1(a,0);
    vector<long long> vec2(a,0);
    if(s.at(0)=='W'){
        vec1.at(0)++;
    }
    if(s.at(a-1)=='E'){
        vec2.at(0)++;
    }
    for(int i=1;i<a;i++){
        if(s.at(i)=='W'){
            vec1.at(i)=vec1.at(i-1)+1;
        }
        else{
            vec1.at(i)=vec1.at(i-1);
        }
        if(s.at(a-1-i)=='E'){
            vec2.at(i)=vec2.at(i-1)+1;
        }
        else{
            vec2.at(i)=vec2.at(i-1);
        }
    }
    long long ans=0;
    long long min=1000000;
    rep(i,a){
        if((vec1.at(i)+vec2.at(a-i-1)-1)<min){
            min=vec1.at(i)+vec2.at(a-i-1)-1;
        }
    }
    cout<<min<<endl;
    /*rep(i,a){
        cout<<vec1.at(i)<<" "<<vec2.at(i)<<endl;
    }*/

    
}


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

class dice
{
public:
  int number[6] ;
  void x_axis()
  {
    int cmp = number[0] ;
    number[0] = number[1] ;
    number[1] = number[5] ;
    number[5] = number[4] ;
    number[4] = cmp ;
  }
  void y_axis()
  {
    int cmp = number[1] ;
    number[1] = number[2] ;
    number[2] = number[4] ;
    number[4] = number[3] ;
    number[3] = cmp ;
  }
  void z_axis()
  {
    int cmp = number[0] ;
    number[0] = number[2] ;
    number[2] = number[5] ;
    number[5] = number[3] ;
    number[3] = cmp ;
  }
};
dice d[100] ;

class check
{
public:
  bool all( int a,int b )
  {
    int Count = 0 ;
    for ( int i = 0 ; i < 6 ; i++ )
    {
      if ( d[a].number[i] == d[b].number[i] ) Count++ ;
    }
    if ( Count == 6 ) return true ;
    return false ;
  }
  bool x_axis( int a,int b )
  {
    int Count = 0 ;
    if ( d[a].number[0] == d[b].number[0] ) Count++ ;
    if ( d[a].number[1] == d[b].number[1] ) Count++ ;
    if ( d[a].number[4] == d[b].number[4] ) Count++ ;
    if ( d[a].number[5] == d[b].number[5] ) Count++ ;
    if ( Count == 4 ) return true ;
    return false ;
  }
  bool y_axis( int a,int b )
  {
    int Count = 0 ;
    if ( d[a].number[1] == d[b].number[1] ) Count++ ;
    if ( d[a].number[2] == d[b].number[2] ) Count++ ;
    if ( d[a].number[3] == d[b].number[3] ) Count++ ;
    if ( d[a].number[4] == d[b].number[4] ) Count++ ;
    if ( Count == 4 ) return true ;
    return false ;
  }
  bool z_axis( int a,int b )
  {
    int Count = 0 ;
    if ( d[a].number[0] == d[b].number[0] ) Count++ ;
    if ( d[a].number[2] == d[b].number[2] ) Count++ ;
    if ( d[a].number[3] == d[b].number[3] ) Count++ ;
    if ( d[a].number[5] == d[b].number[5] ) Count++ ;
    if ( Count == 4 ) return true ;
    return false ;
  }
};

check check ;
int n ;
bool flg ;
/*
bool check( int a,int b )
{
  int Count = 0 ;
  for ( int i = 0 ; i < 6 ; i++ )
  {
    if ( d[a].number[i] == d[b].number[i] ) Count++ ;
  }
  if ( Count == 6 ) return true ;
  return false ;
}
*/
int main()
{
  cin >> n ;
  for ( int i = 0 ; i < n ; i++ )
  {
    for ( int j = 0 ; j < 6 ; j++ )
    {
      cin >> d[i].number[j] ;
    }
  }
  for ( int i = 1 ; i < n ; i++ )
  {
    for ( int j = 0 ; j < 50 ; j++ )
    {
      if ( check.all(0,i) )
      {
        flg = true ;
        break ;
      }
      for ( int k = 0 ; k < 36 ; k++ )
      {
        if ( check.x_axis(0,i) ) break ;
        if ( k == 3  || k == 7  || k == 11 || k == 15 ) d[i].y_axis() ;
        if ( k == 19 || k == 23 || k == 27 || k == 31 ) d[i].z_axis() ;
        d[i].x_axis() ;
      }
      for ( int k = 0 ; k < 50 ; k++ )
      {
        if ( check.y_axis(0,i) ) break ;
        d[i].y_axis() ;
      }
      for ( int k = 0 ; k < 50 ; k++ )
      {
        if ( check.z_axis(0,i) ) break ;
        d[i].z_axis() ;
      }
    }
    if ( flg ) break ;
  }
  if ( !flg ) puts("Yes") ;
  else puts("No") ;
  return 0 ;
}

Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
int n,maxv=-1;
cin>>n;
int num[2][n];
for(int i=0;i<n;i++)cin>>num[0][i];
for(int i=0;i<n;i++)cin>>num[1][i];
for(int i=0;i<n;i++){
int sum=0;
for(int j=0;j<=i;j++)
sum+=num[0][j];
for(int j=i;j<n;j++)
sum+=num[1][j];
maxv=max(sum,maxv);
}
cout<<maxv;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int H, W, N; cin >> H >> W >> N;
  int M = max(H, W);
  int ans = N / M;
  if (N % M != 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <list>
#include <map>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <stdlib.h>

using namespace std;

void solve(int a, int L) {
	vector<int> d;	
	d.push_back(a);

	for(int i = 1; ; i++) {
		char tmp[7];

		sprintf(tmp,"%d",a);
		int size = strlen(tmp);
		tmp[L] = '\0';
		for(int j = size; j < L; j++) {
			tmp[j] = '0';
		}
			
		sort(tmp, tmp+L);
		int x = atoi(tmp);
		reverse(tmp, tmp+L);
		int y = atoi(tmp);
	
		a = y-x;
		for(int j = 0; j < d.size(); j++) {
			if(a != d[j]) continue;

			cout << j << " " << a << " " << i - j << endl;
			return;
		}
		d.push_back(a);
	}

}

int main(void) {
	
	while(true) {
		int a, L;

		cin >> a >> L;

		if(a == 0 && L == 0) return 0;

		solve(a, L);
	}

	return 0;
}

Measured memory_bytes: 0
object Main {
  def main(args:Array[String]) {
    val N = readLine().toInt
    for(i <- 1 until 10) {
      for(j <- 1 until 10) {
        if(i * j == N) {
          println("Yes")
          return 0
        }
      }
    }
    println("No")
  }
}


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


int main(){
  ll a;
  cin >> a;
  ll ans = a + a*a + a*a*a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define maxn 100001
#define maxM 514
#define maxq (1<<18)

using namespace std;

int n,v[maxq],w[maxq],tt,f[maxM][maxn];

int main() {
    //freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin>>n;

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

    for (int t=0;t<maxn;t++) {
        if (t<w[1]) f[1][t] = 0;
        else f[1][t] = v[1];
    }

    for (int i=2;i<min(maxM,n+1);i++) {
        int p = i/2;
        for (int t=0;t<maxn;t++) {
            f[i][t] = f[p][t];
            if (t>=w[i]) f[i][t] = max(f[i][t],f[p][t-w[i]] + v[i]);
        }
    }

    cin>>tt;

    while (tt--) {
        int node,L;
        cin>>node>>L;

        vector<int> q;
        while (node>=maxM) {
            q.push_back(node);
            node/=2;
        }
        //cout<<node<<" "<<L<<endl;

        int sz = q.size();
        //cout<<sz<<endl;
        int res = 0;
        for (int t=0;t<(1<<sz);t++) {
            int sv=0;
            int sw=0;
            for (int i=0;i<sz;i++)
                if (t&(1<<i)) {
                    sv += v[q[i]];
                    sw += w[q[i]];
                }

            if (L>=sw) res=max(res,f[node][L-sw] + sv);
        }
        cout<<res<<endl;
    }

}


Measured memory_bytes: 206048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int d = a/b;
        int r = a%b;
        double f = (double)a/b;
        
       	System.out.printf("%d %d %f",d,r,f);
    }
    
}


Measured memory_bytes: 26496
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);

  int sosu[1001] = {0};
  int flag = 0;
  for(int i = 2;i <= n;i ++){
    int temp = i;
    for(int j = 2;j <= i;j ++){
      flag = 0;
      while(flag == 0){
        if(temp%j == 0){
          sosu[j] ++;
          temp /= j;
        }
        else{
          flag = 1;
        }
      }
    }
  }

  long long ans = 1;
  for(int i = 1;i < 1000;i ++){
    ans *= (sosu[i]+1);
    if(ans > 1000000007){
      ans %= 1000000007;
    }
  }

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

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] += 'A' - 'a';
	b[0] += 'A' - 'a';
	c[0] += 'A' - 'a';
	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

int main()
{
  vector<vector<int>> vv(4);
  for (int i = 0; i < 3; i++) {
    int a, b; cin >> a >> b;
    a--, b--;
    vv[a].PB(b);
    vv[b].PB(a);
  }

  for (int i = 0; i < 4; i++) {
    if (vv[i].size() == 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0 for _ in range(n)]
for i in range(1, n):
    dp[i] = min([dp[j] + abs(h[j] - h[i]) for j in range(max(0, i-k), i)])

print(dp[n-1])

Measured memory_bytes: 56544
import sys

s = input()
t = input()

tset = set(t)
slen = len(s)

if len(tset - set(s)) != 0:
    print(-1)
    sys.exit()

s2t = [i - ord('a') for i in (s + s).encode('ascii')]
lut = [[-1 for _ in range(slen)] for _ in range(26)]
for c in tset:
  b = ord(c) - ord('a')
  j = 0
  for i in range(slen * 2 - 1, -1, -1):
    if s2t[i] == b:
      j = 0
    else:
      j += 1
    if i < slen:
      lut[b][i] = j

p = 0
for c in t:
  b = ord(c) - ord('a')
  p += lut[b][p % slen] + 1
print(p)


Measured memory_bytes: 104684
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int differ = 0;//間違いを入れる
		
		for(int i=1; i<=N; i++) {
			int P =sc.nextInt();
        //iとPが一致していなければ間違いを+1する
		if(i!=P){
				differ++;
			}
		}
        //間違いが2つならそれを入れ替えて昇順にできる
        //2つ以内ならYes
		System.out.println(differ<=2?"YES":"NO");
	}
}

Measured memory_bytes: 21972
let s = read_line ()
let rec f m i c =
  if i >= String.length s then max m c
  else if String.contains "ACGT" s.[i] then f m (i + 1) (c + 1)
  else f (max m c) (i + 1) 0
let _ = Printf.printf "%d\n" @@ f 0 0 0

Measured memory_bytes: 384