akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,b) for(auto i=(a);i<(b);i++)
#define per(i,a,b) for(auto i=(a);i>=(b);i--)
#define Min(a,b) ((a) < (b) ? (a) : (b))
#define Max(a,b) ((a) > (b) ? (a) : (b))
#define int_inf 0x3f3f3f3f
#define int_max 2147483647
#define ll_max 9223372036854775807
#define ull_max 18446744073709551615
#define ll_inf 0x7f7f7f7f7f7f7f7f
#define lowbit(x) (x)&(-x)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define eps 1e-8
#define all(v) (v.begin(),v.end())
#define db double
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const double pi=acos(-1.0);
const double inf = 1e100;
template<class T>
inline T read()
{
	T x=0,f=1;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-')f=-1;s=getchar();};
	while(s>='0'&&s<='9'){x=(x<<3)+(x<<1)+s-48;s=getchar();};
	return x*f;
}
template<typename T>
inline void wri(T x)
{
	if(x<0){x=-x;putchar('-');};
	if(x/10) wri(x/10);
	putchar(x%10+48);
}
template<typename T>
inline void print(T x,char s)
{
	wri(x);
	putchar(s);
}
template<typename T>
T gcd(T a,T b)
{
	return b==0?a:gcd(b,a%b);
}
//关闭流同步就不能手写读入优化啦
int a[200010],b[200010];
ll suma[200010],sumb[200010];
int n,m;
ll t;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin>>n>>m>>t;
  	rep(i,1,n+1){
  		cin>>a[i];
  		suma[i]=suma[i-1]+1ll*a[i];
	}
  	rep(i,1,m+1){
  		cin>>b[i];
  		sumb[i]=sumb[i-1]+1ll*b[i];
	} 
	int pos2=m;
	int ans=0;
	rep(i,0,n+1){
		if(t<suma[i]) break;
		while(sumb[pos2]>t-suma[i])
		pos2--;
		ans=max(ans,pos2+i);
	}
  	cout<<ans<<endl;
  	return 0;
}



Measured memory_bytes: 8272
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll N, M;
vllvll Graph(100);
ll ans = 0;

void rec(ll node, ll cnt, vll seen)
{
        ++cnt;
        seen[node] = 1;
        if (cnt == N) {
                ++ans;
                return;
        }

        for (auto adj : Graph[node]) {
                if (seen[adj]) continue;
                rec(adj, cnt, seen);
        }
}

void dfs(ll start)
{
        vll seen(N+1);
        rec(start, 0, seen);
}

int main()
{
        cin >> N >> M;
        rep(i, 0, M) {
                ll a, b;
                cin >> a >> b;
                Graph[a].push_back(b);
                Graph[b].push_back(a);
        }

        dfs(1);
        cout << ans << endl;
}

Measured memory_bytes: 256
sosu = []
for i in range(2, 1001):
	f = True
	for s in sosu:
		if i % s == 0:
			f = False
	if f:
		sosu.append(i)
ss = set(sosu)
		
while True:
	a, d, n = map(int, input().split())
	if a == 0 and d == 0 and n == 0:
		break
	if a == 1:
		a += d
	while True:
		if a in ss:
			n -= 1
		elif all(not a % s == 0 for s in sosu):
			n -= 1
		if n == 0:
			print(a)
			break
		a += d


Measured memory_bytes: 5616
#include <map>
#include <vector>
#include <iostream>

using namespace std;

int main () {
  int N;
  long long K;
  while (cin >> N >> K) {
    long long g[N][N];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> g[i][j];
      }
    }

    map<long long, vector<vector<long long> > > dp;
    vector<vector<long long> > f;
    for (int i = 0; i < N; i++) {
      vector<long long> v;
      for (int j = 0; j < N; j++) {
        v.push_back(g[i][j]);
      }
      f.push_back(v);
    }

    dp[1] = f;

    long long step = 1;
    long long cur = 1;
    while (step > 0 && cur + step <= K) {
      vector<vector<long long> > n(N, vector<long long>(N));
      // cout << cur << ' ' << step << ' ' << K << endl;
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          for (int k = 0; k < N; k++) {
            n[i][j] = (n[i][j] + (dp[cur][i][k] * dp[step][k][j]) % 1000000007) % 1000000007;
          }
        }
      }
      dp[cur + step] = n;

      cur += step;
      step *= 2;
      while (cur + step > K) {
        step /= 2;
      }
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        ans = (ans + dp[K][i][j]) % 1000000007;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2816
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    
    if(a==b){
      System.out.println(c);
    }else if(b==c){
      System.out.println(a);
    }else{
      System.out.println(b);
    };
  }
}

Measured memory_bytes: 19796
from _collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
a_max = max(a)
l = defaultdict(int)
count = 0
for i in range(n):
    l[a[i]] += 1
    count += 1
    if l[a[i]] == a[i]:
        count -= a[i]
print(count)

Measured memory_bytes: 18160
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)

#define MAXN (100000)
#define MOD (998244353)

char s[MAXN+1];

int main(void)
{
    int n,k;
    scanf("%d %d",&n, &k);
    scanf("%s", s);

    int score = 0;
    int rl = 0;
    int lr = 0;
    for(int i=1;i<n;i++)
    {
        if(s[i-1]=='R' && s[i]=='R')
        {
            score++;
        }
        if(s[i-1]=='R' && s[i]=='L')
        {
            rl++;
        }
        if(s[i-1]=='L' && s[i]=='L')
        {
            score++;
        }
        if(s[i-1]=='L' && s[i]=='R')
        {
            lr++;
        }
    }

    while(k>0)
    {
        if(rl>0 && lr>0)
        {
            rl--;
            lr--;
            score += 2;
        }else if(rl>0)
        {
            rl--;
            score += 1;
        }else if(lr>0)
        {
            lr--;
            score += 1;
        }else break;
        k--;
    }

    printf("%d\n",score);
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define EL '\n'
#define el '\n'
#define all(x) x.begin(),x.end()
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define MOD 1000000007
#define pb push_back
#define MAX 10e+7
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
int n;
cin>>n;
string s1,s2;
for (int i = 0; i < n; i++)
{
    int a;
    cin>>a;
    s1+=a;
}
for (int i = 0; i < n; i++)
{
    int a;
    cin>>a;
    s2+=a;
}
string s11=s1,s22=s2;
sort(s1.begin(),s1.end());
sort(s2.begin(),s2.end());
int ans1=0,ans2=0;
do
{
    ans1++;
    if(s1==s11)
    goto end;
} while (next_permutation(s1.begin(),s1.end()));
end:
do
{
ans2++;
if(s2==s22)
goto end1;
} while (next_permutation(s2.begin(),s2.end()));
end1:
cout<<abs(ans1-ans2)<<endl;
}
int main()
{

FASTIO
 long long int t;
 t=1;
 while(t--)
 {
  solve();
  
 }
  return 0;
}


Measured memory_bytes: 3600
def combi(n):
    if n > 1: return n*(n-1)//2
    else:return 0

N = int(input())
A = list(map(int,input().split()))

sum = [0]*(max(A)+1)
for a in A:sum[a] += 1
total = 0
for s in sum:total += combi(s)
for a in A:
    print(total - combi(sum[a]) + combi(sum[a]-1))


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

a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            value = 500*i+100*j+50*k
            if value == x:
                ans += 1

print(ans)


Measured memory_bytes: 9008
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <map>
#include <cmath>
#include <vector>

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

typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;

    int cnt_one = 0; int cnt_zero = 0; int ans = 0;
    rep (i, s.size()) {
        (s[i] == '1') ? cnt_one++ : cnt_zero++;
    }
    ans = min(cnt_one*2, cnt_zero*2);
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

void InputNumber(int* number, int limitLow, int limitHigh);
int GetDev(int a, int b);
int GetRem(int a, int b);
double GetDob(int a, int b);

int main(void) {
    int a;
    int b;
    
    InputNumber(&a, 1, 1000000000L);
    InputNumber(&b, 1, 1000000000L);
    
    printf("%d %d %.5lf\n", GetDev(a, b), GetRem(a, b), GetDob(a, b));
    
    return 0;
}

void InputNumber(int* number, int limitLow, int limitHigh) {
    int x;
    do {
        scanf("%d", &x);
    } while (x < limitLow || x > limitHigh);
    *number = x;
}

int GetDev(int a, int b) {
    return a / b;
}

int GetRem(int a, int b) {
    return a % b;
}

double GetDob(int a, int b) {
    return (double)a / b;
}


Measured memory_bytes: 2112
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt(), s = sc.nextInt();
		int z, cnt = 0, i, j;
		for(i = 0; i <= k; i++){
			for(j = 0; j <= k; j++){
				z = s-(i+j);
				if(0 <= z && z <= k) cnt++;
			}
		}
		System.out.println(cnt);
	}
}

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

using namespace std;

const int ms = 1e5 + 17;
int t[ms];
int x[ms];
int y[ms];


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

    int n;
    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> t[i] >> x[i] >> y[i];


    int sum = 0 + 0;
    for(int i = 1; i <= n; ++i)
    {
       // cout << i << ' ' << x[i] << ' ' << y[i] << '\n';
        int v = x[i] + y[i];
        int tt = t[i] - t[i - 1];
        if(tt & 1)
        {
            if(((v % 2) != (sum % 2)) && (abs(sum - v) <= tt))
            {
                sum = v;
            }
            else
                return cout << "No\n", 0;
        }
        else
        {
            if(((v % 2) != (sum % 2)))
                return cout << "No\n", 0;
            else
            {
                if(abs(sum - v) <= tt)
                    sum = v;
                else
                    return cout << "No\n", 0;
            }
        }
    }

    cout << "Yes\n";


}


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

int main(){
  string s;cin>>s;
  ll n = s.size();
  ll num0=0;
  rep(i,n){
    if (s.at(i) == '0'){
      num0++;
    }
  }
  ll num1 = n - num0;
  cout << 2*min(num0,num1) << endl;
}

Measured memory_bytes: 512
use std::process;
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}
use std::convert::AsRef;
fn main() {
    let s: String = get!(String);

    match s.as_ref() {
        "Sunny" => println!("Cloudy"),
        "Cloudy"=> println!("Rainy"),
        "Rainy" => println!("Sunny"),
        _       => panic!(""),
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
    char a[1100] = {0};
    scanf("%[^\n]",a);
    int cnt = 0;
    int mx = 0;
    int len[1100] = {0};
    string ans[1100];
    for(int i = 0,j = 0; i <= strlen(a); i++){
        if('a' <= a[i] && a[i] <= 'z' || 'A' <= a[i] && a[i] <= 'Z'){
            ans[cnt] += a[i];
            j++;
        }
        else{
            len[cnt] = j;
            cnt++;
            mx = max(mx,j);
            j = 0;
        }
    }
    string date;
    for(int i = 0; i < cnt; i++){
        if(len[i] == mx){
            date = ans[i];
            break;
        }
    }
    sort(ans,ans+cnt);
    fill(len,len+50,0);
    string mx_date = ans[0];
    ans[cnt] = ' ';
    mx = 0;
    for(int i = 1; i <= cnt; i++){
        if(mx_date == ans[i]){
            mx++;
        }
        else{
            mx_date = ans[i];
            len[i-1] = mx;
            mx = 0;
        }
    }
    for(int i = 0; i < cnt; i++){
        mx = max(mx,len[i]);
    }
    for(int i = 0; i < cnt; i++){
        if(len[i] == mx){
            cout << ans[i] << ' ' << date << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    // Your code here!
    ll n, m;
    cin >> n >> m;
    vector<int> a(m);
    ll ans= 0;
    rep(i, m){cin >> a[i]; ans += a[i];}
    if(ans > n){cout << -1;}
    else{cout << n-ans;}
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        //static int N;
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var bef = 0L;
            long ans = 0;
            for (int i = 1; i <= N; i++)
            {
                var now = long.Parse(Console.ReadLine());
                if(bef > 0)
                {
                    ans += Min(bef,now);
                    now -= Min(bef, now);
                }

                ans += now / 2;
                bef = now % 2;
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 31868
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long N = input.nextLong();
		long A = input.nextLong();
		long B = input.nextLong();
		
		long cnt=N/(A+B);
		long amari=N%(A+B);
		long x=0;
		
		if(amari>=A) {
			x=A;
		}
		else {
			x=amari;
		}
		System.out.println(A*cnt+x);
		
	}
}


Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main(){
	int a=0,b=0;
	char c=getchar();
	while(c=='1'||c=='0'){
		if(c=='1')
			++b;
		else
			++a;
		c=getchar();
	}
	cout<<min(a,b)*2;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[200005];
int main(void)
{
    int k,n,mx=0;
    cin >> k >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    a[n]=a[0]+k;
    for(int i=0;i<n;i++)
        mx=max(mx,a[i+1]-a[i]);
    cout << k-mx;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  
  for (int i = 0; i < N; i++) {
    cin >> v.at(i);
  }
  
  int sum = 0;
  for (int i = 0; i < (N - 1); i++) {
    for (int j = i + 1; j < N; j++) {
      sum += v.at(i) * v.at(j);
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	cout << n * n * n;
}	

	

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    int odp = 0;
    for (int i = 0; i < 2 * n; i += 2)
        odp += a[i];
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

#define REP(i, n) for(int i=0; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin() , (c).end()

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
int func(int m, int d, int h, int min)   {
  int res = 0;
  REP(i, m-1) {
    res += month[i];
  }
  res += d;
  res *= 60*24;
  res += h*60;
  res += min;
  return res;
}

int main() {
  int n;
  while(cin>>n, n) {
    bool table[31*12*24*60];
    int m[n], d[n], h[n], min[n], p[n];
    char c[n];

    int start[1000];
    int point[1000];
    memset(table,0,sizeof(table));
    memset(point,0,sizeof(point));

    int godstart;
    REP(i, n) {
      scanf("%d/%d %d:%d %c %d",  m+i, d+i, h+i, min+i, c+i, p+i);
      //cout << m[i] << " " << d[i] << " " << p[i] << endl;
      if (p[i] == 0) {
        if (c[i] == 'I') {
          godstart = func(m[i], d[i], h[i], min[i]);
        } else {
          for (int j=godstart; j<func(m[i], d[i], h[i], min[i]); ++j) {
            table[j] = 1;
          }
        }
      }
    }
    REP(i, n) {
      if (p[i] == 0) continue;
      if (c[i] == 'I') {
        start[p[i]] = func(m[i], d[i], h[i], min[i]);
      } else {
        for (int j=start[p[i]]; j<func(m[i], d[i], h[i], min[i]); ++j) {
          if (table[j]) {
            //printf("%d:%d\n", i, j);
            point[p[i]]++;
          }
        }
      }
    }
    cout << *max_element(point, point+1000) << endl;;
    
  }
}

Measured memory_bytes: 0
import sys, collections

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    son = [[] for i in range(N)] 
    for i in range(M):
        u, v = map(int, input().split())
        son[u-1].append(v-1)
    S, T = map(int, input().split())

    dist = [[-1, -1, -1] for i in range(N)]
    que = collections.deque()
    que.append((0, S-1, 0)) #k回目の移動, 場所, mod
    while que:
        cost, now, mod = que.popleft()
        if dist[now][mod] == -1:
            dist[now][mod] = cost
            if mod == 0:
                for s in son[now]:
                    if dist[s][1] == -1: que.append((cost + 1, s, 1))
            else:
                for s in son[now]:
                    if dist[s][(mod + 1) % 3] == -1: que.append((cost, s, (mod + 1) % 3))

    print(dist[T-1][0])  
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 31856
#include<iostream>
#include<algorithm>
#include<cassert>
using namespace std;
int main(){
  int n,st,ed,ans,lim;
  int info[100100];
  while(cin >> n){
    ans = lim = 0;
    for(int i=0;i<100100;i++)info[i] = 0;
    for(int i=0;i<n;i++){
      cin >> st >> ed;
      lim = max(lim,ed);
      for(int i=st;i<=ed;i++)info[i]++;
    }
    for(int i=1;i<=lim;i++){
      if(info[i]+1>=i)ans = i;
    }
    cout << ans-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1552
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vi x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    vvi xs(2);
    
    auto compress = [&](vi &x, int i) {
        rep(i_, n) {
            xs[i].push_back(x[i_]);
        }
        sort(all(xs[i]));
        xs[i].erase(unique(all(xs[i])), xs[i].end());
        rep(i_, n) {
            x[i_] = lower_bound(all(xs[i]), x[i_]) - xs[i].begin();
        }
    };
    
    compress(x, 0);
    compress(y, 1);
    
    int X = xs[0].size();
    int Y = xs[1].size();

    vvi point(X+1, vi(Y+1));


    rep(i, n) {
        point[x[i]+1][y[i]+1]++;
    }

    rep(i, X) {
        rep(j, Y) {
            point[i+1][j+1] += point[i][j+1] + point[i+1][j] - point[i][j];
        }
    }

    ll ans = INT64_MAX;
    rep(i1, X) {
        for(int i2 = i1+1; i2 < X+1; ++i2) {
            rep(j1, Y) {
                for(int j2 = j1+1; j2 < Y+1; ++j2) {
                    int cc = point[i2][j2] - point[i2][j1] - point[i1][j2] + point[i1][j1];
                    if(cc >= k) {
                        ans = min(ans, (xs[0][i2-1]-xs[0][i1])*(xs[1][j2-1]-xs[1][j1]));
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

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

namespace abc167_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            if(S == T.Substring(0, S.Length))
            {
                Console.WriteLine("Yes");
            }

            else
            {
                Console.WriteLine("No");
            }

            Console.Read();

        }
    }
}



Measured memory_bytes: 25896
#include <iostream>
#include <vector>
#define T 1001
#define M 1000000007
#define E e[x][i]
#define S e[x].size()
using namespace std;
typedef long long ll;
ll func(int);
int N,s,t;
string n[T];
vector<int> e[T];
 
main(){
  cin>>N;
  for(int i=0;i<N;i++) cin>>n[i];
  for(int i=0;i<N-1;i++) cin>>s>>t,e[s-1].push_back(t-1);
  cout<<func(0)%M<<endl;
}

ll func(int x){
  ll res=0,i;
  if(!S){
    if(n[x]=="E") return 1;
    return 2;
  }
  if(n[x][0]=='E'){
    res++;
    for(i=0;i<S;i++) res*=func(E);
    if(n[x]=="E?") res++;
  }
  else if(n[x][0]=='A'){
    for(i=0;i<S;i++) res+=func(E);
    if(n[x]=="A?") res++;
  }else{
    res++;
    for(i=0;i<S;i++) res*=(1+func(E));
    if(n[x]=="R") res--;
  }
  return res%M;
}

Measured memory_bytes: 1356
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,r,d,i,coun=0;
    cin>>l>>r>>d;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
        {
            coun++;
        }
    }
    cout<<coun<<endl;
}


Measured memory_bytes: 3628
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int P = 998244353;
const int MAX = 3e6;
int pot(int a,int w){
  int r = 1;
  while(w){
    if(w & 1)
      r = r * a % P;
    w/=2;
    a = a * a % P;
  }
  return r;
}
int mul(int a,int b){
  return a * b % P;
}

void sub(int &a,int b){
  a -= b;
  if(a < 0)
    a += P;
}

void add(int &a,int b){
  a += b;
  if(a >= P)
    a -= P;
}

int sil[MAX],odw[MAX];
int dwu(int a,int b){
  if(b > a || b < 0)return 0;
  return mul(sil[a], mul(odw[b], odw[a-b])); 
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  sil[0] = 1;
  R(i,MAX-1){
    sil[i+1] = mul(sil[i], i + 1);
  }
  R(i,MAX){
    odw[i] = pot(sil[i], P-2);
  }
  int n,m;
  cin >> n >> m;
  int res = dwu(m * 3 + n - 1, n - 1);
  
  debug(res);
  
  sub(res, mul(n, dwu(m + n - 2, n - 1)));
  
  debug(res);
  
  for(int i = m + 1; i <= n; i++)if((m * 3 - i) % 2 == 0){
    int ak = mul(dwu(n,i), dwu((3 * m - i)/2 + n - 1, n - 1));
    sub(res, ak);
  }
  
  debug(res);
  
  cout << res << "\n";
}


Measured memory_bytes: 47232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    ll ret = 0;
    int cnt = N - 1;
    int itr = 0;
    while(cnt > 0) {
        if(itr == 0) {
            ret += vec.at(itr);
            cnt--;
            itr++;
        }
        else if(cnt == 1) {
            ret += vec.at(itr);
            cnt--;
        }
        else {
            ret += vec.at(itr) * 2;
            itr++;
            cnt -= 2;
        }
    }
    cout << ret << endl;
}

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

int main() {
	int N;
	cin >> N;

	vector<int> P(N, 0);
	vector<int> Q(N, 0);
	for (int i = 0; i < N; i++) cin >> P[i];
	for (int i = 0; i < N; i++) cin >> Q[i];
	bool isPFirst = true;
	for (int i = 0; i < N; i++) {
		if (P[i] != Q[i]) {
			isPFirst = P[i] < Q[i];
			break;
		}
	}
	int ans = 0;
	while (P != Q) {
		if (isPFirst)next_permutation(P.begin(), P.end());
		else next_permutation(Q.begin(), Q.end());
		ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input())
aaa = 0 
box = []
for i in range(1, 10):
    if N % i == 0:
        box.append(int(N/i))
for k in box:
    if k>=1 and k<=9:
        aaa = 1 
        break
    else:
        aaa = 0 
if aaa == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) x-'0'
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}

ll d[200100];
vector<pll>a;
int main()
{
    weewoo;
    int n,m;
    cin >> n >> m;
    ll ans=0;
    if(n<m){
        while(m--){
            ans+=n;
            ans*=10;
        }
    }
    else{
        while(n--){
            ans+=m;
            ans*=10;
        }
    }
    cout << ans/10 << endl;
    return 0;
}


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

int main(){
  double r;
  cin>>r;

  double PI = acos(-1);
  double area = PI * r * r;
  double length = PI * ( r + r );
  
  cout<<fixed<<setprecision(12);
  
  cout<<area<<" "<<length<<endl;

  return 0;
}



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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int A,B;

    cin>>A>>B;

    if(A%3==0||B%3==0||(A+B)%3==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++)
    {
        if((i%3==0 && i%5!=0) || (i%3!=0 && i%5==0) || (i%3==0 && i%5==0))
        {
            continue;
        }
        sum+=i;
    }
        cout<<sum<<endl;
}


Measured memory_bytes: 3580
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int x , a ;
    cin >> x >> a; 
    if(x < a)cout << 0 ; 
    else cout << 10 ; 























return 0 ;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int p = sc.nextInt();
		int count = 0;
		for (int i = 1; i < n; i++) {
			if (p >= (p = sc.nextInt())) {
				++count;
				if (count > max) {
					max = count;
				}
			} else {
				count = 0;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 48356
N,T=map(int,input().split())
c=[]
t=[]
for i in range(N):
    A,B=map(int,input().split())
    c.append(A)
    t.append(B)
    
C=[]
for i in range(N):
    if t[i]<=T:
        C.append(c[i])

if C==[]:
    print('TLE')
else:
    print(min(C))

Measured memory_bytes: 3064
#include<stdio.h>
#define N 8
#define NOT 1
#define FREE -1

void printBoard(void);
void initialize(void);
void recursive(int);
int col[N],dpos[2*N-1],dneg[2*N-1],row[N],X[N][N];



void initialize(){
  int i;
  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
	if(row[i]!=j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i]==j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i==N){
    printBoard();
    return;
  }
  for(j=0;j<N;j++) {
    if(col[j]==NOT || dpos[i+j]==NOT || dneg[i-j+N-1]==NOT)continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}
int main(){
  int i,j,k,r,c;
  initialize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j]=0;
    }
  }
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d%d",&r,&c);
    X[r][c]=1;
  }
  recursive(0);
  return 0;
}

Measured memory_bytes: 2604
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

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

var N int

func main() {
	defer stdout.Flush()
	N = readInt()
	m := readInt()
	G := make([][]int, N)
	for i := 0; i < m; i++ {
		a := readInt() - 1
		b := readInt() - 1
		G[a] = append(G[a], b)
		G[b] = append(G[b], a)
	}

	println(dfs(G, make([]bool, N), 0, 0))
}

func dfs(G [][]int, visited []bool, nvisited, v int) int {
	if visited[v] {
		return 0
	}
	visited[v] = true
	defer func() {
		visited[v] = false
	}()
	if nvisited+1 == N {
		return 1
	}

	var res int
	for _, u := range G[v] {
		res += dfs(G, visited, nvisited+1, u)
	}
	return res
}

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


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double t = sc.nextDouble();
    double a = sc.nextDouble();
    int ans = 1;
    double s = 1000000;
    for(int i = 1; i <= n; i++) {
      double x = sc.nextDouble();
      double t1 = t - (x * (double)6) / (double)1000;
      double s1 = Math.abs(t1 - a);
      if(s1 < s) {
        ans = i;
        s = s1;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27092
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void)
{
    int i, ans, suma=0, sumb=0, n, w[100], minans=1000000, t;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &w[i]);
    }

    for(t=0;t<=n;t++){
        ans=0;
        suma=0;
        sumb=0;
        for(i=0;i<n;i++){
            if(i<=t) suma=suma+w[i];
            else sumb=sumb+w[i];
        }
        ans=max(suma, sumb)-min(suma, sumb);
        if(ans<minans) minans=ans;
    }
    printf("%d\n", minans);
    
    return 0;
}


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

using namespace std;

int main(){
	int N;
	int V[20], C[20];
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> V[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++){
		int temp;
		cin >> temp;
		
		if(V[i] - temp > 0){
			ans += V[i] - temp;
		}
	}

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

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var n,k,d,x,ans int
	fmt.Scan(&n,&k)
	have := make([]int,n+1)
	for i:=0 ; i<k ; i++ {
		fmt.Scan(&d)
		for j:=0 ; j<d; j++ {
			fmt.Scan(&x)
			have[x]++
		}
	}
	for i:=1 ; i<=n ; i++ {
		if have[i] == 0{
			ans++
		}
	}
	fmt.Println(ans)
}


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

bool is_prime(int x){
    for(int i=2; i*i<=x; i++){
        if(i != x && x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    int x;
    cin >> x;
    while(1){
        if(is_prime(x)){
            cout << x << endl;
            break;
        }
        x++;
    }
}

Measured memory_bytes: 3624
As = []
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))
As.append(list(map(int, input().split())))

cs = [[0,0,0], [0,0,0],[0,0,0]]
pos_dic = {}
for i,x in enumerate(As):
  for j,xx in enumerate(x):
    pos_dic[xx] = (i,j)
    
def check(cs):
  for i in range(3):
    if sum(cs[i]) == 3:
      return True
    if (cs[0][i] + cs[1][i] + cs[2][i]) == 3:
      return True
  if (cs[2][2] + cs[1][1] + cs[0][0]) == 3:
    return True
  if (cs[2][0] + cs[1][1] + cs[0][2]) == 3:
    return True
  return False
    

flag = 0
N = int(input())
for i in range(N):
  x = int(input())
  if x in pos_dic:
    i,j = pos_dic[x]
    cs[i][j] = 1
    if check(cs):
      flag = 1
      break
if flag == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 38384
#[allow(dead_code)]
fn main() {
    let n = i::u();
    let s = i::cmap(2);
    let m = 1_000_000_007usize;
    let mut tate = s[0][0] == s[1][0];
    let mut ans = if tate { 3usize } else { 6usize };
    let mut i = if tate { 1 } else { 2 };
    if i >= n {
        println!("{}", ans);
        return;
    }
    loop {
        if tate {
            if s[0][i] == s[1][i] {
                ans = ans * 2 % m;
                i += 1;
            } else {
                ans = ans * 2 % m;
                i += 2;
                tate = false;
            }
        } else {
            if s[0][i] == s[1][i] {
                i += 1;
                tate = true;
            } else {
                ans = ans * 3 % m;
                i += 2;
            }
        }
        if i >= n {
            break;
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }
    pub fn u2() -> (usize, usize) {
        (read(), read())
    }
    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


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

int main(){
    int a, b;
    int i;
    
    int c = 0;
    
    
    cin>>a;
    cin>>b;
    
    for ( i = 0;  i < 2; i++ ){
    
        if ( a > b ){
            c = c + a;
            a--;
        }
        else {
            c = c + b;
            b--;
        }
    }

    cout<<c<<endl;


    return 0;
}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (a + b > c + d)cout << "Left" << endl;
	else if (a + b == c + d)cout << "Balanced" << endl;
	else cout << "Right" << endl;
}

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

#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define de cout << "debug" << endl;

int main() {
  ll H,W,N,Sr,Sc;
  cin >> H >> W >> N >> Sr >> Sc;
  string S,T;
  cin >> S >> T;
  
  //累積和的に考える
  ll migi = Sc;
  ll hida = Sc;
  ll ue = Sr;
  ll sita = Sr;
  
  REP(i,N){
    if(S[i] == 'R'){
      migi += 1;
      if(migi > W){
        cout << "NO" << endl;
        return 0;
      }
    }
    else if(S[i] == 'L'){
      hida -= 1;
      if(hida < 1){
        cout << "NO" << endl;
        return 0;
      }
    }
    else if(S[i] == 'U'){
      ue -= 1;
      if(ue < 1){
        cout << "NO" << endl;
        return 0;
      }
    }
    else if(S[i] == 'D'){
      sita += 1;
      if(sita > H){
        cout << "NO" << endl;
        return 0;
      }
    }
    
    if(T[i] == 'L'){
      migi -= 1;
      if(migi < 1){
        migi += 1;
      }
    }
    else if(T[i] == 'R'){
      hida += 1;
      if(hida > W){
        hida -= 1;
      }
    }
    else if(T[i] == 'D'){
      ue += 1;
      if(ue > H){
        ue -= 1;
      }
    }
    else if(T[i] == 'U'){
      sita -= 1;
      if(sita < 1){
        sita += 1;
      }
    }
    
  }
  
  cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> hash(h * w + 1);
    REP(i, h)REP(j, w) {
        int a;
        cin >> a;
        hash[a] = make_pair(i + 1, j + 1);
    }

    int mlt_max = h * w / d;
    ll cost_sum[d][mlt_max + 1];
    FOR(mod, 0, d - 1) cost_sum[mod][0] = 0;
    FOR(a, d + 1, h * w) {
        int mod = a % d;
        int mlt = a / d;
        int b = mod + d * (mlt - 1);
        cost_sum[mod][mlt] = cost_sum[mod][mlt - 1];
        cost_sum[mod][mlt] += abs(hash[a].first - hash[b].first);
        cost_sum[mod][mlt] += abs(hash[a].second - hash[b].second);
    }

    int q;
    cin >> q;
    REP(i, q) {
        int l, r;
        cin >> l >> r;
        cout << cost_sum[l % d][r / d] - cost_sum[l % d][l / d] << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    int n, res=0;
    int v[20];
    int c[20];
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&v[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
    }
    for(int i=0;i<n;i++){
        if(v[i]>c[i]) res+=v[i]-c[i];
    }
    printf("%d\n",res);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	string s;
	cin>>s;
	map<char,ll> mp;
	mp[s[0]]++;mp[s[1]]++;mp[s[2]]++;
	if(mp['A']&&mp['B'])cout<<"Yes"<<Endl;
	else cout<<"No"<<Endl;
	return 0;
}


Measured memory_bytes: 3632
n,k = map(int,input().split())
di = [0]*(10**5)
for i in range(n):
    a,b = map(int,input().split())
    di[a-1] += b
q = 0
p = 0
while True:
    q += di[p]
    if k <= q:
        print(p +1)
        break
    p += 1

Measured memory_bytes: 5744
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

constexpr ll MOD = 998244353;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k, l, r;
    cin >> n >> k;

    vector<Pii> lr;
    for(int i=0;i<k;++i) {
        cin >> l >> r;
        lr.emplace_back(l, r);
    }

    vector<ll> dp(n+1, 0);
    dp[1] = 1LL;
    for(int i=2;i<=n;++i) {
        dp[i-1] += dp[i-2];
        dp[i-1] %= MOD;
        for(int j=0;j<k;++j) {
            if(i - lr[j].first < 1) continue;
            ll diff = (dp[i - lr[j].first] - dp[max(0, i - lr[j].second - 1)] + MOD) % MOD;
            dp[i] += diff;
            dp[i] %= MOD;
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 4784