akhauriyash/Code-Regression huggingface dataset:
//Writer: Aditya Singh
//Bleed Blue
#include <bits/stdc++.h>

using namespace std;

#pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define unm unordered_map<int,int>
#define pb emplace_back
#define nt _int128
#define PI 3.1415926535897932384626433
#define inf 1e18

const int N = 100005;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t;cin>>t;while(t--)
    {
        int i, j, k, n, m, ans = 0, cnt = 0, sum = 0, a, b, c;
        cin >> a >> b >> c >> k;
        if (a <= k)
        {
            ans += a;
            k -= a;
            if (k > 0)
            {
                k -= b;
                if (k > 0)
                {
                    if (k <= c)
                        ans -= k;
                    else
                        ans -= c;
                }
            }
        }
        else
            ans += k;
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	long int i, j, k, l;
	long int a, b, sum;
	
	scanf("%ld%ld", &a, &b);
	
	sum = a + b;
	
	if(sum == 3) {
		printf("3\n");
	} else if(sum == 4) {
		printf("2\n");
	} else if(sum == 5) {
		printf("1\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
S = list(set(map(int, input().split())))
S.sort()
Q = int(input())
T = list(map(int, input().split()))
ans = 0
for i in range(Q):
    OK = 0
    NG = len(S)
    while abs(OK-NG)>1:
        mid = (OK+NG)//2
        if S[mid]<=T[i]:
            OK = mid
        else:
            NG = mid
    if S[OK] == T[i]:
        ans += 1

print(ans)


Measured memory_bytes: 16184
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
using ull =unsigned long long;
const ll INF =1001001001;

//10億7。　　　100000007

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);


  
string S;
  cin>>S;
  
  if((S[2]==S[3])&&(S[4]==S[5])){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  
  
  
}



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

int count2(int a) {
	int n = 0;
	while (a % 2 == 0) {
		a /= 2;
		n++;
	}
	return n;
}

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
		ans += count2(a[i]);
	}
	cout << ans << endl;
	return 0;
}


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

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    UnionFind(int n) {
        par.resize(n);
        for (int i=0; i<n; ++i) par[i] = i;
        rank.resize(n, 1);
    }
    int find(int a) {
        if (par[a] == a) return a;
        return par[a] = find(par[a]);
    }
    void unite(int a, int b) {
        a = find(a);
        b = find(b);
        if (a == b) return;
        if (rank[a] < rank[b]) {
            par[a] = b;
        } else {
            par[b] = a;
            if (rank[a] == rank[b]) rank[a]++;
        }
    }
};

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; ++i) cin >> s[i];
    UnionFind uf(h*w);
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            int now = j + w*i;
            for (int k=0; k<4; ++k) {
                int ni = i + dx[k];
                int nj = j + dy[k];
                if (ni < 0 || ni >= h) continue;
                if (nj < 0 || nj >= w) continue;
                if (s[i][j] == s[ni][nj]) continue;
                uf.unite(now, nj + w*ni);
            }
        }
    }
    vector<long long> bl(h*w, 0), wh(h*w, 0);
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            int now = j + w*i;
            if (s[i][j] == '#') {
                bl[uf.find(now)]++;
            } else {
                wh[uf.find(now)]++;
            }
        }
    }
    long long ans = 0;
    for (int i=0; i<h*w; ++i) {
        ans += bl[i] * wh[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

ll n,x,y,m,k,ans,cnt,mini=N,flag;
ll a[N],vis[N],dp[N];
vector<ll>v[N];
void dfs(int s)
{
    vis[s]=1;
    for(auto i:v[s]){
        if(!vis[i])dfs(i);
         dp[s] = max(dp[s],1+dp[i]);
    }

}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
   {
       cin>>x>>y;
       v[x].push_back(y);

   }
   for(int i=1;i<=n;i++)
   {
       if(!vis[i])dfs(i);
   }
   ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dp[i]);
    }
    cout<<ans;
return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define mp       make_pair
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main()
{	//pre();
	//case
	{	int n;
		cin >> n;
		int a[n];
		for (int i = 0; i < n; i++)
			cin >> a[i];
		if (n == 2)
		{cout << abs(a[0] - a[1]); return 0;}
		int dp[n];
		dp[0] = 0;
		dp[1] = abs(a[0] - a[1]);
		for (int i = 2; i < n; i++)
		{	int s1 = dp[i - 1] + abs(a[i - 1] - a[i]);
			int s2 = dp[i - 2] + abs(a[i - 2] - a[i]);
			dp[i] = min(s1, s2);
		}
		cout << dp[n - 1];
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    
    if(n == m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#define fastio {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define nln cout << '\n'
#define ll long long int
#define INF (ll)1e+12
#define MAX 300100
#define mp(i, j) make_pair(i, j)
#define here cout  << "here";nln;
#define mul(a, b, mod) (((a % mod) * (b % mod)) % mod)
#define add(a, b, mod) (((a % mod) + (b % mod)) % mod)
#define inf 100000
#define M 1000000000LL

using namespace std;

int main()
{
    int i, j, n, m;
    vector <int> a;

    cin >> n;
    j = 0;
    for(i = 0; i < n; i++){
        cin >> m;
        if(m&1)continue;
        a.push_back(m);
    }
    n = a.size();
    for(i = 0; i < n; i++){
        if(a[i]%3 and a[i]%5){
            cout << "DENIED" << endl;return 0;
        }
    }

    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	ll n, q;
	cin>>n>>q;
	vector<int> v(n+2);
	v[1] = 2;
	v[2] = 1;
	rep(i, q){
		int a, b;
		cin>>a>>b;
		for(int j = -1; j <= 1; j++){
			v[a+j] |= v[a]>>1;
			v[b+j] |= v[b]>>1;
			v[a] |= v[a+j]>>1;
			v[b] |= v[b+j]>>1;
		}
		swap(v[a], v[b]);
		for(int j = -1; j <= 1; j++){
			v[a+j] |= v[a]>>1;
			v[b+j] |= v[b]>>1;
			v[a] |= v[a+j]>>1;
			v[b] |= v[b+j]>>1;
		}
	}
	int cnt = 0;
	rep(i, n) if(v[i+1]) cnt++;
	cout<<cnt<<endl;
	return 0;
}


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


def solve(N: int, S: "List[str]"):
    ac, wa, re, tle = 0, 0, 0, 0
    for s in S:
        if s == "AC":
            ac += 1
        elif s == "WA":
            wa += 1
        elif s == "RE":
            re += 1
        else:
            tle += 1
    
    print("AC x " + str(ac))
    print("WA x " + str(wa))
    print("TLE x " + str(tle))
    print("RE x " + str(re))

    return


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

if __name__ == '__main__':
    main()


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		
		var A = Enumerable.Range(0,N).ToArray();
		int cnt = 0;
		do{
			if(A[0] != 0) continue;
			bool chk = true;
			for(int i=0;i<N-1;i++){
				chk &= E[A[i]].Contains(A[i+1]);
			}
			if(chk) cnt++;
		}while(NextPermutaion(A));
		
		Console.WriteLine(cnt);
		
		
	}
	
	static public bool NextPermutaion<T>(T[] A)where T:IComparable<T>{
		for(int i=A.Length-2;i>=0;i--){
			if(A[i].CompareTo(A[i+1])<0){
				int trgt=Array.FindLastIndex(A,x=>A[i].CompareTo(x)<0);
				Swap(ref A[i],ref A[trgt]);
				Array.Reverse(A,i+1,A.Length-(i+1));
				return true;
			}
		}
		Array.Reverse(A);
		return false;
	}
	static void Swap<T>(ref T x, ref T y){
		T t=x;x=y;y=t;
	}
	
	
	int N,M;
	List<int>[] E;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		E = new List<int>[N];
		for(int i=0;i<N;i++) E[i] = new List<int>();
		for(int i=0;i<M;i++){
			d = ria();
			E[d[0]-1].Add(d[1]-1);
			E[d[1]-1].Add(d[0]-1);
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 15440
import java.math.BigInteger;
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 0053
public class Main {

	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		sieve(1000000);
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			
			long sum = 0;
			for (int i = 0; i < n; i++)
				sum += prime[i];
			System.out.println(sum);
		}
	}
	
	static int[] prime = new int[1000000];
	static boolean[] is_prime = new boolean[1000000 + 1];
	static int sieve(int n) {
		int p = 0;
		for (int i = 0; i <= n; i++) is_prime[i] = true;
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				prime[p++] = i;
				for (int j = 2 * i; j <= n; j+= i) is_prime[j] = false;
			}
		}
		return p;
	}
		
	// f»è
	static boolean is_prime(int  n) {
		for (int i = 2; i * i <= n; i++) 
			if (n % i == 0) return false;
		
		return n != 1;
	}
	
	// ñÌñ
	static ArrayList<Integer> divisor(int n) {
		ArrayList<Integer> ret = new ArrayList<Integer>();
		for (int i = 1; i * i <= n; i++) {
			if (n % i == 0) {
				ret.add(i);
				if (i != (n / i)) ret.add(n / i);
			}
		}
		
		return ret;
	}
	
	// föªð
	static HashMap<Integer, Integer> prime_factor(int n) {
		HashMap<Integer, Integer> ret = new HashMap<Integer, Integer>();
		for (int i = 2; i * i <= n; i++) {
			ret.put(i, 0);
			while (n % i == 0) {
				ret.put(i, ret.get(i) + 1);
				n /= i;
			}
		}
		
		if (n != 1) ret.put(n, 1);
		
		return ret;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=1e5+10;
ll X[maxn],L[maxn];
int lft[maxn],rht[maxn];
vector<ll> lsh;
int n;
vector<pii> events;
int f[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld",&X[i],&L[i]);
		lsh.push_back(X[i]-L[i]);
		lsh.push_back(X[i]+L[i]);
	}
	sort(lsh.begin(),lsh.end());
	lsh.erase(unique(lsh.begin(),lsh.end()),lsh.end());
	for(int i=0;i<n;i++)
	{
		lft[i]=lower_bound(lsh.begin(),lsh.end(),X[i]-L[i])-lsh.begin();
		rht[i]=lower_bound(lsh.begin(),lsh.end(),X[i]+L[i])-lsh.begin();
		events.push_back(make_pair(lft[i],i+1));
		events.push_back(make_pair(rht[i],-(i+1)));
	}
	sort(events.begin(),events.end());
	int curmax=0;
	for(int i=0;i<events.size();i++)
	{
		if(events[i].second>0)
		{
			int id=events[i].second-1;
			f[id]=curmax+1;
		}
		else
		{
			int id=-events[i].second-1;
			curmax=max(curmax,f[id]);
		}
	}
	printf("%d\n",curmax);
	return 0;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
 
int main(){
    int n;cin>>n;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int ans=0;
    rep(i,n){
        if(v[i]==i+1)continue;
        else ans++;
        if(ans>2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	ll h;cin>>h;
	ll ans = 0;
	ll c = 1;
	while(h){
		ans += c;
		h /= 2;
		c *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            var x = inputLongArray[0];
            var n = inputLongArray[1];

            var result = x;
            if (n != 0)
            {
                // 整数配列の入力
                var inputLongArray2 = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();



                var array = inputLongArray2;

                result = find(x, array);
            }
           

            Console.WriteLine(result);

            Console.Out.Flush();
        }

        private static int find(int x, int[] array)
        {
            if (!array.Contains(x)) return x;
            var except = Enumerable.Range(0, 102)
                .Except(array);

            var result = except.Select(i => new { element = i, diff = Math.Abs(x - i) })
                .OrderBy(s => s.diff)
                .ThenBy(s => s.element)
                .First();

            return result.element;

        }
    }
}


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

int main() {
  string s;
  cin >> s;
  string a = s.substr(0, 5);
  string b = s.substr(6, 7);
  string c = s.substr(14, 5);
  cout << a << " " << b << " " << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
vector <bool> vis(100005);
ll ma=0;
void dfs(ll u,ll d){
	//vis[u]=1;
	ma=max(ma,d);
	for(int ch:v[u]){
			dfs(ch,d+1);
	}
}

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   	ll n,m;
   	cin>>n>>m;
   	char a[n][m];
   	for(ll i=0;i<n;i++){
   		for(ll j=0;j<m;j++){
   			cin>>a[i][j];
   		}
   	}
   	ll dp[n+1][m+1];
   	memset(dp,0,sizeof dp);
   	dp[1][1]=1;
   	for(ll i=1;i<=n;i++){
   		for(ll j=1;j<=m;j++){
   			if(a[i-1][j-1]!='#'){
   				if(i>1){
   					(dp[i][j]+=dp[i-1][j])%=M;
   				}
   				if(j>1){
   					(dp[i][j]+=dp[i][j-1])%=M;
   				}
   			}
   			else{
   				dp[i][j]=0;
   			}
   		}
   	}
   	cout<<dp[n][m]<<endl;
    return 0; 
}

Measured memory_bytes: 14804
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    string s;cin>>s;
    if(s[0] !='A'){
      cout<<"WA";
      return 0;
    }
    int c = 0;
  	int basyo = 0;
    for(int i = 2;i<=s.length()-2;i++){
       if(s[i] == 'C'){
         c++;
         basyo = i;
       }
    }
    if(c != 1){
      cout<<"WA";
      return 0;
    }
    for(int i = 1;i<s.length();i++){
    	if(i == basyo) continue;
        if(s[i]>='A'&&s[i]<='Z'){
          cout<<"WA";
          return 0;
        }
    }
    cout<<"AC";
    return 0;
}

Measured memory_bytes: 3628
import collections
mod=10**9+7
base=257
n=int(input())
S=list(ord(s)-96 for s in input())
B=[0]*(n+1)
B[0]=1
for i in range(n):
  B[i+1]=(B[i]*base)%mod

def chk(x):
  ret=False
  h=0
  bx=B[x]
  d=collections.defaultdict(int)
  for i in range(x):
    h=(h*base+S[i])%mod
  d[h]=x
  for i in range(x,n):
    h=(h*base+S[i]-S[i-x]*bx)%mod
    if d[h]==0:
      d[h]=i+1
    elif d[h]<=i-x+1:
      ret=True
  return ret

l,r=0,n//2
while r-l>1:
  m=(l+r)//2
  if chk(m):
    l=m
  else:
    r=m
print(r if chk(r) else l)


Measured memory_bytes: 4288
#include<stdio.h>

int create_gcd(int,int);

int main(){
  int a,b;

  while(scanf("%d %d",&a,&b) != EOF){
    printf("%d %d\n",create_gcd(a,b),a/create_gcd(a,b)*b);
  }

  return 0;
}

int create_gcd(int a, int b){
  int tmp;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  } 

  if(b==0) return a;
  else return create_gcd(b,a%b);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    int len = (int)S.size();
    reverse(all(S));

    vector<vector<ll>> dp(len + 1, vector<ll>(13));
    ll ct = 1;
    dp[0][0] = 1;
    rep(i, len) {
        if (S[i] != '?') {
            ll n = S[i] - '0';
            n *= ct;
            n %= 13;
            rep(k, 13) {
                dp[i + 1][(n + k) % 13] += dp[i][k];
                dp[i + 1][(n + k) % 13] %= MOD;
            }
        }
        else {
            rep(j, 10) {
                ll n = j * ct;
                n %= 13;
                rep(k, 13) {
                    dp[i + 1][(n + k) % 13] += dp[i][k];
                    dp[i + 1][(n + k) % 13] %= MOD;
                }
            }
        }
        ct *= 10;
        ct %= 13;
    }
/*
    rep(i, len + 1) {
        rep(j, 13) cout << dp[i][j] << " ";
        cout << endl;
    }
*/

    cout << dp[len][5] << endl;
    return 0;
}

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


int main(){

    int N,L[3000],s;
    cin >> N;
    vector<int> v(N);
    int ans =0;
    for(int i=0;i<N;i++) {
         cin >> L[i];
         v[i]=L[i];
    }
    sort(v.begin(),v.end());
    for(int i = 0;i<N;i++) {
        for(int j = i+1;j<N;j++) {
            auto it = lower_bound(v.begin(),v.end(),v[i]+v[j]);
            s = distance(v.begin(),it)-1;
            ans += s - j;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

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


int main() {
    string s, t;
    cin >> s >> t;
    if (t.substr(0, s.size()) == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 1000000000;

int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> W(N, 0), E(N, 0);
  int ans = INF;
  rep(i, N) {
    if (S[i] == 'W') {
      W[i] = 1;
    }
    if (i != 0) {
      W[i] += W[i-1];
    }
  }
  for (int i = N-1; i >= 0; i--) {
    if (S[i] == 'E') {
      E[i] = 1;
    }
    if (i != N -1) {
      E[i] += E[i+1];
    }
  }
  rep(i, N) {
    int cnt = 0;
    cnt = W[i] + E[i] - 1;
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3076
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        
        if( N % 2 == 0 ){
            System.out.println( N );
        } else {
            System.out.println( N*2 );
        }
        
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j,k;
  int n,m;
  cin>>n>>m;
  int v[100][100];
  int x[5000],y[5000],z[5000];
  rep(i,n)rep(j,n)
    if(i==j)v[i][j]=0;
    else v[i][j]=INF;

  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    x[i]=a;
    y[i]=b;
    z[i]=c;
    v[a][b]=c;
    v[b][a]=c;
  }
  rep(k,n)rep(i,n)rep(j,n)
    v[i][j]=min(v[i][j],v[i][k]+v[k][j]);
  int ans=0;
  rep(i,m)
    if(v[x[i]][y[i]]<z[i])ans++;
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> A(N);
    REP(i, N) {
        cin >> A[i].first >> A[i].second;
    }
    SORT(A);
    ll res = 0, cnt = 0;
    REP(i, N) {
        res += A[i].first * min(A[i].second, M - cnt);
        cnt += min(A[i].second, M - cnt);
        if (cnt == M) {
            break;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

char str[1024];
int ap[256];

int main ()
{
    fgets (str, 1024, stdin);

    int n = strlen (str) - 1;
    for (int i = 0; i < n; ++i)
        ap[str[i]] = 1;

    if (!(ap['N'] ^ ap['S']) && !(ap['E'] ^ ap['W'])) printf ("Yes\n");
    else printf ("No\n");

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long L;const L A=2e5;L a[A],s[A],c[A],t,n,N,m,p,i;main(){for(std::cin>>N>>m,a[n=1]=N;m--;){for(std::cin>>t;n&&t<=a[n];--n);a[++n]=t;}for(s[n]=1,i=n-1;i>0;--i)for(s[i]+=a[i+1]/a[i]*s[i+1],t=a[i+1]%a[i];t;)(p=std::upper_bound(a+1,a+1+n,t)-a-1)?s[p]+=(t/a[p])*s[i+1],t%=a[p]:(c[t]+=s[i+1],t = 0);for(c[a[1]]+=s[1],i=N;i>1;--i)c[i-1]+=c[i];for(i=1;i<=N;++i)printf("%lld\n",c[i]);}

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

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

Measured memory_bytes: 256
n, k = gets.split(' ').map(&:to_i)
arr = []
n.times do
  arr << gets.to_i
end
arr.sort!
arr.reverse!
min = 1000000001
(0...(n - k + 1)).each do |i|
  min = [min, arr[i] - arr[i + k - 1]].min
end
puts min

Measured memory_bytes: 4016
#include<iostream>
#include<algorithm>
#define B 100000
using namespace std;

long long sample[B], per_l, per_r;
long long num_l, num_r;
long long koho[5000000], koho_size = 0;
int koho0IndexOfAll;

int n, k;
long long x0;

void solve1() {
	static long long X[B];
	unsigned long long x = x0;
	for(int i = 0; i < n; i++ ) {
		X[i] = x;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	sort(X, X+n);
	cout << X[k] << endl;
}
void solve2(long long maxi) {
	unsigned long long x = x0;
	int i, N = n;
	static long long X[1000000];
	int Xsize = 0;
	
	while(N--) {
		if ( x < maxi ) {
			X[Xsize++] = x;
		}
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	sort(X, X + Xsize);
	cout << X[k] << endl;
}

int main() {
	int i, j;
	cin >> n >> k >> x0;
	k--;
	
	if ( x0 == 0 ) {
		cout << 0 << endl;
		return 0;
	}
	
	if ( n < B ) {
		solve1();
		return 0;
	}
	
	per_l = max( (long long)0, (long long)B * (long long)k/(long long)n - 1000 );
	per_r = min( (long long)B-1, (long long)B * (long long)k/(long long)n + 1000 );
	
	unsigned long long x = x0;
	for( i = 0; i < B; i++ ) {
		sample[i] = (long long)x;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
  	}
  	
  	sort(sample, sample+B);
  	
  	num_l = sample[per_l];
  	num_r = sample[per_r];
  	
  	for( i = per_l; i <= per_r; i++ ) {
  		koho[koho_size++] = sample[i];
  	}
  	
  	for( i = B; i < n; i++ ) {
  		if ( num_l <= (long long)x && (long long)x <= num_r ) {
  			koho[koho_size++] = (long long)x;
  		}
  		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
  	}
  	
  	sort(koho, koho + koho_size);
  	koho0IndexOfAll = 0;
  	
  	x = x0;
  	for( i = 0; i < n; i++ ) {
  		if ( (long long)x < koho[0] )
  			koho0IndexOfAll++;
  		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	
	if ( k < koho0IndexOfAll ) {
		solve2(num_l);
		return 0;
	}
	
	cout << koho[k - koho0IndexOfAll] << endl;
  	return 0;
  }

Measured memory_bytes: 19604
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> VU.Vector Int -> Int
solve !n !x !an = VU.length $ VU.takeWhile (<= x) $ VU.scanl' (+) 0 an

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, x) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n x an


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

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

int main(){


    ll H, W,h,w;
    cin >> H >> W >> h >> w;
    cout << H*W - h*W - w*H + h*w  << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let l: usize = iterator.next().unwrap().parse().unwrap();
    let r: usize = iterator.next().unwrap().parse().unwrap();
    let d: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: usize = 0;
    for i in l..=r {
        if i % d == 0 {
            ans += 1;
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2076
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long h = sc.nextLong();
		long time = 1;
		long count = 0;
		while (h > 1) {
		    count += time;
		    h /= 2;
		    time *= 2;
		}
		count += time;
		System.out.println(count);
	}
}


Measured memory_bytes: 21972
//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
int main(){
    long long x, ans=0;
    cin >> x;
    ans=(x/11)*2;
    x%=11;
    if(x>6) ans+=2;
    else if(x>0) ans++;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3568
import java.util.*;

public class Main {
  public static void main(String[] args) {
    int a;
    String s;
    try(Scanner sc = new Scanner(System.in)) {
      a = sc.nextInt();
      s = sc.next();
    }
    System.out.println(a >= 3200 ? s : "red");
  }
}

Measured memory_bytes: 21844
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
	return 0;
}

Measured memory_bytes: 256
N, T = map(int, input().split())
t = [int(i) for i in input().split()]

res = 0
if N == 1:
    res += T
else:
    for i in range(N-1):
        if t[i+1] - t[i] > T:
            res += T
        else:
            res += t[i+1] - t[i]
    else:
        res += T

print(res)

Measured memory_bytes: 25200
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

int c[1001000],d[1001000];
int n,m,i,j,p,tep=0;
struct node
{
    int l;
    int r;
    bool operator< (const node &p)const
    {
        if(r==p.r)
            return l<p.l;
        return r<p.r;
    }
};
node b[1001000];
int main()
{
    scanf("%d%d",&n,&m);
    //memset(c,0,sizeof(c));
    //memset(d,0,sizeof(d));
    for(i=0; i<m; i++)
        scanf("%d%d",&b[i].l,&b[i].r);
    sort(b,b+m);
    /*for(i=0; i<m; i++)
    {
        c[b[i].r]=1;
        d[b[i].l]=1;
    }*/
    int len=0;
    for(p=0;p<m;p++)
    {
        i=b[p].l;
       if(i>=len)
       {
           len=b[p].r;
           tep++;
       }
    }
    printf("%d\n",tep);

    return 0;
}



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

int main(){
	int n;
	while(cin >> n, n){
		vector<int> vec;
		for(int i = 0; i < n; i++){
			int a;
			cin >> a;
			vec.push_back(a);
		}

		int max = vec[0] + vec[1];
		for(int i = 0; i < vec.size(); i++){
			int add = 0;
			for(int j = i; j < vec.size(); j++){
				add += vec[j];
				if(max < add) max = add;
			}
		}

		cout << max << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << a.at(n-1) << endl;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
strToInt s = (read :: String -> Int) s

main = do
    s <- getLine
    print $ (length s) - (f (elemIndex 'Z' (reverse s))) - (f (elemIndex 'A' s))

f :: Maybe Int -> Int
f (Just n) = n
f Nothing  = 0

Measured memory_bytes: 20988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
    int A ;
    cin >> A ;
    int B =0;
    for(int i=1;i<10;++i){
        if(A%i==0&&A/i<10){
            B++;
        }
    }
    if(B==0){
        cout << "No" <<endl;
    }else{
        cout << "Yes" <<endl;
    }
    return 0;   
}

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


int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    int minM = 10000;
    for (int i=0; i<n; i++) {
        cin >> v.at(i);
        minM = min(minM, v.at(i));
        m -= v.at(i);
    }
    
    cout << v.size() + m / minM << endl;
    
    
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)



int main(){
    int N; cin>>N;
    vec d(N);
    rep(i,N) cin>>d.at(i);
    int count=0;
    int i=0;
    rep(i,N) if(d.at(i)==count+1) count++;
    if(count==0) cout<<-1<<endl;
    else cout<<N-count<<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

#define N_MAX 20

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    ll A[N_MAX];
    ll x[N_MAX][N_MAX];
    ll y[N_MAX][N_MAX];

    cin >> N;

    rep (i, N) {
        cin >> A[i];
        rep (j, A[i]) {
            cin >> x[i][j] >> y[i][j];
        }
    }

    ll ans = 0;
    for (ll bit = 0; bit < (1<<N); bit++) {
        bool flag = false;
        ll cnt = 0;
        rep (i, N) {
            if (bit & (1<<i)) {
                rep (j, A[i]) {
                    if (y[i][j] == 1 && (bit & 1<<(x[i][j]-1)) == 0) {
                        flag = true;
                    }
                    if (y[i][j] == 0 && (bit & 1<<(x[i][j]-1)) != 0) {
                        flag = true;
                    }
                    if (flag) {
                        break;
                    }
                }
            }
        }

        if (!flag) {
            rep (i, N) {
                if (bit & (1<<i)) {
                    cnt++;
                }
            }
        }

        ans = max(ans, cnt);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

void run();

signed main(){
    cout<<fixed;
    run();
    return 0;
}

void f(vi &v,int a,int b,int c,int d){
    v.pb(a);
    v.pb(b);
    v.pb(c);
    v.pb(d);
}

void run(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
        }
    }
    vi v;
    rep(i,h){
        if(i%2==0){
            rep(j,w){
                if(a[i][j]%2){
                    a[i][j]--;
                    if(j<w-1){
                        a[i][j+1]++;
                        f(v,i+1,j+1,i+1,j+2);
                    }
                    else if(i<h-1){
                        a[i+1][j]++;
                        f(v,i+1,j+1,i+2,j+1);
                    }
                }
            }
        }
        else{
            rev(j,w){
                if(a[i][j]%2){
                    a[i][j]--;
                    if(j>0){
                        a[i][j-1]++;
                        f(v,i+1,j+1,i+1,j);
                    }
                    else if(i<h-1){
                        a[i+1][j]++;
                        f(v,i+1,j+1,i+2,j+1);
                    }
                }
            }
        }
    }
    int n=v.size()/4;
    cout<<n<<endl;
    rep(i,n){
        cout<<v[i*4]<<" "<<v[i*4+1]<<" "<<v[i*4+2]<<" "<<v[i*4+3]<<endl;
    }
}

Measured memory_bytes: 8304
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			String[] input = new BufferedReader(new InputStreamReader(System.in)).readLine().split(" ");
			int faces = Integer.parseInt(input[0]);
			int target = Integer.parseInt(input[1]);
			double rate = 0;
			for (int i = 1; i <= faces; i++) {
				int cnt = 0;
				int sum = i;
				while(sum < target) {
					sum += sum;
					cnt++;
				}
				rate += Math.pow(0.5, cnt) / faces;
			}
			System.out.println(String.format("%.10f", rate));
		} catch (IOException e1) {
		}
	}
}


Measured memory_bytes: 20948
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

#define INF	(1 << 30)

#define C_E	(0)
#define C_W	(1)
#define C_R	(2)
#define C_B	(3)

#define MAX_D	(30)

/* typedef */

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

struct cube_t {
  int x, y, z;
};

/* global variables */

cube_t ccube = {C_W, C_R, C_B}, ecube = {C_E, C_E, C_E};
int dxys[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

cube_t brd[9];
int gl[9];
int gdist;

/* subroutines */

void check_rec(int d, int x0, int y0, int pdi) {
  if (d >= gdist) return;

  int diff = 0;
  for (int i = 0; i < 9; i++)
    if (brd[i].x != gl[i]) diff++;
  if (diff == 0) {
    if (gdist > d) gdist = d;
    return;
  }
  if (d + diff > gdist) return;

  int pos0 = y0 * 3 + x0;
  
  for (int di = 0; di < 4; di++) {
    if (((di + 2) % 4) == pdi) continue;
    
    int dx = dxys[di][0];
    int dy = dxys[di][1];
    int x = x0 + dx;
    int y = y0 + dy;

    if (x >= 0 && x < 3 && y >= 0 && y < 3) {
      int pos = y * 3 + x;
      cube_t pcb = brd[pos];
      brd[pos] = ecube;

      cube_t cb = pcb;
      if (dx != 0) {
        int t = cb.x; cb.x = cb.z; cb.z = t;
      }
      else {
        int t = cb.x; cb.x = cb.y; cb.y = t;
      }
      brd[pos0] = cb;

      check_rec(d + 1, x, y, di);

      brd[pos] = pcb;
      brd[pos0] = ecube;
    }
  }
}

/* main */

int main() {
  for (;;) {
    int sx, sy;
    cin >> sx >> sy;
    if ((sx | sy) == 0) break;

    sx--;
    sy--;

    for (int y = 0; y < 3; y++) {
      for (int x = 0; x < 3; x++) {
	int pos = y * 3 + x;
	string ch;
	cin >> ch;
	switch (ch[0]) {
	case 'E': gl[pos] = C_E; break;
	case 'W': gl[pos] = C_W; break;
	case 'R': gl[pos] = C_R; break;
	case 'B': gl[pos] = C_B; break;
	}
      }
    }
    //for (int i = 0; i < 9; i++) cout << gl[i]; cout << endl;
    
    for (int i = 0; i < 9; i++) brd[i] = ccube;
    brd[sy * 3 + sx] = ecube;
    //for (int i = 0; i < 9; i++) cout << brd[i].x; cout << endl;

    gdist = MAX_D + 1;

    check_rec(0, sx, sy, -1);

    cout << (gdist > MAX_D ? -1 : gdist) << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
let nums = require('fs').readFileSync('/dev/stdin', 'UTF-8').split(' ').map(Number);
const a = nums[0];
const b = nums[1];
const c = nums[2];
let count = 0;
for (let i=a; i<=b; i++) {
  if (c%i===0) count++;
}
console.log(count);


Measured memory_bytes: 15392
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define rb(a, b, c) for (int a = b; a <= c; ++a)
#define rl(a, b, c) for (int a = b; a >= c; --a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a, b) make_pair(a, b)
#define FIR first
#define SEC second
#define FREO freopen("check.out", "w", stdout)
#define rep(a, b) for (int a = 0; a < b; ++a)
#define KEEP while (1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng() % a
#define ALL(a) a.begin(), a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef pair<int, int> mp;
typedef pair<mp, mp> superpair;
LL n, a, d;
pair<LL, LL> each[200000 + 1];
LL res = 0;
LL A[200000 + 1];
int main()
{
    fastio;
    cin >> n >> d >> a;
    d <<= 1;
    rb(i, 1, n)
            cin >>
        each[i].FIR >> each[i].SEC;
    sort(each + 1, each + 1 + n);
    LL tmp = 0;
    rb(i, 1, n)
    {
        each[i].SEC -= tmp;
        if (each[i].SEC > 0)
        {
            LL need = (each[i].SEC + a - 1) / a;
            tmp += need * a;
            res += need;
            int l = i, r = n + 1;
            while (l < r - 1)
            {
                int mid = (l + r) >> 1;
                if (each[i].FIR + d >= each[mid].FIR)
                {
                    l = mid;
                }
                else
                {
                    r = mid;
                }
            }
            //			cout<<each[i].FIR+d<<endl;
            //			cout<<l<<endl;
            A[l] += need * a;
        }
        tmp -= A[i];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 4992