akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b>c && c>a){
		if(b<d){
			cout<<b-c<<endl;
		}
		else{
			cout<<d-c<<endl;
		}
	}
	else if(a<d && a>c){
		if(b>d){
			cout<<d-a<<endl;
		}
		else{
			cout<<b-a<<endl;
		}
	}
	else if(a==c && b<d){
		cout<<b-a<<endl;
	}
	else if(a==c && b>d){
		cout<<d-c<<endl;
	}
	else if(a==c && b==d){
		cout<<b-a<<endl;
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def ex_euclid(x, y):
    c0, c1 = x, y
    a0, a1 = 1, 0
    b0, b1 = 0, 1

    while c1 != 0:
        m = c0 % c1
        q = c0 // c1
        c0, c1 = c1, m
        a0, a1 = a1, (a0 - q * a1)
        b0, b1 = b1, (b0 - q * b1)

    return c0, a0, b0


a, b = map(int, input().split())
ans = ex_euclid(a, b)
print(ans[1], ans[2])


Measured memory_bytes: 5600
import java.util.*;

public class Main{
	public static void main(String[] args){
		//new Main().printHelloWorld();
		//System.out.println(new Main().ITP1_1_B(Integer.parseInt(new Scanner(System.in).next())));
		//new Main().ITP1_1_C();
		//new Main().ITP1_1_D();
		//new Main().ITP1_2_A();
		//new Main().ITP1_2_B();
		//new Main().ITP1_2_C();
		//new Main().ITP1_2_D();
		//new Main().ITP1_3_A();
		//new Main().ITP1_3_B();
		//new Main().ITP1_3_C();
		//new Main().ITP1_3_D();
		new Main().ITP1_4_A();
	}

	public void printHelloWorld(){
		System.out.println("Hello World");
	}

	public int ITP1_1_B(int x){
		return x*x*x;
	}

	public void ITP1_1_C(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(a*b + " " + 2*(a+b));
	}

	public void ITP1_1_D(){
		int seconds = new Scanner(System.in).nextInt();
		System.out.println(seconds/3600 + ":" + (seconds%3600)/60 + ":" + (seconds%3600)%60);
	}

	public void ITP1_2_A(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println((a==b)?"a == b":(a > b)?"a > b":"a < b");
	}

	public void ITP1_2_B(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		System.out.println((a < b && b < c)?"Yes":"No");
	}

	public void ITP1_2_C(){
		Scanner scan = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = scan.nextInt();
		a[1] = scan.nextInt();
		a[2] = scan.nextInt();
		for(int i=0;i<a.length-1;i++){
			for(int j=i+1;j<a.length;j++){
				if(a[i] > a[j]){
					int t=a[i];a[i]=a[j];a[j]=t;
				}
			}
		}
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}

	public void ITP1_2_D(){
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		System.out.println((x+r<=w && x-r>=0 && y+r<=h && y-r>=0)?"Yes":"No");
	}

	public void ITP1_3_A(){
		for(int i=0;i<1000;i++){
			System.out.println("Hello World");
		}
	}

	public void ITP1_3_B(){
		Scanner scan = new Scanner(System.in);
		int i = 1;
		while(scan.hasNext()){
			int x = scan.nextInt();
			if(x == 0){
				break;
			}
			System.out.println("Case " + i + ": " + x);
			i++;
		}
	}

	public void ITP1_3_C(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int x = scan.nextInt();
			int y = scan.nextInt();
			if(x == 0 && y == 0){
				break;
			}
			System.out.println((x < y)?x+" "+y:y+" "+x);
		}
	}

	public void ITP1_3_D(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int count=0;
		for(int i=a;i<=b;i++){
			if(c%i==0){
				count++;
			}
		}
		System.out.println(count);
	}

	public void ITP1_4_A(){
		Scanner scan = new Scanner(System.in);
		Long a = scan.nextLong();
		Long b = scan.nextLong();
		System.out.printf("%d %d %.5f\n",a/b,a%b,(double)a/b);
	}
}

Measured memory_bytes: 26468
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n, m, p;
    int d[10000];
 
    scanf("%d %d %d", &n, &m, &p);
 
    for (int i = 0; i < m; i++){
        scanf("%d", d + i);
        d[i] = (d[i] - p + n) % n;
    }
 
    sort(d, d + m);
 
    int ret = n - 1;
 
    int c;
    for (int i = 0; i < m; i++){
        // 0 -> d[i] clockwise
        c = d[i];
        c += min(d[m - 1] - d[i], (d[i] + n - d[(i + 1) % m]) % n);
        ret = min(ret, c);
 
        // 0 -> d[i] counter - clockwise;
        c = n - d[i];
        c += min(d[i] - d[0], (d[(i + m - 1) % m] + n - d[i]) % n);
 
        ret = min(ret, c);
    }
 
    printf("%d\n", ret * 100);
 
    return (0);
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =1e5+5;

int a[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int f=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i+1])
            a[i]--;
        else if(a[i]!=a[i-1])
        {
            a[i]--;
        }
    }
    for(int i=1;i<n;i++)
    {
        if(a[i]>a[i+1])
        {
            f=1;
            break;
        }
    }
    if(f)
    {
        cout<<"No"<<'\n';
    }
    else
        cout<<"Yes"<<'\n';



}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int fact(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= n - i;
		ans %= mod;
	}
	return ans %= mod;
}

signed main(void) {
	int n, c, k;
	cin >> n >>c>> k;
	priority_queue<int,vector<int>,greater<int>>t;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		t.push(tmp);
	}
	int ans = 1;
	int passenger = 1;
	int start = t.top();
	t.pop();
	while (!t.empty()) {
		int front = t.top();
		t.pop();
		if ((front - start <= k) &&( passenger < c)) {
			passenger++;
		}
		else {
			ans++;
			start = front;
			passenger = 1;
		}
	}
	println(ans);
}

Measured memory_bytes: 4332
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

int curTime = 1;
void dfs(int cur, const vector<vector<bool> >& a, vector<int>& d, vector<int>& f, vector<bool>& visited){
  visited[cur] = true;
  d[cur] = curTime;
  curTime++;
  // cerr << "visiting [" << cur << "], time = " << curTime << endl;

  for(int dst = 1; dst <= a.size(); dst++){
    if(a[cur][dst] && !visited[dst]) {// cur????????¶??????????????????????????????
      dfs(dst, a, d, f, visited);
    }
  }
  f[cur] = curTime;
  curTime++;
  return;
}

int main(){
  int n;
  cin >> n;
  vector<vector<bool> > a(n+1, vector<bool>(n+1, false));
  for(int i = 1; i <= n; i++){
    int u;
    cin >> u;
    int k;
    cin >> k;
    for(int j = 0; j < k; j++){
      int v;
      cin >> v;
      a[i][v] = true;
    }
  }

  vector<bool> visited(n+1, false);
  vector<int> d(n+1), f(n+1);

  for(int i = 1; i <= n; i++){
    if(!visited[i]){
      dfs(i, a, d, f, visited);
    }
  }

  for(int i = 1; i <= n; i++){
    cout << i << " " << d[i] << " " << f[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N; cin >> N;
    vec a(N); readvec(a);

    int n_color = -1;
    REP(i, N) n_color = max(n_color, a[i]);
    int n = 0;
    REP(i, N){
        if(a[i] < n_color - 1){
            cout << "No";
            return 0;
        }
        if(a[i] == n_color - 1) n++;
    }

    if(n_color == N - 1 && n == 0){
        cout << "Yes";
    }else if(n + 1 <= n_color && n_color <= n + (N - n) / 2){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int c=0;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	REP(i,0,s1.length()-1){
		if(s1[i]!=s2[i])c++;
	}
	cout<<c;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 3984
import qualified Data.Vector as V
main = mapM_ (print . solve . map read . words) . lines =<< getContents
m=1000000007
solve [h,w,a,b] = foldr (\a b->(a+b)`mod`m) 0 $ map f [1..h-a] where
  fact = V.generate (h+w+1) $ \i->if i<2 then 1 else fact V.! (i-1)*i`mod`m
  d1=inv $ fact V.! (b-1)
  d2=inv $ fact V.! (w-b-1)
  f i = v1*v2`mod`m where
    v1 = fact V.! (b+i-2) * inv (fact V.! (i-1)) `mod` m * d1 `mod` m
    v2 = fact V.! (h-i+w-b-1) * inv (fact V.! (h-i)) `mod` m * d2 `mod` m
inv a =  inv' a m 0 1
inv' a b u v 
  |a==0 = (u+m)`mod`m
  |otherwise = let t=b`div`a in inv' (b-t*a) a v (u-t*v)

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const int kind=26;

int main(){
	int D;
	cin >> D;
	vector<int> c(kind);
	rep(i,kind) cin >> c[i];
	int c_sum=0;
	rep(i,kind) c_sum+=c[i];
	vector<vector<int>> s(D,vector<int>(kind));
	rep(i,D){
		rep(j,kind) cin >> s[i][j];
	}
	vector<int> t(D);
	rep(i,D) cin >> t[i];
	rep(i,D) t[i]--;
	int M;
	cin >> M;
	vector<int> d(M), q(M);
	rep(i,M) cin >> d[i] >> q[i];
	rep(i,M) d[i]--, q[i]--;
	rep(i,M){
		int ans=0, dec=0;
		vector<int> last(kind);
		t[d[i]]=q[i];
		for(int day=1; day<=D; day++){
			int k=t[day-1];
			ans+=s[day-1][k];
			dec+=c_sum;
			ans-=dec;
			ans+=c[k]*(day-last[k]);
			dec-=c[k]*(day-last[k]);
			last[k]=day;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3960
n = input()
n = n.split()
m = int(n[1])
n = int(n[0])
a = input()
a = a.split()
b = int(a[0])
for c in range(m-1):
    b = b + int(a[c+1])
if n - b < 0:
    print("-1")
else:
    print(n-b)

Measured memory_bytes: 9420
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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    println!("{}", if s[2] == s[3] && s[4] == s[5] {"Yes"} else {"No"});
}


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

int main()
{
  int n,sum=0;
  int m;
  cin >> n >> m;

  for(int i=0; i<m; i++){
    int data;
    cin >> data;
    sum+=data;
    if(sum>n)break;
  }

  if(sum>n)
    cout << -1 << endl;
  else
    cout << n-sum << endl;
  
  return 0;
}

Measured memory_bytes: 3624
n, q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q):
  l[i],r[i] = map(int,input().split())
count = 0
c_sum = [0]*n
for i in range(n-1):
  if s[i] == 'A' and s[i+1] == 'C':
    count += 1
  c_sum[i] = count
for i in range(q):
  print(c_sum[r[i]-2] - c_sum[l[i]-2])

Measured memory_bytes: 14156
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int N, Q; scanf("%d %d\n", &N, &Q);
    struct P {
        int y;
        string name;
    }
    P[] X = new P[N];
    foreach (i; 0 .. N) {
        int Y; scanf("%d ", &Y);
        string Name = readln.chomp;
        X[i] = P(Y, Name);
    }
    X.sort!"a.y < b.y";
    string Ans = "kogakubu10gokan";
    int i = 0;
    for (int y = 1; y <= Q; y++) {
        if (X[i].y == y) {
            Ans = X[i].name;
            i++;
            if (i == N) break;
        }
    }
    writeln(Ans);
}

Measured memory_bytes: 1100
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

int hs(string r){
  string s = r;
  int n = s.size(), res = 0, base = 1;
  REP(i,n){
    res += (s[i] - 'a') * base;
    res %= MOD;
    base *= 2;
  }
  return res;
}

int main(){
	ll N; cin >> N;
    string tmp;
    map<string, int> mp;
    REP(i,N){
      cin >> tmp;
      mp.insert(make_pair(tmp, hs(tmp)));
    }
    cout << mp.size();
  	return 0;
}

Measured memory_bytes: 19180
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int N = 1e5 + 100;
pii a[N], b[N];
pair<int, pii> es[N << 1];
int fa[N];
int getf(int x) { return x == fa[x] ? x : fa[x] = getf(fa[x]); }
int main() {
    int ecnt = 0;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) {
        scanf("%d %d", &a[i].X, &b[i].X);
        a[i].Y = b[i].Y = i;
    }
    for(int i = 1; i <= n; i ++) fa[i] = i;
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);
    for(int i = 1; i < n; i ++) {
        es[++ ecnt] = pair<int, pii>(a[i + 1].X - a[i].X, 
                pii(a[i + 1].Y, a[i].Y));
        es[++ ecnt] = pair<int, pii>(b[i + 1].X - b[i].X,
                pii(b[i + 1].Y, b[i].Y)); 
    }
    LL ans = 0;
    sort(es + 1, es + ecnt + 1);
    for(int i = 1; i <= ecnt; i ++) {
        int u = es[i].Y.X, v = es[i].Y.Y;
        if(getf(u) == getf(v)) continue;
        ans += es[i].X;
        fa[getf(u)] = getf(v);
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1)*a%MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1)*a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size()>n) return kaijo_memo[n];
  if(kaijo_memo.size()==0) kaijo_memo.push_back(1);
  while(kaijo_memo.size()<=n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1]*kaijo_memo.size()%MOD);
  return kaijo_memo[n];
}

signed main(){
	ll n,m; cin>>n>>m;

	if(abs(n-m)>1) cout<<0<<endl;
	else if(n==m) cout<<(((ll)2*kaijo(n))%MOD)*kaijo(m)%MOD;
	else cout<<(((
		kaijo(n))%MOD)*kaijo(m))%MOD;
	return 0;
}


Measured memory_bytes: 1400
n = gets.to_i
a = gets.strip.split(' ').map(&:to_i)
b = gets.strip.split(' ').map(&:to_i)
result = 0
n.times do |i|
  if a[i] < b[i]
    result += a[i]
    b[i] -= a[i]
    a[i] = 0
    if a[i+1] < b[i]
      result += a[i+1]
      a[i+1] = 0
    else
      result += b[i]
      a[i+1] -= b[i]
    end
  else
    result += b[i]
    a[i] -= b[i]
  end
end
puts result


Measured memory_bytes: 17556
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>

#define PI 3.14159265358979323846

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N-1);
    for (int i = 0; i < N-1; i++)cin >> A[i];
    sort(A.begin(), A.end());
    vector<int> B(N);

    for (int i = 0; i < N - 1; i++) {
        B[A[i]-1]++;
    }
    for (int i = 0; i < N; i++)cout << B[i] << endl;
    return 0;
}

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

int n;

int main(){
  cin >> n;
  int res = 1e9;
  for(int i = 0; i <= n; i++){
    int left = i, right = n - i;
    int sum6 = 0, sum9 = 0;
    while(left){
      sum6 += left % 6;
      left /= 6;
    }
    while(right){
      sum9 += right % 9;
      right /= 9;
    }
    res = min(sum6 + sum9, res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [0] * (N-K+1)
A[0] = sum(P[:K])
for i in range(N-K):
    A[i+1] = A[i] + P[K+i] - P[i]
m = 0
for i in range(N - K + 1):
    m = max(m, ((A[i] + K) / 2))
print(m)

Measured memory_bytes: 25060
X, K, D = (int(i) for i in input().split())

if abs(X) - abs(K * D) > 0:
    res =  abs(X) - abs(K * D)
else:
    m = abs(X) // abs(D)
    delta = abs(X) - abs(m * D)
    if (K - m) % 2 == 0:
        res = delta
    else:
        res = abs(delta - abs(D))

print(res)


Measured memory_bytes: 61640
N,M=map(int,input().split())
root=[-1]*N
def search(i):
    if root[i]>=0:
        root[i]=search(root[i])
        return root[i]
    return i
for i in range(M):
    x,y,z=map(int,input().split())
    x-=1
    y-=1
    rx=search(x)
    ry=search(y)
    if rx==ry:
        continue
    elif root[rx]<=root[ry]:
        root[ry]+=root[rx]
        root[rx]=ry
    else:
        root[rx]+=root[ry]
        root[ry]=rx
ans=0
for i in range(N):
    if root[i]<0:
        ans+=1
print(ans)


Measured memory_bytes: 6916
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int a[200005];
map<int, int> mii;
int main(){
	int n;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &a[i]);
	sort(a, a + n, greater<int>());
	REP(i, n)mii[a[i]]++;
	int x = 1 << 30;
	int ret = 0;
	REP(i, n) {
		while (a[i] < x)x >>= 1;
		if (mii[a[i]] == 0)continue;
		mii[a[i]]--;
		int target = (x << 1) - a[i];
		if (mii[target] > 0) {
			ret++;
			mii[target]--;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 19712
#include<bits/stdc++.h>
using namespace std;
int n,m,sum=0,p,x,a[100010];
int main() {
	cin>>n;
	for(int i=1;i<=n;++i) {
		cin>>a[i];
		sum+=a[i];
	}
	cin>>m;
	for(int i=1;i<=m;++i) {
		cin>>p>>x;
		cout<<sum-a[p]+x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    a = len(s); z = 0
    for i, t in enumerate(s):
        if t == 'A':
            a = min(a, i)
        if t == 'Z':
            z = max(z, i)
    ans = z-a+1
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9328
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[105],n,i,A=0,B=0,b,d,c,e,f;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n,greater<int>());
   for(i=0;i<n;i=i+2){
     A=A+a[i];
   }
   for(i=1;i<n;i=i+2){
     B=B+a[i];
   }
    A=A-B;
  cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
const LL m = 998244353;
LL dp[3005];
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  LL n,s; cin>>n>>s;
  vector <LL> v(n+1);
  LL an = 0;
  for(int i=1;i<=n;i++){
    LL a; cin>>a;
    if(s>a) (an += dp[s-a]*(n-i+1) )%=m;
    if(s==a) (an+=i*(n-i+1))%=m;
    for(int su = s; su>=0; su--)
      if(su>=a) (dp[su]+=dp[su-a])%=m;
    (dp[a]+=i)%=m;
  }
  cout<<an<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

struct Edge {
    ll to, cost;
    Edge(ll to, ll cost):to(to),cost(cost) {}
};

struct Data {
    ll v, x;  // いまいる頂点v, 進んだ距離x
    Data(ll v, ll x):v(v),x(x) {}
    bool operator<(const Data& hoge) const {
        return x > hoge.x;
    }
};

int main() {
    ll n;
    cin >> n;
    
    vector<vector<Edge>> G(n);
    rep(i, n-1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    ll q, sv;
    cin >> q >> sv;
    sv--;

    vl dp(n, INF);
    priority_queue<Data> Q;
    auto push = [&](ll v, ll x) {
        if(dp[v] <= x) {
            return;
        }
        dp[v] = x;
        Q.emplace(v, x);
    };
    
    // ダイクストラ法。計算量はO((V+E)*log(V))
    push(sv, 0);
    while(!Q.empty()) {
        Data hoge = Q.top();  Q.pop();
        ll v = hoge.v, x = hoge.x;
        if(dp[v] != x) {
            continue;
        }
        for(Edge e : G[v]) {
            push(e.to, dp[v] + e.cost);
        }
    }

    rep(i, q) {
        ll x, y;
        cin >> x >> y;
        x--;  y--;
        out(dp[x] + dp[y]);
    }

    re0;
}

Measured memory_bytes: 14100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
 
using namespace std;
 
int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b)*h/ 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int d[K];
  vector<vector<int> > A(K);
  int a;
  rep(i, K){
    cin >> d[i];
    rep(j, d[i]){
      cin >> a;
      A[i].push_back(a);      
    }
  }

  bool aru[N];
  rep(i, N)
    aru[i] = false;

  rep(i, N){
    rep(j, K){
      rep(k, A[j].size() ){
	if(A[j][k] == i+1)
	  aru[i] = true;
      }
    }
  }
    

  int ans = 0;
  rep(i, N)
    if(aru[i] == false)
      ans++;
  
  cout << ans << endl;


  return 0;
}


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

if K == 1:
  print(0)
  exit()

L = [-1] * N
D = {}
D[A[0] % K] = 1
t = A[0] % K
L[0] = t
for i in range(1, min(K - 1, N)):
  t = (t + A[i] - 1) % K
  if t < 0:
    t += K
  if t in D:
    D[t] += 1
  else:
    D[t] = 1
  L[i] = t

n = 1
if n in D:
  ans = D[n]
else:
  ans = 0
for i in range(N):
  if L[i] != -1:
    D[L[i]] -= 1
  if i + K - 1 < N:
    t = (t + A[i + K - 1] - 1) % K
    if t < 0:
      t += K
    if t in D:
      D[t] += 1
    else:
      D[t] = 1
    L[i + K - 1] = t
  n = (n - 1 + A[i]) % K
  #n -= 1
  if n < 0:
    n += K
  if n in D:
    ans += D[n]
  
print(ans)

Measured memory_bytes: 110796
MOD = 10**9 + 7

n,k = gets.chomp.split(" ").map(&:to_i)
ans = 0
for i in k..n+1
  ans += (n*(n+1)/2 - ((n-i)*(n-i+1)/2)) - (i*(i-1)/2) + 1
  ans %= MOD
end

puts ans

Measured memory_bytes: 14320
#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;

string ss;
int dp[1<<26], ans[N];

int main(){
	cin>>ss;
	int n = ss.size(), cur = 0;
	fill(dp, dp+(1<<26), 1<<30);
	dp[cur] = 0;
	for(int i=0;i<n;i++){
		cur ^= (1<<(ss[i]-'a'));
		ans[i] = dp[cur]+1;
		for(int j=0;j<26;j++) ans[i] = min(ans[i], dp[cur ^ (1<<j)]+1);
		dp[cur] = min(dp[cur], ans[i]);
	}
	cout<<ans[n-1]<<'\n';
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  int r;
  cin>>r;
  cout<<r*r<<endl;
}

Measured memory_bytes: 3636
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  map<char, int> mp;
  string s;
  cin >> s;
  rep(i, n) { mp[s[i]]++; }

  int cnt;
  cnt = min(mp['W'], mp['R']);
  map<char, int> ma;
  rep(i, mp['R']) { ma[s[i]]++; }
  int ans = min(cnt, ma['W']);  //あやしい
  cout << ans;
  return 0;
}


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

int main() {
  int n, m, ac = 0, o = 0;
  cin >> n >> m;
  vector<int> p(m), c(n), f(n);
  vector<string> s(m);
  for(int i = 0; i < m; i++) {
    cin >> p.at(i) >> s.at(i);
    if(s.at(i) == "WA" && !f.at(p.at(i) - 1))
      c.at(p.at(i) - 1)++;
    else
      f.at(p.at(i) - 1) = 1;
  }
  for(int i = 0; i < n; i++) {
    ac += f.at(i);
    if(f.at(i))
      o += c.at(i);
  }
  cout << ac << " " << o << endl;
}

Measured memory_bytes: 6912
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, _ := nextInt()

		if n == 0 {
			break
		}

		s := make([]int, n)
		for i := range s {
			s[i], _ = nextInt()
		}

		mean := 0.0
		squaredMean := 0.0
		for i := range s {
			x := float64(s[i])
			mean += x
			squaredMean += x * x
		}
		mean = mean / float64(n)
		squaredMean = squaredMean / float64(n)

		fmt.Println(math.Sqrt(squaredMean - mean*mean))
	}
}



Measured memory_bytes: 1108
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int main(){
	boost;
	int n;
	cin>>n;
	vector<long double> vec(n);
	for(auto& it:vec)
		cin>>it;
	sort(all(vec));
	long double ans=vec[0];
	for (int i = 1; i < n; ++i)
		ans=(ans+vec[i])/2.0;
	cout<<fixed<<setprecision(7)<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 256
import java.util.*;

public class Main{

  public static void main(String[] args) {
  
    Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        int steps = in.nextInt();
    
    if(n==0){
            System.out.println(0);
            return;
        }
        int []arr = new int[n];
        for(int i=0;i<n;i++)arr[i] = in.nextInt();
        int []dp = new int[n];
        dp[0] = 0;
        for(int i=1;i<n;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int k=1;k<=steps;k++){
                if((i-k)>=0){
                    dp[i] = Math.min(dp[i],(Math.abs(arr[i]-arr[i-k]))+dp[i-k]);
                }
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 50472
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A.at(i);
  sort(A.begin(),A.end());
  rep(i,N-1){
    if(A.at(i)==A.at(i+1)){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    println(problem065c(n, m))
}

fun problem065c(n: Long, m: Long): Long {
    if (Math.abs(n - m) >= 2) return 0
    val mod: Long = (Math.pow(10.0, 9.0) + 7).toLong()
    fun computeFactorial(n: Long): Long {
        return (1..n).toList().reduce { acc, l -> acc * l % mod }
    }

    return if (n != m) {
        computeFactorial(Math.max(n, m)) * computeFactorial(Math.min(n, m)) % mod
    } else {
        computeFactorial(n) * computeFactorial(n) * 2 % mod
    }
}

Measured memory_bytes: 40348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % s(n) == 0)System.out.println("Yes");
		else System.out.println("No");
	}
	
	static int s(int n) {
		int num = n;
		int sum = 0;
		while(num != 0) {
			sum += num % 10;
			num /= 10;
		}
		return sum;
	}
}

Measured memory_bytes: 21716
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N >> M >> K;
	cout << K << " " << N << " " << M << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int H, W, K;
char grid[6][6];
int res = 0;

int countblack() {
    int black = 0;
    for(int r=0; r<H; r++) {
        for(int c=0; c<W; c++) {
            if(grid[r][c]=='#') {
                black++;
            }
        }
    }
    return black;
}

//ith row or col
void fillways(int i) {
    if(i>=H+W) {
        //see if there is a solution
        int black = countblack();
        if(black==K) {
            res++;
        }
        return;
    }
    //rows
    if(i<H) {
        //consider not coloring this row red
        fillways(i+1);
        //consider filling this row with red
        for(int c=0; c<W; c++) {
            if(grid[i][c]=='.') {
                grid[i][c] = 'W';
            } else if(grid[i][c]=='#') {
                grid[i][c] = 'B';
            }
        }
        fillways(i+1);
        //backtrack
        for(int c=0; c<W; c++) {
            if(grid[i][c]=='W') {
                grid[i][c] = '.';
            } else if(grid[i][c]=='B') {
                grid[i][c] = '#';
            }
        }
    } else {
        //cols
        int c = i-H;
        //consider not coloring this col red
        fillways(i+1);
        //consider filling this row with red
        for(int r=0; r<H; r++) {
            if(grid[r][c]=='.') {
                grid[r][c] = 'E';
            } else if(grid[r][c]=='#') {
                grid[r][c] = 'F';
            }
        }
        fillways(i+1);
        //backtrack
        for(int r=0; r<H; r++) {
            if(grid[r][c]=='E') {
                grid[r][c] = '.';
            } else if(grid[r][c]=='F') {
                grid[r][c] = '#';
            }
        }
    }
}

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    cin >> H >> W >> K;
    for(int r=0; r<H; r++) {
        for(int c=0; c<W; c++) {
            cin >> grid[r][c];
        }
    }
    //brute force
    //fill row then fill column
    //at most 2^12 combinations
    //decide whether to fill row or not
    fillways(0);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std ;
int Max( int a, int b, int c, int i ){
    if( i == 0 ) return b > c ? b : c ;
    else if( i == 1 ) return a > c ? a : c ;
    else return a > b ? a : b ;
}
int main(){
    int N ;
    cin >> N ;
    int arr[N][3] ;
    for( int i = 0 ; i < N ; i++ ){
        for( int j = 0 ; j < 3 ; j++ ) cin >> arr[i][j] ;
    }
    int dp[3][N] ;
    for( int i = 0 ; i < 3 ; i++ ){
        for( int j = 0 ; j < N ; j++ ) dp[i][j] = 0 ;
    }
    for( int i = 0 ; i < 3 ; i++ ) dp[i][0] = arr[0][i] ;
    for( int i = 1 ; i < N ; i++ ){
        for( int j = 0 ; j < 3 ; j++ ){
            dp[j][i] = arr[i][j] + Max( dp[0][i-1] , dp[1][i-1] , dp[2][i-1] , j ) ;
        }
    }
    cout << max( dp[0][N-1], max( dp[1][N-1] , dp[2][N-1] ) ) << "\n" ;
    return 0 ;
}

Measured memory_bytes: 2560
# coding: utf-8
# Your code here!

while True:
   H, W = map(int, input().split())
   if H + W == 0: break
   for i in range(H):
      if (i == 0 or i == H - 1):
         for j in range(W):
            print("#", end = "")
         print("")
      else:
         for j in range(W):
            if (j == 0 or j == W - 1):
               print("#", end = "")
            else:
               print(".", end = "")
         print("")
   print("")



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

int main()
{
	int x[5];

	for (int i = 0; i < 5; i++) {
		cin >> x[i];
	}

	for (int i = 0; i < 5; i++) {
		if (x[i] == 0)
		{
			cout << i + 1;
		}
	}

	return 0;
}

Measured memory_bytes: 3636
n,ais = int(raw_input()), map(int, raw_input().split())
import collections
cc = collections.Counter()
for ai in ais:
	if ai % 4 == 0: cc[0] += 1
	elif ai % 2 == 0: cc[1] += 1
	else: cc[2] += 1

q = collections.deque()
while(n):
	if len(q) == 0:
		for u in range(3)[::-1]:
			if cc[u] > 0:
				q.append(u)
				cc[u]-=1
				n -=1
				break
		if len(q) == 0: break
	else:
		if q[-1] == 0:
			if cc[2]:
				q.append(2)
				cc[2]-=1
				n-=1
			elif cc[1]:
				q.append(1)
				cc[1]-=1
				n-=1
			elif cc[0]:
				q.append(0)
				cc[0]-=1
				n-=1
			else:
				break
		elif q[-1] == 2:
			if cc[0] == 0:
				break
			else:
				q.append(0)
				cc[0]-=1
				n-=1
		elif q[-1] == 1:
			if cc[1] > 0:
				q.append(1)
				cc[1]-=1
				n-=1
			else:
				break

print 'Yes' if n == 0 else 'No'


Measured memory_bytes: 89324
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<cstdlib>
#include<queue>
#include<utility> //pair
using namespace std;

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

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	//入力;
	int N;
	cin >> N;
	vector<string> s(N);
	vector<int> t(N);
	REP(i, N) {
		cin >> s[i] >> t[i];
	}
	string X;
	cin >> X;

	int ans = 0;
	bool sleep = false;

	REP(i, N) {
		if (sleep) ans += t[i];
		if (s[i] == X) sleep = true;
	}

	cout << ans << endl;

	//小数点以下の桁数表示;
	//cout << fixed << setprecision(15);

	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
a = np.zeros((N,M))
for i in range(N):
    K = list(map(int, input().split())) 
    for j in K[1:]:
        a[i][j-1] = 1
b = a.sum(axis=0)
print(len(np.where(b==N)[0]))

Measured memory_bytes: 21160
n,m,c=list(map(int,input().split()))

b=list(map(int,input().split()))
a=[]
for i in range(n):
    tmp=list(map(int,input().split()))
    a.append(tmp)
#print(a[0][1])
total=0
for v in a:
    combined1=[x*y for (x,y) in zip(b,v)]
    if sum(combined1)+c > 0:
        total+=1
print(total)


Measured memory_bytes: 9080
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int N, M;
vector<int> G[100000];
int D[100000];
int P[100000];
int used[100000];
int len[100000];

void dfs(int u) {
    if (used[u]) return;
    used[u] = 1;
    for (int v : G[u]) {
        dfs(v);
        if (len[u] < len[v] + 1) {
            len[u] = len[v] + 1;
        }
    }
}

int main() {
    scanf("%d %d", &N, &M);
    for (int i = 0; i < N - 1 + M; i++) {
        int u, v;
        scanf("%d %d", &u, &v);
        u--; v--;
        G[v].push_back(u);
        D[v]++;
    }
    int r = -1;
    for (int i = 0; i < N; i++) {
        if (D[i] == 0) {
            r = i;
        }
    }
    for (int i = 0; i < N; i++) {
        dfs(i);
    }
    for (int i = 0; i < N; i++) {
        for (int j : G[i]) {
            if (len[i] == len[j] + 1) {
                P[i] = j;
            }
        }
    }
    P[r] = -1;
    for (int i = 0; i < N; i++) {
        printf("%d\n", P[i] + 1);
    }
    return 0;
}


Measured memory_bytes: 10752
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] array = str.split(" ");
        int size = array.length;
        int[] num = new int[size];
        int[] num2 = new int[size];
        int[] num3 = new int[size];
        for(int i=0;i<array.length;i++){
            num[i]=Integer.parseInt(array[i]);
            num3[i]=num[i];

        }
        int suu =sc.nextInt();
        int max = 0;
        
        if(suu!=1){
            for(int i=0;i<suu;i++){
                num2[0]=num3[0]*2+num[1]+num[2];
                num3[0]=num3[0]*2;
                num2[1]=num[0]+num3[1]*2+num[2];
                num3[1]=num3[1]*2;
                num2[2]=num[0]+num[1]+num3[2]*2;
                num3[2]=num3[2]*2;
            }
            for(int k=0;k<num2.length;k++){
                max=Math.max(max, num2[k]);
            }
        }else{
            num2[0]=num[0]*2+num[1]+num[2];
            num2[1]=num[0]+num[1]*2+num[2];
            num2[2]=num[0]+num[1]+num[2]*2;
            for(int k=0;k<num2.length;k++){
                max=Math.max(max, num2[k]);
            }
            
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21204