akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}

int main(void) {
  int a, b, ans;
  cin >> a >> b;
  ans = max(0, a-2*b);
  pr(ans);
  return 0;
}



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

using ll = long long;
using namespace std;

const int N = 2e9;

void solveCase() {


   string s;
   cin >> s;
   if(s.length() < 25) {
      cout << s;
      for(char c = 'a'; c <= 'z'; c++) {
         if(s.find(c) == string::npos) {
            cout << c;
            break;
         }
      }
      cout << endl;
   } else if(s == "zyxwvutsrqponmlkjihgfedcba") {
      cout << -1 << endl;
   } else {
      string t = s;
      next_permutation(s.begin(), s.end());
      for(int i = 1; i <= 26; i++) {
         if(s.substr(0, i) > t) {
            cout << s.substr(0, i) << endl;
            return;
         }
      }
      // cout << -1 << endl;
   }

}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;


int main()
{
    int a ,b;
    cin >> a >> b;
    if(a >= 13)
        cout << b << endl;
    else if(a >= 6)
        cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main() {
    int n, t, a; cin >> n >> t >> a;
    vector<double> vec(n);
    
    int sindex;
    for (int i=0; i<n; i++) {
        cin >> vec[i];
    }
    double divide = pow(10., 9);
    for (int i=0; i<n; i++) {
        double avetemp = t-vec[i]*0.006;
        if (divide > abs(avetemp - a)) {
            divide = abs(avetemp - a);
            sindex = i;
        }
    }
    
    cout << sindex + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
S=input()
S="E"+S+"W"
E=[0]*(N+2)
W=[0]*(N+2)
for i in range(len(S)-1):
    if S[i]=="W":
        E[i+1]=E[i]+1
    else:
        E[i+1]=E[i]

for i in range(len(S)-1,0,-1):
    if S[i]=="E":
         W[i-1]=W[i]+1
    else:
         W[i-1]=W[i]
ans=10**9
for i in range(N):
    ans=min(ans,E[i+1]+W[i+1])
print(ans)


Measured memory_bytes: 47856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	ll N;
	cin >> N;
	ll a = N;
	ll count = 0, keta = 0;
	while(a/10>0)
	{
		keta++;
		a /= 10;
	}
	if(N%2!=1 && keta!=0)
	{
	    ll i=10;
		while(N/i>0)
		{
			count += N/i;
			i *= 5;
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 3
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define mod 998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll ter; cin>> ter; while(ter--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
 ll fact[1000005];
//ll modIN[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//    modIN[n]=modInverse(fact[n],MOD);
//    for(ll i=n-1;i>=1;i--)
//    {
//        modIN[i] = (modIN[i+1]*(i+1))%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modIN[b]);
//    ret%=MOD;
//    ret*=modIN[a-b];
//    ret%=MOD;
//    return ret;
//}
void solve()
{
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    ll ans =0;
    ll mx =0;
    for(ll i=0;i<n;i++)
    {
        if(mx<=a[i])
            mx=a[i];
        else ans+=mx-a[i];
    }
    cout<<ans<<endl;
}
signed main()
{
   Need_for_speed(activated);
    
//    satisfy
//    {
// solve();
//    }
//
//
    solve();
    
    return 0;
}


Measured memory_bytes: 5212
#include <stdio.h>


int main(void) {
  int a,b,c;
  scanf ("%d", &a);
  b = 3;
  c = a % b;
  if (a < 3) {
    printf("0\n");
    return 0;
  }
  printf("%d\n",(a-c) / b );
    return 0;
}


Measured memory_bytes: 128
T=int(input())
for t in range(T):
	a,b,c,d=map(int,input().split(' '))
	l,x,y,o=(a+b)//(min(a,b)+1),0,0,""
	if a*l<=b:y=a+b
	elif b*l<=a:x=a+b
	else:x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	for i in range(c,d+1):o+="AB"[i%(l+1)==0] if i<=x else "BA"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else "AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(o)

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n, k; std::cin >> n >> k;
    std::vector<int> A(n); for(int i = 0; i < n; ++i) std::cin >> A[i];
    int ng = 0, ok = *std::max_element(A.cbegin(), A.cend());
    while(ok - ng > 1){
        const int mid = (ok + ng) / 2;
        long long int cnt = 0;
        for(int i = 0; i < n; ++i){
            cnt += (A[i] % mid == 0) ? (A[i] / mid - 1) : A[i] / mid;
            if(cnt > k) break;
        }
        if(cnt <= k) ok = mid; else ng = mid;
    }
    std::cout << ok << '\n';
    return 0;
}

Measured memory_bytes: 3976
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    string s;
    ll k;
    cin>>s>>k;
    int co=0;
    char ke;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')co++;
        else {
            ke=s[i];
            break;
        }
    }
    if(k<=co)cout<<1<<endl;
    else cout<<ke<<endl;
    
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000000;

int main() {
    vector<long> A(3);
    for(int i=0;i<3;i++) cin>>A.at(i);
    sort(A.begin(),A.end());
    cout<<A.at(0)-A.at(1)+A.at(2)<<endl;
}

Measured memory_bytes: 256
n,k = [int(x) for x in input().split()]
p = [(int(x)+1)/2.0 for x in input().split()]
m = 0
t = 0

for i in range(k):
    t += p[i]
m = t
for i in range(k,n):
    t =t + p[i] - p[i-k]
    m = max(m,t)

print(m)

Measured memory_bytes: 23148
c = []
for i in range(3):
    c.append([int(s) for s in input().split()])

print("Yes" if c[0][0]-c[0][1] == c[1][0]-c[1][1] == c[2][0]-c[2][1] and c[0][1]-c[0][2] == c[1][1]-c[1][2] == c[2][1]-c[2][2] and c[0][2]-c[0][0] == c[1][2]-c[1][0] == c[2][2]-c[2][0] and c[0][0]-c[1][0] == c[0][1]-c[1][1] == c[0][2]-c[1][2] and c[1][0]-c[2][0] == c[1][1]-c[2][1] == c[1][2]-c[2][2] and c[2][0]-c[0][0] == c[2][1]-c[0][1] == c[2][2]-c[0][2] else "No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int w = sc.nextInt();
	int n = sc.nextInt();
	int[] values = new int[w];
	for(int i=0;i<values.length;i++){
	values[i]=i+1;
	}
	for(int i=0;i<n;i++){
	String str = sc.next();
	String[] ab = str.split(",");
	int a = Integer.parseInt(ab[0])-1;
	int b = Integer.parseInt(ab[1])-1;
		int temp=values[a];
			values[a]=values[b];
			values[b]=temp;	
	}
		for(int i=0;i<w;i++){
		System.out.println(values[i]);
	}
	}
}

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

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

  ll H; cin >> H;
  ll ans = 0;
  ll cnt = 1;
  while (H > 0) {
    ans += cnt;
    H /= 2;
    cnt *= 2;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n , a[N] , dp[N];
int main(){
    cin >> n;
    for(int i = 0 ; i < n ; i++)
		cin >> a[i];
    dp[0] = 0;
    dp[1] = dp[0] + abs(a[0] - a[1]);
    for(int idx = 2 ; idx < n ; idx++){
    	// dp[idx] is equal how i came to this (idx) from min(idx - 1 , idx - 2) + the cost !
        dp[idx] = min(dp[idx - 1] + abs(a[idx] - a[idx - 1]) , dp[idx - 2] + abs(a[idx] - a[idx - 2]));
    }
    cout<<dp[n - 1];
    return 0;
}

Measured memory_bytes: 1024
using System;
using static System.Console;

class Program
{
  static void Main(string[] args)
  {
    string[] str = ReadLine().Split(' ');
    int n = int.Parse(str[0]);
    int m = int.Parse(str[1]);
    
    int result = (n * (n - 1) / 2) + (m * (m - 1) / 2);
    WriteLine(result);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Graph = vector<vector<tuple<int, int, int>>>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
Int dp[55][5050], cut[55];
const Int INF = 1e18;
int main() {
    int N, M, S; cin >> N >> M >> S;
    Graph G(N);
    for (int i = 0; i < M; i++) {
        int u, v, a, b; cin >> u >> v >> a >> b; u--, v--;
        G[u].emplace_back(v, a, b);
        G[v].emplace_back(u, a, b);
    }
    vector<int> C(N), D(N);
    for (int i = 0; i < N; i++) cin >> C[i] >> D[i];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 5000; j++) {
            dp[i][j] = INF;
        }
    }
    MinHeap<tuple<Int, int, int>> Q;
    Q.emplace(0, 0, min(S, 5000));
    while (!Q.empty()) {
        auto [time, node, silver] = Q.top(); Q.pop();
        if (dp[node][silver] != INF) continue;
        dp[node][silver] = time;
        if (cut[node] > silver) continue;
        cut[node] = silver;
        for (auto [next, s, t] : G[node]) {
            if (silver >= s && dp[next][silver - s] == INF) {
                Q.emplace(time + t, next, silver - s);
            }
        }
        if (dp[node][min(silver + C[node], 5000)] == INF) {
            Q.emplace(time + D[node], node, min(silver + C[node], 5000));
        }
    }
    for (int t = 1; t < N; t++) {
        Int ans = INF;
        for (int u = 0; u <= 5000; u++) {
            ans = min(ans, dp[t][u]);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 5684
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


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

    cout << min(a + b, min(b + c, c + a)) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;

int main() {
  io();
  cin >> N;
  
  foris(i, 1, 10) {
    foris(j, i, 10) {
      if(i * j == N) {
        cout << "Yes";
        return 0;
      }
    }
  }
  
  cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n;
map<long long,long long>q;
map<long long,long long>::iterator it;
long long  modl(long long a, long long b, long long c)        //快速幂取余a^b%c
{
    long long res, t;
    res = 1 % c;
    t = a % c;
    while (b)
    {
        if (b & 1)
        {
            res = res * t % c;
        }
        t = t * t % c;
        b >>= 1;
    }
    return res;
}
long long mod=1e9+7;
int main()
{
    q.clear();
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        long long num;
        cin>>num;
        q[num]++;
    }
    if(q[0]>1)
    {
        cout<<"0"<<endl;
    }
    else if(q[0]==1||q[0]==0)
    {
        int num=0;
        for(it=q.begin();it!=q.end();it++)
        {
            if(it->second==2)
            {
                num++;
            }
            else if(it->second>2)
            {
                cout<<"0"<<endl;
                return 0;
            }
        }
        num%=mod;
        cout<<modl(2,num,mod)%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> s >> ss;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

  //if(a > 9 || b > 9) ans = -1;
  //else ans = a*b;

  cout << ss << s << endl;

}

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

using namespace std;

#define MAXSIZE 100010

int main(void) {
  uint A, B, M, a[MAXSIZE], b[MAXSIZE], a_min, b_min;
  a_min = numeric_limits<uint>::max();
  b_min = numeric_limits<uint>::max();
  cin >> A >> B >> M;
  for (size_t i = 0; i < A; i++)
  {
    cin >> a[i];
    if (a[i] < a_min)
    {
      a_min = a[i];
    }
  }
  for (size_t i = 0; i < B; i++)
  {
    cin >> b[i];
    if (b[i] < b_min)
    {
      b_min = b[i];
    }
  }

  uint min = a_min + b_min;

  for (size_t i = 0; i < M; i++)
  {
    uint sum, x, y, c; 
    cin >> x >> y >> c;
    sum = a[x-1] + b[y-1] - c;

    if (sum < min)
    {
      min = sum;
    }
  }

  std::cout << min << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int BTC_RATE = 380000;

int main() {
  float result = 0;

  int N;
  cin >> N;
  rep(i, N) {
    float x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      result += x;
    } else if (u == "BTC") {
      result += x * BTC_RATE;
    } else {
      cout << "error" << endl;
    }
  }

  cout << result << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

int hpb[10] = {1,1,0,2,0,0,1,0,1,0};
string yomi[3] = {"hon", "pon", "bon"};

void solve()
{
  ll n; cin >> n;
  
  cout << yomi[hpb[n%10]] << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3628
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! { (n, k): (u64, u64) };

    let mut sum = 0u64;

    let m = 1000000007;

    for i in k..=n + 1 {
        sum += (n + (n + 1 - i)) * i / 2 - (0 + (i - 1)) * i / 2 + 1;
        sum %= m;
    }

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


Measured memory_bytes: 2164
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ETakAndHotels {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> x(N);
        REP(i, N) cin >> x[i];
        x.push_back(x.back() + 1);
        N = x.size();
        int L, Q;
        cin >> L >> Q;

        vector<vector<int>> next(N, vector<int>(51));
        REP(i, N) {
            int to = x[i] + L;
            auto itr = upper_bound(x.begin(), x.end(), to);
            itr--;
            next[i][0] = itr - x.begin();
        }
        REP(j, 50) {
            REP (i, N) {
                int to = next[i][j];
                next[i][j+1] = next[to][j];
            }
        }

        while (Q--) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            if (a > b) swap(a, b);
            if (a == b) {
                cout << 0 << endl;
                continue;
            }

            int res = 0;
            REV(j, 50, 0) {
                if (next[a][j] < b) {
                    a = next[a][j];
                    res += 1 << j;
                }
            }
            cout << res + 1 << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ETakAndHotels solver;
    solver.solve(in, out);
    return 0;
}


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

const int MAXN = 2005, mod = 1e9+7;

int dp[MAXN][MAXN];
int n, k;

int inv[MAXN*MAXN], fac[MAXN*MAXN], ifac[MAXN*MAXN];

inline int choose(int n, int m)
{
	if (n < m) return 0;
	return (long long)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

int dfs(int i, int j)
{
	if (j == 0 && i == 0) return 1;
	if (i < 0 || j < 0) return 0;
	if (dp[i][j] != -1) return dp[i][j];
	dp[i][j] = (dfs(i-1, j)+(long long)dfs(i+1, j-1)*choose((n-j+1)*k-(i+1)-1, k-2))%mod;
	return dp[i][j];
}

int main()
{
	cin >> n >> k;
	if (k == 1) {
		puts("1");
		return 0;
	}
	memset(dp, -1, sizeof dp);
	inv[1] = 1;
	for (int i = 2; i <= n*k; i++) inv[i] = (mod-(long long)mod/i*inv[mod%i]%mod)%mod;
	fac[0] = 1, ifac[0] = 1;
	for (int i = 1; i <= n*k; i++)
		fac[i] = (long long)fac[i-1]*i%mod, ifac[i] = (long long)ifac[i-1]*inv[i]%mod;
	cout << (long long)dfs(0, n)*fac[n]%mod << endl;
	return 0;
}


Measured memory_bytes: 63232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k,ans=0;
  cin >> h >> w >> k;
  string s[h];
  for(int i=0;i<h;i++)cin >> s[i];
  for(int mask=0;mask<(1<<h);mask++){
    for(int mask2=0;mask2<(1<<w);mask2++){
      int brack=0;
      for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
          if(mask&(1<<i) && mask2&(1<<j) && s[i][j]=='#')brack++;
        }
      }
      if(brack==k)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

struct Edge{
    ll a;
    ll b;
    Edge(ll _a, ll _b){
        a = _a;
        b = _b;
    }
};

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

    // input
    ll N;
    cin >> N;

    vector<Edge> answer;
    if(N%2==1){
        FOR(i, 1, N+1){
            FOR(j, i+1, N+1){
                if(i+j!=N){
                    answer.push_back(Edge(i, j));
                }
            }
        }
    }
    else{
        FOR(i, 1, N+1){
            FOR(j, i+1, N+1){
                if(i+j!=N+1){
                    answer.push_back(Edge(i, j));
                }
            }
        }
    }

    p(answer.size());
    for(auto edge : answer){
        cout << edge.a << " " << edge.b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
// AOJ 2555 Everlasting Zero
// 2018.4.25 bal4u

#include <stdio.h>
#include <string.h>

// バッファを経ずstdinから数値を得る
//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	while (c <= ' ') c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}
 
#define INF 110
char min[101][101], max[101][101];
char to[101][101], hi[101];
int q[101], top, end;
int count[101];

int topological_sort(int n)
{
    int i, j, k, f;

//  for (i = 0; i < n; i++) for (j = 0; j < hi[i]; j++) count[to[i][j]]++;
    top = end = 0, f = 0;
    for (i = 0; i < n; i++) if (!count[i]) q[end++] = i;
    while (top < end) {
		i = q[top++];
        f++;
        for (j = 0; j < hi[i]; j++) {
            k = to[i][j];
            if (--count[k] == 0) q[end++] = k;
        }
    }
	return f == n;
}

int main()
{
	int M, N, K, s, cond, t, i, j, k;

	M = in(), N = in();
	memset(max, INF, sizeof(max));
	for (i = 0; i < M; i++) {
		K = in();
		while (K--) {
			s = in()-1;
			cond = (getchar_unlocked() == '<') ;
			getchar_unlocked(), getchar_unlocked();
			t = in();
			if (cond) {
				if (t < max[i][s]) max[i][s] = t;
			} else {
				if (t > min[i][s]) min[i][s] = t;
			}
			if (min[i][s] > max[i][s]) { puts("No"); return 0; }
		}


	}
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) for (k = 0; k < M; k++) if (j != k) {
			if (min[j][i] > max[k][i]) to[j][hi[j]++] = k, count[k]++;
		}
	}
	puts(topological_sort(M)? "Yes": "No");
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll long long int
using namespace std;


int main()
{
	//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
	ll n,w;
	cin>>n>>w;
	ll in[n][2];
	for(ll i=0;i<n;i++)
		cin>>in[i][0]>>in[i][1];
	ll dp[w+1];
	for(ll i=0;i<=w;i++)
	{
		dp[i]=0;	
	}
	// dp[i] will represent the maximum sum with total number of weights equal to i
	for(ll i=0;i<n;i++)
	{
		ll weight=in[i][0];
		for(ll j=w-weight;j>=0;j--)
		{
			// if(j+weight<=w)
				dp[j+weight]=max(dp[j+weight],dp[j]+in[i][1]);
		}
	}
	ll ans=0;
	for(ll i=0;i<=w;i++)	
	{
		// cout<<dp[i]<<'\n';
		ans=max(ans,dp[i]);
	}
	cout<<ans<<'\n';
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int val = x - 400;
  int tmp = val/200;
  int ans = 8 - tmp;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char s[1000];
    int m,i,t;
    while(~scanf("%s",s))
    {
        t=0;
        m=strlen(s);
        for(i=0;i<m;i++)
        {
            if(s[i]=='+')
            {
                t=t+1;
            }
            else
            {
                t=t-1;
            }
        }
        printf("%d\n",t);
    }
    return 0;
}


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

using namespace std;

#define ll long long

const int N=1e6+5;

int m,n,k,ans,l,r,u,v,x,tc,y,q,sz,d,a[N];


char s[N];

int main(){ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    scanf("%d",&n);
    scanf("%s",s);
    if (n>=3200)
        printf("%s\n",s);
    else
        printf("red\n");
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    double  w,h,x,y;
    cin>>w>>h>>x>>y;
    if(x==(w/2.0000000)&&y==(h/2.0000000)){
    	double ans=(w*h)/2.000000;
    	cout<<ans<<" 1"<<endl;
	}else {
		double ans=(h*w)/2.00000000;
		cout<<ans<<" 0"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

struct edge{
  int from;
  int to;
  int cost;
};

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

  int L;
  cin >> L;

  vector<edge> vec;


  for (int i = 1; i <= 19;++i){
    edge a = {i, i + 1, 0};
    vec.push_back(a);
  }

  int nowL = 1;

  for (int i = 1; i <= 19; ++i)
  {
    if (L > (1 << i) - 1)
    {
      edge a = {i, i + 1, 1 << (i - 1)};
      vec.push_back(a);
      nowL *= 2;
    }
    else
    {
      break;
    }
  }

  for (int i = 19; i >= 1;--i){
    if(nowL+(1<<(i-1))<=L){
      edge a = {i, 20, nowL};
      vec.push_back(a);
      nowL += (1 << (i-1));
    }
  }

  cout << 20 << " " << vec.size() << endl;

  REP(i,vec.size()){
    cout << vec[i].from << " " << vec[i].to << " " << vec[i].cost << endl;
  }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	s := read()
	t := read()

	var b bytes.Buffer
	for i := 0; i < n; i++ {
		b.WriteByte(s[i])
		b.WriteByte(t[i])
	}
	fmt.Println(b.String())
}

var stdin *bufio.Scanner

func read() string {
	if stdin == nil {
		stdin = bufio.NewScanner(os.Stdin)
		stdin.Split(bufio.ScanWords)
		stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	}
	stdin.Scan()
	return stdin.Text()
}

func readInt() int {
	n, _ := strconv.Atoi(read())
	return n
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(read(), 10, 64)
	return n
}

func readFloat64() float64 {
	n, _ := strconv.ParseFloat(read(), 64)
	return n
}


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

#define int long long

const int MOD = 1e9+7;

int pow(int x, int n) {
  int ret = 1;
  while ( n > 0 ) {
    if ( n & 1 ) (ret *= x) %= MOD;
    (x *= x) %= MOD;
    n /= 2;    
  }
  return ret;
}

int inv(int x) {
  return pow(x, MOD-2);  
}

int dp[2010][2010];

signed main() {
  int N, D, X;
  while ( cin >> N >> D >> X, N ) {    
    fill_n(*dp, 2010*2010, 0);
    dp[0][0] = 1;
    for ( int i = 0; i < N; i++ ) {
      int sum = 0;      
      for ( int j = 0; j <= N; j++ ) {	
	if ( j >= X ) sum -= dp[i][j-X];	
	dp[i+1][j] += sum;
	dp[i+1][j] %= MOD;	
	sum += dp[i][j];
	sum %= MOD;
      }
    }
    /* for ( int i = 0; i <= N; i++ ) {
      for ( int j = 0; j <= N; j++ ) {
	cout << dp[i][j] << " ";
      }
      cout << endl;
      } */
    int ans = 0;
    for ( int i = 1; i <= min(D, N); i++ ) {
      int a = 1, b = 1;
      for ( int j = 0; j < i; j++ ) {
	a *= ((D-j)%MOD);	
	a %= MOD;
	b *= (i-j);	
	b %= MOD;	
      }
      int add = a*inv(b)%MOD;      
      add = add*dp[i][N]%MOD;
      ans += add;
      ans %= MOD;
    }

    if ( ans < 0 ) ans += MOD;    
    cout << ans << endl;
  }  
  return 0;
}



Measured memory_bytes: 34564
import java.util.Scanner;

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

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h == 0 && w == 0){
                break;
            }
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(i == 0 || j == 0 || i == h - 1 || j == w - 1){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    } 
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35040
#include<iostream>
#define N 3
#define loop(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[100002][N];
int dp[100002][N+1];
int n;

int min_cost(int n,int c){
    if(n==0) return 0;
    if(dp[n][c]!=-1) return dp[n][c]; 
    int ans=0;
    for(int i=0;i<=2;i++)
        if(c==3) 
             ans=max(ans,a[n-1][i]+min_cost(n-1,i));
        else if(c!=i) 
             ans=max(ans,a[n-1][i]+min_cost(n-1,i));
    return dp[n][c]=ans;
}

int main()
{
    cin>>n;
    loop(i,n) loop(j,N) 
    cin>>a[i][j];
    loop(i,n+1) loop(j,N+1)
    dp[i][j]=-1;
    cout<<min_cost(n,3)<<endl;
    return 0;
}




Measured memory_bytes: 14092
#include<iostream>
#include<vector>

using namespace std;

int main(){
int N,D,X ; cin >> N >> D >> X;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
   cin >> A[i];}
  
  int sum = 0;
  
  for(int i = 0; i < N; i++){
    int k = 1;
    while( k <= D){ sum ++;k += A[i];}}
  
  cout << sum + X << endl;
  
  return 0;}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "bust" << '\n'; exit(0); }
inline void no() { cout << "win" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) yes(); no();
}


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

AC = set()
cnt = {i: 0 for i in range(1, N + 1)}
for _ in range(M):
    p, S = input().split()
    p = int(p)
    if (S == "AC"):
        AC.add(p)
    elif (S == "WA" and p not in AC):
        cnt[p] += 1

WA = sum([v for k, v in cnt.items() if k in AC])
print(len(AC), WA)


Measured memory_bytes: 63076
A,B,M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [list(map(int,input().split())) for _ in range(M)]

ans = min(a) + min(b)

for i in range(M):
	ans = min(ans, a[c[i][0]-1]+b[c[i][1]-1]-c[i][2])

print(ans)

Measured memory_bytes: 80452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

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

	cout << n*n*n << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int a[3][3], n;
    bool isselected[3][3] = {false};
    bool isbingo = false;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            cin >> a[i][j];
        }
    }
    cin >> n;
    for (int k=0; k<n; k++) {
        int b;
        cin >> b;
        for (int i=0; i<3; i++) {
            for (int j=0; j<3; j++) {
               if (a[i][j] == b) {
                   isselected[i][j] = true;
               }
            }
        }
    }
    for (int i=0; i<3; i++) {
        if (isselected[i][0] && isselected[i][1] && isselected[i][2]) {
            isbingo = true;
        }
    }
    for (int j=0; j<3; j++) {
        if (isselected[0][j] && isselected[1][j] && isselected[2][j]) {
            isbingo = true;
        }
    }
    if (isselected[1][1]) {
        if ((isselected[0][0] && isselected[2][2]) || (isselected[2][0] && isselected[0][2])) {
            isbingo = true;
        }
    }
    if (isbingo) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
mod = 10**9+7
X, Y = map(int, input().split())
if (X+Y) % 3 != 0:
	print(0)
	sys.exit()

tot = (X+Y) // 3

x = X - tot
y = tot - x

if x < 0:
	print(0)
	sys.exit()

if x == 0 or y == 0:
	print(1)
	sys.exit()

ans = 1
for i in range(y+1, tot+1):
	ans *= i
	ans %= mod

for i in range(1,x+1):
	ans *= pow(i, mod-2, mod)
	ans %= mod

print(ans%mod)

Measured memory_bytes: 39024
import java.io.IOException;
	import java.util.ArrayList;
	import java.util.HashMap;
	import java.util.Scanner;
	import java.util.Stack;
	
	public class Main {
		public static class pair implements Comparable<pair> {
			int id;
			int ans;
	
			pair(int x, int y) {
	
				id = x;
				ans = y;
	
			}
	
			public pair() {
	
			}
	
			public int compareTo(pair o) {
				// TODO Auto-generated method stub
	
				return this.id - o.id;
			}
		}
	
	//	static int mod = (int) 998244353.;
		static int mod = (int) 1e9 + 7;
		static ArrayList<Integer> gr[];
		static int[] ar;
		static Scanner sc = new Scanner(System.in);
		static int pri[] = new int[(int) 1e6 + 5];
		static StringBuilder out = new StringBuilder();
	
		// static long dp[];
	
		public static void main(String[] args) throws IOException {
			int t = 1;// sc.nextInt();
	
			while (t-- > 0) {
				int n = sc.nextInt();
				long k = sc.nextLong();
	
				ar = new int[n + 1];
				HashMap<Integer, Integer> hm = new HashMap<>();
				for (int i = 1; i <= n; i++) {
					ar[i] =sc.nextInt();
				}
				int j = 1;
				int cnt = 1;
				long val = 0;
				while (true) {
					if (k == 0)
						break;
					if (hm.containsKey(j)) {
						val =cnt- hm.get(j);
						break;
					}
					hm.put(j, cnt);
					j = ar[j];
					k--;
					cnt++;
				}
				if(k!=0)
				k = k % val;
				while (k > 0L) {
					j = ar[j];
					k--;
	
				}
				out.append(j);
			}
	
			System.out.println(out);
		}
	}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    string s,t ;
    cin >> s >> t;
    cout << t << s;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const ull B = 1777771;
ull S[100010],PB[100010]={1};
int n;
string str;


ull get(int l,int r){return S[r]-S[l]*PB[r-l];}
ull get(int l,int r,int x,char ch){
  ull res=get(l,r);
  if(x<l||r<=x) return res;
  return res+ch*PB[r-x-1]-str[x]*PB[r-x-1];
}

int search(int a,int b,int x,int ch){
  int L=0,M,R=1e5+1;
  while(L<R){
    M = (L+R)/2;
    if(max(a,b)+M>n||get(a,a+M,x,ch)!=get(b,b+M,x,ch)) R = M;
    else L = M+1;
  }
  return L-1;
}


bool check(int l,int r,int t){
  int x =l+t+search(l,l+t,-1,0);
  char ch=str[l+(x-l-t)%t];
  int a=get(l,r-t,l+(x-l-t)%t,str[x])==get(l+t,r,l+(x-l-t)%t,str[x]);
  return a||get(l,r-t,x,ch)==get(l+t,r,x,ch);
}

int main(){
  cin>>str;
  n = str.size();
  for(int i=0;i<n;i++) S[i+1]=S[i]*B+str[i];
  for(int i=1;i<n;i++) PB[i]=PB[i-1]*B;
  
  int q;
  cin>>q;
  while(q--){
    int l,r,t;
    cin>>l>>r>>t;
    cout<<(check(l-1,r,t)? "Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 4872
//#define _GLIBCXX_DEBUG //(compiler options)
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define sz(x) ((int)(x).size())
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
using namespace std;
using ll = long long; using ull = unsigned ll; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> T mind(T &x, const T &y) {if (y < x) {T d = y-x; x = y; return d;} else return 0;} //RETURNS A NON-POSITIVE VALUE
template<typename T> T maxd(T &x, const T &y) {if (y > x) {T d = y-x; x = y; return d;} else return 0;}
template<typename C> int uniq(C &a) {a.erase(unique(all(a)), end(a)); return sz(a);}
template<typename C, typename F> int uniq(C &a, F cmp) {a.erase(unique(all(a), cmp), end(a)); return sz(a);}
const int mod = 1e9+7, infi = 1e9; const ll infl = 1e18; const ld infd = INFINITY;

#define x(a) real(a)
#define y(a) imag(a)
using G = ll; using point = complex<G>;
istream& operator>>(istream &is, point &p){G x, y; is >> x >> y; p = {x, y}; return is;}
ostream& operator<<(ostream &os, const point &p){os << p.x() << ' ' << p.y(); return os;}
G dot(const point &a, const point &b) {return (conj(a)*b).x();}
G crs(const point &a, const point &b) {return (conj(a)*b).y();}
G ori(const point &a, const point &b, const point &c) {return crs(b-a, c-b);};
bool cmpyx(const point &a, const point &b) {return a.y()<b.y() || (a.y()==b.y()&&a.x()<b.x());};

int main()
{
    #ifndef LOCAL
    //ifstream cin("hull.in"); ofstream cout("hull.out");
    #endif // LOCAL
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout << setprecision(15);
    char s[5]; cin >> s;
    cout << (s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3] ? "Yes" : "No");
}



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

int  main()
{
	string s;
	cin >> s;
	int nb = 0;
	int i = 0;
	while (s[i])
	{
		nb += s[i] - '0';
		i++;
	}
	if (nb % 9 == 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return (0);
}


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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int MOD = 1000000007;
const int INF = 1000000000;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const int MAX = 100001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

    COMinit();
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    llong n, k;
    cin >> n >> k;
    vector<llong> A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    if (k == 1) {
        cout << 0 << endl;
        return 0;
    }

    vector<llong> sumf(n + 1, 0), sume(n + 1, 0);
    rep(i, n) {
        sumf[i + 1] += sumf[i] + (A[i] + MOD);
        sumf[i + 1] %= MOD;
    }
    reverse(all(A));
    rep(i, n) {
        sume[i + 1] += sume[i] + (A[i] + MOD);
        sume[i + 1] %= MOD;
    }

    int l = n - 2, r = k - 2, i = 0;
    llong ans = 0;
    while (l >= r) {
        ++i;
        ans += COM(l, r) * (sume[i] - sumf[i] + MOD);
        ans %= MOD;
        --l;
    }

    cout << ans << endl;

    return 0;
}

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

const long long dx[8] = {-1, 1, -1, -1, -1, 1, 1, 1};
const long long dy[8] = {-1, -1, 1, -1, 1, -1, 1, 1};
const long long dz[8] = {-1, -1, -1, 1, 1, 1, -1, 1};

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

    int n, m;
    cin >> n >> m;
    vector<long long> X(n), Y(n), Z(n);
    for(int i = 0; i < n; i++){
        cin >> X[i] >> Y[i] >> Z[i];
    }

    long long ans = 0;
    for(int i = 0; i < 8; i++){
        vector<long long> A(n);
        for(int j = 0; j < n; j++){
            A[j] = X[j] * dx[i] + Y[j] * dy[i] + Z[j] * dz[i]; 
        }
        sort(A.begin(), A.end(), greater<long long>());
        
        long long t = 0;
        for(int j = 0; j < m; j++){
            t += A[j];
        }

        ans = max(ans, t);
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256