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

using namespace std;

#define int long long
#define PB push_back
#define MP make_tuple
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 105;
constexpr int MAX_M = 1005;
//constexpr int MAX_H = 1005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

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

    int k, s, ans = 0;
    cin >> k >> s;

    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            if (s < i + j || k < s - i - j) continue;
            ans++;
        }
    }

    cout << ans << endl;
}

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


int main(int argc, char const* argv[])
{
  int n;
  float ans;
  cin >> n;
  if (n%2==0) {
    cout << 0.5 << endl;
  } else {
    float nn = n;
    ans = (nn+1)/2/nn;
    cout << ans << endl;
  }
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt(),L[][]=new int[n+1][n+1];
		
		for(int i=0;i<n;i++) {
			int u=Integer.parseInt(in.next()), k=Integer.parseInt(in.next());
			for(int j=0;j<k;j++) {
				int v=Integer.parseInt(in.next());
				L[u][v]=1;
			}
		}
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=1;i<=n;i++) {
			for(int j=1;j<n;j++) out.print(L[i][j]+" ");
			out.println(L[i][n]);
		}
		out.flush();
	}

}



Measured memory_bytes: 30940
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>

using namespace std;
typedef long long ll;

void solve(int N, int K) {
  int M = N*(N-1)/2 - K;
  printf("%d\n", M);
  for (int i = 0; i < N-1; i++) {
    printf("%d %d\n", 1, i+2);
  }
  int c = M - (N-1);
  for (int i = 1; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      if (c == 0) return;
      c--;
      printf("%d %d\n", i+1, j+1);
    }
  }
}

int main() {
  int N, K;
  cin >> N >> K;
  if (K > N*(N-1)/2 - (N-1)) printf("-1\n");
  else solve(N, K);
}


Measured memory_bytes: 256
k = int(input())

if k == 1:
    print("ACL")
if k == 2:
    print("ACLACL")
if k == 3:
    print("ACLACLACL")
if k == 4:
    print("ACLACLACLACL")
if k == 5:
    print("ACLACLACLACLACL")

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = (a*b) % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = 1;
    fact[1] = 1;
    for(int i=2; i<=num; i++){
        fact[i] = fact[i-1] * i % MOD;
    }
}

void create_seq_inv_mod(int num){
    seq_inv[0] = 1;
    seq_inv[1] = 1;
    for(int i=2; i<=num; i++){
        seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
    }
}

void create_fact_inv_mod(int num){
    fact_inv[0] = 1;
    fact_inv[1] = 1;
    for(int i=2; i<=num; i++){
        fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
    }
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int main(){
    int N, X;
    cin >> N >> X;
    create_mod_tables(6010);

    static int64_t dp[3001][6010], sub[3001][6010];
    dp[0][0] = 1;
    sub[0][0] = 1;
    for(int i=0; i<N; i++) for(int j=0; j<=2*N; j++){
        for(int k=0; k<=2; k++) add(dp[i+1][j+k], dp[i][j]);
        for(int k=1; k<=2; k++) add(sub[i+1][j+k], sub[i][j]);
    }
    int64_t ans = 0;
    for(int j=0; j<X; j++) add(ans, dp[N][j]);

    for(int t=X+1; t<=2*N; t+=2){
        int s = t+1-X;
        if(X%2 == 0 && X <= s) break;
        if(s <= X-1){
            for(int d=0; d<=N; d++){
                int64_t result = 1;
                mul(result, sub[d][X-1-s]);
                int stp = s/2 + d + (t - (X-1))/2;
                if(stp > N) continue;
                mul(result, comb_mod(N, stp));
                add(ans, result);
            }
        }else{
            add(ans, comb_mod(N, t/2));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 282112
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=105;
int n,a[maxn],q[maxn],tax[maxn],tq[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

inline bool cmp(int a,int b){ return a > b; }

inline bool check(){
	go(i,n+1,1) tax[a[i]]++;
	int tl=0,len=a[1]-1;
	q[++tl]=a[1];
	while(len > 0){
		q[tl+1]=q[tl]-1; tl++;
		len-=2;
	}
	go(i,tl,1){
		if(tax[q[i]] < 2) return 0;
		tq[q[i]]+=2;
	}
	if(tax[q[tl]] < (len == 0 ? 2 : 1)) return 0;
	tq[q[tl]]+=(len == 0 ? 2 : 1);
	q[tl]++;
	go(i,n+1,1)
		if(a[i] < q[tl]){
			if(tq[a[i]] == 0) return 0;
			tq[a[i]]--;
		}
	return 1;
}

int main(){
	n=rd();
	go(i,n+1,1) a[i]=rd();
	sort(a+1,a+n+1,cmp);
	if(check()) puts("Possible");
	else puts("Impossible");
	return 0;
}//Faze


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
int euclid(ll a,ll b)
{
	if(a%b==0)
	{
		return b;
	}
	else
	{
		return euclid(b,a%b);
	}

}
//namespace mp = boost::multiprecision;
int main() 
{
	ll A,B,C,D;
	cin>>A>>B>>C>>D;
	ll B_a,B_b,B_c,lcm,gcd;
	gcd=euclid(C,D);
	lcm=C*D/gcd;
	B_a=B/C;
	B_b=B/D;
	B_c=B/lcm;
	ll B_ans=B-B_a-B_b+B_c;
	ll A_a,A_b,A_c,A_ans;
	A_a=(A-1)/C;
	A_b=(A-1)/D;
	A_c=(A-1)/lcm;
	A_ans=A-A_a-A_b+A_c;
	B_ans-=A_ans;
	B_ans++;
	cout<<B_ans<<endl;
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  int h, w; cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];
  map<char, int> mp;
  rep(i, h) rep(j, w) ++mp[a[i][j]];

  int four = 0, two = 0, one = 0;
  for(auto &x : mp) {
    four += x.second/4;
    x.second %= 4;
  }
  for(auto &x : mp) {
    two += x.second / 2;
    x.second %= 2;
  }
  for(auto &x : mp) {
    one += x.second;
  }
  if(four < (h/2)*(w/2)) {
    cout << "No" << endl;
    return 0;
  }

  two += (four-(h/2)*(w/2))*2;

  int d = ((w%2)*h)/2+((h%2)*w)/2;
  if(two != d) {
    cout << "No" << endl;
    return 0;
  }

  if(w%2==1 && h%2==1) {
    if(one != 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  else {
    if(one != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

int main()
{
  int a, b, n;
  while (cin >> a >> b, a || b){
    cin >> n;
    int Map[17][17] = {0}, x, y;
    bool No[16][16] = {false};
    for (int i = 0; i < n; i++){
      cin >> x >> y;
      No[y - 1][x - 1] = true;
    }
    Map[0][0] = 1;
    for (int i = 0; i < a; i++){
      for (int j = 0; j < b; j++){
        if (!No[j][i + 1])  Map[j][i + 1] += Map[j][i];
        if (!No[j + 1][i])  Map[j + 1][i] += Map[j][i];
      }
    }
    cout << Map[b - 1][a - 1] << endl;
  }
}

Measured memory_bytes: 1160
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    a,b,c,d = map(int, input().split())
    while True:
        c -= b
        if c<= 0:
            print("Yes")
            exit()
        a -= d
        if a <= 0:
            print("No")
            exit()

if __name__=="__main__":
    main()


Measured memory_bytes: 65252
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    
    int n;
    cin >> n;
    vector<int> alpha;
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        alpha.push_back(a);
    }
    vector<int> beta;
    for (int i=0;i<=n-1;i++)
    {
        int a;
        cin >> a;
        beta.push_back(a);
    }

    int count=0;
    vector<int> first=min(alpha,beta);
    vector<int> second=max(alpha,beta);
    while (first!=second)
    {
        next_permutation(first.begin(),first.end());
        count++;
    }
    
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	ld a, b, c, d;
	while (cin >> a >> b >> c >> d, a)
	{
		int ans = 0;
		while (c * b > a)
		{
			ans++;
			a += d;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
#include <stdio.h>

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

    int rate = 0;
    for(int i = 0; n > 0; i++){
        n -= 111;
        rate++;
        //printf("current n = %d, rate = %d\n", n, rate);
    }

    printf("%d\n", 111 * rate);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n,k;
  cin >>n >>k;
  
  int x=1;
  
  for(int i; i<n; i++){
    if(x>k){
      x +=k;
    }
    else{
      x *=2;
    }
  }
  cout <<x <<endl;
}


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

int n;
double x[100],y[100];

inline double square(double a){
	return a*a;
}
bool in(double a,double b,int i){
	return square(a-x[i])+square(b-y[i])<=1.0;
}
int main(){
	char ch;
	while(cin>>n&&n){
		int ans=0,s;
		for(int i=0;i<n;i++)cin>>x[i]>>ch>>y[i];
		for(int i=0;i<n;i++){
			for(int j=0;j<1000;j++){
				double a=x[i]+cos(2*M_PI*j/1000);
				double b=y[i]+sin(2*M_PI*j/1000);
				s=0;			
				for(int k=0;k<n;k++)if(in(a,b,k))s++;
				ans = max(ans,s);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define int long long int
// #include"Template.cpp"



void solve() {
    int n, k; cin >> n >> k;
    vector<int> arr(n, 0);
    for(int i = 0; i < n; i ++) cin >> arr[i];
    int l = 1, r = 1e10;
    // int ans = *max_element(arr.begin(), arr.end());
    int ans = 1e10;
    auto check = [&](int len) {
        int req = 0;
        for(int i = 0; i < n; i ++) {
            if(arr[i] == len) {
                continue;
            }
            req += (arr[i]/len);
        }
        return req;
    };
    while(l <= r) {
        int mid = l + (r - l)/2;
        int req = check(mid);
        if(req <= k) {
            ans = min(ans, mid);
            r = mid - 1;
        }
        else {
            l = mid + 1;
        }
    }
    cout << ans << endl;
}


int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,0,n) cin>>h[i];
    vector<int> dp(n);
    dp[1] = abs(h[1]-h[0]);
    rep(i,2,n) dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    cout<<dp[n-1]<<"\n";
}


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

// THINGS TO REMEMBER
// ENDL is slow, '\n' is fast
// Clear everything (including graphs) between test cases
// use anti-anti-hash: https://codeforces.com/blog/entry/62393
// pb-ds: https://codeforces.com/blog/entry/11080
// check when to use LLONG_MAX/LLONG_MIN vs INT_MAX or INT_MIN
// You frequently suffer from confirmation bias - you trust your initial solution and miss simple things. 
// When you hit a roadblock, remember to rethink the solution ground up, not just try hacky fixes

int main(){
	
	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
    	freopen("error", "w", stderr);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,k;
    cin>>n>>k;

    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }

    ll ans=0;
    sort(arr,arr+n);

    for(int i=0;i<k;i++){
    	ans+=arr[i];
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3664
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQUE(c)   sort(ALL((c)));(c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

LL n, c, x[101010], v[101010], s1[101010], ans =- HLINF;

LL solve() {
	REP(i, n + 1)s1[i] = -HLINF;
	LL g = 0, ret = 0;
	for (int i = 1; i <= n; i++) {
		g += v[i];
		s1[i] = max(s1[i - 1], g - x[i]);
	}
	ret = max(ret,s1[n]);
	LL z = 0;
	for (int i = n; i >= 1; i--) {
		z += v[i];
		ret = max(ret, s1[i - 1] + (z - (c - x[i]) * 2));
	}
	return ret;
}

int main() {
	cin >> n >> c;
	for (int i = 1; i <= n; i++)cin >> x[i] >> v[i];
	REP(i, 2) {
		ans = max(ans, solve());
		for (int j = 1; j <= n; j++) x[j] = c - x[j];
		reverse(x + 1, x + n + 1);
		reverse(v + 1, v + n + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
def popcount(n):
    c = (n & 0x5555555555555555) + ((n>>1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c>>2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c>>4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c>>8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c>>16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c>>32) & 0x00000000ffffffff)
    return c

n = int(input())
x = input()
mod = x.count("1")
U = 2**20
C = [0]*U
for i in range(1, U):
  q = popcount(i)
  C[i] = C[i%q] + 1
t_1 = 0
t_2 = 0
for j, s in enumerate(x):
  if s == "1":
    if mod > 1:
      t_1 += pow(2, n-1-j, mod-1)
      t_1 %= mod-1
    t_2 += pow(2, n-1-j, mod+1)
    t_2 %= mod+1
for i in range(n):
  if x[i] == "1":
    if mod == 1:
      print(0)
      continue
    temp = t_1
    temp -= pow(2, n-1-i, mod-1)
    temp %= mod-1
  else:
    temp = t_2
    temp += pow(2, n-1-i, mod+1)
    temp %= mod+1
  res = C[temp] + 1
  print(res)

Measured memory_bytes: 82312
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string A, B, C;
    std::cin >> A >> B >> C;

    if ((A.back() == B.front()) && (B.back() == C.front())) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO"  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	while (true) {
		int a, b, c;
		cin >> a >> b >> c;
		if (a == 0) return 0;
		vector<int> geko;
		REP(i, a) {
			int tmp;
			cin >> tmp;
			geko.push_back(tmp);
		}
		int ans = -1;
		int now_a = 0;
		for (int i = b; i <= c&&i < geko.size(); ++i) {
			if (ans <= geko[i-1] - geko[i ]) {
				ans = geko[i-1] - geko[i ];
				now_a = i;
			}
		}
		cout << now_a << endl;
	}
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,x,y,c=0;
  cin>>x>>y;
  int w[10][10];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>a;
      w[i][j]=a;
    }
  }
  for(int k=0;k<10;k++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++){
        if(w[i][j]>w[i][k]+w[k][j]){
          w[i][j]=w[i][k]+w[k][j];
        }
      }
    }
  }
  for(int i=0;i<x;i++){
    for(int j=0;j<y;j++){
      cin>>a;
      if(a!=-1) c+=w[a][1];
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int r;

	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	} else if (r < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 

vector<int> s[11];
int swi[11];
vector<int> p;
int ans;
void init(){
    rep(i,11)swi[i]=0;
}
signed main(){

    int n,m;
    cin>>n>>m;
    rep(i,m){
        int k;
        cin>>k;
        rep(j,k){
            int x;
            cin>>x;
            x--;
            s[i].push_back(x);
        }
    }
    rep(i,m){
        int x;cin>>x;
        p.push_back(x);
    }

    //cerr<<"fin input"<<endl;

    //2^10

    for(int i=0;i<(1<<n);i++){
        bool flag=true;

        init();
        for(int j=0;j<=n;j++){
            if((i>>j)&1){
                swi[j]=1;
            }
        }

        //それぞれの電球について
        rep(j,m){
            int cnt=0;
            for(int k=0;k<s[j].size();k++){
                if(swi[s[j][k]])cnt++;
            }
            //dump(cnt);
            if(cnt%2!=p[j])flag=false;
            
        }


        if(flag)ans++;
    }

    cout<<ans<<endl;

 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)
ll mod=1e9+7;

//cf dont use unordered map. use simply map<... , ... > m;

//They are Iterator minus v.begin() krna //lower_bound(v.begin(),v.end(),x)-v.begin()  //upper_bound(v.begin(),v.end(),x)-v.begin()
// lower bound tells greater than or equal to // upper bound tells strictly greater than
//int a[1001][1001] //aise global me hi// ll lcm(ll a, ll b){ return a / __gcd(a, b) * b; }
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string //memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find() //for(auto it=set.begin();....) cout<<*it;   // sort(v.begin(),v.end(),compare)

void solve()
{
    long long int a;cin>>a;
//n

long long int p=100,i=0;

while(p<a)
{
	if(p<=a) i++;
	p=(long long int)p*1.01;

}
cout<<i;
}

int main()
{
cout << fixed << setprecision(14);
ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
    //cin>>t;
    while(t--)
    {
     solve();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>

using namespace std;

int main(){

    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < S.length(); i++){
        int a = S[i] - '0';
        ans += a;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
H=[int(i) for i in input().split()]
res=[1 for i in range(n)]

for inp in range(m):
    a,b=map(int,input().split())
    if H[a-1]>H[b-1]:
        res[b-1]*=0
    elif H[a-1]<H[b-1]:
        res[a-1]*=0
    else:
        res[a-1]*=0
        res[b-1]*=0

print(sum(res))

Measured memory_bytes: 20052
N=int(input())
P = list(map(int,input().split()))

#print(N)
#print(P)

SUCCESS = N
pre_max = P[0]
pre_min = P[0]
for i in range(N):
    j = i - 1

    if pre_min < P[i]:
        SUCCESS -= 1
        continue
    else:
        pre_min = P[i]
print(SUCCESS)

Measured memory_bytes: 24744
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int rlsub = 0;
	int lnum = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '('){
			rlsub++;
		} else if (rlsub > 0){
			rlsub--;
		} else {
			lnum++;
		}
	}
	int rnum = rlsub;
	string ans = "";
	for(int i = 0; i < lnum; i++){
		ans += "(";
	}
	ans += s;
	for(int i = 0; i < rnum; i++){
		ans += ")";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   
    long long int n1,m1,t;
   // cin>>t;
   t=1;
    while(t--)
    {
   long long int i,j;
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=1,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int c=0,n,m,l=0,r=0,k,min1=10000000000000,max2=-100;
 cin>>n;
cout<<(n+n*n+n*n*n);

    }
 return 0;
}


Measured memory_bytes: 3576
#include <stdio.h>

int main(void) {
  char s[4];
  scanf("%s", s);
  int ans = 0;
  int i;
  for (i = 0; i < 4; i++) {
    if (s[i] == '+') ans++;
    if (s[i] == '-') ans--;
  }
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;

int n, k, a[10];

bool check(int x) {
    while (x) {
        int t = x % 10;
        if (a[t]) {
            return false;
        }
        x /= 10;
    }
    return true;
}

int main() {
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        a[x] = 1;
    }
    for (int i = n; i <= 10 * n + 1; i++) {
        if (check(i)) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    ll n, m;
    cin >> n >> m;
    
    ll cost_before[4096] = {0}, cost_after[4096] = {0};
    brep(i, 1, 4096){
        cost_before[i] = (ll)1e6;
        cost_after[i] = (ll)1e6;
    }
    
    ll a, b;
    rep(i, m){
        cin >> a >> b;
        
        ll c;
        ll box = 0;
        rep(j, b){
            cin >> c;
            box += (ll)pow(2, c - 1);
        }
        
        rep(j, pow(2, n)){
            cost_after[j | box] = (cost_after[j | box] < cost_before[j] + a) ? cost_after[j | box] : cost_before[j] + a;
        }
        
        brep(j, 1, pow(2, n)){
            cost_before[j] = cost_after[j];
        }
    }
    
    cout << (cost_after[(ll)pow(2, n) - 1] != (ll)1e6 ? cost_after[(ll)pow(2, n) - 1] : -1) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int a, b,c,d;
 
  scanf("%d %d %d" , &a,&b, &c);
  
 if(a > b) {
    d = a;
      a = b;
      b = d;
  } if(b > c) {
    d = c;
    c = b;
    b = d;
 
  } if(a > b) {
    d = a;
    a = b;
    b = d;
  }
  printf("%d %d %d\n",a ,b ,c);
 
 
 
  return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, x, cnt = 1, d = 0;
  cin >> n >> x;
  vector<ll> l(n);
  REP(i, n) { cin >> l[i]; }
  REP(i, n) {
    d = d + l[i];
    if (d <= x) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int pow(int x, int y) {
    if(y==0) return 1;
    else return x*pow(x,y-1);
}

int min(int a, int b) {
    return (a<b)? a: b;
}

int main(int argc, char const *argv[])
{
    int n, a, b, c; cin >> n >> a >> b >> c;
    vector<int> l(n,0);
    for(int i=0;i<n;++i) cin >> l[i];

    const int PAT_MAX = pow(4,n);

    int min_cost = 3000;

    for(int i=0;i<PAT_MAX;++i) {
        int ax=0, bx=0, cx=0, cost=0;
        for(int j=0;j<n;++j) {
            int u = (i>>(2*j)) & 3;
            switch(u) {
                case 0:
                break;
                case 1:
                if(ax>0) cost+=10;
                ax += l[j];
                break;
                case 2:
                if(bx>0) cost+=10;
                bx += l[j];
                break;
                case 3:
                if(cx>0) cost+=10;
                cx += l[j];
                break;
            }
        }
        if(ax==0 || bx==0 || cx==0) continue;
        cost += abs(ax-a) + abs(bx-b) + abs(cx-c);
        //cout << i << " " << cost << " " << min_cost <<  endl;
        min_cost = min(min_cost,cost);
    }
    cout << min_cost << endl;

    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n;
		int north, south, west, east, top, under, swap;
		String order;
		int sum = 1;
		
		top   = 1;
		south = 2;
		east  = 3;
		west  = 4;
		north = 5;
		under = 6;
		
		n = scanner.nextInt();
		while (n != 0) {
			sum = 1;
			top   = 1;
			south = 2;
			east  = 3;
			west  = 4;
			north = 5;
			under = 6;
			for (int i = 0; i < n; i++) {
				order = scanner.next();
				if (order.equals("North")) {
					swap = north;
					north = top;
					top = south;
					south = under;
					under = swap;
					sum += top;
				} else if (order.equals("South")) {
					swap = north;
					north = under;
					under = south;
					south = top;
					top = swap;
					sum += top;
				} else if (order.equals("West")) {
					swap = top;
					top = east;
					east = under;
					under = west;
					west = swap;
					sum += top;
				} else if (order.equals("East")) {
					swap = top;
					top = west;
					west = under;
					under = east;
					east = swap;
					sum += top;
				} else if (order.equals("Right")) {
					swap = north;
					north = west;
					west = south;
					south = east;
					east = swap;
					sum += top;
				} else if (order.equals("Left")) {
					swap = north;
					north = east;
					east = south;
					south = west;
					west = swap;
					sum += top;
				}
			}
			System.out.println(sum);
			n = scanner.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int ans = x;
    int a;
    rep(i,n){
        cin >> a;
        x+=1+(d-1)/a;
    }
    cout << x << endl; 
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007;

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 n, q;
VVI ev;
VI pv;
VI ansv;
VI usedv;

void dfs(int v, int point) {
    if (usedv[v] == 1) {
        return;
    }
    usedv[v] = 1;
    point += pv[v];
    ansv[v] = point;
    REP(i, ev[v].size()) {
        dfs(ev[v][i], point);
    }
}
void Main(){
    cin >> n >> q;
    REP(i, n) {
        pv.push_back(0);
        ansv.push_back(0);
        usedv.push_back(0);
    }
    ev.resize(n);
    REP(i, n-1) {
        int a, b;
        cin >> a >> b;
        ev[a-1].push_back(b-1);
        ev[b-1].push_back(a-1);
    }
    REP(i, q) {
        int p, x;
        cin >> p >> x;
        pv[p-1] += x;
    }
    dfs(0, 0);
    REP(i, n) {
        cout << ansv[i] << endl;
    }
}   

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



Measured memory_bytes: 25792
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
# from bisect import *
# from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
MOD = 10**9+7

n = int(input())
a = [int(x) for x in input().split()]
if 1 not in a:
    print(-1)
    exit()
i, k = 0, 1
cnt = 0
while i < n:
    while i < n:
        if a[i] == k:
            cnt += 1
            i += 1
            k += 1
            break
        i += 1
print(n-cnt)


Measured memory_bytes: 76364
n = int(input())
kij=100
for i in range(1,n):
  aa = len(str(i))
  bb = len(str(n-i))
  asum=0
  bsum=0
  t=i
  s=n-i
  while(t>0):
    asum += t%10
    t = (t-t%10)/10
  while(s>0):
    bsum += (s)%10
    s = (s-s%10)/10
  if asum+bsum<kij:
    kij=asum+bsum
print(int(kij))

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 510

struct Info {
    int from_y, from_x, to_y, to_x;
};

int H, W;
vector<int> Odds[MAX_N];  // 各行にある奇数の位置
vector<Info> ans;

// i 行目の l の位置のコインを r まで移動させる
void make_ans(int i, int l, int r) {
    i++; l++; r++;
    for(int j = l; j < r; ++j) {
        ans.push_back({i, j, i, j+1});
    }
}

signed main()
{
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) {
            int a;
            cin >> a;
            if(a % 2 != 0) { Odds[i].push_back(j); }
        }
        SORT(Odds[i]);
    }

    REP(i, H) {
        // 偶数ペアにする
        for(int j = 0; j < Odds[i].size(); j += 2) {
            if(j+1 < Odds[i].size()) { make_ans(i, Odds[i][j], Odds[i][j+1]); }
        }
        if(Odds[i].size() % 2 != 0 && i != H-1) {
            // 余りは右端から下におろす
            int remain = Odds[i][Odds[i].size()-1];
            make_ans(i, remain, W-1);
            ans.push_back({i+1, W, i+2, W});
            Odds[i+1].push_back(W-1);
            // 既に W-1 の位置にある場合は、両方消す
            if(Odds[i+1][Odds[i+1].size()-2] == W-1) {
                Odds[i+1].pop_back();
                Odds[i+1].pop_back();
            }
        }
    }

    printf("%zu\n", ans.size());
    for(auto& a : ans) {
        printf("%lld %lld %lld %lld\n", a.from_y, a.from_x, a.to_y, a.to_x);
    }

    return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

ll XOR(ll a){
    if(a % 4 == 1)return 1;
    else if(a % 4 == 3)return 0;
    else if(a == 0)return 0;
    else return (XOR(a-1)^a);
}
signed main()
{   
    gearup;
    int n,k;cin>>n>>k;k--;
    vl a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    ll res = L_INF;
    for(int i=0;i+k<n;i++){
        res = min(res,a[i+k]-a[i]);
    }
    cout << res << endl;
}


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

#define AS(arr)  (sizeof(arr)/sizeof(arr[0]))
#define ALL(c) (c).begin(),(c).end() 
#define SIZE(a) int((a).size())
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl

#define pb push_back
#define mp make_pair

typedef vector<int> VI;
typedef vector<string> VS;
typedef long long LL;

const double EPS = 1e-11;
#define EQ(a,b) (abs(a-b)<EPS)
#define EQ0(x) (abs(x)<EPS)

    int x[30];
int main(void){
    
    string s;
    cin >> s;
    for(char c : s)
    {
        x[c - 'a']++;
    }
    REP(i, 27)
    {
        if(x[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=998244353;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=505;
int n;
int p[N*N];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
int dis[N][N];
int check(int x,int y){
	return 1<=x&&x<=n&&1<=y&&y<=n;
}
int alive[N][N];
int vis[N][N],tag=0;
void upd(int x,int y){
	if (vis[x][y]==tag)
		return;
	vis[x][y]=tag;
	For(k,0,3){
		int a=x+dx[k],b=y+dy[k];
		if (check(a,b)){
			if (dis[x][y]+alive[a][b]<dis[a][b]){
				dis[a][b]=dis[x][y]+alive[a][b];
				upd(a,b);
			}
		}
	}
}
int main(){
	n=read();
	For(i,1,n*n)
		p[i]=read();
	For(i,1,n)
		For(j,1,n){
			dis[i][j]=min(min(i,j),min(n-i+1,n-j+1));
			alive[i][j]=1;
		}
	int ans=0;
	For(i,1,n*n){
		int x=(p[i]-1)/n+1;
		int y=(p[i]-1)%n+1;
		dis[x][y]--;
		alive[x][y]=0;
		ans+=dis[x][y];
		tag++;
		upd(x,y);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26796
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: i64);
    puts!("{}\n", a + a * a + a * a * a);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2228
def pass_baton(n_list, current, in_data):
    if in_data % 2 != 0:
        current -= in_data
        while current < 0:
            current += len(n_list)
        return current

    else:
        current += in_data
        while len(n_list) <= current:
            current -= len(n_list)
        return current

N, M, Q  = map(int ,input().split(' '))

m_data = map(int, input().split(' '))
q_data = map(int, input().split(' '))

n_list = [x for x in range(N)]
baton_place  = 0
for m in m_data:
    baton_place = pass_baton(n_list, baton_place, m)
    del n_list[baton_place]

for q in q_data:
    if q in n_list:
        print(1)
    else:
        print(0)

Measured memory_bytes: 29624
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll n, a, b; cin >> n >> a >> b;
	ll x[100001] = {};
	repe(i, 1, n)cin >> x[i];

	ll c = 0;
	rep(i, 1, n) {
		ll A = a * (x[i + 1] - x[i]);
		ll B = b;
		c += ((A > B) ? B : A);
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 1024