akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e5;
int n, m, a, d;
ll l;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n){
    cin >> a;
    if(!d){
      d = __builtin_ctz(a);
      l = a/2;
    }
    if(d != __builtin_ctz(a)){
      cout << 0 << endl;
      return 0;
    }
    a >>= d;
    l *= a/__gcd(l, (ll)a);
    if(l > m) break;
  }
  cout << (m/l+1)/2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int ans = 1001001001;
        for(int i =0;i<s.length()-2;i++){
            int tmp = Integer.parseInt(s.substring(i, i+3));
            ans = Math.min(ans,Math.abs(753-tmp));
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21840
n, m = gets.split.map(&:to_i)
abs = []
n.times do |_ni|
  abs << gets.split.map(&:to_i)
end

abs.sort_by! { |a| a[0] }
total_price = 0
count = 0
abs.each do |ab|
  if count + ab[-1] < m
    total_price += ab[0] * ab[-1]
    count += ab[-1]
  else
    total_price += ab[0] * (m - count)
    break
  end
end
puts total_price

Measured memory_bytes: 12664
import itertools

N, M, X = (int(v) for v in input().split())
c = [0]*N
a = [0]*N

for i in range(N):
    items = [int(v) for v in input().split()]
    c[i] = items[0]
    a[i] = items[1:]

coin = list(itertools.product([0,1], repeat=N))
ans_cost = -1

for i in range(len(coin)):
    score = [0] * M
    for j in range(N):
        if coin[i][j] == 1:
            for k in range(M):
                score[k] += a[j][k]
    if min(score) >= X:
        cost = 0
        for l in range(N):
            cost += coin[i][l] * c[l]
        if (ans_cost == -1) | (cost < ans_cost):
            ans_cost = cost

print(ans_cost)






Measured memory_bytes: 9504
using System;
using System.Linq;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = input[0];
            var M = input[1];
            var C = input[2];

            var B = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var A = new int[N][];
            for (int i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            }

            var result = 0;
            for (int i = 0; i < N; i++)
            {
                var temp = A[i].Zip(B, (a, b) => a * b).Sum();
                result = temp + C > 0 ? ++result : result;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13524
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int a,b;
    scanf("%d%d", &a, &b);
    printf("%d\n", MAX(MAX(a+b,a-b),a*b));





    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}

int sqs(llint a[],llint n,llint s){
    if(s==4){qsort(a,n,sizeof(llint),compare);}
    return 0;
}
// llint pgauss(ldouble a){llint b=a;return a==b?b:pgauss(b+1);}

int main(void){
    // ldouble t;
    llint n,p[5],i,t;
    scanf("%lld",&n);
    for(i=0;i<5;i++){
        scanf("%lld",&p[i]);
        if(p[i]<p[0])p[0]=p[i];
    }
    t= n%p[0]==0 ?  n/p[0]:n/p[0]+1;
    printf("%lld\n",t+4);
    return 0;
}


Measured memory_bytes: 128
#include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <fstream>

using namespace std;


#define int ll
const bool online_judge =
#ifdef ONLINE_JUDGE
  true
#else
  false
#endif
  ;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#define all(v)  (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define eb emplace_back
#define SZ(a) ((int)((a).size()))
#define rep(i,n) for(int i = 0; i < n; i++)
#define tag(i,v) rep(i,SZ(v))
#define _trace(x) #x << " = " << (x)
#define trace(x)  { if(!online_judge) cerr << _trace(x) << endl; }
#define trace2(x,y) { if(!online_judge) cerr << _trace(x) << " " << _trace(y) << endl; }
#define trace3(x,y,z) { if(!online_judge) cerr << _trace(x) << " " << _trace(y) << " " << _trace(z) << endl; }
#define tracev(x) { if(!online_judge) { cerr << #x << " = "; tag(__i, x) { cerr << x[__i] << ","; } cerr << endl; } }
#define fst get<0>
#define snd get<1>
#define thd get<2>
#define divup(x,y) (x/y+x%y)

const int inf = 1LL << 60;
int toInt(string s) {int res; stringstream ss; ss<<s; ss>>res; return res; }
string toString(int n) { stringstream ss; ss<<n; return ss.str(); }

void run() {

  /* entry point */
  int t, n, k;
  vi v;

  cin >> t;

  rep(_,t){
    cin >> n >> k;

    v.clear();

    rep(i,n){
      int tmp;
      cin >> tmp;
      v.pb(tmp);
    }

    int w = v[v.size()-1] - v[0];
    vi x;
    rep(i,n-1){
      x.pb(v[i+1] - v[i]);
    }
    sort(rall(x));

    rep(i, min(k-1, (int)x.size()))
      w -= x[i];

    cout << w << endl;

  }


}

#undef int

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

  #if 0
  if(online_judge){
    ifstream ifile("input.txt");
    if(ifile) freopen("input.txt", "rt", stdin);
    if(ifile) freopen("output.txt", "wt", stdout);
  }
  #endif

  run();

  return 0;

}

Measured memory_bytes: 2604
#include <bits/stdc++.h>
#define double long double
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans;int a[114];double cnt,inf=1e9;
signed main() {
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cnt+=a[i];
	cnt=cnt/n;
	rep(i,n){
		if(abs(a[i]-cnt)<inf){
			inf=abs(a[i]-cnt);
			ans=i;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]

d = []
for i in range(3):
  d.append([])
  for j, k in zip([0, 1, 2], [1, 2, 0]):
    d[i].append(c[i][j]-c[i][k])

if d[0] == d[1] == d[2]:
  print('Yes')
else:
  print('No')

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

struct StructAdHoc {
	static const int maxn = 100000;
	string str;
	int pref[maxn + 5];
	int has;
	
	void read() {
		cin >> str;
	}

	void flip() {
		if(str[(int)str.length() / 2] == '1') {
			for(int i = 0; i < (int)str.length(); i++) {
				str[i] ^= 1;
			}
		}
		for(int i = 0; i < (int)str.length(); i++) {
			pref[i + 1] = pref[i] + str[i] - '0';
		}
	}

	void solve() {
		int aw = 1, ak = (int)str.length();
		has = (int)str.length();
		while(pref[aw - 1] != pref[ak]) {
			has--;
			aw++;
			ak--;
		}
	}

	void print() {
		cout << has << "\n";
	}

} A;

int main() {
	A.read();
	A.flip();
	A.solve();
	A.print();
}

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

int main()
{
  ll N;
  scanf("%lld",&N);
  vector<ll> A(N);
  vector<ll> x(N);
  for(int i=0; i<N; i++){
    scanf("%lld",&A[i]);
    x[i]=A[i];
  }
  sort(x.rbegin(),x.rend());

  for (int i=0; i<N; i++) {
    if (x[0]==A[i]) cout << x[1] << endl;
    else cout << x[0] << endl;
  }

  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define lg2 std::__lg

inline long long doz(long long x) {return ~(x >> 63) & x;}

int main() {
	int c, d; long long L, R;
	scanf("%lld%lld", &L, &R);
	if (L == R) return putchar(49), putchar(10), 0;
	c = lg2(L ^ R), L &= ~(-2ll << c), R &= ~(-1ll << c), d = R ? lg2(R) + 1 : 0;
	printf("%lld\n", (2ll << c) - L - doz(L - (1ll << d)));
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 2000000

int Htw,Atw[N+1];


void swap(int *a, int*b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void maxHeapify(int i){
    int l,r,largest;
    l=2*i;
    r=2*i+1;


    if(l<=Htw && Atw[l]>Atw[i])largest = l;
    else largest = i;
    if(r<=Htw && Atw[r] > Atw[largest])largest = r;

    if(largest != i){
        swap(&Atw[i],&Atw[largest]);
        maxHeapify(largest);
    }
}


int main(){
    int i;
    scanf("%d",&Htw);
    for(i=1;i<=Htw;i++)scanf("%d",&Atw[i]);

    for(i=Htw/2;i>=1;i--)maxHeapify(i);

    for(i=1;i<=Htw;i++)printf(" %d",Atw[i]);


    printf("\n");

    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s == "SUN"){
    cout << "7\n";
    return 0;
  }
  if(s == "MON"){
    cout << "6\n";
    return 0;
  }
  if(s == "TUE"){
    cout << "5\n";
    return 0;
  }
  if(s == "WED"){
    cout << "4\n";
    return 0;
  }
  if(s == "THU"){
    cout << "3\n";
    return 0;
  }
  if(s == "FRI"){
    cout << "2\n";
    return 0;
  }
  if(s == "SAT"){
    cout << "1\n";
    return 0;
  }
}

Measured memory_bytes: 3592
a, v, b, w, t = [gets,gets,gets].join().split().collect{|i|i.to_i}
if a < b
  you = t * v + a
  me  = t * w + b
  puts you >= me ? "YES" : "NO"
else
  you = - t * v + a
  me  = - t * w + b
  puts you <= me ? "YES" : "NO"
end

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> a(n);
    int nr = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector< vector<int> > odp(n, vector<int>(m, -1));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i][j] == '#')
            {
                odp[i][j] = nr;
                ++nr;
            }
        }
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i][j] == '.')
                continue;
            for (int k = j - 1; k >= 0 && a[i][k] == '.'; --k)
                odp[i][k] = odp[i][j];
            for (int k = j + 1; k < m && a[i][k] == '.'; ++k)
                odp[i][k] = odp[i][j];
        }
    }
    for (int j = 0; j < m; ++j)
        for (int i = 1; i < n; ++i)
            if (odp[i][j] == -1)
                odp[i][j] = odp[i - 1][j];
    for (int j = 0; j < m; ++j)
        for (int i = n - 2; i >= 0; --i)
            if (odp[i][j] == -1)
                odp[i][j] = odp[i + 1][j];
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
            cout << odp[i][j] + 1 << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* the recursive version can't go to 2e5 */

const int inf = 1e9;
const int maxn = 1e6;
int n; string s;

bool isW(const int i)
{ return s[i] == '.'; }
bool isB(const int i)
{ return !isW(i); }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> s) {
        s = '.' + s; n++;
        map<int,int> dp[2];
        int cur,nxt; cur = 0; nxt = 1;
        dp[cur][0] = 0;
        FOR(i,1,n) {
            dp[nxt][0] = dp[nxt][1] = inf;
            FOR_ALL(x,dp[cur]) {
                const int j = x->first;
                const int v = x->second;
                if (j) {
                    if (isW(i))
                        dp[nxt][1] = min(dp[nxt][1],v+1);
                    else {
                        dp[nxt][1] = min(dp[nxt][1],v);
                    }
                }
                else {
                    if (isW(i)) {
                        dp[nxt][0] = min(dp[nxt][0],v);
                        dp[nxt][1] = min(dp[nxt][1],v+1);
                    }
                    else {
                        dp[nxt][0] = min(dp[nxt][0],v+1);
                        dp[nxt][1] = min(dp[nxt][1],v);
                    }
                }
            }
            swap(cur,nxt);
        }
        int ans = inf;
        FOR_ALL(x,dp[cur])
            ans = min(ans,x->second);
        cout << ans << endl;
    }
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += a[i] - 1;
  }
  cout << ans << endl;
}

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

long long power(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a ;
        a = a * a ;
        b >>= 1;
    }
    return res;
}

int find(int x)
{
    int cnt=0;
    while (x)
    {
        cnt+=x%10;
        x/=10;
    }
    return cnt;       
}

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int k;
    cin>>k;
    
    vector<int>lol;
    int add=1;
    int z=1e16;
    for(int i=1;i<=z;i+=add)
    {
        long double x=i;
        long double y=find(i);
        long double xx=i+add;
        long double yy=find(i+add);
        x/=y;
        xx/=yy;
        if(x>xx)
        {
            i-=add;
            add*=10;
        }
        else
        {
            lol.push_back(i);
        }        
    }

    for(int i=0;i<k;i++)
        cout<<lol[i]<<'\n';
}


Measured memory_bytes: 3524
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n;
            while((n = scn.nextInt()) > 0) {
                ArrayList<Island> islands = new ArrayList<>();
                while(n-- > 0) {
                    islands.add(new Island(scn.nextInt(), scn.nextInt()));
                }
                Collections.sort(islands);

                boolean fail = false;
                int weight = 0;
                for(Island island : islands) {
                    weight += island.getTreasure();
                    if(weight > island.getDurability()) {
                        fail = true;
                    }
                }

                System.out.println(fail ? "No" : "Yes");
            }
        }
    }
}

class Island implements Comparable<Island> {
    private int treasure;
    private int durability;

    public Island(int treasure, int durability) {
        this.treasure   = treasure;
        this.durability = durability;
    }

    public int getTreasure() {
        return treasure;
    }

    public int getDurability() {
        return durability;
    }

    public int compareTo(Island another) {
        return this.getDurability() > another.getDurability() ? 1 : -1;
    }
}

Measured memory_bytes: 32428
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    String[] s = new String[n];

    for (int i = 0; i <n; i++) {
      s[i] = scanner.next();
    }

    System.out.println(Arrays.stream(s).distinct().count());

  }
}


Measured memory_bytes: 70152
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[[int(i) for i in input().split()] for l in range(n)]
d=0
for x in a:
    l=[p*q for p,q in zip(x,b)]
    if sum(l)+c>0:d+=1
print(d)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <utility>
using namespace std;
int N, Q;
string s;
vector<char> t(200000),d(200000);
int tou(int x){
	int ans=x;
	for(int i=0;i<Q;i++){
		if(ans < 0 || ans >= N)break;
		if(t[i] == s[ans]){
			if(d[i] == 'L')ans--;
			else ans++;
		}
	}
	return ans;
}
int main(){
	cin >> N >> Q;
	cin >> s;
	for(int i=0;i<Q;i++){
		cin >> t[i] >> d[i];
	}
	int mid1 = N / 2;
	int last1 = N - 1;
	int first1 = 0;
	while(last1 - first1 > 0){
		/*if(last1 - first1 == 1){
			if(tou(last1)<0){
				first1 = last1;
				mid1 = last1;
			}
			else{
				last1 = first1;
				mid1 = first1;
			}
			break;
		}*/
		if(tou(mid1) < 0){
			first1 = mid1 + 1;
		}
		else{
			last1 = mid1 - 1;
		}
		mid1 = (last1 - first1) / 2 + first1;
		//cout<< 1 << ":" << first1 << ":" << last1 << ":" << mid1 << endl;
	}
	int mid2 = N / 2;
	int last2 = N - 1;
	int first2 = 0;
	while(last2 - first2 > 0){
		/*if(last2 - first2 == 1){
			if(tou(first2)>=N){
				last2 = first2;
				mid2 = first2;
			}
			else{
				first2 = last2;
				mid2 = last2;
			}
			break;
		}*/
		if(tou(mid2) >= N){
			last2 = mid2 - 1;
		}
		else{
			first2 = mid2 + 1;
		}
		mid2 = (last2 - first2) / 2 + first2;
		//cout<< 2 << ":" << first2 << ":" << last2 << ":" << mid2 << endl;
	}
	if(tou(mid1) < 0)mid1++;
	if(tou(mid2) >= N)mid2--;
	cout << mid2 - mid1 + 1 << endl;
}

Measured memory_bytes: 1028
def main():
  n, k = map(int, input().split())
  
  plst = []
  xlst = []
  ylst = []
  dlst = []
  
  for i in range(n):
    x1,y1,d1,x2,y2,d2 = map(int, input().split())
    plst.append((x1,y1,d1,x2,y2,d2))
    xlst.append(x1)
    xlst.append(x2)
    ylst.append(y1)
    ylst.append(y2)
    dlst.append(d1)
    dlst.append(d2)
  
  xlst = list(set(xlst))
  ylst = list(set(ylst))
  dlst = list(set(dlst))
  
  xlst.sort()
  ylst.sort()
  dlst.sort()
  
  xdic = {}
  ydic = {}
  ddic = {}
  
  for i, v in enumerate(xlst):
    xdic[v] = i
  for i, v in enumerate(ylst):
    ydic[v] = i
  for i, v in enumerate(dlst):
    ddic[v] = i
  
  new_map = [[[0] * len(dlst) for _ in ylst] for _ in xlst]
  
  for p in plst:
    x1, y1, d1, x2, y2, d2 = p
    x1, y1, d1, x2, y2, d2 = xdic[x1], ydic[y1], ddic[d1], xdic[x2], ydic[y2], ddic[d2]
    for x in range(x1, x2):
      for y in range(y1, y2):
        for d in range(d1, d2):
          new_map[x][y][d] += 1
  
  ans = 0
  for i in range(len(xlst) - 1):
    xlsti = xlst[i]
    xlsti1 = xlst[i + 1]
    x = xdic[xlsti]
    for j in range(len(ylst) - 1):
      ylstj = ylst[j]
      ylstj1 = ylst[j + 1]
      y = ydic[ylstj]
      for z in range(len(dlst) - 1):
        dlstz = dlst[z]
        dlstz1 = dlst[z + 1]
        d = ddic[dlstz]
        if new_map[x][y][d] >= k:
          ans += (xlsti1 - xlsti) * (ylstj1 - ylstj) * (dlstz1 - dlstz)
  print(ans)

main()


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

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

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll a_I, ll a_O, ll a_T, ll a_J, ll a_L, ll a_S, ll a_Z) {
    ll ans = a_O;

    if ((a_I % 2) + (a_J % 2) + (a_L % 2) >= 2 && a_I > 0 && a_J > 0 && a_L > 0) {
        a_J--;
        a_L--;
        a_I--;
        ans += 3;
    }

    ans += a_I / 2 * 2;
    ans += a_J / 2 * 2;
    ans += a_L / 2 * 2;


    cout << ans << endl;

}


void main_(istream &cin) {
    ll a_I;
    ll a_Z;
    ll a_L;
    ll a_O;
    ll a_J;
    ll a_S;
    ll a_T;
    cin >> a_I;
    cin >> a_O;
    cin >> a_T;
    cin >> a_J;
    cin >> a_L;
    cin >> a_S;
    cin >> a_Z;
    solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 256
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N = I()
prev_t = 0
prev_x = 0
prev_y = 0
flag = True
for i in range(N):
    t,x,y = map(int,input().split())
    t = t-prev_t
    if abs(x-prev_x)+abs(y-prev_y) > t:
        flag = False
        break
    elif (abs(x-prev_x)+abs(y-prev_y)) %2 != t%2:
        flag = False
        break
    prev_t = t+prev_t
    prev_x = x
    prev_y = y
print('Yes' if flag else 'No')


Measured memory_bytes: 5068
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back

void solve()
{
  long long n;
  cin>>n;
  if(n<=1)
  {
      cout<<0<<endl;
      return;
  }
  long long hell = 1e9+7;

  long long total = 1LL;

  long long i,j;

  for(i=0;i<n;i++)
  {
      total = (total*10LL)%hell;
  }
  long long del1 = 1LL;
  long long del2 = 1LL;

  long long total1 = 1LL;

  for(i=0;i<n;i++)
  {
      total1 = (total1*9LL)%hell;
  }

  for(i=0;i<n;i++)
  {
      del1 = (del1*8LL)%hell;
  }
  long long ans1 = (total1-del1)%hell;
  ans1  = ans1 + (total1-del1)%hell;

  long long ans = (total - ans1 - del1)%hell;

  if(ans <0)ans = ans +hell;
  cout<<ans<<endl;



}

int main()
{
    int t = 1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3620
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;





int main()
{
   
   
    int n, w;
    cin >> n >> w;
    vector<ll>p(100200);
    vector<int>a(n), b(n);
    for (int i = 1; i <p.size(); i++) {
        p[i] = 99999999999999;
        
    }
    p[0] = 0;
    ll ans = 0;
    ll t = 0;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        
        for (int j = t; j >= 0; j--) {
            p[j+y] = min(p[j+y], p[j] + x);
            if(p[j+y]<=w)ans = max(ans, (ll)j+y);
            
        }
        t += y;
    }
    cout << ans << endl;
    return 0;

}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n, k;
    cin >> n >> k;

    v_int a(n); 
    cin >> a;

    v_string ans;
    int r = 0;

    irep(l,n-k+1) {
        while(r-l+1 <= k) {
            r++;
        }
        //cout << a[l] << "," << a[r-1] << endl;
        if(l > 0) {
            if(a[l-1] < a[r-1]) { 
                if(l > 0) { ans.push_back("Yes"); } 
            } else {
                if(l > 0) { ans.push_back("No"); } 
            }
        }
    }

    for(auto s : ans) {
        cout << s << endl;
    }
    return 0;
}

/*atcoder*/



Measured memory_bytes: 12432
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

void fprint() { std::cout << '\n'; }
template <class H, class... T> void fprint(H &&head, T &&... args) {
    std::cout << std::fixed << std::setprecision(10) << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}

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

    int N;
    cin >> N;
    priority_queue<double> que;
    REP(i, N) {
        double a;
        cin >> a;
        que.push(-a);
    }
    while (que.size() != 1) {
        double a = que.top();
        que.pop();
        double b = que.top();
        que.pop();
        double x = (a + b) / 2.0;
        que.push(x);
    }
    double ans = -que.top();
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC target ("avx")
#pragma GCC target ("avx2")
#pragma GCC target ("fma")
#pragma GCC optimize ("Ofast")
#pragma GCC optimization ("unroll-loops, no-stack-protector")
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#define ordered_set tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update>
#pragma 03
using namespace std;
using namespace __gnu_pbds;
// hj cho minh bulli bai nay
ll dp[200005], a[200005];
int st[800005][2]; 
void update(ll root, ll l, ll r, ll i, ll val, ll id){
	if (i < l || r < i) return;
	if (l == r){
		st[root][id] = val; return;
	}
	int mid = (l + r) / 2;
	update(root * 2 + 1, l, mid, i, val, id);
	update(root * 2 + 2, mid + 1, r, i, val, id);
	st[root][id] = min(st[root * 2 + 1][id], st[root * 2 + 2][id]);
}
ll query(ll root, ll l, ll r, ll u, ll v, ll id){
	if (u > v) return 1e18;
	if (v < l || r < u) return 1e18;
	if (u <= l && r <= v) return st[root][id];
	ll mid = (l + r) / 2;
	return min(query(root * 2 + 1, l, mid, u, v, id), query(root * 2 + 2, mid + 1, r, u, v, id));
}
int main(){
	fastio;
	ll n, e, t; cin >> n >> e >> t;
	for (ll i = 1; i <= n; i++) cin >> a[i];
	// dp[i]: shortest time to clear first i candies.
	dp[0] = 0;
	// 2 segtrees: one record dp[j] - 2 * a[j + 1] - a[j], one record dp[j] - a[j].
	update(0, 0, n - 1, 0, dp[0] - 2 * a[1], 0);
	for (ll i = 1; i <= n; i++){
		dp[i] = 1e18;
		ll lw; // lw: (a[i] - a[lw]) * 2 <= t, (a[i] - a[lw - 1]) * 2 > t. (lw - 1 -> 0)
		// manual binsearch? lw >= l, <= r
		ll l = 0, r = i - 1;
		while (l < r){
			ll mid = (l + r) / 2;
			if ((a[i] - a[mid + 1]) * 2 <= t) r = mid;
			else l = mid + 1;
		}
		lw = l;
		// so (dp[j] - 2 * a[j + 1] - a[j]) + 3 * a[i] with a from 0 to lw - 1, (dp[j] - a[j]) + a[i] + t to lw to i - 1
		dp[i] = min(query(0, 0, n - 1, 0, lw - 1, 0) + 3 * a[i], query(0, 0, n - 1, lw, i - 1, 1) + a[i] + t);
		update(0, 0, n - 1, i, dp[i] - 2 * a[i + 1] - a[i], 0); update(0, 0, n - 1, i, dp[i] - a[i], 1);
		// for (ll j = 0; j < i; j++) dp[i] = min(dp[i], dp[j] + max(2 * (a[i] - a[j + 1]), t) + a[i] - a[j]);
	}
	// hj, optimize nao
	cout << dp[n] + (e - a[n]) << endl;
}

Measured memory_bytes: 7328
#include<stdio.h>

int main(void){

	char str[100]={0};

	for(int i=0; i<20; i++){
		
		scanf("%c",&str[i]);
		
		if(str[i] == '\n'){
			str[i]='\n';
			break;
		}
	
	}
		
	for(int i=19; i>=0; i--){
			printf("%c",str[i]);
	}
			printf("\n");
}
	

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


def solve(N: int, S: str, T: str):
    ans = ""
    for s, t in zip(S, T):
        ans = ans + s + t
    print(ans)


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
package main

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

func main() {
	var N, T int
	fmt.Scan(&N, &T)
	t := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range t {
		sc.Scan()
		t[i], _ = strconv.Atoi(sc.Text())
	}
	ans := 0
	for i := 1; i < N; i++ {
		if t[i]-t[i-1] <= T {
			ans += t[i] - t[i-1]
		} else {
			ans += T
		}
	}
	ans += T
	fmt.Println(ans)
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>

using namespace std;

//マクロ
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 999999999

//debug
#define dump(x) cout << #x << " = " << (x) << endl;

//ALDS1_2_A
//Bubble Sort

//配列の要素を順番に出力
void trace(int A[], int N){
    int i;
    for (i = 0; i < N; i++){
        if (i>0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void bubble_sort(int A[], int N, int& count){
    int i;
    bool flag = true; //逆の隣接行列が存在する
    while (flag){
        flag = false;
        for (i = N-1; i>0; i--){
            if (A[i] < A[i-1]){
                swap(A[i], A[i-1]);
                flag = true;
                count++;
            }
        }
    }
}

int main(){
    const int N_MAX = 100;
    int A[N_MAX];
    int N;
    int count = 0;
    scanf("%d", &N);
    REP(i, N) scanf("%d", &A[i]);
    bubble_sort(A, N, count);
    trace(A, N);
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 3220
import sys
 
N, X = map(int, (input().split()))
L = list(map(int, input().split()))
point = 0
count = 1
 
for x in range(0, N):
    point+=L[x]
    if(point<=X):
        count+=1
    if(point>=X):
        print(count)
        sys.exit()
 
print(count)

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
const int N=55;
ll fact[N],inv[N];
void solve()
{
    ll n,p;
    cin>>n>>p;
    ll odd=0,even=0;
    fact[0]=1;
    fr(i,1,N)
    {
        fact[i]=i*fact[i-1];
    }
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        if(x%2==0)
            even++;
        else
            odd++;
    }
    ll ans=0;
    if(p==1)
    {

            if(odd!=0)
            ans+=(power(2,even)*power(2,odd-1));

    }
    else
    {
        if(even==0)
        {
            if(odd!=0)
                ans+=(power(2,odd-1));
        }
        else
        {
            if(odd==0)
                ans+=(power(2,even));
            else
                ans+=(power(2,even)*power(2,odd-1));
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3620
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string, int> P;

void call(int n) {
	int i = 1;
	bool flag = 0;
	while(i <= n) {
		int x = i;
		if(x % 3 == 0) printf(" %d", i);
		else {
			while(1) {
				if(x % 10 == 3) {
					printf(" %d", i);
					break;
				}
				x /= 10;
				if(x) continue;
				else break;
			}
		}
		++i;
	}
	printf("\n");
	return;
}

int main() {
	int N;
	scanf("%d", &N);
	call(N);
	return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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 main(){
    int i,j;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        s[i]='A'+(s[i]-'A'+23)%26;
    }
    cout<<s<<endl;

}


Measured memory_bytes: 3208
import java.util.Scanner;

// Main
class Main {
	static final int INIT = 8;
	static int[] grow(int[] s) {
		int[] d = new int[s.length * 2];
		System.arraycopy(s, 0, d, 0, s.length);
		return d;
	}

	static class Queue {
		private int[] data;
		private int r, w;
		public Queue() {
			data = new int[INIT];
			// r 読み込み
			// w 書き込み
		}
		public boolean isEmpty() {
			return r == w;
		}
		public void enqueue(int x) {
			if (w >= data.length) {
				data = grow(data);
			}
			data[w++] = x;
		}
		public int getFront() {
			return data[r];
		}
		public void dequeue() {
			if (!isEmpty()) {
				r++;
			}
		}
	}

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			Queue[] qq = new Queue[n];
			for (int i = 0; i < n; i++) {
				qq[i] = new Queue();
			}
			int q = sc.nextInt();
			for (int i = 0; i < q; i++) {
				int c = sc.nextInt();
				int t = sc.nextInt();
				switch (c) {
				case 0:
					int x = sc.nextInt();
					qq[t].enqueue(x);
					break;
				case 1:
					if (!qq[t].isEmpty()) {
						System.out.println(Integer.toString(qq[t].getFront()));
					}
					break;
				case 2:
					qq[t].dequeue();
					break;
				}
			}
		}
	}
}



Measured memory_bytes: 164536
use proconio::{fastout, input};
use proconio::marker::*;

#[fastout]
fn main() {
   input! {
      t: Chars
   }

   for &c in t.iter() {
      if c == '?' {
         print!("D");
      } else {
         print!("{}", c);
      }
   }
   println!("");
}


Measured memory_bytes: 3036
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 1e5 + 10, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
string s;
int n, a[N] = { };
pii pos[N] = { };
ll fact[N] = { };
ll fast_pow(int base, int power) {
	if (!power)
		return 1;
	ll answer = fast_pow(base, power / 2) % mod;
	answer *= answer;
	if (answer >= mod)
		answer %= mod;
	if (power & 1)
		answer *= base;
	if (answer >= mod)
		answer %= mod;
	return answer;
}
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n, num;
	cin >> n;
	lp(i,1,n+1)
	{
		cin >> a[i];
		if (!pos[a[i]].F)
			pos[a[i]].F = i;
		else
			pos[a[i]].S = i, num = a[i];
	}
	fact[0] = 1;
	lp(i,1,n+5)
	{
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
	int sum = (n + 1 - pos[num].S) + (pos[num].F - 1);
	lp(i,1,n+1)
	{
		ll sub = 0;
		if (sum - (i - 1) >= 0) {
			ll dd = fact[i - 1] * fact[sum - (i - 1)];
			dd %= mod;
			sub = fact[sum] * fast_pow(dd, mod - 2);
			sub %= mod;
		}
		//-----------------------------------
		ll d = fact[i] * fact[n + 1 - i];
		d %= mod;
		ll ans = fact[n + 1] * fast_pow(d, mod - 2);
		ans %= mod;
		ans -= sub;
		ans += mod;
		ans %= mod;
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3200
#include <iostream>
using namespace std;
int main(void){
    int n;
    long a, max=-1000000, min=1000000, sum=0;
    cin >> n;
    while(n--!=0){
        cin >> a;
        if(a>max) max = a;
        if(a<min) min = a;
        sum += a;
    }
    cout << min << " " << max << " " << sum << endl; 
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
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;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,K; cin >> N >> K;
    vecl A(N); REP(i,N) cin >> A[i];
    ll ans = 1LL << 60;
    for(int i = 0; i <= N-K; i++) {
        //cout << A[i] << " " << A[i+K-1] << endl;
        if(A[i] > 0 && A[i+K-1] > 0) chmin(ans,A[i+K-1]);
        else if(A[i] < 0 && A[i+K-1] < 0) chmin(ans,-A[i]);
        else if(abs(A[i]) >= abs(A[i+K-1])) chmin(ans,2*abs(A[i+K-1])+abs(A[i]));
        else chmin(ans,2*abs(A[i])+abs(A[i+K-1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
static const long long MOD = 1000000007LL;
int n;
char s[100005];
long long unsigned int dp[100005][13];
int main () {
  int i, j, ki;
  long long unsigned int res = 0;

  scanf("%s", s);
  n = strlen(s);

  dp[0][0] = 1;
  for (i = 0; i < n; i++) {
    int c;
    if (s[i] == '?') c = -1;
    else c = s[i] - '0';

    for (j = 0; j < 10; j++) {
      if (c != -1 && c != j) continue;
      for (ki = 0; ki < 13; ki++) {
        dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki];
      }
    }
    for (j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
  }
  res = dp[n][5];

  printf("%llu\n", res);
  return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int mod = 1000000007;
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
int main()
{
    fast

        int n;
        cin>>n;
        cout<<(1000-(n%1000))%1000<<endl;


    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mod=1000000007;
int main()
{
	int n,k,i,d,j,x,c=0;
	cin>>n>>k;
	int f[n];
	for(i=0;i<n;i++) f[i]=0;
	for(i=0;i<k;i++)
	{
		cin>>d;
		for(j=0;j<d;j++)
		{
			cin>>x;
			f[x-1]=1;
		}
	}
	for(i=0;i<n;i++)
	{
		if(f[i]==0) c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M, Q;
  cin >> N >> M >> Q;
  vector<ll> L(M), R(M);
  REP(i, 0, M) cin >> L[i] >> R[i], L[i]--, R[i]--;
  vector<ll> S(Q), T(Q);
  REP(i, 0, Q) cin >> S[i] >> T[i], S[i]--, T[i]--;

  vector<vector<ll>> sum(N + 1, vector<ll>(N + 1));
  REP(i, 0, M) sum[L[i] + 1][R[i] + 1]++;
  REP(i, 0, N + 1) REP(j, 0, N) sum[i][j + 1] += sum[i][j];
  REP(i, 0, N) REP(j, 0, N + 1) sum[i + 1][j] += sum[i][j];

  REP(i, 0, Q) {
    ll s = S[i], t = T[i] + 1;
    cout << sum[t][t] - sum[s][t] - sum[t][s] + sum[s][s] << endl;
  }
}

Measured memory_bytes: 7552
s = input()
if 1 <= int(s[0:2]) <= 12:
  if 1 <= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= int(s[2:4]) <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 2940