akhauriyash/Code-Regression huggingface dataset:
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64;
typedef vector<int> ivec;
typedef vector<string> svec;
 
int N, X, Y, Z;
 
i64 dp[41][1 << 17];
const int mask = (1 << 17) - 1;
 
int trans[1 << 17][11];
i64 powten[41];
 
int main()
{
    scanf("%d%d%d%d", &N, &X, &Y, &Z);
 
    dp[0][1] = 1;
 
    powten[0] = 1;
    for (int i = 0; i < N; ++i) {
        powten[i + 1] = powten[i] * 10 % MOD;
    }

    for (int i = 0; i < (1 << 17); ++i) {
        for (int j = 1; j <= 10; ++j) {
            int i2 = i;

            i2 <<= j; // shift 1
            i2 |= 1;  // turn 0th element to 1
            i2 &= (1 << 18) - 1;

            trans[i][j] = i2;
        }
    }
 
    i64 ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < (1 << 17); ++j) {
            for (int k = 1; k <= 10; ++k) {
                int j2 = trans[j][k];
 
                if (
                    j2 & (1 << (X + Y + Z)) &&
                    j2 & (1 << (Y + Z)) &&
                    j2 & (1 << (Z)) 
                    ) {
                    ADD(ans, dp[i][j] * powten[N - i - 1] % MOD); // 10^(N-i-1)
                    continue;
                }

                j2 &= mask;
                ADD(dp[i + 1][j2], dp[i][j]);
            }
        }
    }

    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 46848
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        string p,s;
        cin>>p>>s;
        reverse(p.begin(),p.end());
        for(int i=0;i<p.length();i++){
            if(p[i]=='C')rotate(s.begin(),s.begin()+1,s.end());
            else if(p[i]=='J')rotate(s.begin(),s.begin()+s.length()-1,s.end());
            else if(p[i]=='E'){
                for(int j=0;j<s.length()/2;j++)swap(s[j],s[j+(s.length()+1)/2]);
            }
            else if(p[i]=='A'){
                reverse(s.begin(),s.end());
            }
            else if(p[i]=='M'){
                for(int i=0;i<s.length();i++){
                    if(!isdigit(s[i]))continue;
                    s[i]=((s[i]-'0')+1)%10+'0';
                }
            }
            else{
                for(int i=0;i<s.length();i++){
                    if(!isdigit(s[i]))continue;
                    s[i]=((s[i]-'0')+9)%10+'0';
                }
            }
        }
        cout<<s<<endl;
    }
    return 0;
}

Measured memory_bytes: 1220
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
"""
n = I()
d = defaultdict(int)
for i in range(n):
    a = I()
    d[a] ^= 1
d = list(d.values())
print(sum(d))
"""
#D
def dfs(n,k,l,a):
    if n == 0:
        a.append(l)
    for i in range(n):
        dfs(n-1,k[:i]+k[i+1:],l+[k[i]],a)
n,m,R = LI()
r = LI()
f = [i for i in range(n)]
for i in range(R):
    r[i] -= 1
v = [[float("inf") for j in range(n)] for i in range(n)]
for i in range(n):
    v[i][i] = 0
for i in range(m):
    a,b,c = LI()
    a -= 1
    b -= 1
    v[a][b] = c
    v[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            v[i][j] = min(v[i][j],v[i][k]+v[k][j])
l = []
dfs(R,r,[],l)
ans = float("inf")
for k in l:
    d = 0
    for i in range(R-1):
        d += v[k[i]][k[i+1]]
    ans = min(ans,d)
print(ans)
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
bool is_prime (int x){
  if (x<=1) return false ;
  for (int i=2 ; i*i<=x ; i++){
    if (x%i==0) return false ;
  }
   return true;
}

 
/*CODE START HERE*/
int main() {
  int n , x;
  cin >> n >> x;
  int left = x ;
    vector <int> a(n);
  forn(i,n){
    cin >> a.at(i);
  }
  sort(a.begin() , a.end());
  int ans = 0;
  for ( int i = 0 ;i<n ; i++ ){
    left -=  a.at(i);
    if ( left < 0){
      break ;
    }
    ans ++ ;
  }
  if ( left > 0){
    ans -- ;
  }
  cout << ans <<  endl;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int N,P,A;
long ans=0;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>A;
		if(P<=A)P=A;
		else ans+=P-A;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int H,W,K;
    cin >> H >> W >> K;
    int m[H][W];
    int countW[H];
    int strCount = 0;
    for(int yi = 0; yi < H; yi++){
        int count = 0;
        for(int xi = 0; xi < W; xi++){
            char tmp;
            cin >> tmp;
            if(tmp == '#'){
                strCount++;
                m[yi][xi] = strCount;
                count++;
            }else{
                m[yi][xi] = -1;
            }
        }
        countW[yi] = count;
    }
    //一週目　塗れるだけ塗る
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            if(countW[yi] == 0){

            }else{
                for(int i = 0; i < W; i++){
                    if(xi + i < W){
                        if(m[yi][xi + i] != -1){
                            m[yi][xi] = m[yi][xi + i];
                            break;
                        }
                    }
                    if(xi - i >= 0){
                        if(m[yi][xi - i] != -1){
                            m[yi][xi] = m[yi][xi - i];
                            break;
                        }
                    }
                }
            }
        }
    }
    //二週目　縦処理
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            if(countW[yi] == 0){
                for(int i = 0; i < H; i++){
                    if(yi + i < H){
                        if(m[yi + i][xi] != -1){
                            m[yi][xi] = m[yi + i][xi];
                            break;
                        }
                    }
                    if(yi - i >= 0){
                        if(m[yi - i][xi] != -1){
                            m[yi][xi] = m[yi - i][xi];
                            break;
                        }
                    }
                }
            }else{

            }
        }
    }
    //出力
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            cout << m[yi][xi] << " ";
        }
        cout << endl;
    }

}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    if(b%a==0){
        cout<<a+b<<endl;
    }
    else {
        cout<<b-a<<endl;
    }
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 N;
    int64 sum = 0, maxi = 0, l = INF_LL;
    cin >> N;
    REP(i, N) {
        int64 a, b;
        cin >> a >> b;
        sum += a;
        if (a > b) chmin(l, b);
    }
    if (l == INF_LL) l = sum;
    cout << sum - l << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
}



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

using int64 = long long;

int main() {
    int64 a_i, a_o, a_j, a_l, x;
    cin >> a_i >> a_o >> x >> a_j >> a_l >> x >> x;

    int64 ans = 0;
    for (int i = 0; i <= 1; i++) {
        if (a_i < i or a_j < i or a_l < i) continue;
        int64 a = ((a_i - i) / 2) * 2,
              b = ((a_j - i) / 2) * 2,
              c = ((a_l - i) / 2) * 2;
        ans = max(ans, a_o + i * 3 + a + b + c);
    }
    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n, d, cnt = 0;
  cin >> n >> d;
  vector<vector<int>> v(n);
  for(int i=0; i<n; i++)
  {
    for(int j=0; j<d; j++)
    {
      int k;
      cin >> k;
      v[i].push_back(k);
    }
  }
  for(int i=0; i<n-1; i++)
  {
    for(int j=i+1; j<n; j++)
    {
      long long tmp = 0;
      for(int k=0; k<d; k++)
        tmp += pow(v[i][k] - v[j][k], 2);
      
      int s = (int)sqrt(tmp);
      double t = sqrt(tmp);
      if((double)s == t)
        cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define fix  cout<<std::fixed;
#define mk make_pair
#define time  cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
#define IOS             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{  
 ll n;cin>>n;
 ll a[n],b[n],c[n],dp[3][n];
 for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
dp[0][0]=a[0];dp[1][0]=b[0];dp[2][0]=c[0];
    for(int i=1;i<n;i++)
    { 
        dp[0][i]=a[i]+max(dp[1][i-1],dp[2][i-1]);
        dp[1][i]=b[i]+max(dp[0][i-1],dp[2][i-1]);
        dp[2][i]=c[i]+max(dp[1][i-1],dp[0][i-1]);

    }   

  cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cmath>

int main(){
	double x1, y1, x2, y2, d, dx, dy;
	scanf("%lf", &x1);
	scanf("%lf", &y1);
	scanf("%lf", &x2);
	scanf("%lf", &y2);
	dx = x1 - x2;
	dy = y1 - y2;
	d = sqrt(dx * dx + dy * dy);
	printf("%.5lf", d);
	return 0;
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N;
int x[100010];

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N;
    REP(i, N) cin >> x[i];
    stack<int> st;
    int ans = 1;
    REP(i, N) {
        st.push(x[i]);
        if (st.top() < 2 * st.size() - 1) {
            (ans *= st.size()) %= MOD;
            st.pop();
        }
    }
    int fac = 1;
    for (int i = 1; i <= st.size(); i++) {
        (fac *= i) %= MOD;
    }
    (ans *= fac) %= MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	ll h; cin >> h;
	ll cnt = 0, num = 1;
	while (h != 0) {
		cnt += num;
		num *= 2, h /= 2;
	}
	cout << cnt << "\n";
}

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

int main() 
{
   char a, b;
   cin >> a >> b;

   if (a == 'H')
      cout << b << endl;
   else
   {
      if (b == 'H')
         cout << 'D' << endl;
      else
         cout << 'H' << endl;
   }
}


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

#define pow(n) (n)*(n)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  // int ans;  // output

  int i;    // subscript
  // int cnt_1, cnt_2;
  int64_t sum;


  /* Input, Array_Proclamation */
  cin >> N;
  vector<int64_t> a(N*3);
  // vector< vector<int> > teams( N, vector<int>(3) );


  for(i=0; i<N*3; i++)
  {
    cin >> a.at(i);
  }


  /* Initialize */
  // ans   = 0;
  // cnt_1 = 0;
  // cnt_2 = 0;

  sum = 0;


  /* Calculation */
  sort   ( all(a) );
  reverse( all(a) );

  for( i = 1;  i < N*2;  i += 2 )
  {

    sum += a.at(i);

    // if(i%2 == 0)
    // {
    //   team_1.at(cnt_1);
    //   cnt_1++;
    // }
    // else if(i%2 == 1)
    // {
    //   team_2.at(cnt_2);
    //   cnt_1++;
    // }
  }
  

  /* Output */
  cout << sum << endl;


  return 0;

}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	string a,b,c;
	cin >> a >> b >> c;
	cout << (char)(a[0] + BC) << (char)(b[0] + BC) << (char)(c[0] + BC) << endl;
	return 0; 
}

Measured memory_bytes: 256
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
a = int(input())
print(n[a-1])

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

int main(){
  int N; cin >> N;
  vector<vector<pair<int,long long>>> e(N,vector<pair<int,long long>>());
  for(int i=0; i<N-1; i++){
    int u,v; long long w; cin >> u >> v >> w;
    e[u-1].push_back(make_pair(v-1,w));
    e[v-1].push_back(make_pair(u-1,w));
  }
  
  vector<int> color(N,0); // W:1, K:2
  queue<pair<int,long long>> q;
  color[0]=1;
  q.push(make_pair(0,0));
  while(!q.empty()){
    auto c=q.front();
    for(auto d:e[c.first]){
      if(color[d.first]==0){
        if((c.second+d.second)%2==0){
          color[d.first]=1;
        }else{
          color[d.first]=2;
        }
        q.push(make_pair(d.first,c.second+d.second));
      }
    }
    q.pop();
  }
  for(int i=0; i<N; i++) cout << color[i]-1 << endl;
}

Measured memory_bytes: 8320
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    bool up_flg = false;
    bool dn_flg = false;
    int ans = 1;
    rep(i, n-1) {
        if (a[i] == a[i+1]) continue;
        if (a[i] < a[i+1]) {
            if (dn_flg) {
                dn_flg = false;
                ++ans;
            }
            else if (!up_flg) {
                up_flg = true;
            }
        }
        if (a[i] > a[i+1]) {
            if (up_flg) {
                up_flg = false;
                ++ans;
            }
            else if (!dn_flg) {
                dn_flg = true;
            } 
        }
        //cout << i << " " << ans << " " << dn_flg <<" " << up_flg << endl;
    }
    cout << ans << endl;
    return 0;
}


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

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

int main(){
    int n,ans=0;
    cin>>n;
    for(int j=1;j<=n;j+=2){
        vector<int> f(j+1,0);
        int tmp=j;
        for(int i=2;i<=tmp;i++){
           while(tmp%i==0){
                f[i]++;
                tmp/=i;
            }
        }
        int sum=1;
        for(int i=0;i<=j;i++){
            sum*=(f[i]+1);
        }
        if(sum==8){
            ans++;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n;
    int total;
    total=0;
    cin >> n;
    int arr[n];
    for (int i=0; i<n;i++) {
        cin >> arr[i];
    }
    for ( int x=0;x<n;x++){
        bool ishighest = true;
      for (int y=0;y<x;y++){
          if(arr[x]<arr[y]){
              ishighest = false;
              break;
          }
      }
      if (ishighest) total ++;
    }
    cout << total;
}



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

using namespace std;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) ans++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	int t = 1;
	// cin >> t;
	while(t--) {
		string s;
		cin >> s;
		int n = s.size();
		if(s[n - 1] == 's') s += "es";
		else s += 's';
		cout << s << endl;
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int m = n - k + 1;
  double ans = 0.0;
  rep(i, k) ans += ((double)p[i] + 1) / 2;
  double now = ans;
  for(int i = 0; i + k < n; i++) {
    now += ((double)p[i + k] + 1) / 2;
    now -= ((double)p[i] + 1) / 2;
    ans = max(ans, now);
    dbg(i);
    dbg(i + k);
    dbg(ans);
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
int LCS(string,string);
int dp[3001][3001];
vector<char> ans;
 
signed main(){
    fast
 
    string s,t;
    cin>>s>>t;
    LCS(s,t);
    for(auto x:ans) cout<<x;
}
 
int LCS(string s,string t){
    f1(i,0,s.size())
        f1(j,0,t.size()){
            if(i==0||j==0){
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    
    int i=s.size(),j=t.size();
    while(i!=0&&j!=0){
        if(s[i-1]==t[j-1]){
            ans.pb(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    reverse(ans.begin(),ans.end());
    return dp[s.size()][t.size()];
}

Measured memory_bytes: 73988
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
const int INF = 1e5 + 7;
const int MAX = 1e2 + 7;
const int MOD = 1e9 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

int w[MAX] = {0}, v[MAX] = {0};
vvi f(MAX, vi(INF, ((int) (1e15))));
int N, W;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> W;

    int sum = 0;
    for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];

    f[0][0] = 0;
    for (int i = 1; i <= N; i++)
    {
        for (int k = 0; k <= sum; k++)
        {
            f[i][k] = min(f[i][k], f[i - 1][k]);
            f[i][k + v[i]] = min(f[i][k + v[i]], f[i - 1][k] + w[i]);
        }
        sum += v[i];
    }

    for (int i = sum; i >= 0; i--)
    {
        if (f[N][i] <= W)
        {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 84992
n,m,c = map(int,input().split())
b = list(map(int,input().split()))

ans =0

for i in range(n):
    a = list(map(int,input().split()))
    t = 0
    for k in range(m):
        t += b[k]*a[k]
    if t+c>0:
        ans += 1

print(ans)


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }

    vector<int> d(10, 1000000000);
    vector<int> p{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    do {
        int t = 0;
        int idx = 0;
        while (p[idx] != 1) {
            idx++;
            t += c[p[idx - 1]][p[idx]];
        }
        d[p[0]] = min(d[p[0]], t);
    } while (next_permutation(ALL(p)));

    int m = 0;
    int a;
    for (int i = 0; i < h * w; i++) {
        cin >> a;
        m += d[a];
    }
    cout << m << endl;
}


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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

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

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

namespace math {
    long long pow_mod(long long a, long long b, long long M);

    long long nCk(long long n, long long k, long long M) {
        long long ret = 1;
        int _min = std::min(k, n-k);

        for(int i=1;i<=_min;i++) {
            ret = (ret * pow_mod(i, M-2, M)) % M;
        }
        for(int i=n-_min+1;i<=n;i++) {
            ret = (ret * i) % M;
        }

        return (long long) ret;
    }

    long long pow_mod(long long a, long long b, long long M) {
        long long ret = 1;
        long long tmp = a;

        while(b>0) {
            if((b&1)==1) ret = (ret * tmp) % M;
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }

        return ret;
    }

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

signed main() {
    int x, y;
    cin >> x >> y;

    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int a = (-x + 2 * y) / 3;
    int b = ( 2 * x - y) / 3;

    if (a < 0 || b < 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = math::nCk(a+b, a, MOD);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 500005;
const int mod = 1e9 + 7;
int main() {
    LL a,b,c;
    cin>>a>>b>>c;
    if ((a&1) && (b&1) && (c&1)) {
        LL ans = min(a*b, min(b*c,c*a));
        cout<<ans<<endl;
    } else cout<<"0"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int a,b,c,r,s,t,d,x=0,u;
    scanf("%d%d%d%d", &a,&b,&c,&d);
    r=abs(a-b);
    s=abs(b-c);
    u=abs(a-c);
    if(r<=d&&s<=d)
        x=1;
    else if(u<=d)
        x=1;
    if(x==1)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

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

  double t,x;cin>>t>>x;
  cout<<t/x<<endl;

  return 0;
}


Measured memory_bytes: 256
def solve(n, k, t)
  return 1 if n == 0
  return 0 if k == 0
  ret = 0
  t.downto(t/k) do |x|
    ret += solve(v = n - x * x, k - 1, @cmp[x][v])
  end
  ret
end

@cmp = (0..Math.sqrt(2**15).to_i).map{ |i| (0..2**15).map{ |j| i * i > j ? Math.sqrt(j).to_i : i } }

while n = gets.to_i
  break if n == 0
  puts solve(n, 4, Math.sqrt(n).to_i)
end

Measured memory_bytes: 56112
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int k,n;
 	string s;
 	string s1("...");
 	cin>>k;
 	cin>>s;
 	n=s.length();
 	if(k<n)
 	{
 		s.resize(k);
 		s.append(s1);
	 }
 	cout<<s<<endl;
 	return 0;
 }

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

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

const ll mod = 1000000007;


map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value,vector<ll> a)
{
	
	for (ll i = 0; i < a.size();i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}
ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}
//E869120 
void comb(vector<vector <long long int> >& v) {
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}


int main() {
 ll n,v;
 cin>>n;
 vector<pair<ll,ll>> od(1e6),ev(1e6);
 rep(i,n){
   cin>>v;
   if(i%2){
     ev[v].first++;
     ev[v].second=v;
   }else{
    od[v].first++;
    od[v].second=v;
   }
 }
 sort(rall(ev));sort(rall(od));
 if(od[0].second!=ev[0].second)cout<<n-od[0].first-ev[0].first<<endl;
 else cout<<min(n-od[1].first-ev[0].first,n-od[0].first-ev[1].first);
	return 0;
}













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

public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), m = fs.nextInt();
		int P[] = new int[m];
		String[] S = new String[m];
		for(int i=0;i<m;i++) {
			P[i] = fs.nextInt() - 1;
			S[i] = fs.next();
		}
		int ac[] = new int[n];
		int wa[] = new int[n];
		for(int i=0;i<m;i++) {
			int p = P[i];
			String s = S[i];
			if("AC".equals(s)){
				ac[p]=1;
			}
			else {
				if(ac[p]!=1) {
					wa[p]++;
				}
			}
		}
		
		int ansac = 0;
		int answa = 0;
		for(int i=0;i<n;i++) {
			if(ac[i]==1) {
				ansac++;
				answa += wa[i];
			}
		}
		System.out.println(ansac + " " + answa);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 46724
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(K: int, N: int, A: "List[int]"):
    lmax=0
    A.append(K+A[0])
    for i in range(N):
        lmax=max(lmax, A[i+1]-A[i])
    print(K-lmax)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(K, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27056
//K.Chaitanya
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//std::ios::sync_with_stdio(false);
int main(){
    std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n,m,x;
	cin>>n>>m>>x;
	int a[m];
	for(int i=0;i<m;i++) cin>>a[i];
	int idx=lower_bound(a,a+m,x)-a;
	int c=0;
	if(a[m-1]!=n) c=1;
	int mini=min(idx,m-idx-1+c);
	cout<<mini<<endl;
	return 0;
}
































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

int main(){
	int a,b;
	cin>>a>>b;
	vector<int> d(a),mn(b),mx(b),ha(b);
	for(int i=0; i<a; i++) cin>>d[i];
	for(int i=0; i<b; i++) cin>>mn[i]>>mx[i]>>ha[i];
	vector<vector<int>> dp(a,vector<int>(b,0));
	for(int i=0; i<b; i++){
		if(mn[i] > d[0] || d[0] > mx[i]){
			dp[0][i] = -INT_MAX;
		}
	}
	for(int i=1; i<a; i++){
		for(int j=0; j<b; j++){
			if(mn[j] <= d[i] && d[i] <= mx[j]){
				for(int k=0; k<b; k++){
					dp[i][j] = max(dp[i][j], dp[i-1][k] + abs(ha[j] - ha[k]));
				}
			}else{
				dp[i][j] = -INT_MAX;
			}
		}
	}
	int ans = -INT_MAX;
	for(int x : dp[a-1]){
		ans = max(ans,x);
	}
	cout<<ans<<endl;
}

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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string N, temp;
    int ans = 0;
    cin >> N;
    for (int i = 1; i <= stoi(N); i++) {
        temp = to_string(i);
        if (temp.length() % 2 == 1) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e5+10, mod = 2e9+10;

void solve() {
    int n; cin >> n;

    int a[n], m = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = 0; i < n; ++i) {
        m ^= a[i];
    }

    for (int i = 0; i < n; ++i) {
        a[i] ^= m;
        cout << a[i] << endl;
    }

}

int main(void) {
    int t = 1; //cin >> t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 4364
#include <iostream>

int main()
{
	int N, M;
	int X, Y;
	int x[110];
	int y[110];
	std::string res = "No War";

	std::cin >> N >> M >> X >> Y;
	for (int i = 0; i < N; i++)
	{
		std::cin >> x[i];
	}
	for (int j = 0; j < M; j++)
	{
		std::cin >> y[j];
	}

	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (x[i] >= y[j] || x[i]>=Y)
			{
				res = "War";
				std::cout << res.c_str() << std::endl;
				return 0;
			}
		}
	}
	for (int j = 0; j < M; j++)
	{
		if (X >=y[j] || X >= Y)
		{
			res = "War";
			std::cout << res.c_str() << std::endl;
			return 0;
		}
	}
	
	std::cout << res.c_str() << std::endl;
	return 0;

}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	#A:0 G:1 C:2 T:3
	DP = [[0] * 64 for i in range(N)]
	for i in range(64):
		DP[2][i] = 1
	DP[2][6] = 0
	DP[2][9] = 0
	DP[2][18] = 0

	for p in range(2, N - 1):
		for i in range(4):
			for j in range(4):
				for k in range(4):
					for s in range(4):
						if not ((i == 0 and k == 1 and s == 2) or (i == 0 and j == 1 and s == 2)):
							DP[p + 1][16 * j + 4 * k + s] += DP[p][16 * i + 4 * j + k]
							DP[p + 1][16 * j + 4 * k + s] %= con

		DP[p + 1][6] = 0
		DP[p + 1][9] = 0
		DP[p + 1][18] = 0

	ans = sum(DP[N - 1])
	print(ans % con)


if __name__ == '__main__':
	main()

Measured memory_bytes: 41584
n=int(input())
lista=[]
list1=[1,2,3,4,5,6,7,8,9]

list2=list(map(lambda x:x*2,list1))
list3=list(map(lambda x:x*3,list1))
list4=list(map(lambda x:x*4,list1))
list5=list(map(lambda x:x*5,list1))
list6=list(map(lambda x:x*6,list1))
list7=list(map(lambda x:x*7,list1))
list8=list(map(lambda x:x*8,list1))
list9=list(map(lambda x:x*9,list1))

lista.append(list1)
lista.append(list2)
lista.append(list3)
lista.append(list4)
lista.append(list5)
lista.append(list6)
lista.append(list7)
lista.append(list8)
lista.append(list9)

ans="No"

for i in range(9):
	for j in range(9):
		if lista[i][j]==n:
			ans="Yes"
			
		
		
print(ans)
			


Measured memory_bytes: 38484
#include<cstdio>
#include<algorithm>
using namespace std;

const int Maxn=1e5;

int N,X;
int t[Maxn+5];

inline int abs(int x) {
	return x<0?-x:x;
}

int GCD(int a,int b) {
	if(b==0)return a;
	return GCD(b,a%b);
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	scanf("%d %d",&N,&X);
	for(int i=1;i<=N;i++) {
		int tmp;
		scanf("%d",&tmp);
		t[i]=abs(tmp-X);
	}
	int ans=GCD(t[1],t[2]);
	for(int i=3;i<=N;i++)
		ans=GCD(ans,t[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
    ll gcd(ll a, ll b) {
        return (a == 0 ? b : gcd(b % a, a));
    }
    ll gcdex(ll a, ll b, ll& x, ll& y) {
        if (a == 0) {
            x = 0; y = 1;
            return b;
        }
        ll x1, y1;
        ll d = gcdex(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return d;
    }

    ll inv_eu(ll a, ll m) {
        ll x, y;
        ll g = gcdex(a, m, x, y);
        if (g != 1)
            assert(0);
        else {
            x = (x % m + m) % m;
            return x;
        }
    }
}

ll const maxn = 3e5 + 5;

ll dp[2005];

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

    ll x; cin >> x; cout << (1 ^ x) << endl;

    return 0;
}

/*

*/


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = max((a),(b))
#define chmin(a, b) a = min((a),(b))
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000
 
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
 
int main() {
    int n;
    cin>>n;
    vint a(n);
    vint check(n);
    rep(i,n)cin>>a[i];
    vint table;

    rep(i,n){
        if(table.size()>=1){
            if(a[i]<=*(table.begin())){
                table.insert(table.begin(),a[i]);
            }
            else{
                auto iter=lower_bound(all(table),a[i]);
                //cout<<iter-table.begin()<<endl;
                if(iter==table.end()){
                    *(table.end()-1)=a[i];
                }
                else{
                    *(iter-1)=a[i];
                }
                /* 
                int start=0;
                int end=table.size();
                while(true){
                    int middle=(start+end)/2;
                    if(table[middle]<a[i]){
                        start=middle;
                    }
                    else{
                        end=middle+1;
                    }
                    if(end-start<=1){
                        break;
                    }
                    //cout<<start<<" "<<end<<endl;
                }
                */
            }
        }
        else{
            table.insert(table.begin(),a[i]);
        }



    }
    //rep(i,table.size())cout<<table[i]<<endl;
    cout<<table.size()<<endl;
}

Measured memory_bytes: 1660