akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

vt GCD(vt a, vt b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

bool IsPrime(vt num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (vt i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<vt> dvs(vt n) {
	vector<vt> ret;
	for (vt i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return(ret);
}

int main() {
	ll a, b, g, ans = 1;
	cin >> a >> b;
	g = GCD(a, b);
	vector<ll> dv = dvs(g);
	for (vt i : dv) {
		if(IsPrime(i)) ans++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
    l[i-1] += 1
    
al = 0
for i in l:
    al += i*(i-1)//2

for k in range(n):
    print(al - (l[a[k]-1] - 1))

Measured memory_bytes: 81740
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char b = sc.next().charAt(0);
		if (b == 'A') System.out.println('T');
		else if (b == 'T') System.out.println('A');
		else if (b == 'C') System.out.println('G');
		else System.out.println('C');
	}

}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m;
vector<pair<ll, ll>> v[100000];
bool used[100000];
ll koko[100000];
bool dfs(ll now){
	bool ret = 1;
	for(pair<ll, ll> next : v[now]){
		if(used[next.first]){
			if(koko[next.first] != koko[now] + next.second) return false;
		}else{
			used[next.first] = 1;
			koko[next.first] = koko[now] + next.second;
			ret &= dfs(next.first);
		}
	}
	return ret;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	for(ll i = 0; i < m; i++){
		ll l, r, d; cin >> l >> r >> d;
		v[--l].push_back(pair<ll, ll>(--r, d));
		v[r].push_back(pair<ll, ll>(l, -d));
	}
	bool ans = 1;
	for(ll i = 0; i < n; i++){
		if(!used[i]){
			used[i] = 1;
		}
		ans &= dfs(i);
	}
	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 16640
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int aa = min(a, c * 2);
    int bb = min(b, c * 2);
    int ab = min(a + b, c * 2);

    int ans = 0;
    if(x < y){
        ans += x * ab;
        ans += (y - x) * bb;
    }else{
        ans += y * ab;
        ans += (x - y) * aa;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		Scanner scan=new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		for (int i = 0;; i++) {
			int x=scan.nextInt();
			int y=scan.nextInt();
			if(x==0 && y==0)
				break;
			if(x>y)
				System.out.println(y+" "+x);
			else
				System.out.println(x+" "+y);
		}

	}

}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  int L[2000];

  cin >> N;
  REP(i, N) { cin >> L[i]; }

  ll result = 0;
  sort(L, L + N);

  for (int i = 0; i < N - 2; ++i) {
    for (int j = i + 1; j < N - 1; ++j) {
      for (int k = j + 1; k < N; ++k) {
        if ((L[i] < L[j] + L[k]) && (L[j] < L[k] + L[i])) {
          if (L[k] < L[i] + L[j]) {
            ++result;
          } else {
            break;
          }
        }
      }
    }
  }

  cout << result;

  return 0;
}


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

int main(){
	int h,w;
	string a[100];
	cin >>h >>w;

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

	for (int i = 0; i < h; ++i){
		a[i].insert(0,"#");
		a[i].insert(w+1,"#");
	}

	for(int i=0;i<w+2;i++){
		cout << "#";
	}
	cout <<endl;
	for(int i=0;i<h;i++){
		cout << a[i] <<endl;
	}
	for(int i=0;i<w+2;i++){
		cout << "#";
	}
	cout <<endl;






	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> l_l;
const ll dx[4]={1,0};
const ll dy[4]={0,1};
const int MOD=1000000007;
int main(){
    ll H,W; cin >> H >> W;
    vector<vector<char>> grid(H,vector<char>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> grid[i][j];
        }
    }
    queue<l_l> q;
    q.push({0,0});
    vector<vector<ll>> dp(H,vector<ll>(W,0));
    vector<vector<bool>> used(H,vector<bool>(W,false));
    dp[0][0]=1;
    while(!q.empty()){
        l_l now=q.front();q.pop();
        if(used[now.first][now.second]) continue;
        used[now.first][now.second]=true;
        for(int i=0; i<2; i++){
            if(now.first+dx[i]>=0&&now.first+dx[i]<H&&now.second+dy[i]>=0&&now.second+dy[i]<W&&grid[now.first+dx[i]][now.second+dy[i]]=='.'){
                dp[now.first+dx[i]][now.second+dy[i]]+=dp[now.first][now.second];
                dp[now.first+dx[i]][now.second+dy[i]]%=MOD;
                q.push({now.first+dx[i],now.second+dy[i]});
            }
        }
    }
    cout << dp[H-1][W-1]%MOD << endl;
    return 0;
}

Measured memory_bytes: 9344
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int na;
int a[MAXN];

int b[MAXN],nb;
int c[MAXN],nc;
int d[MAXN],nd;

int solve() {
	nb=0; REP(i,na) b[nb++]=a[i];
	sort(b,b+nb);
	int ret=0;
	while(nb>0) {
		int largest=b[nb-1];
		int target=1; while(target<=largest) target*=2;
		nc=0; int nhalf=0; while(nb>0&&b[nb-1]>=target/2) { int cur=b[--nb]; if(cur==target/2) ++nhalf; else c[nc++]=cur; }
		ret+=nhalf/2;
		nd=0; REP(i,nb) d[nd++]=b[i];
		nb=0;
		//printf("target=%d (nhalf=%d)\n",target,nhalf);
		//printf("c:"); REP(i,nc) printf(" %d",c[i]); puts("");
		//printf("d:"); REP(i,nd) printf(" %d",d[i]); puts("");
		int ci=0,di=0;
		while(ci<nc&&di<nd) {
			int have=c[ci]+d[di];
			if(have<target) b[nb++]=d[di++]; else if(have>target) ++ci; else { ++ret; ++ci; ++di; }
		}
		while(di<nd) b[nb++]=d[di++];
	}
	return ret;
}

void run() {
	scanf("%d",&na);
	REP(i,na) scanf("%d",&a[i]);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#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 ll MAX_N = 100010;

int main() {
    ll h, w;
    cin >> h >> w;

    vvl board(h, vl(w));  // board[i][j] : 黒なら1
    rep(i, h) {
        string s;
        cin >> s;
        rep(j, w) {
            if(s[j] == '#') {
                board[i][j] = 1;
            }
        }
    }

    vvl dp(h, vl(w));  // dp[i][j] : (i,j)に到達するための操作回数の最小値
    if(board[0][0]) {
        dp[0][0] = 1;
    }
    rep(i, h-1) {
        if(board[i][0] == 0 && board[i+1][0] == 1) {
            dp[i+1][0] = dp[i][0] + 1;
        }
        else {
            dp[i+1][0] = dp[i][0];
        }
    }
    rep(j, w-1) {
        if(board[0][j] == 0 && board[0][j+1] == 1) {
            dp[0][j+1] = dp[0][j] + 1;
        }
        else {
            dp[0][j+1] = dp[0][j];
        }
    }

    exrep(i, 1, h-1) {
        exrep(j, 1, w-1) {
            if(board[i][j] == 0) {
                dp[i][j] = min(dp[i][j-1], dp[i-1][j]);
            }
            else if(board[i][j] == 1) {
                ll x = dp[i][j-1];
                ll y = dp[i-1][j];
                if(board[i][j-1] == 0) {
                    x++;
                }
                if(board[i-1][j] == 0) {
                    y++;
                }
                dp[i][j] = min(x, y);
            }
        }
    }

    /*cout << "\n";
    rep(i, h) {
        rep(j, w) {
            cout << dp[i][j] << " ";
        }
        cout << "\n";
    }*/

    out(dp[h-1][w-1]);
    re0;
}

Measured memory_bytes: 384
import bisect
s = int(input())
Data = []
Data.append(s)
n = 1
while True:
    n += 1
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    index = bisect.bisect_left(Data,s)
    if index < len(Data) and Data[index] == s:
        break
    Data.insert(index,s) 
print(n)


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//切り上げ除算
long long cutup(long long a,long long b){return (a+b-1)/b;}

//累乗
template<typename t>
constexpr t my_pow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
    }
    return x;
}
#define pow my_pow

//chmin,chmax
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;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    cout<<cutup(n,111)*111<<endl;
}

Measured memory_bytes: 3664
N = int(input())
A = [int(s) for s in input().split(' ')]
B = [int(s) for s in input().split(' ')] + [0]
m = 0
pa = 0
for a, b in zip(A, B):
    m1 = 0
    if pa > 0:
        m1 = min(pa, a)
        a -= m1
    m2 = min(a, b)
    pa = b - m2
    m += m1 + m2

print(m)


Measured memory_bytes: 19648
import sys


def input():
    return sys.stdin.readline().strip()


N, M = map(int, input().split())
g = {i: set() for i in range(1, N + 1)}
for _ in range(M):
    A, B = map(int, input().split())
    if A in (1, N) or B in (1, N):
        g[A].add(B)
        g[B].add(A)

if g[1].intersection(g[N]):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 89184
fn main() {
    let (n,k) = {let v = read_vec(); (v[0],v[1])};
    let mut h:Vec<i32> = (0..n).map(|_| read()).collect();
    h.sort();
    let mut ans = 10i32.pow(9);
    for i in 0..h.len()-k+1 {
        ans = std::cmp::min(h[i+k-1]-h[i], ans);
    }
    println!("{}",ans);
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}

fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys


def solve(S: str):
    p1 = int(S[:2])
    p2 = int(S[2:])

    if(0 < p1 <= 12 and 0 < p2 <= 12):
        print('AMBIGUOUS')
    elif(0 < p1 <= 12 and (p2 == 0 or p2 > 12)):
        print('MMYY')
    elif((p1 == 0 or p1 > 12) and 0 < p2 <= 12):
        print('YYMM')
    else:
        print('NA')

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)
flag = true
(n-1).times do |i|
	flag = false if arr[i] > arr[i+1]
end
if flag 
	puts "YES"
	exit
end

def check(n, arr)
	(n-1).times do |i|
		if arr[i] > arr[i + 1]
			return false
		end
	end
	return true
end

(n-1).times do |i|
	(i+1..n-1).each do |j|
		arr[i], arr[j] = arr[j], arr[i]
		if check(n, arr)
			puts "YES"
			exit
		end
		arr[i], arr[j] = arr[j], arr[i]
	end
end
puts "NO"


Measured memory_bytes: 14288
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

pub fn main() {
    loop {
        let v: Vec<i32> = read_vec();
        let (h,w) = (v[0],v[1]);
        if h==0 && w==0 {
            break;
        }
        for i in 0..h {
            for j in 0..w {
                let c = if (i+j) % 2 == 0 { '#' }
                        else { '.' };
                print!("{}", c);
            }
            println!();
        }
        println!();
    }
}



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

int main(){
    ll a[8] = {1,10,100,1000,10000,100000,1000000};
    ll n;
    ll cnt = 0;
    cin >> n;
    for(ll i=n;i>=1;i--){
        ll j=0;
        while(i>=a[j]) j++;
        if(j%2==1)  cnt++;
    }
    cout << cnt << endl;
}

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

using ll = long long;

const int MAXN = 3010;
int N, M;
char S[MAXN];
int pref[MAXN];

int to[MAXN];
ll dp[MAXN][MAXN];

const ll MOD = 1e9 + 7;

int main() {
	scanf("%d %d", &N, &M);
	scanf("%s", S);
	for (int i = 0; i < N; i++) {
		pref[i+1] = pref[i] + S[i] - '0';
	}

	for (int i = 0; i <= N; i++) {
		to[i] = i;
	}
	for (int i = 0; i < M; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		to[l] = max(r, to[l]);
	}
	for (int i = 1; i <= N; i++) {
		to[i] = max(to[i], to[i-1]);
	}

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		int add = pref[to[i+1]] - pref[to[i]];
		for (int j = 0; j <= N; j++) {
			int newj = j + add;
			if (newj > 0) {
				dp[i+1][newj-1] = (dp[i+1][newj-1] + dp[i][j]) % MOD;
			}
			if (to[i+1] - i - newj > 0) {
				dp[i+1][newj] = (dp[i+1][newj] + dp[i][j]) % MOD;
			}
		}
	}

	printf("%lld\n", dp[N][0]);
}

Measured memory_bytes: 70912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int ans = a + b;
			int i = 0;
			while (ans != 0) {
				ans /= 10;
				i++;
			}
			System.out.println(i);
		}

	}

}

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

using namespace std;

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

ll cal(ll a, ll b) {
	ll x = a % b;
	if (x == 0)
		return a * 2;
	return (a - x) * 2 + b + x + cal(b - x, x);
}

int main() {
	ll n, x;
	cin >> n >> x;
	
	ll s = 0;
	s += x + (n - x);
	if (x * 2 < n)
		s += x + cal(n - x * 2, x);
	else if (x * 2 > n)
		s += (n - x) + cal(n - (n - x) * 2, n - x);
	else
		s += x;
	
	cout << s << endl;
	
	return 0;
}


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

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int base[302][302];
int a[302];
int sum, n, m;

long long fsp(int p) {
    long long rt = 1, base = 2;
    while (p) {
        if (p & 1) (rt *= base) %= mod;
        (base *= base) %= mod;
        p >>= 1;
    }
    return rt;
}

void work() {
    for (int i = m; i >= 1; --i) {
        if (!a[i]) continue;
        if (!base[i][i]) {
            sum--;
            for (int j = 1; j <= i; ++j) {
                base[i][j] = a[j];
            }
            for (int j = 1; j < i; ++j) {
                if (!base[i][j]) continue;
                for (int k = 1; k <= j; ++k) {
                    base[i][k] ^= base[j][k];
                }
            }
            for (int j = i + 1; j <= m; ++j) {
                if (!base[j][i]) continue;
                for (int k = 1; k <= i; ++k) {
                    base[j][k] ^= base[i][k];
                }
            }
            break;
        } else {
            for (int j = 1; j <= i; ++j) {
                a[j] ^= base[i][j];
            }
        }
    }
    return ;
}

int main() {
    n = sum = read(), m = read();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            a[j] = read();
        }
        work();
    }
    printf("%lld", fsp(m - 1) * (fsp(n) + mod - fsp(sum)) % mod);
    return 0;
}

Measured memory_bytes: 640
n = int(input())

ans = [[[0]*10,[0]*10,[0]*10],[[0]*10,[0]*10,[0]*10], [[0]*10,[0]*10,[0]*10], [[0]*10,[0]*10,[0]*10]]

for i in range(n):
    b, f, r, v = map(int, input().split())
    ans[b-1][f-1][r-1] += v

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' '+str(ans[i][j][k]), end='')
        print()
    if i != 3:
        print('####################')


Measured memory_bytes: 5616
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		
		
		Scanner sc = new Scanner(System.in);
		
		int numbers = Integer.parseInt(sc.next());
		String taroCard = null;
		String hanakoCard = null;
		
		int[] scores = new int[2];
		
		
		for(int i =0; i< numbers;i++){
		
			taroCard = sc.next();
			hanakoCard = sc.next();
			
			scores = computeCards(taroCard,hanakoCard,scores);
			
		}
		
		System.out.println(scores[0] +" " + scores[1]);
		
		sc.close();
		
		
	}

	private static int[] computeCards(String priorCard, String postCard,int[] score) {
		
		int count = priorCard.length() > postCard.length() ? postCard.length() : priorCard.length();
		
		for(int i=0;i<count;i++){
			
			int result = Character.compare(priorCard.charAt(i), postCard.charAt(i));
			
			if(result > 0){
				score[0] += 3;
				return score;
			}
			else if(result == 0){
				continue;
			}
			else{
				score[1] += 3;
				return score;
			}
		}
		
		if(priorCard.length() > postCard.length()){
			score[0] += 3;
			return score;
		}
		else if(priorCard.length() < postCard.length()){
			score[1] += 3;
			return score;
		}
		
		score[0] += 1;
		score[1] += 1;
		return score;
	}

}



Measured memory_bytes: 30136
#include <bits/stdc++.h>
#define REPZ(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12
#define MOD 1000000007    //合同式の法

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 setprecision()
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
using namespace std;
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n,a,b; cin >> n >> a >> b;
  ll t = n/(a+b);
  ll u = n%(a+b);
  cout << t*a+min(u,a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

  cin >> n;
  for(int i=0; i < n; i++) cin >> R[i];

  int maxv = -2000000000;
  int minv = R[0];

  for(int i=1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


const int INF = int(1e9 + 7);


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	auto dist = make_unique<int[][3]>(N);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dist[i][j] = INF;
		}
	}

	queue<Pii> q;
	q.emplace(S, 0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


Measured memory_bytes: 6912
from fractions import gcd
N,M=map(int,input().split())
S=input()
T=input()
g=gcd(N,M)
n=N//g
m=M//g
for i in range(g):
    if S[i*n]!=T[i*m]:
        print(-1)
        break
else:
    print(n*m*g)

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<string>s(n);
    map<string,ll> mp;
    for (int i = 0; i < n; ++i) {
        cin >>s[i];
        mp[s[i]]++;
    }
    ll mx=0;
    for(auto p:mp)mx=max(mx,p.second);
    for(auto p:mp){
        if(p.second==mx){
            cout <<p.first<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 26752
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
 
#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)
 
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
 
#define pb push_back
#define mp make_pair
#define INF 1e8
#define EPS 1e-9
#define PI acos(-1.0)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
 
int n, m, C, s, g;
 
struct edge {
    int to, c, d;
};
vector<vector<edge> > E;
vector<vector<int> > q;
vector<vector<int> > r;
vector<vector<int> > sum;
 
bool input() {
    cin >> n >> m >> C >> s >> g;
    if(!(n||m||C||s||g)) return false;
    s--; g--;
    E.clear();
    E.resize(n);
    // edge
    rep(i, m) {
        int x, y, d, c;
        cin >> x >> y >> d >> c;
        x--; y--; c--;
        E[x].pb((edge){y, c, d});
        E[y].pb((edge){x, c, d});
    }
 
    // lines
    q.clear();
    vector<int> p(C);
    rep(i, C) cin >> p[i];
    r.clear();
    rep(i, C) {
        vector<int> tq(p[i]+1);
        rep(j, p[i]-1) cin >> tq[j+1];
        tq[0] = 0;
        tq[p[i]] = INF;
        q.pb(tq);
         
        vector<int> tr(p[i]);
        rep(j, p[i]) cin >> tr[j];
        r.pb(tr);
    }
 
    // clac sum
    sum.clear();
    sum.resize(C);
    rep(c, C) {
        sum[c].resize(r[c].size()+1);
        rep(i, sum[c].size()-1) {
            sum[c][i+1] = sum[c][i] + (q[c][i+1] - q[c][i]) * r[c][i];
        }
    }
     
    return true;
}
 
int f(int c, int dst) {
    int pos = upper_bound(all(q[c]), dst) - q[c].begin();
    pos--;
    return sum[c][pos] + r[c][pos] * (dst - q[c][pos]);
}

int min_dst[32][128][128]; 
int min_cst[128][128];
int solve() {
  // calc minimum distance
  memset(min_dst, 0, sizeof(min_dst));
  rep(c, C) rep(i, n) repi(j, i+1, n) min_dst[c][i][j] = min_dst[c][j][i] = INF;
  rep(i, n) rep(j, E[i].size()) {
    edge &e = E[i][j];
    min_dst[e.c][i][e.to] = min(min_dst[e.c][i][e.to], e.d);
  }
  rep(c, C) rep(k, n) rep(i, n) rep(j, n) min_dst[c][i][j] = min(min_dst[c][i][j], min_dst[c][i][k] + min_dst[c][k][j]);
  
  // calc minimum cost
  rep(i, n) rep(j, n) min_cst[i][j] = INF;
  rep(i, n) min_cst[i][i] = 0;
  rep(c, C) rep(i, n) rep(j, n) {
    if(min_dst[c][i][j] < INF) min_cst[i][j] = min(min_cst[i][j], f(c, min_dst[c][i][j]));
  }
  rep(k, n) rep(i, n) rep(j, n)
    min_cst[i][j] = min(min_cst[i][j], min_cst[i][k] + min_cst[k][j]);

  // return
  int ret = min_cst[s][g];
  if(ret == INF) return -1;
  return ret;

}
 
int main()
{
    while(input())
      cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3696
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
int[] a=new int[n];
int[] b=new int[n];
int[] c=new int[m];
int[] d=new int[m];
    for (int i = 0; i < n; i++) {
        a[i]=Integer.parseInt(sc.next());
        b[i]=Integer.parseInt(sc.next());
    }
    for (int i = 0; i <m; i++) {
        c[i]=Integer.parseInt(sc.next());
        d[i]=Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
    int min=200000000,s=0;
        for (int j = 0; j < m; j++) {
            int temp=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(temp<min){
            min=temp;
            s=j;
            }
        }
        out.println(s+1);
    }
}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<ll> A, B;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
 
  ll ret = 0;
  for(int i=N-1; i>=0; i--){
    ll a = A[i] + ret;
    ll b = B[i];
    if(b == 1) continue;
    //cout << b - (a%b) << endl;
    if(a%b != 0) ret += b - (a%b);
  }
  cout << ret << endl;
  
  return 0;
}


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

// メモ化再帰
int dp[100100];
int n, m;

int rec(int v, vector<vector<int>>&G){
    if (dp[v] != -1) return dp[v];
    int result = 0;
    
    for (auto nv : G[v]){
        result = max(result, rec(nv, G) + 1);
    }
    
    return dp[v] = result;
}

int main(){
    
    int n, m;
    cin >> n >> m;
    
    vector<vector<int>> G(n, vector<int>());
    
    // 有向グラフの入力
    
    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        
        G[x].push_back(y);
    }
    
    // initialization
    for (int v = 0; v < n; v++) dp[v] = -1;
    
    
    //  DP の更新順序が非自明
    // 各点を調べる
    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i, G));
    cout << ans << endl;
}



Measured memory_bytes: 8192
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;

int main() {
    int N, D, X;
    int A[200];
    scanf("%d", &N);
    scanf("%d %d", &D, &X);
    REP(i, N){
        scanf("%d", &A[i]);
    }
    //printf("%d", A[N-1]);
    int sum = 0;
    REP(i, N){
        sum += (D-1)/A[i] + 1;
    }
    printf("%d\n", sum+X);
    return 0;
}

Measured memory_bytes: 128
/********************************************************************************
	
	Code by a weak man who named CYJian, and he hopes the code can get more points.

	Algorithm: 

 ********************************************************************************/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

//{{{ FAST IO AND SOME FUNCTIONS
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T> inline void chkmin(T&a, T b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T&a, T b) { a = a > b ? a : b; }
//}}}

const int mod = 1e9 + 7;

inline int Mod(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y, x -= x >= mod ? mod : 0; }

int f[5010];
int g[5010];
int P[5010];
int M[5010];
int F[2][5010];

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri, A = ri, B = ri, res = 1;
	for(int i = 1; i <= n; i++) res = Mod(res << 1);
	if(A == 1 || B == 1) return printf("%d\n", res), 0;
	if(A > B) swap(A, B);
	f[0] = 1, g[0] = 1;
	for(int i = A; i < B; i++) {
		f[i] = Mod(f[i - 1] + g[i - 1]);
		for(int j = A; j <= i; j++)
			Add(g[i], f[i - j]);
	}

	for(int i = 1; i < B; i++)
		for(int j = 1; j <= i; j++)
			P[i] = (P[i] + 1LL * g[i - j] * (i == j ? 1 : j)) % mod;
	for(int i = 1; i < B; i++)
		for(int j = 1; j <= i; j++)
			M[i] = (M[i] + 1LL * g[i - j] * (i == j ? 1 : j - 1)) % mod;

	F[0][0] = F[1][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < B; j++) {
			if(i == j || i == n) {
				F[1][i] = (F[1][i] + 1LL * F[0][i - j] * P[j]) % mod;
				if(i == j) break;
			} else F[1][i] = (F[1][i] + 1LL * F[0][i - j] * M[j]) % mod;
		}
		for(int j = 1; j < A; j++) {
			Add(F[0][i], F[1][i - j]);
			if(i == j) break;
		}
	}

	cout << Mod(res + mod - Mod(F[0][n] + F[1][n])) << endl;
	return 0;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  char x,y;cin>>x>>y;
  x-'0'<y-'0' ? cout<<"<"<<endl : x-'0'>y-'0' ? cout<<">"<<endl :cout<<"="<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
void input() {
	cin >> n;
}
void solve() {
	cout << (n - 1) / 2 << endl;
}

int main() {
	input();
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


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


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>
 
using namespace std;
 
void Solution()
{
    int n;
    bool a[5][14] = {{0}};
    char pattern;
    int digit;
    
    cin>>n;
    for(int i = 0; i < n; i++)
    {
        cin>>pattern>>digit;
        
        switch(pattern)
        {
            case 'S': a[0][digit - 1] = true; break;
            case 'H': a[1][digit - 1] = true; break;
            case 'C': a[2][digit - 1] = true; break;
            case 'D': a[3][digit - 1] = true; break;
        }
    }
    
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 13; j++)
        {
             if( false == a[i][j] ) 
             {
                switch( i ) 
                {
                    case 0: cout <<"S "<<j + 1<<endl; break;
                    case 1: cout <<"H "<<j + 1<<endl; break;
                    case 2: cout <<"C "<<j + 1<<endl; break;
                    case 3: cout <<"D "<<j + 1<<endl; break;
                }
            }
        }
    }
     
     
}
 
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(int)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(int)(n)+1;i++)
#define vec vector
typedef int64_t intl;
#define fi first
#define se second
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
vec<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};

void lunlun(intl n, vec<intl> &lun){
  if (n/4 >= 1000000000){return;}
  lun.push_back(n);
  int digit = log10(n) +1;
  intl top=n;
  intl nexttop =10;
  Rep(i,digit-1){
    top /= 10;
    nexttop*=10;
  }
  if (top == 1){
    lunlun(n + nexttop , lun);
    lunlun(n + 2*nexttop ,lun);
    intl longnext = 1;
    Rep(j,10-digit){
    longnext *=10;
    lunlun(n + nexttop*longnext,lun);
    }
  }
  else if(top==9){
    lunlun( n + nexttop * 8 ,lun);
    lunlun( n + nexttop*9 ,lun);
  }
  else {
    lunlun( n + nexttop *(top-1) ,lun);
    lunlun( n + nexttop *top ,lun);
    lunlun( n + nexttop *(top+1) ,lun);
  }
}
    
  

int main(){
 int K;
  cin >> K;
  vec<intl> lun(0);
  Rep1(i,9){
    lunlun(i,lun);
  }
  intl ten = 10;
  Rep(i,10){
    lunlun(ten ,lun);
    ten*=10;
  }
  SortA(lun);
  
  cout << lun.at(K-1);
}
  
  
  
  

Measured memory_bytes: 1656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	vector<string>c(2);
	cin >> c[0]>>c[1];
	if (c[0][0] == c[1][2] && c[0][1] == c[1][1] &&
		c[0][2] == c[1][0]  ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let a: usize = sc.read();
    let b: usize = sc.read();
    let h: usize = sc.read();

    let ans = (a + b) * h / 2;
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}

#[allow(dead_code)]
fn yn(flag: bool) {
    if flag {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 8572
use proconio::input;

fn main() {
	input!(n: usize, p: [f64; n]);
	let mut dp = vec![vec![0f64; n+1]; n+1];
	dp[0][0] = 1f64;
	for i in 0..n {
		for j in 0..=i+1 {
			let mut q = dp[i][j] * (1f64 - p[i]);
			if j > 0 { q += dp[i][j-1] * p[i] };
			dp[i+1][j] = q;
		}
	}
	let mut q_sum = 0f64;
	for j in n/2+1..=n {
		q_sum += dp[n][j];
	}
	println!("{}", q_sum);
}

Measured memory_bytes: 72608
#define MAX 10000001
int p[MAX];
int four[1000];

int main(void)
{
  int i,j,f=0;

  for(i=2;i<=MAX;i++){
    if(p[i]==0)
      {
	for(j=i*2 ; j<=MAX ; j+=i){
	  p[j] = 1;
	}
      }
  }
  
  for(i=3 ; i < MAX-7 ; i+=2){
    if(p[i] == 0 && p[i+2]==0 && p[i+6]==0 && p[i+8]==0)
      {
	four[f++]=i+8;
      }
    four[f]=10000005;
  }
  
  for(;scanf("%d",&j);)
    {
      if(j==0)
	exit(0);
      for(i=0 ;four[i]<=j; i++);
      printf("%d\n",four[i-1]);
    }
  
  return 0;
}

Measured memory_bytes: 0
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e6+10;
const double eps=1e-10;
void solve()
{
	double d,t,s;
	cin>>d>>t>>s;
	double ans=d/s;
	if(ans-t>eps)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,sum=0;cin>>n>>k;
  vector<int>l(n);
  for(int i=0;i<n;i++)cin>>l[i];
  sort(l.begin(),l.end());
  for(int i=n-1;i>n-k-1;i--){
    sum+=l[i];
  }
  cout<<sum;;
}

Measured memory_bytes: 384
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

#define MAX_W (10000)
#define MAX_N (100)
int N, W;
int v[MAX_N];
int w[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];

int main() {

	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i]) {
				dp[i+1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]); // 個数制約なし
//				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]); // 個数制約あり
			}
		}
	}

	cout << dp[N][W] << endl;

	return 0;
}




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

N,X,Y = map(int,readline().split())
X -= 1
Y -= 1
ans = [0] * N
for i in range(N - 1):
  for j in range(i + 1, N):
    val = min(abs(i - j),abs(i - X) + 1 + abs(j - Y), abs(i - Y) + 1 + abs(j - X))
    ans[val] += 1
    
for i in range(1, len(ans)):
  print(ans[i])

Measured memory_bytes: 74712
class Tree:
    def __init__(self,n):
        self.ver=[[] for _ in range(n)]
        self.par=[-1 for _ in range(n)]
    
    def unite(self,x,y):
        self.ver[x].append(y)
        self.ver[y].append(x)

        self.par[y]=x

    def getdepth(self,i):
        ret=0
        while True:
            if self.par[i]==-1:
                return ret
            else:
                i=self.par[i]
                ret+=1

        
N=int(input())
T=Tree(N)
for _ in range(N):
    i,m,*chi=map(int,input().split())
    for j in chi:
        T.unite(i,j)

# print(T.ver)
# print(T.par)

for i in range(N):
    ans=''
    ans+='node %i: '%i
    ans+='parent = %i, '%T.par[i]
    ans+='depth = %i, '%T.getdepth(i)

    kind=''
    if T.par[i]==-1:
        kind+='root'
    elif len(T.ver[i])==1:
        kind+='leaf'
    else:
        kind+='internal node'
    ans+=kind+', '
    ans+=str(list(v for v in T.ver[i] if v!=T.par[i]))
    print(ans)


Measured memory_bytes: 24128
def main():
    s = list(raw_input())
    flag = False
    if s[0] == s[1] and s[2] == s[3]:
        if s[0] != s[2]:
            flag = True
    elif s[0] == s[3] and s[1] == s[2]:
        if s[0] != s[1]:
            flag = True
    elif s[0] == s[2] and s[1] == s[3]:
        if s[0] != s[1]:
            flag = True
    if flag == True:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()


Measured memory_bytes: 2568
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B < C + D)cout << "Right" << endl;
    else if (A + B > C + D)cout << "Left" << endl;
    else cout << "Balanced" << endl;
}

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

using namespace std;

/**
 * @brief  Union-Find木
 * @note   size(x)で頂点xの属しているグループの頂点数を返す
 *         same(x,y)で頂点x,yが同じグループの属しているかのboolを返す
 *         unite(x,y)で頂点x,yの属してるグループを統合する．もともと同じ頂点だったなら何もしない
 */
class UnionFindTree {
  const std::size_t N_;
  std::size_t species_;
  std::vector<std::size_t> parent_;
  std::vector<std::size_t> sz_;

 public:
  explicit UnionFindTree(std::size_t);
  std::size_t root(std::size_t);
  std::size_t size(std::size_t);
  bool same(std::size_t, std::size_t);
  void unite(std::size_t, std::size_t);
  std::size_t sets();
};
/**
 * @brief  コンストラクタ
 * @param  n: グラフの頂点数
 */
UnionFindTree::UnionFindTree(std::size_t n) : N_(n), species_(n) {
  parent_.reserve(N_);
  sz_.reserve(N_);
  for (std::size_t i = 0; i < N_; i++) {
    parent_[i] = i;
    sz_[i] = 1;
  }
}
/**
 * @brief  xの属する木の根っこを見つける
 */
std::size_t UnionFindTree::root(std::size_t x) {
  if (parent_[x] == x) {
    return x;
  }
  return parent_[x] = root(parent_[x]);
}
/**
 * @brief  xの属する木のサイズを返す
 */
std::size_t UnionFindTree::size(std::size_t x) { return sz_[root(x)]; }
/**
 * @brief  頂点x,yが同じ木に属しているかをbooleanで返す
 */
bool UnionFindTree::same(std::size_t x, std::size_t y) { return root(x) == root(y) ? true : false; }
/**
 * @brief  頂点x,yの属する木を統合する
 */
void UnionFindTree::unite(std::size_t x, std::size_t y) {
  x = root(x);
  y = root(y);
  if (x != y) {
    parent_[x] = y;
    sz_[y] += sz_[x];
    species_--;
  }
}
// uftに何種類の集合があるか調べる関数を作りたい。
std::size_t UnionFindTree::sets() { return species_; }

int main() {
  size_t N, M;
  cin >> N >> M;
  UnionFindTree uft(N);
  for (size_t i = 0; i < M; i++) {
    size_t x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    z--;
    uft.unite(x, y);
  }
  cout << uft.sets() << endl;
  return 0;
}


Measured memory_bytes: 1792