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

public class Main {
    public static void main(String args[]) {
        Scanner scn = new Scanner(System.in);
        int a = scn.nextInt();
        int b = scn.nextInt();
        int c = scn.nextInt();

        int n = b - a + 1;
        int count = 0;

        for (int i = 0; i < n; i++) {
            if ((c % a) == 0) {
                count = count + 1;
            }
            a = a + 1;
        }

        System.out.println(count);


    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

ll mod=1000000007;

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;}


int main() {
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  reps(i,n-1){
    if(a[i]<a[i-1]){
      sum+=a[i-1]-a[i];
      a[i]+=a[i-1]-a[i];
    }
  }
  cout<<sum;
}

Measured memory_bytes: 4772
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n-1;i>s;i--)
#define rep_re(i,s,n)for(ll i = n-1;i>=s;i--)
ll MOD = 1e9 + 7;

////unite x and y : if(x>y)swap(x,y);p[uf(x)] = uf(y);

//initial : call init_uf();
//unite x and y : unite(ll x, ll y)
//same x and y : uf(x) == uf(y);
//size s[uf(a)];

static const ll MAX_N = 100001;
ll p[MAX_N] = {};
ll s[MAX_N] = {};
ll uf(ll i) { return (p[i] == i) ? i : p[i] = uf(p[i]); }
void init_uf() { rep(i, 1, MAX_N) { p[i] = i; s[i] = 1; }}
void unite(ll x, ll y) {
	x = uf(x); y = uf(y);
	if (x == y) return ;
	if (p[x] > p[y]) swap(x, y); // merge technique
	s[x] += s[y];
	p[y] = x;
}


ll a[100001] = {};
ll b[100001] = {};
ll ans[100001] = {};
int main() {
	ll n, m; cin >> n >> m;
	init_uf();

	rep(i, 0, m)cin >> a[i] >> b[i];
	ans[m - 1] = n * (n - 1) / 2;

	rep_r(i, 0, m) {
		if (uf(a[i]) == uf(b[i])) {
			ans[i - 1] = ans[i];
		}
		else {
			ans[i - 1] = max((ll)0,ans[i] - s[uf(a[i])] * s[uf(b[i])]);
			unite(a[i], b[i]);
		}

	}

	rep(i, 0, m)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 5248
N,A,B = map(int,input().split())
if (A-B) % 2 == 0:
    print((B-A)//2)
else:
    # 右に寄せる
    if A-1 > N-B:
        print((N-B+1) + (N - (A + (N-B+1)))//2)
    else:
        print(A + (B-A)//2)

Measured memory_bytes: 3060
n = input()
if(len(n) == 1):
    print(n)
    exit()
ans = 0
if len(n) % 2:
    ans += int(n) - 10 ** (len(n) - 1) + 1
    print(str(int('90' * ((len(n) - 3) // 2) + '9') + ans))

else:
    print(str(int('90' * ((len(n) - 2) // 2) + '9')))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007


/*nまでの素数を列挙して配列に保持*/
vector<int> Eratosthenes(int n,vector<int>& arr){

	for(int i = 0; i < n;i++){
		arr[i] = 1;
    }
    arr[0] = arr[1] = 0;

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < n; j++){
				arr[i *(j + 2)] = 0;
			}
		}
    }
    return arr;
}


int main(){


    int a,d,n;
    int tmp = 1000000;
    vector<int> arr(tmp+1);


    arr = Eratosthenes(tmp,arr);/*50000までの素数を列挙*/    
   
    while(cin >> a >> d >> n,a){
    
        int count = 0;
        for(int i = a;i < arr.size();i++){
            
            if(arr[i] && ((i-a) % d == 0)){/*素数であり、かつ等差数列上にある数字ならばカウント*/
                count++;
                if(count == n){
                    cout << i << endl;
                    break;
                }
            }
        }

    }  
    
    
    return 0;
}




Measured memory_bytes: 10636
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

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;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	ll n;
	cin >> n;
	
	ll ans=1e9;
	ll mx=0;
	vector<ll> v(n);

	rep(i, n) {
		cin >> v[i];
		mx=max(mx,v[i]);
	}

	for(ll i = 0; i <= mx ; i++) {
		ll num=0;
		rep(j, n) {
			num += pow(v[j]-i, 2);
		}
		ans=min(ans, num);
	}

	cout << ans << endl;
}

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

typedef long long ll;
const int N = (int)1e5 + 50;

int n;
multiset<int> L, R;

struct P {
    int l, r;
} p[N];

bool cmp(P a, P b) {
    return a.l < b.l;
}

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

    cin >> n;
    ll res = 0;
    for(int i = 0; i < n; i++) {
        cin >> p[i].l >> p[i].r;
    }
    for(int i = 0; i < n; i++) L.insert(p[i].l);
    for(int i = 0; i < n; i++) R.insert(p[i].r);
    for(int i = 0; i < n; i++) {
        L.erase(L.find(p[i].l));
        R.erase(R.find(p[i].r));
        res = max(1LL * max(0, p[i].r - p[i].l + 1) + max(0, *R.begin() - *L.rbegin() + 1), res);
        L.insert(p[i].l);
        R.insert(p[i].r);
    }


    int idx = 0;
    for(int i = 1; i < n; i++) {
        if(p[i].r < p[idx].r || (p[i].r == p[idx].r && p[i].l > p[idx].l)) idx = i;
    }
    swap(p[idx], p[n-1]);
    n--;
    sort(p, p + n, cmp);
    L.erase(L.find(p[n].l));
    R.erase(R.find(p[n].r));
    int lb = p[n].l, rb = p[n].r;
    for(int i = 0; i < n; i++) {
//        cout << p[i].l << " " << p[i].r << endl;
//        cout << lb << " " << rb << " " << *R.begin() << " " << *L.rbegin() << endl;
        res = max(1LL * max(0, rb - lb + 1) + max(0, *R.begin() - *L.rbegin() + 1), res);
        lb = max(lb, p[i].l);
        L.erase(L.find(p[i].l));
        R.erase(R.find(p[i].r));
    }
    cout << res << endl;
}

Measured memory_bytes: 10368
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{chars :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base as u8 ) as usize ) .collect ::<Vec <usize >>() } ;($iter :expr ,{char :$base :expr } ) =>{read_value !($iter ,{chars :$base } ) [0 ] } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,char ) =>{read_value !($iter ,chars ) [0 ] } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
fn main() {
    input! { n, k, v: [i64; n] };
    let mut ans = 0i64;
    for i in 1..n + 1 {
        if i > k {
            continue;
        }
        for j in 0..i + 1 {
            let mut get: Vec<i64> = vec![];
            get.extend(&v[..j]);
            get.extend(&v[n + j - i..]);
            get.sort();
            get.reverse();
            let x = k - i;
            for _ in 0..x {
                if get.last().map(|&vv| vv < 0i64).unwrap_or(false) {
                    get.pop();
                }
            }
            ans = std::cmp::max(ans, get.iter().sum());
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <ctype.h>
 
using namespace std;
int main() {
	// your code goes here
	string S;
	int f=0;
	while(cin>>S){
		if(f++){cout<<" ";}
 
		for(int i=0; i<S.size(); i++){
			if(S[i]>='A' && S[i]<='Z'){
				S[i]=tolower(S[i]);
			}else if(S[i]>='a' && S[i]<='z'){
				S[i]=toupper(S[i]);
			}
		}
		cout<<S;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final char[] s = sc.next().toCharArray();
			final char[] t = sc.next().toCharArray();
			
			LOOP:
			for(int st = 0; st < s.length; st++) {
				for(int i = 0; i < s.length; i++) {
					final int index = (st + i) % s.length;
					
					if(s[i] != t[index]) { continue LOOP; }
				}
				
				System.out.println("Yes");
				return;
			}
			
			System.out.println("No");
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124
#include<stdio.h>
  
int main()
{
  int i,j,n,count=0;
  int G[101][101],color[101],d[101],pi[101],mincost,ii;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  for(i=0;i<n;i++){
    color[i]=0;
    pi[i]=-1;
    d[i]=2001;
  }
  d[0]=0;
  
  while(1){
    mincost=2001;
    for(i=0;i<n;i++){
      if(color[i]!=2 && d[i]<mincost){
        mincost=d[i];
        ii=i;
      }
    }
    if(mincost==2001)break;
    color[ii]=2;
    for(i=0;i<n;i++){
      if(G[ii][i]!=-1 && color[i]!=2 && G[ii][i]<d[i]){
    pi[i]=ii;
    d[i]=G[ii][i];
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i]!=-1)count+=G[i][pi[i]];
    }
  printf("%d\n",count);
  return 0;
}


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

int n, k;
bool b[10];

int main() {
	fill(b, b + 10, 1);
	cin >> n >> k;
	for (int i = 0, d; i < k; i++) {
		cin >> d;
		b[d] = 0;
	}
	for (int i = n, m;; i++) {
		bool flag = 1;
		for (int m = i; m; m /= 10) {
			if (!b[m % 10]) {
				flag = 0;
				break;
			}
		}
		if (flag) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(A),
    get_number(B),
    get_number(T),
    X is T div A * B,
    writeln(X).


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

const ll INF = pow(10, 9) + 7;

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=2*b) cout << 0 << endl;
  else cout << a-2*b << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  constexpr char endl = '\n';

  int n;
  const int INF=1e9+5;
  cin >> n;
  vector<int> arr;
  vector<int> dp(n,INF);
  for (int i=0; i<n; ++i) {
    int a;
    cin >> a;
    arr.push_back(a);
  }

  dp[0]=0;
  for (int i=0; i<n-1; ++i) {
    if (i+1<n) {
      dp[i+1]=min(dp[i+1], dp[i]+abs(arr[i]-arr[i+1]));
    }
    if (i+2<n) {
      dp[i+2]=min(dp[i+2], dp[i]+abs(arr[i]-arr[i+2]));
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
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;}
//------------------------------------------------------------------------------

int alpha[26];
signed main() {
    string s;
    cin>>s;
    int n=SZ(s);
    cout<<((n%2==0)^(s[0]==s[n-1])?"Second":"First")<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int a,b,c,d,e;
	while(scanf("%d",&a),a){
		scanf("%d%d%d%d",&b,&c,&d,&e);
		bool ok=false;
		int bestA=0;
		int bestB=0;
		for(int i=1;i<=e;i++){
			int f=b-c*i;
			int g=f/d;
			if(f>=0&&i+g>=a){
				bestA=i;
				bestB=g;
				ok=true;
			}
		}
		if(!ok)printf("NA\n");
		else printf("%d %d\n",bestA,bestB);
	}
}

Measured memory_bytes: 0
// Problem : D - Wide Flip
// Contest : AtCoder - AtCoder Regular Contest 088
// URL : https://atcoder.jp/contests/arc088/tasks/arc088_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
string str;
int N;

bool calc(int K)
{
	int a0=true,a1=true;
	F0R(x,N)
	{
		if(x>=K || x<N-K)
			continue;
		if(str[x]=='0')
			a1=false;
		else
			a0=false;
	}
	return a1||a0;
}

int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>str;
	N=sz(str);
	int l=1,r=N,ans=-1;
	while(l<=r)
	{
		int m=l+(r-l)/2;
		if(calc(m))
		{
			ckmax(ans,m);
			l=m+1;
		}
		else
			r=m-1;
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3744
N = int(input())
INF =101
sum_num = 0
min_num = INF

for _ in range(N):
  num = int(input())
  if num%10 != 0:
    min_num = min(min_num, num)
  sum_num += num
if min_num == INF:
  print(0)
elif sum_num%10 == 0:
  print(sum_num-min_num)
else:
  print(sum_num)

Measured memory_bytes: 3064
class Node:
    def __init__(self, x, y):
        self.id = x
        self.k = y
        self.children = []
        self.type = ''
        self.depth = 20
        self.parent = '-1'

def findRoot(tree):
    for x in tree:
        for y in x.children:
            tree[int(y)].parent = x.id
            if tree[int(y)].k == 0:
                tree[int(y)].type = 'leaf'
            else:
                tree[int(y)].type = 'internal node'
            '''for a in tree:
                if y == a.id:
                    if a.k == 0:
                        a.type = 'leaf'
                    else:
                        a.type = 'internal node'
                    a.parent = x.id
            '''
    for i,x in enumerate( tree):
        if x.type == 'root':
            return i


def setd(tree,node,d):
    node.depth = d
    if node.k == 0:
        return
    else:
        for tmp in node.children:
            setd(tree,tree[int(tmp)],d+1)
            '''for x in tree:
                if x.id == tmp:
                    setd(tree,x,d+1)
            '''


if __name__ == '__main__':
    n = (int)(input())
    tree = [None]*n
    for i in range(0,n):
        tmp = input().split()
        a = Node(tmp[0],(int)(tmp[1]))
        a.children=tmp[2:]
        a.type = 'root'
        tree[int(a.id)] = a
    ri = findRoot(tree)
    setd(tree,tree[ri],0)
    
    for tmp in tree:
        print("node {}: parent = {}, depth = {}, {}, {}".format(tmp.id, tmp.parent,tmp.depth,tmp.type,list(map(int,tmp.children))))

    

Measured memory_bytes: 58556
H,N = map(int,input().split())
Magic = [list(map(int, input().split())) for i in range(N)]

inf = float("inf")
dp = [inf]*(H+1)
dp[0]=0

for i in range(N):
    a,b = Magic[i]
    for h in range(H):
        
        next_h = min(h+a,H)
        dp[next_h]=min(dp[next_h],dp[h]+b)

print(dp[-1])

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

namespace Template
{
    public static class Scanner
    {
        public static string NextLine => Console.ReadLine();
        public static int NextInt => int.Parse(NextLine);
        public static long NextLong => long.Parse(NextLine);
        public static double NextDouble => double.Parse(NextLine);

        public static string[] StrAry(char separator = ' ') => Console.ReadLine().Split(separator);
        public static int[] IntAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), int.Parse);
        public static long[] LongAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), long.Parse);
        public static double[] DoubleAry(char separator = ' ') => Array.ConvertAll(StrAry(separator), double.Parse);
    }

    internal class Template
    {
        public static void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
        private static void Fill<T>(T[] src, T value, int len) { for (int i = 0; i < len; i++) { src[i] = value; } }

        static void Solve() 
        {
            var n = Scanner.NextInt;
            var sum = Enumerable.Range(1,n).Sum();
            Console.WriteLine(sum);
        }
        private static void Main()
        {
            Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define REP(i,n) for(long long i = 0;i < n;++i)
#define FOR(i,a,b) for(long long i = a;i < b;++i)
using namespace std;
using ll = long long;
using point = pair< int,int >;

int main() {
    int i, uru;
    ll y, m, d;
    ll b, ka, t, w, ki;
    ll year, month, day;
    ll sum;
    string str;
    const int table[][13] = {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
                             {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};

    while (cin >> str) {
        if (str == "#") break;
        if (count(str.begin(), str.end(), '.') == 4) {
            sscanf(str.c_str(), "%lld.%lld.%lld.%lld.%lld", &b, &ka, &t, &w, &ki);

            sum = ki + w * 20 + t * 360 + ka * 7200 + b * 144000;
            for (i = 0, year = 2012, month = 12, day = 21; i < sum; ++i) {
                uru = (year % 400 == 0 || year % 100 && year % 4 == 0);
                day++;
                if (table[uru][month] < day) {
                    day = 1;
                    month++;
                }
                if (month > 12) {
                    month = 1;
                    year++;
                }
            }

            printf("%lld.%lld.%lld\n", year, month, day);
        } else {
            sscanf(str.c_str(), "%lld.%lld.%lld", &y, &m, &d);

            sum = (y - 2013) * 365 + 10;
            if (y == 2012) sum--;
            uru = (y % 400 == 0 || y % 100 && y % 4 == 0);
            for (i = 2013; i < y; ++i) {
                sum += (i % 400 == 0 || i % 100 && i % 4 == 0);
            }
            for (i = 1; i < m; ++i) {
                sum += table[uru][i];
            }
            sum += d;

            printf("%lld.%lld.%lld.%lld.%lld\n", sum / 144000 % 13, sum / 7200 % 20, sum / 360 % 20, sum / 20 % 18, sum % 20);
        }
    }

    return 0;
}




Measured memory_bytes: 3284
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll plu;
int main() {
    for(int i=0;i<5;i++){
        int a;
        cin >> a;
        if(a==0){
            cout << i+1<<endl;
            return 0;
        }
    }
    
}


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

# define C continue;
# define D double
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b));
# define mod 1000000007

# define pp(n) printf("%.10f",n);
# define line cout<<"\n";

const D pie = acos(-1);
const D hpie = asin(1);
const D qpie = atan2(-1,1);
const D tpie = 2*pie;

int gcd ( int a , int b )
{
    while ( a%b )
    {
        int temp = b;
        b = a%b;
        a = temp;
    }

    return b;
}

void solve( int test_case )
{
    int n;
    cin>>n;

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

    vi pref_gcd ( n );
    vi suff_gcd ( n );

    pref_gcd[0] = v[0];
    suff_gcd[n-1] = v[n-1];

    for ( int i=1 ; i<n ; i++ )
        pref_gcd[i] = gcd(pref_gcd[i-1] , v[i] );

    for ( int i=n-2 ; i>=0 ; i-- )
        suff_gcd[i] = gcd ( suff_gcd[i+1] , v[i] );

    int ans = max(suff_gcd[1] , pref_gcd[n-2]);

    for ( int i=1 ; i<n-1 ; i++ )
        ans = max ( ans , gcd(pref_gcd[i-1] , suff_gcd[i+1] ) );

    cout<<ans<<"\n";
}

int main()
{
    int t = 1;
    //cin>>t;

    for ( int i=0 ; i<t ; i++ ) solve(i);
    return 0;
}



Measured memory_bytes: 1408
x,y=map(int,input().split())
def fun(x):
	price=0
	if x==3:
		price=100000
	elif x==2:
		price=200000
	elif x==1:
		price=300000
	return price
if x ==1 and y ==1:
	print(fun(x)+fun(y)+400000)
else:
	print(fun(x)+fun(y))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//
constexpr ll MOD=1e9+7;
//constexpr ll MOD=998244353;
//constexpr ll MOD=10000000;
//constexpr ll MOD=1e5;
constexpr ll MAX=1e7;
constexpr ll INF=(1ll<<62);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
const ll N=26;
ll solve(ll D,vii &A,vi &C,vi &S){
    vi last(N,-1);
    ll a=0;
    rep(i,0,D){
        ll memo; memo=S[i];
        last[memo]=i;
        a+=A[i][memo];
        rep(j,0,N) a-=(i-last[j])*C[j];
    }
    return a;
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    srand((unsigned)time(NULL));
    ll D; cin>>D;
    vi C(N);
    rep(i,0,N) cin>>C[i];
    vii A(D,vi(N));
    rep(i,0,D){
        rep(j,0,N) cin>>A[i][j];
    }
    vi last(N,-1);
    vi ans(D);
    rep(i,0,D){
        ll max=0,memo=0;
        rep(j,0,N){
            if(max<A[i][j]+(i-last[j])*C[j]){
                max=A[i][j]+(i-last[j])*C[j];
                memo=j;
            }
        }
        last[memo]=i;
        ans[i]=memo;
    }
    ll max=solve(D,A,C,ans);
    rep(_,0,45){
        if(_%3==1){
            rep(i,0,D){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
        else{
            per(i,D-1,0){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
    }
    rep(i,0,D) cout<<ans[i]+1<<endl;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int n,m;
int k[10] = {};	//switch
int p = 0;

int main() {
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int _k;
		cin >> _k;
		for(int j = 0; j < _k; j++) {
			int s;
			cin >> s;
			s--;
			k[s] |= (1<<i);
		}
	}
	/*
	for(int i = 0; i < n; i++) {
		cout << k[i] << endl;
	}
	*/
	for(int i = 0; i < m; i++) {
		int _p;
		cin >> _p;
		if(_p%2==1) p |= (1<<i);
	}
	//cout << p << endl;

	int ans = 0;
	for(int i = 0; i < (1<<n); i++) {
		int bits = 0;
		for(int j = 0; j < n; j++) {
			if((i&(1<<j))!=0) {
				bits ^= k[j];
			}
		}
		if(bits==p) ans++;

		//cout << "(i,bits)=("<<i<<","<<bits<<")"<<endl;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
  int n, d;
  cin >> n;
  cin >> d;

  int range = d * 2 + 1; // People can check this range.

  int r = n / range;
  if ((n % range) == 0) {
    // Do nothing
  } else {
    r += 1;
  }
  cout << r << endl;
}


Measured memory_bytes: 256
import java.util.*;

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

        int[] base_a = new int[N]; // 0 or 1
        int[] ball_b = new int[N]; // 0 or 1
        for(int i = 0; i < N; i++){
            base_a[i] = scanner.nextInt();
            ball_b[i] = 0;
        }
      
       /*
       * 最後の箱(Nコ目)の余り計算は、以下の箱のボールの個数に依存しない
       * そのため、最後の箱から余りを考えていくのが良さそう(-1にはならない？)
       */
       for(int i = N-1; i >= 0; i--){
           
           // iの倍数の箱のボールの合計
           int total_b = 0; 
           for(int j = i; j < N; j += i+1){
                total_b += ball_b[j];
           }
           
         //ボールを入れる条件
           if(base_a[i] == 1 && total_b % 2 == 0){
               ball_b[i] = 1;
           } else if(base_a[i] == 0 && total_b % 2 == 1){
               ball_b[i] = 1;
           }
       }
       
       //出力準備
       int count_b = 0;
       for(int i = 0; i < N; i++){
           if(ball_b[i] == 1){
               count_b++;
           }
       }
       System.out.print(count_b);

       System.out.println("");

       for(int i = 0; i < N; i++){
           if(ball_b[i] == 1){
               System.out.print(i+1 + " ");
           }
       }
    }
}

Measured memory_bytes: 84844
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

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

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll n;
    vector <ll> conf;
    cin >>n;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        conf.push_back(tmp);
    }
    sort(ALL(conf), greater<ll>() );

    ll ans=0;
    ll pos=0;
    bool flg=false;
    REP(i,n-1){
        if(i ==0){
            ans += conf[pos];
            pos++;
            continue;
        }
        if(flg){
            flg = false;
            ans += conf[pos];
            pos++;
        }else{
            ans += conf[pos];
            flg =true;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b >= c) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 123;

int a[N][N], b[N][N];

void solve() {
  int h, w; scanf("%d%d", &h, &w);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      char c; scanf(" %c", &c);
      a[i][j] = c == '#';
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int u = 1e9, v = 1e9;
      b[i][j] = a[i][j];
      if (j) {
	u = b[i][j]+b[i][j-1];
	if (a[i][j] && a[i][j-1]) --u;
      }
      if (i) {
	v = b[i][j]+b[i-1][j];
	if (a[i][j] && a[i-1][j]) --v;
      }
      if (i || j) b[i][j] = min(u, v);
    }
  }
  printf("%d", b[h-1][w-1]);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> ab(N);
    ll a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        ab[i] = {a, b};
    }
    sort(ab.begin(), ab.end());
    ll cnt = 0;
    for (int i = 0; i < N; i++) {
        a = ab[i].first;
        b = ab[i].second;
        cnt += b;
        if (K <= cnt) {
            cout << a << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4840
N = int(input())

works = []
for work in range(N):
    a, b = [int(i) for i in input().split()]
    works.append((a, b))
    
works.sort(key=lambda x: x[1])

time_cnt = 0
flag = True
for work in works:
    t = work[0]
    l = work[1]
    time_cnt += t
    if time_cnt > l:
        flag = False
        break
        
if flag:
    print('Yes')
else :
    print('No')

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {
  int n, c;
  int dp[31][1<<16];
  int a[31], b[31];
  
  while(cin>> n>> c, n) {
    for(int i=0; i<n; i++) {
      a[i] = 0;
      for(int j=0; j<16; j++) {
	int bit;
	cin>> bit;
	a[i] = (a[i]<<1)+bit;
	
      }
    }
    
    for(int i=0; i<c; i++) {
      b[i] = 0;
      for(int j=0; j<16; j++) {
	int bit;
	cin>> bit;
	b[i] = (b[i]<<1)+bit;
	
      }
    }
    
    for(int i=0; i<n+1; i++) {
      for(int j=0; j<(1<<16); j++) {
	dp[i][j] = -1;
      }
    }
    
    dp[0][0]=0;
    for(int i=0; i<n; i++) {
      for(int j=0; j<(1<<16); j++) {
	if(dp[i][j] == -1) continue;
	int panel = (a[i] | j);
	for(int k=0; k<c; k++) {
	  int push_panel = (panel & b[k]);
	  int score = __builtin_popcount(push_panel);
	  dp[i+1][panel-push_panel] = max(dp[i+1][panel-push_panel],dp[i][j]+score);
	}
      }
    }

    int ans=0;
    for(int i=0; i<(1<<16); i++){
      ans = max(ans,dp[n][i]);
    }

    cout<< ans<< endl;
  }
}

Measured memory_bytes: 9100
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a>b){
      System.out.println("a > b");
    }else if(a<b){
      System.out.println("a < b");
    }else{
      System.out.println("a == b");
    }
  }
}



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

#define int long long

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

  string s;
  cin >> s;

  sort(s.begin(), s.end());

  if ( s[0] == s[1] && s[2] == s[3] && s[1] != s[2] ) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

void Pr(bool f){
    cout << (f ? "Yes" : "No") << endl;
    exit(0);
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h){
        cin >> s[i];
    }
    vll cnt(26, 0);
    rep(i, h)rep(j, w){
        cnt[s[i][j]-'a']++;
    }
    if((h&1) && (w&1)){
        ll c = 0;
        rep(i, 26){
            if(cnt[i] & 1){
                c++;
                cnt[i]--;
            }
        }
        if(c != 1) Pr(0);
        c = 0;
        rep(i, 26){
            if(cnt[i] % 4){
                c++;
            }
        }
        if(c <= (h + w - 2)/2 && ((h + w - 2)/2 - c) % 2 == 0){
            Pr(1);
        }
        Pr(0);
    }else if(h&1){
        rep(i, 26){
            if(cnt[i] & 1){
                Pr(0);
            }
        }
        ll c = 0;
        rep(i, 26){
            if(cnt[i] % 4){
                c++;
            }
        }
        if(c <= w/2 && (w/2 - c) % 2 == 0){
            Pr(1);
        }
        Pr(0);
    }else if(w&1){
        rep(i, 26){
            if(cnt[i] & 1){
                Pr(0);
            }
        }
        ll c = 0;
        rep(i, 26){
            if(cnt[i] % 4){
                c++;
            }
        }
        if(c <= h/2 && (h/2 - c) % 2 == 0){
            Pr(1);
        }
        Pr(0);
    }else{
        rep(i, 26){
            if(cnt[i] % 4) Pr(0);
        }
        Pr(1);
    }
    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    cout << fixed << setprecision(6) << ((n + 1) / 2) / (double) n;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[321];
int n, K;
int d[321][321][321];
bool v[321][321][321];
int dfs(int s, int len, int edits)
{
	if (len == 0) return 0;
	if (len == 1) return 1;
	if (v[s][len][edits]) return d[s][len][edits];
	int e = s + len - 1;
	if (a[s] == a[e]) return dfs(s + 1, len - 2, edits) + 2;
	int ret = max(dfs(s, len - 1, edits), dfs(s + 1, len - 1, edits));
	if (edits < K)
		ret = max(ret, dfs(s + 1, len - 2, edits + 1) + 2);
	v[s][len][edits] = true;
	return d[s][len][edits] = ret;
}
int main()
{
	scanf("%s%d", &a[1], &K);
	n = strlen(&a[1]);
	printf("%d\n", dfs(1, n, 0));
	return 0;
}


Measured memory_bytes: 148480
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)

using namespace std;

struct P {
	int64_t x;
	int64_t y;
	int64_t p;
};

int64_t ans[16];

struct VA {
	int64_t v[16];
};

unordered_map<int64_t, VA> xl_memo;
unordered_map<int64_t, VA> yl_memo;

void eval(vector<P>& ps, vector<int>& ss, int n)
{
	int c = 0;
	int64_t xs = 0;
	int64_t ys = 0;
	FOR_LT(i, 0, n) {
		if (ss[i] == 1) {
			xs += (1 << i);
			c++;
		}
		else if (ss[i] == 2) {
			ys += (1 << i);
			c++;
		}
	}

	auto xit = xl_memo.find(xs);
	if (xit == xl_memo.end()) {
		VA va = { 0 };
		set<int64_t> xl = { 0 };
		FOR_LT(i, 0, n) {
			if (ss[i] == 1) {
				xl.insert(ps[i].y);
			}
		}

		FOR_LT(i, 0, n) {
			int64_t val = INT_MAX;
			auto it = xl.lower_bound(ps[i].y);
			if (it != xl.end()) {
				val = min(val, abs(*it - ps[i].y));
			}
			if (it != xl.begin()) {
				it--;
				val = min(val, abs(*it - ps[i].y));
			}
			va.v[i] = val;
		}

		xit = xl_memo.insert({ xs, va }).first;
	}

	auto yit = yl_memo.find(ys);
	if (yit == yl_memo.end()) {
		VA va = { 0 };
		set<int64_t> yl = { 0 };
		FOR_LT(i, 0, n) {
			if (ss[i] == 2) {
				yl.insert(ps[i].x);
			}
		}

		FOR_LT(i, 0, n) {
			int64_t val = INT_MAX;
			auto it = yl.lower_bound(ps[i].x);
			if (it != yl.end()) {
				val = min(val, abs(*it - ps[i].x));
			}
			if (it != yl.begin()) {
				it--;
				val = min(val, abs(*it - ps[i].x));
			}
			va.v[i] = val;
		}

		yit = yl_memo.insert({ ys, va }).first;
	}

	int64_t sum = 0;
	FOR_LT(i, 0, n) {
		int64_t cs = INT64_MAX;
		{
			cs = min(cs, xit->second.v[i] * ps[i].p);
		}
		{
			cs = min(cs, yit->second.v[i] * ps[i].p);
		}
		sum += cs;
	}
	ans[c] = min(ans[c], sum);
}

void sel(vector<P>& ps, vector<int>& ss, int i, int n)
{
	if (i == n) {
		eval(ps, ss, n);
		return;
	}
	FOR_LT(j, 0, 3) {
		ss[i] = j;
		sel(ps, ss, i + 1, n);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	vector<P> ps(n);
	FOR_LT(i, 0, n) {
		auto& p = ps[i];
		cin >> p.x >> p.y >> p.p;
	}

	vector<int> ss(n);

	FOR_LE(i, 0, n) {
		ans[i] = INT64_MAX;
	}

	sel(ps, ss, 0, n);

	FOR_LE(i, 0, n) {
		cout << ans[i] << endl;
	}

	return 0;
}

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

using namespace std;

int main (){

     int N ; cin >> N;
     //char S[N], T[N]; 
     string S, T;
     cin >> S >> T;
     
     for(int i = 0;i < N; i++){
     char c = S[i];
     char d = T[i];
     cout << c << d;
     }
    

}

Measured memory_bytes: 256
import sys
from itertools import permutations
sys.setrecursionlimit(1000000) # 再帰上限を増やす

def main():
    input = sys.stdin.readline  # 文字列に対してinputした場合は、rstripするのを忘れずに！
    N, M = map(int, input().rstrip().split())
    path_list = []
    for _ in range(M):
        a, b = map(int, input().rstrip().split())
        path_list.append((a-1, b-1))
        path_list.append((b-1, a-1))

    count = 0
    for path in permutations(range(1, N)):
        now_posi = 0
        for next_posi in path:
            if (now_posi, next_posi) not in path_list:
                break
            now_posi = next_posi
        else:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<P> c1; //fueru
  vector<P> c2; //heru
  int op=0;
  int cl=0;
  rep(i,n){
    string s; cin >> s;
    int m = s.size();
    int a=0, b=0;
    rep(j,m){
      if(s[j]=='('){
        a++; 
      } else {
        if(a==0){ b++; }else{ a--; }
      }
    }
    if(a==0&&b==0) continue;
    if(a==0){ cl+=b; continue; }
    if(b==0){ op+=a; continue; }
    if(a>=b){ c1.emplace_back(b,a); } else { c2.emplace_back(b,a); }
  }
  sort(c1.begin(),c1.end());
  sort(c2.rbegin(),c2.rend());
  for(auto it:c1){
    if(op>=it.F){
      op = op-it.F+it.S;
    } else {
      cout << "No" << endl; return 0;
    }
  }
  for(auto it:c2){
    if(op>=it.F){
      op = op-it.F+it.S;
    } else {
      cout << "No" << endl; return 0;
    }
  }
  if(op==cl){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 5300