akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*int power(int a,int n)
{
    if(n == 1)return a%mod;
    if(n == 0)return 1;
    if(n&1)return ((a%mod)*(power((a*a)%mod,n>>1))%mod)%mod;
    return power((a*a)%mod,n>>1)%mod;
}
*/
const int md = 998244353;
int dp[100100][105];


signed main()
{
    showoff;
    int n,W;
    cin >> n >> W;
    int v[110],w[110];
    FOR(i,1,n+1)
    cin >> w[i] >> v[i];
    FOR(i,1,100005)
    FOR(j,0,105)
    dp[i][j] = mod;
    FOR(i,1,100005){
        FOR(j,1,n+1){
        if(v[j] <= i){
            dp[i][j] = min(dp[i][j-1],dp[i-v[j]][j-1]+w[j]);
        }
        else dp[i][j] = dp[i][j-1];
        }
    }
    int ans = 0;
    FOR(i,0,100001){
    if(dp[i][n] <= W)ans = max(ans,i);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 82304
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#include <unordered_map>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;

int N, S[100010];
unordered_map<int, int> dp[100010];

void solve(int k, int C) {
    if(dp[k].count(C) and dp[k][C] != -INF) return;
    if(k > 0) {
        solve(k-1, C);
        int A = N - 1 - k*C;
        dp[k][C] = dp[k-1][C] + S[A] + S[k*C]; 
    }
    else dp[k][C] = 0;
}

signed main() {
    cin >> N;
    for(int i=0; i<N; i++) cin >> S[i];

    // ありえる k, C の列挙
    for(int A=1; A<=N-2; A++) {
        int kC = N - 1 - A;

        // 約数列挙
        vector<int> ks;
        for(int k=1; k*k<=kC; k++) {
            if(kC % k == 0) {
                ks.push_back(k);
                if(k*k != kC) ks.push_back(kC/k);
            }
        }

        for(const auto &d : ks) {
            int k = d, C = kC / d;
            if(A <= C) continue;
            if(A%C == 0 and 0 <= A/C and A/C <= k) continue;
            dp[k][C] = -INF;
        }
    }

    for(int k=N-1; k>=1; k--) {
        for(auto &e : dp[k]) {
            int C = e.first;
            solve(k, C);
        }
    }

    int ans = 0;
    for(int k=N-1; k>=0; k--) {
        for(auto &e : dp[k]) {
            int C = e.first, val = e.second;
            int A = N - 1 - k*C;

            if(A <= 0 or C <= 0 or A <= C) continue;
            if(A%C == 0 and 0 <= A/C and A/C <= k) continue;
            chmax(ans, val);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 55448
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
#include <queue>
#include <complex>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int x1,y1,x2,y2;

  cin >> x1 >>y1 >>x2 >> y2;

  // int dis = sqrt( pow(x1-x2,2) + pow(y1-y2,2) );

  pair<int,int> vectr;
  vectr.first = x2-x1;
  vectr.second = y2-y1;

  int x3,y3;
  int x4,y4;

  pair<int,int> vectr2;
  vectr2.first = -vectr.second;
  vectr2.second = vectr.first;

  x3 = x2+ vectr2.first;
  y3 = y2+ vectr2.second;


  pair<int,int> vectr3;
  vectr3.first = -vectr2.second;
  vectr3.second = vectr2.first;

  x4 = x3+ vectr3.first;
  y4 = y3+ vectr3.second;

  cout << x3 <<" " <<y3 <<" ";


  cout << x4 <<" " <<y4;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0037
{
	class Program
	{
		const	int	R	= 0x01;
		const	int	D	= 0x02;
		const	int	L	= 0x04;
		const	int	U	= 0x08;
		
		static void Main(string[] args)
		{
			var	grid	= new int[ 20, 20 ];	// 範囲外チェックを省略するため大きめにとる。実際は10,10から使用
			input_grid( grid );

			int[]	dir_tbl		= { R, D, L, U };
			char[]	path_dir	= { 'R', 'D', 'L', 'U' }; 
			int[,]	move		= { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };

			int	dir	= 0;
			int	x	= 10;
			int	y	= 10;
			var	path	= "";
			do {
				for( int i = -1; i <= 2; i++ ) {
					int	dir_chk	= (dir + i) & 0x03;
					if( (grid[ y, x ] & dir_tbl[ dir_chk ]) == dir_tbl[ dir_chk ] ) {
						dir	= dir_chk;
						x	+= move[ dir, 0 ]; 
						y	+= move[ dir, 1 ]; 
						path	+= path_dir[ dir ];
						break;
					}
				}
			} while( (x != 10) || (y != 10) );
			Console.WriteLine( path );
		}


		static void input_grid( int[,] grid )
		{
			for( int i = 0; i < 9; i++ ) {
				var	str	= Console.ReadLine();
				int	y	= i / 2;
				if( (i & 0x01) == 0x00 ) {
					for( int x = 0; x < 4; x++ ) {
						if( str[ x ] == '1' ) {
							grid[ y + 10, x + 10 ]	|= R;
							grid[ y + 10, x + 11 ]	|= L;
						}
					}
				} else {
					for( int x = 0; x < 5; x++ ) {
						if( str[ x ] == '1' ) {
							grid[ y + 10, x + 10 ]	|= D;
							grid[ y + 11, x + 10 ]	|= U;
						}
					}
				}
			}
		}
	}
}

Measured memory_bytes: 5256
import java.util.Scanner;

public class Main {

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

        int num1 = scan.nextInt();
        int num2 = scan.nextInt();
        int num3 = scan.nextInt();

        int count = 0;

        if(num1 != num2){
            count++;
        }

        if(num2 != num3){
            count++;
        }

        if(num1 != num3){
            count++;
        }

        if(count == 1 || count ==2){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764
S = str(input())
length = len(S)
n = 0

while length > n:
  if n == 0 or n % 2 == 0:
    if S[n] == 'R' or  S[n] == 'U' or  S[n] == 'D':
      n += 1
      continue
    else:
      print("No")
      break
  else:
    if S[n] == 'L' or  S[n] == 'U' or  S[n] == 'D':
      n += 1
      continue
    else:
      print("No")
      break
if n == length:
  print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long n = scan.nextInt();
			long a = scan.nextInt();
			long b = scan.nextInt();
			long goukei = 0;
			goukei+=mod_pow(2,n,mod);
			goukei=(goukei+mod-1)%mod;
			long A = 1;
			long B = 1;
			long x =1;
			long y = 1;
			
			for(long i = 0;i<a;i++) {
				
				x=x*(n-i)%mod;
				y=y*(a-i)%mod;
				//System.out.println(x);
				//System.out.println(y);
				
				
			}
			A = (x*mod_pow(y,mod-2,mod))%mod;
			
			x=1;
			y=1;
			
			for(long i = 0;i<b;i++) {
				
				x=x*(n-i)%mod;
				y=y*(b-i)%mod;
				
			}
			B = (x*mod_pow(y,mod-2,mod))%mod;
			
			//System.out.println(x);
			//System.out.println(y);
			goukei=(goukei-A+mod)%mod;
			goukei=(goukei-B+mod)%mod;
			
			//System.out.println(A);
			//System.out.println(B);
			System.out.println(goukei);
		}
		
		
	}
	
	private static long mod_pow(long x, long n ,long mod) {//Xのn乗を二分累乗法(繰り返し２乗法)で計算modもあり大きくしない
		long res = 1;
		    while(n > 0){
		        if((n&1)==1) {
		        	res = res*x%mod;
		        }
		        x = x*x%mod;
		        n >>= 1;
		    }
		    return res;
	}
	
	//組み合わせを使う際は、限界まで自力でできるか考えてから使う、ex nC2を求める場合自力でできる
	
	
	 /* int n = 1_000_000; //n=100万まで求めるとする
    pre_factorials(n); //1!からn!までの値を持った配列を準備する    
    System.out.println(fastFermatComb(5, 2)); //5C2を計算 -> 出力10
    System.out.println(fastFermatComb(50000, 3000)); //50000C3000を計算 -> 出力890850597 (1e9+7で割った余り)
	
	*mainメソッドはこのように使うことでコンビネーション使える　mod指定されてるので問題によってかえる
	*/
	
	
	
	 //Fast Fermat Combination
    static int mod = (int) 1e9 + 7;
    static long factorials[]; //事前に階乗計算の結果を格納しておく配列

    static void pre_factorials(int n) { //0!〜n!まで求めておく
        factorials = new long[n + 1];
        factorials[0] = 1;
        for (int i = 0; i < n; i++) {
            factorials[i + 1] = (long)(i + 1) * factorials[i] % mod;
        }
    }

    static long fastFermatComb(long a, long b) {
        if (factorials.length == 0)
            System.err.println("error : factorials has not been culculated!! do [pre_factorials] method");
        long af = factorials[(int) a];
        long bf = factorials[(int) b];
        long abf = factorials[(int) (a - b)];
        long res = af * modpow(bf, mod - 2) % mod * modpow(abf, mod - 2) % mod;
        return res;
    }

    //mod条件下の高速pow
    static long modpow(long a, long p) {
        if (p == 0)
            return 1;
        if (p % 2 == 0) {
            long root = modpow(a, p / 2);
            return root * root % mod;
        } else
            return a * modpow(a, p - 1) % mod;
    }
}
	
	


Measured memory_bytes: 23508
#!/usr/bin/env python3

N = int(input())
x = [None] * N
u = [None] * N
for i in range(N):
    x[i], u[i] = input().split()
    x[i] = float(x[i]) if u[i] == 'JPY' else float(x[i]) * 380000.0
print(sum(x))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(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 pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll res = 0;
    ll n;
    cin >> n;
    
    res = n * n;
    cout << res << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    string a, b;
    read(a, b);
    if (a.size() > b.size()) {
        print("GREATER");
    }
    else if (a.size() < b.size()) {
        print("LESS");
    }
    else{
        FOR(a.size()) {
            if (a[i] > b[i]) {
                print("GREATER");
                return;
            }
            else if (a[i] < b[i]) {
                print("LESS");
                return;
            }
        }
        print("EQUAL");
    }
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        
        solve();
        
    }
    
}



Measured memory_bytes: 3548
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include<iomanip>
#include<map>

using namespace std;

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

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);

int main(){
  int n;
  cin>>n;
  ll x[n];
  REP(i,n) cin>>x[i];
  ll nmin=2,nmax=2;
  for(int i=n-1;i>=0;i--){
    ll min_b=((nmin-1)/x[i])+1;
    ll max_b=(nmax/x[i])+1;
    ll nmin_c=x[i]*min_b;
    ll nmax_c=x[i]*max_b-1;
    if(nmin_c>nmax_c){
      nmin=-1;
      break;
    }
    nmin=nmin_c;
    nmax=nmax_c;

  }
  if(nmin==-1){
    cout<<"-1\n";
  }else{
    cout<<nmin<<" "<<nmax<<"\n";
  }
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**6)

s = input()

d = {}

for ch in s:
    d[ch] = d.get(ch, 0) + 1
    
if len(d) == 2:
    for k in d:
        if d[k] == 2:
            pass
        else:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int n;
char s[1010];
vector<PII> ans,c,trash;
vector<PII> build(VI w) {
	if (SZ(w)==1) return vector<PII>{{w[0],0}};
	vector<PII> z{{w[0],0},{w[1],0},{w[0],1},{w[1],1}};
	rep(i,2,SZ(w)) {
		vector<PII> nz=z; 
		z.pb({w[i],0});
		reverse(all(nz));
		for (auto p:nz) z.pb({p.fi,p.se^1});
		z.pb({w[i],1});
	}
	return z;
}
int zz;
int main() {
	scanf("%d",&n);
	scanf("%s",s);
	//rep(i,0,(1<<n)) s[i]=(__builtin_popcount(i)<5)+'0';
	rep(i,0,(1<<n)) if (s[i]=='0') {
		rep(j,0,(1<<n)) if ((j&i)==i&&s[j]=='1') {
			puts("Impossible");
			return 0;
		}
		bool cc=0;
		rep(j,0,(1<<n)) if ((i&j)==j&&i!=j&&s[j]=='0') cc=1;
		if (cc) continue;
		VI w;
		fprintf(stderr,"%d\n",i);
		rep(j,0,n) if (i&(1<<j)) w.pb(j);
		auto x=build(w);
		for (auto p:x) ans.pb(p);
		zz++;
		//rep(i,0,n) ans.pb(mp(i,0)),trash.pb(mp(i,0));
		rep(i,0,100) {
			int x=rnd(n);
			ans.pb(mp(x,(SZ(w)>=2))),trash.pb(mp(x,(SZ(w)>=2)));
		}
	}
	//fprintf(stderr,"%d\n",zz);
	reverse(all(trash));
	for (auto p:trash) ans.pb(mp(p.fi,p.se^1));
 // rep(i,0,zz) per(j,0,n) ans.pb(mp(j,-1));
	rep(i,0,(1<<n)) {
		stack<PII> s;
		for (auto x:ans) {
			if (!(i&(1<<x.fi))) continue;
			if (!s.empty()&&s.top().fi==x.fi&&s.top().se==(x.se^1)) s.pop();
			else s.push(x);
		}

		if (s.empty()!=(::s[i]=='1')) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	int pos=0;
	c.pb(mp(0,0));
	for (auto p:ans) {
		//printf("pp %d %d\n",p.fi,p.se);
		if (p.se==0) {
			while (pos<p.fi) {
				pos+=1;
				c.pb(mp(pos,0));
			}
			while (pos>p.fi) {
				pos-=1;
				c.pb(mp(pos,0));
			}
			c.pb(mp(pos,1));
			c.pb(mp(pos+1,1));
			c.pb(mp(pos+1,0));
			pos+=1;
		} else {
			while (pos<p.fi+1) {
				pos+=1;
				c.pb(mp(pos,0));
			}
			while (pos>p.fi+1) {
				pos-=1;
				c.pb(mp(pos,0));
			}
			c.pb(mp(pos,1));
			c.pb(mp(pos-1,1));
			c.pb(mp(pos-1,0));
			pos-=1;
		}
	}
	while (pos>0) {
		pos--;
		c.pb(mp(pos,0));
	}
	assert(SZ(c)<=250000);
	printf("%d\n",SZ(c)-1);
	for (auto x:c) printf("%d %d\n",x.fi,x.se);
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int A,V,B,W,T;

signed main(){
	cin>>A>>V>>B>>W>>T;
	if(V<=W){
		cout<<"NO"<<endl;
		return 0;
	}
	int d=abs(A-B);
	int s=V-W;
	if(s*T>=d){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#隣接行列を書く
n,m = map(int,input().split())
ll = [[0]*n for _ in [0]*n]
for i in range(m):
  a,b = map(int,input().split())
  ll[a-1][b-1] = 1
  ll[b-1][a-1] = 1
#初期は1番目の点のみ訪問済み。かつ現在地は0番目
visit = [1]+[0]*(n-1)
place = 0
ans=0
#探索用関数
def search(visit,place):
  ans = 0
  if visit == [1]*n:
    return 1
  for i in range(n):
    if visit[i] == 0 and ll[place][i] == 1:
      tmpvisit = visit.copy()
      tmpvisit[i] = 1
      ans += search(tmpvisit,i)
  return ans
ans = search(visit,place)
print(ans)

Measured memory_bytes: 3064
from collections import defaultdict, deque

N = int(input())
edges = {}
scores = defaultdict(lambda: -1)

for _ in range(N):
    l = list(map(int, input().split()))
    node = l[0]
    degree = l[1]
    edges[node] = l[2:]

q = deque()
q.append((1, 0))

while q:
    node, score = q.popleft()
    if scores[node] != -1:
        continue
    scores[node] = score
    for child in edges[node]:
        q.append((child, score+1))

for node in range(1, N+1):
    print('%d %d' % (node, scores[node]))




Measured memory_bytes: 6008
#include <iostream>
#include <cstdlib>
#include<string>
#include<stdlib.h>
#include<math.h>
using namespace std;

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


int main()
{
    int x,y,z;
    int ans;
    
    cin>>x>>y>>z;
    ans=x/(y+z);
    x-=ans*(y+z);
    if(x<z)ans--;
    cout<<ans<<endl;
    
    return 0;
}


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

int main(){

    int a,b;
    cin >> a>>b;
    int ans1=0;
    int ans2=0;
    int ans3=0;

    ans1=a+(a-1);
    ans2=b+(b-1);
    ans3=a+b;
    int ans;
    if (ans1>ans2){
        ans=ans1;
        if (ans3>ans){
            ans=ans3;
        }

    }
    else{
        ans=ans2;
        if (ans3>ans){
            ans=ans3;
        }
    }
    cout << ans <<endl;

    return 0;
}


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

if N<=3:
  print(max(A))
  exit(0)
  
INF = 10**(9+6)
if N % 2:
  # when N is odd, 2 blocks are skippable
  dp = [[-INF]*3 for i in range(N)]
  
  dp[0][0] = A[0]
  dp[1][1] = A[1]
  dp[2][2] = A[2]
  
  for i in range(N):
    if i+2 < N:
      for j in range(3):
        if dp[i+2][j] < dp[i][j] + A[i+2]:
          dp[i+2][j] = dp[i][j] + A[i+2]
    if i+3 < N:
      for j in range(2):
        if dp[i+3][j+1] < dp[i][j] + A[i+3]:
          dp[i+3][j+1] = dp[i][j] + A[i+3]
    if i+4 < N:
      if dp[i+4][2] < dp[i][0] + A[i+4]:
        dp[i+4][2] = dp[i][0] + A[i+4]
  print(max(dp[-3][0],dp[-2][1],dp[-1][2]))
  
else:
  # when N is even, 1 block is skippable
  dp = [[-INF]*2 for i in range(N)]
  
  dp[0][0] = A[0]
  dp[1][1] = A[1]
  
  for i in range(N):
    if i+2 < N:
      for j in range(2):
        if dp[i+2][j] < dp[i][j] + A[i+2]:
          dp[i+2][j] = dp[i][j] + A[i+2]
    if i+3 < N:
      if dp[i+3][1] < dp[i][0] + A[i+3]:
        dp[i+3][1] = dp[i][0] + A[i+3]
  print(max(dp[-2][0],dp[-1][1]))


Measured memory_bytes: 61872
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

int main() {

	cin.tie(0);

	vector<string> s(3);
	FOR(i, 0, 3) cin >> s[i];
	int offset = 'A' - 'a';

	for (int i = 0; i < 3; i++){

		cout << ((char)(s[i][0] + offset));
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    char[][] field;
    boolean[][] visited;
    int[] dx = {-1, 0, 1, 0};
    int[] dy = {0, 1, 0, -1};
    Queue<Integer[]> q = new ArrayDeque<>();

    void run() {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        field = new char[h][w];
        visited = new boolean[h][w];
        int bCount = 0;

        for (int i = 0; i < h; i++) {
            char[] chars = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                field[i][j] = chars[j];
                if (chars[j] == '#') {
                    q.add(new Integer[]{i, j, 0});
                    visited[i][j] = true;
                }
            }
        }

        int count = -1;
        while (!q.isEmpty()) {
            Integer[] next = q.remove();
            int x = next[0];
            int y = next[1];
            int depth = next[2];
            count = Math.max(count, depth);
            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (0 <= nx && nx < h && 0 <= ny && ny < w && !visited[nx][ny]) {
                    visited[nx][ny] = true;
                    q.add(new Integer[]{nx, ny, depth + 1});
                }
            }
        }

        System.out.println(count);
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 123056
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n

for i in range(m):
    p, s = input().split()
    idx = int(p) -1
    if ac[idx]==1:
        continue
    else:
        if s == 'AC':
            ac[idx]=1
        else:
            wa[idx] += 1
w = sum([v for i, v in enumerate(wa) if ac[i]==1])
a = sum(ac)
print(a, w)

Measured memory_bytes: 5424
from itertools import accumulate

N, K = map(int, input().split())
a_list = list(map(int, input().split()))

b_list = []
for a in a_list:
    if a > 0:
        b_list.append(a)
    else:
        b_list.append(0)
b_list = list(accumulate(b_list))
a_acc = list(accumulate(a_list))

b_list.insert(0, 0)
b_list.append(b_list[-1])
a_acc.insert(0, 0)
ans = 0


for i in range(N - K + 1):

    ans = max(ans, b_list[i] + a_acc[i + K] - a_acc[i] + b_list[N] - b_list[i + K])
    ans = max(ans, b_list[i] + b_list[N] - b_list[i + K])
print(ans)


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

 
const int INF = (int) 1e9;

struct point {
	int x;
    int y;
	point() : x(0), y(0) {}
};
 
struct fenwick_tree {
	int n;
	unordered_map<int, int> F;
 
    fenwick_tree() : n(INF) {
        F.rehash((int) 3e5);
    }
	void upd(int i, int x) {
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	} 
	int get(int i) {
		int res = 0;
		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);
		return res;
	}
};
 
 
bool cmp(point a, point b) {
    return make_pair(a.x, a.y) < make_pair(b.x, b.y); 
}
 
 
int main() {
#ifdef NICK
	freopen("input.txt", "r", stdin);
#else

#endif
    point start, finish;
    int n;
    cin >> start.x >> start.y;
    cin >> finish.x >> finish.y;
    cin >> n;
    point p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    if (start.x > finish.x)
        swap(start, finish);
    if (start.y > finish.y) {
        finish.y = 2 * start.y - finish.y;
        for (int i = 0; i < n; i++) {
            p[i].y = 2 * start.y - p[i].y;
        }
    }
    vector<point> a;
    for (int i = 0; i < n; i++) {
        if (start.x <= p[i].x && p[i].x <= finish.x && start.y <= p[i].y && p[i].y <= finish.y)
            a.emplace_back(p[i]);
    }
    fenwick_tree dp;
    sort(a.begin(), a.end(), cmp);
    for (int i = 0; i < (int)a.size(); ++i)
        dp.upd(a[i].y, dp.get(a[i].y) + 1);
    int cur = dp.get(INF);
    long double ans = 0;
    if (cur != min(finish.y - start.y, finish.x - start.x) + 1)
        ans = 100.0 * (finish.y + finish.x - start.y - start.x) - 20.0 * cur + 5 * M_PI * cur;
    else
        ans = 100.0 * (finish.y + finish.x - start.x - start.y) - 20.0 * cur + 5 * M_PI * (cur - 1) + 10 * M_PI;
    cout << fixed << setprecision(13) << ans << "\n";
	return 0;
}


Measured memory_bytes: 76780
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
using pii = pair<i32, i32>;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
using vpii = vector<pii>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;

template<typename T, typename S> bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; }
template<typename T, typename S> bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; }

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) const { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

using mint = modint<1000000007>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<mint>> dp(n + 1, vector<mint>(4));
  dp[0][0] = 1;
  rep(i, n) rep(j, 4) {
    if (j < 3) {
      if (s[i] == "ABC"[j] || s[i] == '?') {
        dp[i + 1][j + 1] += dp[i][j];
      }
    }
    if (s[i] == '?') {
      dp[i + 1][j] += dp[i][j] * 3;
    } else {
      dp[i + 1][j] += dp[i][j];
    }
  }
  cout << dp[n][3] << endl;
  return 0;
}

Measured memory_bytes: 5840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int n, m;
    cin >> n;
    vector<string> blue(n);

    rep(i, n){
        cin >> blue[i];
    }

    cin >> m;
    vector<string> red(m);
    rep(i, m){
        cin >> red[i];
    }
    int cnt=0;
    int max_cnt = 0;
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if (blue[i] == blue[j]){
                cnt++;
            }
        }
        for (int l=0; l<m; l++){
            if (blue[i] == red[l]){
                cnt--;
            }
        }
        max_cnt = max(max_cnt, cnt);
        cnt = 0;
    }
    printf("%d\n", max_cnt);



}

Measured memory_bytes: 3720
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 10000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

signed main() {
	int n, k;
	cin >> n >> k;
	if (k % 2 == 1) {
		cout << (n / k) * (n / k) * (n / k) << endl;
	}
	else {
		cout << (n / k) * (n / k) * (n / k) + ((n + (k / 2)) / k) * ((n + (k / 2)) / k) * ((n + (k / 2)) / k) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define long long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0);

const int MAXN = 3003;
int n, T;
pair<int, int> arr[MAXN];
int memo[MAXN][MAXN];

int solve(int idx, int t) {
//    cout << idx << ' ' << t  << endl;
    if (idx == n || t >= T)
        return 0;
    int &ret = memo[idx][t];
    if (~ret)
        return ret;
    ret = solve(idx + 1, t);
    ret = max(ret, solve(idx + 1, t + arr[idx].first) + arr[idx].second);
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("friday.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

    cin >> n >> T;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
    }

    sort(arr, arr + n);
    memset(memo, -1, sizeof memo);
    cout << solve(0, 0) << '\n';



    return 0;
}

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

int main(){
  int n; cin >> n;
  string s, ans; cin >> s;
  ans = s;

  int cnt=0;
  for(int i=0; i<n; i++){
    if(s[i]=='('){
      cnt++;
    }else{
      if(cnt){
        cnt--;
      }else{
        ans.insert(0, "(");
      }
    }
  }

  for(int i=0; i<cnt; i++) ans.append(")");

  cout << ans << endl;
  return 0;
}


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

int main(){
    ll x; cin >> x;
    ll k = x / 11;
    x = x - k * 11;
    if(x >= 7){
        cout << k*2 + 2 << endl;
    }else if(x >= 1){
        cout << k*2 +1 << endl;
    }else{
        cout << k * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#define __float128 long double
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

const int N = 1010;
int dp[N][N][2];

int rec(int odd, int even, int parity){
	if (odd + even == 2) return parity;

	int &res = dp[odd][even][parity];
	if (res + 1) return res;

	res = 0;
	if (odd >= 2) res |= !rec(odd - 2, even + 1, parity);
	if (odd&&even) res |= !rec(odd, even - 1, !parity);
	if (even >= 2) res |= !rec(odd, even - 1, !parity);

	return res;
}

struct UnionFind{
	vector<int> par, sz;
	UnionFind(int n){
		par = sz = vector<int>(n);
		for (int i = 0; i < n; ++i) par[i] = i, sz[i] = 1;
	}
	int find(int x){
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y){
		x = find(x), y = find(y);
		if (x == y) return;
		par[x] = y;
		sz[y] += sz[x];
	}
	bool same(int x, int y){
		return find(x) == find(y);
	}
	int size(int x){
		return sz[find(x)];
	}
};

int main(){

	int n;
	cin >> n;
	UnionFind uf(n);

	vector<string> v(n);
	rep(i, n) cin >> v[i];

	rep(i, n) rep(j, n){
		char c = v[i][j];
		if (c == 'Y') uf.unite(i, j);
	}
	
	vector<int> edge(n);
	rep(i, n) rep(j, i){
		char c = v[i][j];
		if (c == 'Y') --edge[uf.find(i)];
	}

	set<int> st;

	int odd = 0, even = 0, parity = 0;
	rep(i, n){
		int x = uf.find(i);
		if (st.count(x)) continue;
		st.insert(x);
		int sz = uf.size(x);
		if (sz & 1) ++odd;
		else ++even;

		int cnt = sz*(sz - 1) / 2;
		if((cnt - edge[x])&1) parity ^= 1;
	}

	MEMSET(dp, -1);
	cout << (rec(odd, even, parity) ? "Taro" : "Hanako") << endl;

	return 0;
}

Measured memory_bytes: 10364
#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
#define M 2005
int n;
char a[M][M];
int f[M][M],l[M][M],r[M][M];

inline void max(int &x,int y) {if(x<y) x=y;}
inline void min(int &x,int y) {if(x>y) x=y;}

int main () {
    scanf("%d",&n);
    for1(1,n,i) scanf("%s",a[i]+1);
    
    ll ans=0;
    FOR2(n,1,i) FOR2(n,1,j) 
        if(isdigit(a[i][j])) {
            bool t[2]={isdigit(a[i+1][j]),isdigit(a[i][j+1])};
            if(!t[0]&&!t[1]) {
                l[j][i]=r[j][i]=j;
                for1(i+1,n,k) l[j][k]=n+1,r[j][k]=0;
            }
            else if(!t[0]) {
                f[i][j]=f[i][j+1];
                l[j][i]=j,r[j][i]=r[j+1][i];
                for1(i+1,n,k) l[j][k]=l[j+1][k],r[j][k]=r[j+1][k];
            }
            else if(!t[1]) {
                f[i][j]=f[i+1][j];
                l[j][i]=r[j][i]=j;
            }
            else {
                int las=0;
                int tot=f[i+1][j]+f[i][j+1];
                l[j][i]=j,r[j][i]=r[j+1][i];
                
                for1(i+1,n,k) {
                    if(l[j+1][k]<=r[j][k]&&l[j+1][k]>las) tot-=f[k][l[j+1][k]];
                    max(las,r[j][k]);
                    min(l[j][k],l[j+1][k]);
                    max(r[j][k],r[j+1][k]); 
                }
                f[i][j]=tot;
            }
            ans+=f[i][j]*(a[i][j]-'0');
            f[i][j]+=a[i][j]-'0';
        }
        else l[j][i]=n+1,r[j][i]=0;
    cout<<ans<<endl;
}

Measured memory_bytes: 44160
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,x[16][15],y[16][15],flg[16],a[16],ii,f,k,xx,yy;
	int cnt,mx,n;
	scanf("%d",&n);
	for(i=1;i<=n;i++)	{
		scanf("%d",&a[i]);
		for(j=0;j<a[i];j++)	{
			scanf("%d %d",&x[i][j],&y[i][j]);
		}
	}
	mx=0;
	for(i=0;i<(1<<n);i++)	{
		ii=i;
		for(j=1;j<=n;j++)	{
			flg[j]=ii%2;
			ii/=2;
		}
		f=1;
		for(j=1;j<=n;j++)	{
			if(flg[j]==1)	{
				for(k=0;k<a[j];k++)	{
					xx=x[j][k];
					yy=y[j][k];
					if(flg[xx]!=yy)	{
						f=0;	break;
					}
				}
			}
			if(f==0)	break;
		}
		if(f==1)	{
			cnt=0;
			for(j=1;j<=n;j++)	{
				cnt+=flg[j];
			}
			mx=max(mx,cnt);
		}
	}
	printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
ll n;
ll a[100010];
set<ll>st;
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int i=0;i<n;i++){
    if(st.count(a[i])==0) st.insert(a[i]);
    else st.erase(a[i]);
}
cout<<st.size()<<endl;

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    ll dp[n];
    for(i=1;i<n;i++)dp[i]=inf;
    dp[0]=0;
    for(i=1;i<n;i++)
    {
        dp[i]=min(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
        if(i>1)
        {
            dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include <stdio.h>
int xx[200],xy[200],yx[1000],yy[1000],n,m,i,j,k,sum=0;
int dx,dy;
int main(){
	while(1){
scanf("%d",&n);
if(n==0) break;
for(i=0;i<n;i++){
	scanf("%d %d",&xx[i],&xy[i]);
}
scanf("%d",&m);
for(i=0;i<m;i++){
	scanf("%d %d",&yx[i],&yy[i]);
}
for(i=0;i<m;i++){
	dx=yx[i]-xx[0];
	dy=yy[i]-xy[0];
	for(j=1;j<n;j++){
		for(k=0;k<m;k++){
			if(xx[j]+dx==yx[k]){
				if(xy[j]+dy==yy[k]){
				sum++;
				goto g;
			}
			}
		}
		g:;
	}
	if(sum==n-1){
		printf("%d %d\n",dx,dy);
		sum=0;
	    break;
	}
	sum=0;
}
	}
return 0;
}

Measured memory_bytes: 1036
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	public static void main(String[] args) {
		N = sc.nextInt();
		while (read())
			solve();
	}
	
	static String str;
	static boolean read() {
		if ((N--) <= 0) return false;
		str = sc.next();
		return true;
	}
	
	static void solve() {
		HashSet<String> set = new HashSet<String>();
		String a,b,ra, rb;
		for (int i = 1; i < str.length(); i++) {
			a = str.substring(0, 0 + i);
			b = str.substring(i);
			ra = new StringBuffer(a).reverse().toString();
			rb = new StringBuffer(b).reverse().toString();
			set.add(a + b);
			set.add(b + a);

			set.add(ra + rb);
			set.add(rb + ra);
			
			set.add(ra + b);
			set.add(rb + a);
			
			set.add(a + rb);
			set.add(b + ra);
			
			set.add(ra + b);
			set.add(b + ra);
			
			set.add(a + rb);
			set.add(rb + a);
		}
			
		System.out.println(set.size());
	}
}

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

int main() {
	int N;
	cin >> N;
	int cntA = 0, cntB = 0, cntsame = 0;
	long long ans = 0;

	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		int len = tmp.size();
		if (tmp[0] == 'B') cntB++;
		if (tmp[len - 1] == 'A') cntA++;
		if (tmp[0] == 'B' && tmp[len - 1] == 'A') cntsame++;
		for (int j = 0; j < len - 1; j++)
		{
			if (tmp[j] == 'A' && tmp[j + 1] == 'B') ans++;
		}
	}

	ans += min(cntA, cntB);
	if (cntA == cntB && cntA == cntsame && cntsame > 0) ans--;

	cout << ans << endl;
	return 0;
}


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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

bool check_(VI &A)  {
    bool flag=true;
    REP(i, A.size())
    {
        if (A.at(i)%2==1){
            flag=false;
            break;
        }
        A.at(i) /= 2;
    }
    return flag;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    VI A(N);
    REP(i, N)
    {
        cin >> A.at(i);
    }
    int r=0;
    while(check_(A))
    {
        r++;
    }
    cout << r << endl;

    return 0;
}



Measured memory_bytes: 256
import math
from itertools import product
import sys
input = sys.stdin.readline

N = int(input())
ans = 0

for j in range(3, int(math.log10(N))+2):
    list753 = [['3', '5', '7'] for _ in range(j)]
    for i in product(*list753):
        if ('3' in i) and ('5' in i) and ('7' in i) and int(''.join(i)) <= N:
            ans += 1
        else:
            continue

print(ans)

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

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

		int[] b = new int[n];

		for(int i=0; i<n; i++){
			b[i] = sc.nextInt();
		}	

		int min = 0;

		for(int i=0; i<n; i++){
			if(Math.abs(2* b[i]) < Math.abs(2*(k-b[i]))){
				min += Math.abs(2 *b[i]);		
			}else{
				min += Math.abs(2*(k-b[i])); 
			}
		}

		System.out.println(min);
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
const int MOD = 1000000007;
signed main() {
  int N; cin >> N;
  vector<int> C(1001, 0);
  for(int i = 1; i <= N; ++i) {
    int x = i;
    while(x > 1) {
      bool f = true;
      for(int j = 2; j * j <= x; ++j) {
        if(x % j == 0) {
          C[j]++;
          x /= j;
          f = false;
          break;
        }
      }
      if(f) {
        C[x]++;
        break;
      }
    }
  }
  int ans = 1;
  REP(i, 1001) {
    if(C[i] > 0) {
      // cerr << "C[" << i << "] = " << C[i] << endl;
      ans *= (C[i] + 1);
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256