akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly int Mod = (int)1e9 + 7;
    static void Add(ref int a, int b) { if ((a += b) >= Mod) a -= Mod; }

    public void Solve()
    {
        int N = Reader.Int(), C = Reader.Int();
        var A = Reader.IntArray(N);
        var B = Reader.IntArray(N);

        int Bmax = B.Max();
        var powSum = new int[Bmax + 1, C + 1];
        for (int x = 1; x <= Bmax; x++)
            for (long n = 0, p = 1; n <= C; n++, p = p * x % Mod)
                powSum[x, n] = (int)((powSum[x - 1, n] + p) % Mod);

        var dp = new int[C + 1];
        dp[0] = 1;
        for (int i = 0; i < N; i++)
        {
            var nextdp = new int[C + 1];
            for (int sum = 0; sum <= C; sum++)
                if (dp[sum] > 0)
                    for (int add = 0; sum + add <= C; add++)
                    {
                        long v = Mod + powSum[B[i], add] - powSum[A[i] - 1, add];
                        Add(ref nextdp[sum + add], (int)(v % Mod * dp[sum] % Mod));
                    }
            dp = nextdp;
        }

        Console.WriteLine(dp[C] % Mod);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 4184
X = [int(input()) for _ in range(4)]
ans = 0
for i in range(X[0] + 1):
    for j in range(X[1] + 1):
        for k in range(X[2] + 1):
            if 500 * i + 100 * j + 50 * k == X[3]:
                ans += 1
print(ans)

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

using namespace std;

int main()
{
	set<string> s;
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		string a,b;
		cin>>a>>b;
		if(a[0]=='i') s.insert(b);
		else if(a[0]='f')
			if(s.count(b))
				printf("yes\n");
			else
				printf("no\n");
	}
	return 0;
}

Measured memory_bytes: 32164
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long ll;
#define print(x) cout<<(x)<<endl


#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


// DONT USE "int", USE "ll" !!!!!!!!!!!!
int main() {
	int N;
	cin >> N;

	int tmp = N;

	while (tmp % 4 != 0) {
		tmp -= 7;
		if (tmp < 0)break;
	}

	if (tmp < 0)print("No");
	else print("Yes");








	return 0;
}

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

using namespace std;
const int N = 1e6+100;
int main(){
	string s;
	cin>>s;
	int num=0;
	for(int i=1;i<4;i++){
		if(s[i]==s[i-1]) num++;
	}
	if(num){
		cout<<"Bad"<<endl;
	}
	else cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();
    LL h, w;
    cin >> h >> w;
    if(h==1 || w==1) cout << 1 << endl;
    else cout << (w+1)/2*((h+1)/2)  + w/2*(h/2) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

#define MAXN 1000000

using namespace std;

int n;
int h[MAXN];
int ans[MAXN];

int main(){

	cin >> n;

for (int i = 1; i <= n; i++){

	cin >> h[i];

}	

ans[1] = 0;
ans[2] = abs(h[1] - h[2]);

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

	ans[i] = min((ans[i - 1] + abs(h[i - 1] - h[i])), (ans[i - 2] + abs(h[i - 2] - h[i])));	

}

cout << ans[n];

}

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

//2019/07/10
int main(){
  int w,h,x,y;
  cin>>w>>h>>x>>y;
  double ans=(double)w*h/2;//キャストしないとオーバーフローする
  int num=(w==x*2&&h==y*2)?1:0;//xyが両方中心にある

  cout<<fixed<<setprecision(6)<<ans;
  cout<<" "<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '+')count++;
		if (s[i] == '-')count--;
	}
	cout << count << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n;

    cin >> n;

    vector<int> w(n), sum(n + 1);

    int ans;
    ll m = INF;

    sum[0] = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        sum[i + 1] = w[i] + sum[i];
    }

    for (int i = 0; i <= n; i++)
    {
        if (m > abs(sum[i] - sum[0] - (sum[n] - sum[i])))
        {
            ans = i;
            m = abs(sum[i] - sum[0] - (sum[n] - sum[i]));
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);
	

	int D, N;
	cin >> D >> N;

	int A = pow(100, D);
	if (N < 100) cout << A * N << "\n";
	else cout << A * 101 << "\n";
	Would you please return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<set>
#include<bitset>
//#include<>
using namespace std;

typedef bitset<26> b26;
typedef long long int64;
typedef int int32;
typedef char int8;
typedef int32 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define repeat_eq(i,j,k) for(int__ i=(j);i<=(k);i++)
#define all(v) (v).begin(),(v).end()

const int INF=1<<30;//=10E10

void rec(set<string> &ans,b26 rplflg,b26 preflg,string str,int pos){
  //最後まで見たら終わり
  if(pos==str.size()){
    ans.insert(str);
    return;
  }

  //まだ置き換えしていない文字
  if(rplflg[str[pos]-'a']==false){

    //aならそのままもあり
    if(str[pos]=='a'){
      rec(ans,rplflg,preflg|(b26)1,str,pos+1);
    }
    
    //以前にその文字が現れているなら置き換えない場合ある。
    else if(preflg[str[pos]-'a']==true){
      rec(ans,rplflg,preflg|(b26)(1<<(str[pos]-'a')),str,pos+1);
    }
    
    //z以外なら置き換え可能性あり
    if(str[pos]!='z'){
      str[pos]=str[pos]+1;
      rec(ans,rplflg|b26(1<<(str[pos]-1-'a')),preflg|b26(1<<(str[pos]-'a')),str,pos+1);
    }
    
  }
  //すでに置き換えた文字
  else if(str[pos]=='a'||preflg[str[pos]-'a']==true){
    rec(ans,rplflg,preflg|(b26)(1<<(str[pos]-'a')),str,pos+1);
  }
    
}

int main()
{
  string in_str;
  while(true){
    cin>>in_str;
    if(in_str=="#")break;
    b26 repflg,preflg;
    set<string> ans;
    rec(ans,repflg,preflg,in_str,0);

    cout<<ans.size()<<endl;
    if(ans.size()<=10){
      for(auto item : ans){
	cout<<item<<endl;
      }
    }
    else{
      auto eitr=ans.begin();
      advance(eitr,5);
      for(auto itr=ans.begin();itr!=eitr;itr++)
	cout<<*itr<<endl;
      auto itr=ans.end();
      advance(itr,-5);
      for(;itr!=ans.end();itr++)
	cout<<*itr<<endl;
    }
  }

  
  return 0;
}

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

int main(){
	double r;
	double pai = 3.141592653589793;
	cin >> r;
	cout << fixed << setprecision(6) << r * r * pai << " ";
	cout << 2 * r * pai << endl;
	return 0;
}

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

ll N, M, P[15], KI, SI, ans;
bitset<15> G[15];

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

	cin >> N >> M;
	for (ll i = 0; i < M; i++) {
		cin >> KI;
		for (ll j = 0; j < KI; j++) {
			cin >> SI;
			G[i][SI-1] = 1;
		}
	}
	for (ll i = 0; i < M; i++) {
		cin >> P[i];
	}

	for (ll i = 0; i < (1LL << N); i++) {
		bitset<15> t;
		t.reset();
		for (ll j = 0; j < N; j++) {
			if (((1LL << j) & i) > 0) {
				t[j] = 1;
			}
		}
		ll cnt = 0;
		for (ll j = 0; j < M; j++) {
			if ((G[j]&t).count() % 2 == P[j] % 2) {
				cnt++;
			}
		}
		if (cnt == M) {
			ans++;
		}
	}

	cout << ans << "\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int leye[4]={0,0,0,0},reye[4]={0,0,0,0};
    double lef,righ;
    while(cin>>lef>>righ){
        if(lef==0.1)leye[0]++;else if(lef<0.6)leye[1]++;else if(lef<1.1)leye[2]++;else leye[3]++;
        if(righ==0.1)reye[0]++;else if(righ<0.6)reye[1]++;else if(righ<1.1)reye[2]++;else reye[3]++;
    }
    for(int i=3;i>-1;i--)cout<<leye[i]<<" "<<reye[i]<<endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
	int n, m, l;
	cin >> n >> m >> l;

	int i, j, k;
	ll A[100][100] = {{}};
	ll B[100][100] = {{}};

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}

	for (j = 0; j < m; j++) {
		for (k = 0; k < l; k++) {
			cin >> B[j][k];
		}
	}

	ll temp = 0;

	for (i = 0; i < n; i++) {
		for (k = 0; k < l; k++) {
			temp = 0;
			for (j = 0; j < m; j++) {
				temp += A[i][j] * B[j][k];
				
			}
			if (k == 0) cout << temp;
			else cout << " " << temp;
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3272
N = int(input())
A = sorted([int(a) for a in input().split()])
X = [[0] * N for _ in range(30)]

if N % 3:
    if max(A):
        print("No")
    else:
        print("Yes")
else:
    n = N//3
    if A[0] == A[n-1] and A[n] == A[2*n-1] and A[2*n] == A[3*n-1] and A[0]^A[n] == A[2*n]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 80244
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

using namespace std;

int n;
string s;
map < pair < string, string >, int > cnt;

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> s;
	//~before_midle
	for (int mask = 0; mask < (1 << n); mask++)
	{
		string a, b;
		for (int i = 0; i < n; i++)
		{
			if (mask & (1 << i))
				a += s[i];
			else
				b += s[i];
		}
		cnt[{a, b}]++;
	}
	//~after_midle
	ll ans = 0;
	for (int mask = 0; mask < (1 << n); mask++)
	{
		string a, b;
		for (int i = 0; i < n; i++)
		{
			if (mask & (1 << i))
				a += s[i + n];
			else
				b += s[i + n];
		}      
		reverse(all(a)), reverse(all(b));
		ans += cnt[{a, b}];
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 87040
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    std::string S;
    std::cin >> S;

    std::vector<int64_t> R(S.size(), 0);
    std::vector<int64_t> L(S.size(), 0);

    for (int64_t i = 0; i < S.size(); ++i) {
        if (S.at(i) == 'R') R.at(i) = 1;
        else L.at(i) = 1;
    }

    for (int64_t i = 0; i < S.size() - 1; ++i) {
        if (S.at(i) == 'L') continue;
        if (i+2 >= S.size()) {
            if (S.at(i+1) == 'R') {
                R.at(i+1) += R.at(i);
                R.at(i) = 0;
            }
        } else if (S.at(i+1) == 'R') {
            R.at(i+2) += R.at(i);
            R.at(i) = 0;
        }
    }

    for (int64_t i = S.size() - 1; i >= 1; --i) {
        if (S.at(i) == 'R') continue;
        if (i-2 < 0) {
            if (S.at(i-1) == 'L') {
                L.at(i-1) += L.at(i);
                L.at(i) = 0;
            }
        } else if (S.at(i-1) == 'L') {
            L.at(i-2) += L.at(i);
            L.at(i) = 0;
        }
    }

    for (int64_t i = 0; i < S.size(); ++i) {
        std::cout << (R.at(i) + L.at(i)) << " ";
    }
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 2176
a, b, c, d = map(int, input().split())
ABC = [a, b, c]
ABC.sort()

if abs(a-c) <= d:
    print("Yes")
    exit()

if ABC[0] + d >= ABC[1] and ABC[1] + d >= ABC[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
cnt=[0 for i in range(n)]
for i in range(q):
  cnt[a[i]-1]+=1
for i in range(n):
  if k-q+cnt[i]>0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 8644
#include<bits/stdc++.h>
using namespace std;
bool sm[400];
int main()
{
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	int bigx=x,smally=y;
	int x2,y2;
	for(int i=0;i<n;i++)
	{
		cin>>x2;
		bigx=max(x2,bigx);
	}
	for(int i=0;i<m;i++)
	{
		cin>>y2;
		smally=min(y2,smally);
	}
	if(bigx<smally)
	{
		cout<<"No War";
		return 0;
	}
	else
	{
		cout<<"War";
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import Data.Array.Unboxed
import qualified Data.ByteString.Char8 as C
import qualified Data.IntMap.Strict as M
import Data.List

main = sol <$> get >>= print

get = fmap (unfoldr (C.readInt . C.dropWhile (==' '))) . C.lines <$> C.getContents 

sol ([n,k]:ab) = (a!) $ bsearch 0 m ((k<=) . (b!))
  where
  mp = M.fromListWith (+) $ (\[a,b] -> (a,b)) <$> ab
  m = M.size mp
  (a,b) = (,) <$> listArray (1,m) . fmap fst <*> listArray (1,m) . scanl1 (+) . fmap snd
    $ M.toAscList mp :: (UArray Int Int, UArray Int Int)

bsearch :: Int -> Int -> (Int -> Bool) -> Int
bsearch l r p -- precondition: not (p l) && (p r)
  | l+1>=r    = r
  | p m       = bsearch l m p
  | otherwise = bsearch m r p
  where m = (l+r) `div` 2

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

using namespace std;

int main(){
  int n; cin >> n;
  vector<pair<long long,int> > light(2 * n);
  for(int i=0;i<n;++i){
    long long a ,b; cin >> a >> b;
    light[i * 2] = make_pair(a, 1);
    light[i * 2 + 1] = make_pair(b + 1, -1);
  }
  sort(light.begin(), light.end());
  int cnt = 0, ans = 0;
  for(int i = 0;i < 2 * n;++i){
    cnt += light[i].second;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 6004
import itertools
import commands
num=raw_input()
num=list(num)

a=["+","-"]

for i in itertools.product(a,a,a):
    a=commands.getoutput("echo $(("+num[0]+i[0]+num[1]+i[1]+num[2]+i[2]+num[3]+"))")
    if(a=="7"):
        print(num[0]+i[0]+num[1]+i[1]+num[2]+i[2]+num[3]+"=7")
        break

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main()
{    
	scanf("%s",s+1);
	register int sum=0,l=strlen(s+1),p=0,g=0;
	for(register int i=1;i<=l;++i)
		if(s[i]=='g')
			if(g>p)
				++sum,++p;
			else
				++g;
		else
			if(g>p)
				++p;
			else
				--sum,g++;
	return printf("%d",sum),0;
} 


Measured memory_bytes: 384
// My first rust submission
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf);
    let mut s = buf.split_whitespace();
    let a: u32 = s.next().unwrap().parse().unwrap();
    let b: u32 = s.next().unwrap().parse().unwrap();
    if a + b >= 24 {
        println!("{}", a + b - 24);
    }
    else {
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int D;
int c[26];
int s[365][26];


int main() {
    clock_t start = clock();
    cin >> D;
    for(int i=0;i<26;i++){
        cin >> c[i];
    }
    for(int i=0;i<D;i++)for(int j=0;j<26;j++){
        cin >> s[i][j];
    }

    for(int i=0;i<D;i++){
        int maxNum =0;
        int maxArg = 0;
        for(int j=0;j<26;j++){
            if(s[i][j] > maxNum){
                maxNum = s[i][j];
                maxArg = j;
            }
        }
        cout << maxArg +1 <<"\n";
    }
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
ll INF=10e6;
//------------------------------------------------------------
int N,M,Q,ans=0;
vector<int> A(100);
vector<int> B(100);
vector<int> C(100);
vector<int> D(100);

void dfs(vector<int> v, int cnt, int last)
{
  if(cnt != N)
  {
    rep(i,last,M+1)
    {
      vector<int> nv;
      nv = v;
      nv.push_back(i);
      dfs(nv, cnt+1, i);
    }
  }
  else
  {
    int tmpans=0;
    rep(i,0,Q)
    {
      if(v[B[i]]-v[A[i]]==C[i]) tmpans+=D[i];
    }
    ans = max(ans, tmpans);
  }
}

void solve() {
  cin>>N>>M>>Q;

  rep(i,0,Q)
  {
    cin >> A[i]>> B[i]>> C[i]>> D[i];
    A[i]--;B[i]--;
  }

  vector<int> v;
  dfs(v,0,1);
  print(ans);

  return;
}


Measured memory_bytes: 3660
#include <iostream>
using namespace std;
int main(){
	int x,y,z,i,j;
	j=0;
	cin >>x >>y >>z;
	for(i = x; i <= y ; ++i){
		if( z%i == 0){
			j=j+1;
		};
	};
	cout << j <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>

using namespace std;

int v[100010];

int main ()
{
   // freopen ("file.in", "r", stdin);

    int n;
    scanf ("%d", &n);

    for (int i = 1; i <= n; ++i)
        scanf ("%d", &v[i]);

    sort (v + 1, v + n + 1);
    reverse (v + 1, v + n + 1);

    int st = 1, dr = 0;
    for (; st < n && dr < v[st + 1] - 1; ++st, ++dr);

    int x = v[st] - dr - 1, y = 0;
    for (; st < n && dr < v[st + 1]; ++y, ++st);

    if ((y & 1) || (x & 1)) printf ("First\n");
    else printf ("Second\n");

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();

		ArrayList<Long> l = new ArrayList<Long>();
		for(int i=1; i*i<=m; i++) {
			if(m%i==0) {
				l.add((long)i);
				if(i*i!=m) {
					l.add(m/i);
				}
			}
		}
		long ans = 1;
		for(int i=0; i<l.size(); i++) {
			long v=l.get(i);
			if(v*n<=m) {
				ans = Math.max(ans, v);
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22996
#include <vector>
#include <math.h>
#include <string>
#include <ios>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long N, M;
	cin >> N >> M;
	int sorted[100001] = { 0 };

	vector< vector<long long> > city_list(N + 1);
	vector< pair< long long, long long > > py_list(M + 1);
	for (int i = 0; i < M; i++) {
		long long pi, yi;
		cin >> pi >> yi;
		city_list[pi].push_back(yi);
		py_list[i].first = pi;
		py_list[i].second = yi;
	}
	for (int i = 0; i < M + 1; i++) {
		long long pi = py_list[i].first;
		if (city_list[pi].size() == 0) continue;
		if (sorted[pi] == 0) {
			sort(city_list[pi].begin(), city_list[pi].end());
			sorted[pi] = 1;
		}
		
		long long zi = (lower_bound(city_list[pi].begin(), city_list[pi].end(), py_list[i].second)- city_list[pi].begin()) + 1;

		std::cout << std::setfill('0') << std::right << std::setw(6) << pi;
		std::cout << std::setfill('0') << std::right << std::setw(6) << zi << endl;
	}

	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
//#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<double,double> P;
const ll INF = 1e18;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main(){
  int k;cin>>k;
  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[k-1] << endl;
}


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

int main(){
	string s, str1, str2;
	map<string, int> mp;
	while(cin >> s){
		mp[s]++;
		if(mp[s] > mp[str1])str1 = s;
		if(s.size() > str2.size())str2 = s;
	}
	cout << str1 << " " << str2 << endl;
	return 0; 
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    int nx=0,ny=0;
    int nt = 0;
    rep(i,N){
        int t,x,y;
        cin >> t >> x >> y;
        int dt = t - nt;
        int diff = abs(x-nx) + abs(y-ny);

        if(!(dt >= diff and (dt-diff)%2==0)){
            cout << "No" << endl;
            return 0;
        }

        nx = x;
        ny = y;
        nt = t;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import std.stdio : writeln;

void main() {
    int a,b;
    scan(a,b);
    writeln((a+b+1)/2);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.array : split;
    import std.conv  : to;
    import std.range.primitives;

    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

vector<int> range_mod_inverse(int n, const int mod) {
  vector<int> ret(n + 1);
  ret[1] = 1;
  for (int i = 2; i <= n; i++)
    ret[i] = (long long)(mod - mod / i) * ret[mod%i] % mod;
  return ret;
}

vector<int> getFactorials(int n, const int mod) {
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*i%mod);
  return ret;
}

vector<int> getInverseFactorials(int n, const int mod) {
  vector<int> invmod(range_mod_inverse(n, mod));
  vector<int> ret(1, 1);
  for (int i = 1; i <= n; i++) ret.push_back((long long)ret.back()*invmod[i] % mod);
  return ret;
}

vector<int> fact;
vector<int> ifact;
constexpr int mod = 1'000'000'007;
long long binom(int n, int r) {
  if (n < 0 || r < 0 || r > n) return 0;
  long long a = fact[n];
  a *= ifact[r]; a %= mod;
  a *= ifact[n - r]; a %= mod;
  return a;
}
long long solve(int n, int m, int s) {
  if (n == 2) {
    return s / 2 + 1;
  }
  long long ans = binom(s + n, n);
  for (int v = 1; s - v*m >= 0; v++) {
    long long cur = binom(s - v*m + n, n) - binom(s - (v+1)*m + n, n);
    for (int i = 1; i <= n - m && s - v*m - v*i >= 0; i++) {
      long long sub = (
        binom(s - v*m - v*i + n, n) - binom(s - (v+1)*m - v*i + n, n)
        )
        * binom(n - m, i) % mod;
      if (i % 2 == 0) {
        cur += sub;
      } else {
        cur -= sub;
      }
    }
    cur %= mod;
    ans -= cur * binom(n, m);
    ans %= mod;
  }
  ans %= mod;
  ans += mod;
  ans %= mod;
  return ans;
}
int main() {
  int n, m, l, r;
  scanf("%d%d%d%d", &n, &m, &l, &r);
  fact = getFactorials(r+n+10, mod);
  ifact = getInverseFactorials(r+n+10, mod);
  long long ans = solve(n, m, r) - solve(n, m, l - 1);
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 14444
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int t[2][5], m = 11, to = 0, c, co = 0;
	for (int x = 0; x < 5; ++x) {
		cin >> t[0][x];

	}
	for (int x = 0; x < 5; ++x) {
		t[1][x] = t[0][x] % 10;

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

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

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

	}
	for (int x = 0; x < 5; ++x) {
		if (t[1][x] !=m) {
			if (t[1][x] == 0)to = to + t[0][x];
			else to = to + (t[0][x] / 10 + 1) * 10;
			
		}
		else {
			if(co==1)to = to + (t[0][x] / 10 + 1) * 10;
			else c = x;
			co = 1;
		}
		
	}
	if (co ==1) {
		to = to + t[0][c];
	}
	cout << to << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

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

using namespace std;

// dp[i][j] :=
// i個目までみていて,j問解いた時のスコアの最大値
int dp[20][1200];

int main()
{
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  REP(i, D) {
    cin >> p[i] >> c[i];
  }

  REP(i,20)REP(j,1200)dp[i][j] = -1;
  REP(j, 1200)dp[0][j] = 0;

  REP(i, D) {
    REP(j, 1001) {
      if (dp[i][j] == -1) continue;
      for (int k = 0; k < p[i]; k++) {
        dp[i + 1][j + k] = max(dp[i + 1][j + k], dp[i][j] + 100*(i + 1)*k);
      }
      dp[i + 1][j + p[i]] = max(dp[i + 1][j + p[i]], dp[i][j] + 100*(i + 1)*p[i] + c[i]);
    }
  }

  int ans;
  REP(i, 1001) {
    if (dp[D][i] >= G) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
int main(void)
{
  int R, G, B, N, i, j, n1, n2, x;
  n1=0; n2=0; x=0;
  scanf("%d %d %d %d", &R, &G, &B, &N);
  for(int i=0; i<=N/R; i++){
    n1=N-R*i;
      for(int j=0; j<=n1/G; j++){
        n2=n1-G*j;
        if(n2 % B == 0)
          x=x+1;
      }
  }
  printf("%d", x);
  return(0);
}

Measured memory_bytes: 128
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)

    val N = sc.nextInt()
    val arr = Array.fill(N)(sc.nextInt())

    var num = 0

    for (i <- 0 until N) {
      while (arr(i) % 2 == 0) {
        arr(i) /= 2
        num += 1
      }
    }

    println(num)

  }
}


Measured memory_bytes: 37848
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

using namespace std;
typedef long long ll;

int main()
{
    // Input
    int k;
    string s;
    cin >> k;
    cin >> s;

    if (s.length() <= k) {
        cout << s;
    } else {
        // string snew = s.substr(0, k) + "...";
        cout << s.substr(0, k) + "...";
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 998244353;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

ll pow_mod(ll a,ll b) {
    ll ret;
    if (b < 0) ret = pow_mod(a,mod+b-1);
    else if (b == 0) ret = 1;
    else if (b == 1) ret = a;
    else {
        ll c = pow_mod(a,b/2);
        if (b%2) ret = (c*c)%mod*a%mod;
        else ret = c*c%mod;
    }
    return ret;
}

struct BinaryIndexedTree {
private:
    int n;
    vector<int> bit;
public:
    BinaryIndexedTree(int n_) {
        n = n_+10;
        bit = vector<int>(n,0);
    }

    void add(int a,int w) {
        for (int x = a;x <= n;x += x&-x) bit[x] += w;
    }

    int sum(int a) {
        int ret = 0;
        for (int x = a;x > 0;x -= x&-x) ret += bit[x];
        return ret;
    }

    void update(int a,int w) {
        int v = w-sum(a)+sum(a-1);
        add(a,v);
    }
};

int main() {
    int n;
    cin >> n;
    vector<P> a(n),b(n);
    vector<int> s(n);
    map<int,int> mpx,mpy;
    BinaryIndexedTree bit(n);
    for (int i = 0;i < n;++i) {
        scanf("%d%d",&a[i].first,&a[i].second);
        mpx[a[i].first] = 0;
        mpy[a[i].second] = 0;
    }
    {
        int i = 1;
        for (auto& p : mpx) {
            p.second = i;
            i++;
        }
        i = 1;
        for (auto& p : mpy) {
            p.second = i;
            i++;
        }
    }
    sort(a.begin(),a.end());
    for (int i = 0;i < n;++i) {
        b[i].first = mpx[a[i].first];
        b[i].second = mpy[a[i].second];
        s[i] = b[i].second;
    }
    sort(s.begin(),s.end());
    ll ans = (pow_mod(2,n)-1)*n%mod;
    for (int i = 0;i < n;++i) {
        P p = b[i];
        ll w = bit.sum(p.second);
        ll x = lower_bound(s.begin(),s.end(),p.second)-s.begin()-w;
        ll z = i-w;
        ll y = n-1-w-x-z;
        (ans -= pow_mod(2,w+x)-1) %= mod;
        (ans -= pow_mod(2,x+y)-1) %= mod;
        (ans -= pow_mod(2,y+z)-1) %= mod;
        (ans -= pow_mod(2,z+w)-1) %= mod;
        (ans += pow_mod(2,w)-1) %= mod;
        (ans += pow_mod(2,x)-1) %= mod;
        (ans += pow_mod(2,y)-1) %= mod;
        (ans += pow_mod(2,z)-1) %= mod;
        bit.add(p.second,1);
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			if (n == 1) {
				Console.WriteLine("Yes");
				Console.WriteLine("2");
				Console.WriteLine("1 1");
				Console.WriteLine("1 1");
				return;
			}

			int m = 2 * n;
			int k = 0;
			for (int i = 2; i < m; i++) {
				if (m % i == 0 && i * (i + 1) == m) {
					k = i;
					break;
				}
			}

			if (k == 0) {
				Console.WriteLine("No");
				return;
			}

			var values = new List<int>[k + 1];
			int[] counts = new int[n];
			int current = 0;
			for (int i = 0; i < k + 1; i++) {
				values[i] = new List<int>();

				for (int j = 0; j < i; j++) {
					foreach (int t in values[j]) {
						if (counts[t] == 1) {
							values[i].Add(t);
							counts[t]++;
							break;
						}
					}
				}

				for (int j = i; j < k; j++) {
					values[i].Add(current);
					counts[current]++;
					++current;
				}
			}

			var sb = new StringBuilder();
			sb.AppendLine("Yes");
			sb.AppendLine((k + 1).ToString());

			for (int i = 0; i < k + 1; i++) {
				sb.Append($"{k} ");
				sb.AppendLine(
					string.Join(" ", values[i].Select(x => (x + 1).ToString())));
			}

			Console.WriteLine(sb.ToString());
		}
	}
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

inline char opp(char ch){
	return ch == 'S'?'W':'S';
}

inline bool check(string s, string ret){
	int n = s.size();
	if(ret[0] == 'S'){
		if(s[0] == 'o' && ret[1] != ret[n - 1])return false;
		if(s[0] == 'x' && ret[1] == ret[n - 1])return false;
	}else{
		if(s[0] == 'o' && ret[1] == ret[n - 1])return false;
		if(s[0] == 'x' && ret[1] != ret[n - 1])return false;
	}
	if(ret[n - 1] == 'S'){
		if(s[n - 1] == 'o' && ret[0] != ret[n - 2])return false;
		if(s[n - 1] == 'x' && ret[0] == ret[n - 2])return false;
	}else{
		if(s[n - 1] == 'o' && ret[0] == ret[n - 2])return false;
		if(s[n - 1] == 'x' && ret[0] != ret[n - 2])return false;
	}
	return true;
}

void process(string s, string t){
	string ret = t;
	int n = s.size();
	for(int i = 1; i + 1 < n; i++){
		if(ret[i] == 'S'){
			if(s[i] == 'o')ret += ret[i - 1];
			else ret += opp(ret[i - 1]);
		}else{
			if(s[i] == 'x')ret += ret[i - 1];
			else ret += opp(ret[i - 1]);
		}
	}
	if(!check(s, ret))return;
	cout<<ret<<'\n';
	exit(0);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	string s;
	cin>>s;
	process(s, "SS");
	process(s, "SW");
	process(s, "WS");
	process(s, "WW");
	cout<<-1<<'\n';

	return 0;
}

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

int main(){
  int K,X;
  cin>>K>>X;
  for(int i=X-K+1; i<=X+K-1; i++){
    cout<<i<<" ";
    if(i==X+K-1){
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3620
import java.util.Scanner;


public class Main {


//	final int MOD = 1000000007;

//	public static int min = 3000000;

	public static void main(String[] args) {

		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

		int n = sc.nextInt();
//		int m = sc.nextInt();
//		int k = sc.nextInt();

//		long k = sc.nextLong();

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

//		String s = sc.next();

//		int[] ans = new int[n];

//		ArrayList<Integer> list = new ArrayList<>();

		//-------------------------------------------------------------------------------------

		n = n % 100;
		n = n % 10;

		String string;

		if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
			string = "hon";
		} else if(n == 0 || n == 1 || n == 6 || n == 8) {
			string = "pon";
		} else {
			string = "bon";
		}

		//-------------------------------------------------------------------------------------

//		if(!f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(string);

		sc.close();
	}



}

Measured memory_bytes: 35828
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        Scanner sc = new Scanner(is);
        /* read */
        int n = sc.nextInt();

        Map<Integer, Set<Integer>> lists = new HashMap<>();

        for (int i = 0; i < n; i++) {
            String s = sc.next();
            Set<Integer> list = new HashSet<>();

            for (int j = 0; j < n; j++) {
                if (s.charAt(j) == '1') {
                    // matrix[i][j] = true;
                    list.add(j);
                }
            }
            lists.put(i, list);
        }

        int max = -1;
        for (int i = 0; i < n; i++) {
            max = Math.max(depth(i, lists, n), max);
        }

        os.println(max);
    }

    private static class Node {
        int node;
        Set<Integer> parents = new HashSet<>();
    }

    private static int depth(int start, Map<Integer, Set<Integer>> lists, int N) {
        HashMap<Integer, HashSet<Integer>> tempLists = new HashMap<>();
        for (int j = 0 ; j < N ; j++) {
            tempLists.put(j, new HashSet<>(lists.get(j)));
        }
        Set<Integer> visited = new HashSet<>();
        Set<Node> curr = new HashSet<>();
        Node s = new Node();
        s.node = start;
        curr.add(s);

        int count = 0;
        while (0 < curr.size()) {
            count++;
            Map<Integer, Node> next = new HashMap<>();
            for (Node n : curr) {
                Set<Integer> nexts = tempLists.get(n.node);
                for (int nx : nexts) {
                    if (n.parents.contains(nx)) {
                        // parent. ignore
                        continue;
                    }
                    if (visited.contains(nx)) {
                        // visiting again
                        return -1;
                    }
                    Node node;
                    if (next.containsKey(nx)) {
                        node = next.get(nx);
                    } else {
                        node = new Node();
                        node.node = nx;
                        next.put(nx, node);
                    }
                    node.parents.add(n.node);
                }
                visited.add(n.node);
            }
            for (Node n : curr) {
                for(Integer child : next.keySet()) {
                    tempLists.get(child).remove(n.node);
                }
            }
            curr = new HashSet<>(next.values());
        }
        return count;
    }
}

Measured memory_bytes: 167228
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

using namespace std;

using ll = int64_t;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

template <class T>
ostream &operator<<(ostream &os, vector<T> const &vec) {
    if (vec.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream &operator<<(ostream &os, array<T, S> const &arr) {
    if (arr.empty()) {
        os << "{}";
    } else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream &operator<<(ostream &os, pair<T, U> const &p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

namespace math {
ll gcd(ll u, ll v) {
    while (v != 0) {
        ll r = u % v;
        u = v;
        v = r;
    }
    return u;
}
ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;

    return ((m / math::gcd(m, n)) * n);
}
}  // namespace math

struct UnionFind {
    vector<ll> data;
    UnionFind(ll size) : data(size, -1) {}
    bool unionSet(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool findSet(ll x, ll y) { return root(x) == root(y); }
    ll root(ll x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    ll size(ll x) { return -data[root(x)]; }
};

template <class T, class U>
pair<T, U> operator+(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first + b.first, a.second + b.second);
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const &a, pair<T, U> const &b) {
    return pair<T, U>(a.first - b.first, a.second - b.second);
}

ll bound(function<bool(ll)> f, ll ng, ll ok) {
    while (abs(ng - ok) > 1) {
        ll mid = (ng + ok) / 2;
        if (f(mid))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}


int main(void) {
    int N, K;
    cin >> N >> K;
    cout << N - K + 1 << endl;



    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll a, b, key;

	cin>>a>>b;

	vll sum(1000, 0);

	rep(i, 999){
		sum[i+1]=sum[i]+i+1;
	}
	key=b-a;

	cout<<sum[key]-b<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<pair<int, int> > adj[n];
    while (m--) {
        int a, b, c; cin >> a >> b >> c;
        adj[a-1].push_back({b-1, p-c});
    }
    int save;
    long long dist[n];
    fill(dist, dist+n, 1LL<<60);
    dist[0] = 0;
    for (int t = 0; t < 2*n; t++) {
        bool upd = false;
        for (int i = 0; i < n; i++)
            for (auto &e : adj[i]) {
                int j = e.first, w = e.second;
                if (dist[j] > dist[i] + w) {
                    upd = true;
                    dist[j] = dist[i] + w;
                }
            }
        if (t == n) save = dist[n-1];
        // cerr << t << ' ' << dist[n-1] << endl;
    }
    if (save == dist[n-1]) {
        cout << max(-dist[n-1], 0LL) << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 384
n = gets.to_i
s1 = gets.chomp
s2 = gets.chomp

ans = 1
i = 0
prev_tile = 0

while i < n do
  if s1[i] == s2[i]
    i += 1
    case prev_tile
    when 1
      ans *= 2
    when 2
      ans *= 1
    else
      ans *= 3
    end
    prev_tile = 1
  else
    i += 2
    case prev_tile
    when 1
      ans *= 2
    when 2
      ans *= 3
    else
      ans *= 6
    end
    prev_tile = 2
  end
end
puts ans % 1000000007


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
   ll n,d,c=0;
   cin>>n>>d;;
   d*=d;
   for(int i=0;i<n;i++)
   {
       ll x,y,ans=0;
       cin>>x>>y;
       ans+=(x*x+y*y);
       if(ans<=d)
       {
           c++;
       }

   }
   cout<<c<<endl;

}


Measured memory_bytes: 3596
import math
import copy
import sys

# inputa = input().split()
# inputb = input().split()
# inputc = input().split()

# a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])

# x = int(inputb[0])
# y = int(inputb[1])

# inputb = input().split()
# inputbList = [int(n) for n in inputb]
#
# inputList=[]
# inputNumList = []
# for i in range(a):
#     inputNum = input().split()
#     inputNumList = [int(n) for n in inputNum]
#     inputList.append(inputNumList)

# inputList = [int(n) for n in inputList]

# b = [int(n) for n in inputb]
# c = [int(n) for n in inputc]

inputa = input().split()
inputaList = [int(n) for n in inputa]

inputb = input().split()
inputbList = [int(n) for n in inputb]

inputc = input().split()
inputcList = [int(n) for n in inputc]

inputbList.append(inputaList[2])
xmin = min(inputbList)
xmax = max(inputbList)

inputcList.append(inputaList[3])
ymin = min(inputcList)
ymax = max(inputcList)

if xmax < ymin or ymax < xmin:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3444