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

using namespace std;
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define sz(a) (int)(a).size()
#define rep(i, a, b) for (int i = (a), _b = (b); i < _b; ++i)
#define frep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)

typedef complex<ld> cplex;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int inf = 1000000007;
const ll linf  = 1ll * inf * inf;
const int N = 200000 + 7;
const int M = 31;
const int multipleTest = 0;



string s;
int n;
int dp[N];

vi need;

int L[1 << 26];

int calc() {
    rep(i, 1, n + 1) {
        int c = s[i - 1] - 'a';
        dp[i] = dp[i - 1] ^ (1 << c);
    }
    if (!dp[n]) return 1;
    rep(mask, 1, 1 << 26) L[mask] = inf;
    L[0] = 0;
    rep(i, 1, n + 1) {
        rep(j, 0, 26) {
            L[dp[i]] = min(L[dp[i]], L[dp[i] ^ (1 << j)] + 1);
        }
    }
    return L[dp[n]];
}

void solve() {
    cin >> s; n = sz(s);
    
    int res = calc();
    cout << res;
    
}

int main() {
#ifdef _LOCAL_
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    int Test = 1;
    if (multipleTest) {
        cin >> Test;
    }
    for(int i = 0; i < Test; ++i) {
//        printf("Case #%d: ", i + 1);
        solve();
    }
#ifdef _LOCAL_
    cout<<"\n" << 1.0 * clock() / CLOCKS_PER_SEC <<endl;
#endif
}


Measured memory_bytes: 263428
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,sum=0;
    cin>>n>>k;
    int a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<k;i++)
    sum+=a[i];
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3584
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if (a[i][j]=="."):
            a[i][j] = 0
xx = [-1,-1,-1,0,0,1,1,1]
yy = [-1,0,1,-1,1,-1,0,1]
for i in range(h):
    for j in range(w):
        if (a[i][j] =="#"):
            continue
        for k in range(8):
            x = i+xx[k]
            y = j+yy[k]
            if (0<=x and x<h and 0<=y and y<w):
                if (a[x][y]=="#"):
                    a[i][j] += 1
for i in range(h):
    for j in range(w):
        if (a[i][j]!="#"):
            a[i][j] = str(a[i][j])
for i in range(h):
    print(''.join(a[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll k, n ;cin>>k>>n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll mxm = a.at(0) + (k-a.at(n-1));
    for(int i=1;i<n;i++){
        mxm = max(mxm,a.at(i) - a.at(i-1));
    }
    cout << k - mxm << endl;
    }

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    unsigned long X,Y,A,R;
    cin >> X >> Y;
    A = X;
    R = 0;
    
    while(A >= X && A <= Y){
        R++;
        A *= 2;
    }
    
    cout << R;
}


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

int main() {
  int n, d;
  cin>>n>>d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n) {
    rep(j,d) cin >> x[i][j];
  }
  int ans = 0;
  rep(i,n)rep(j,i) { // j < i
    int sq = 0;
    rep(k,d) {
      int s = x[i][k]-x[j][k];
      sq += s*s;
    }
    int s = sqrt(sq);
    if (s*s == sq) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int len=s.size();
	int flag=0;
	for(int i=0;i<len;i++){
//		cout<<i%2<<" "<<s[i]<<endl;
		if(i%2==0) {
			if(s[i]!='R' && s[i]!='U' && s[i]!='D'){
				flag=1;
//				cout<<i<<s[i]<<endl;
//				break;
			}
		}
		else{
			if(s[i]!='L' && s[i]!='U' && s[i]!='D'){
				flag=1;
//				cout<<i<<s[i]<<endl;
//				break;
			}
		}
					
	}
	printf("%s\n",flag?"No":"Yes");
	return 0;
} 

Measured memory_bytes: 256
N,T=map(int,input().split())
c,t=[],[]
for i in range(N):
  a,b=map(int,input().split())
  c.append(a)
  t.append(b)
if min(t)>T:
  print("TLE")
else:
  for i in range(N):
    if t[c.index(min(c))]>T:
      c[c.index(min(c))]=1001
    else:
      print(min(c))
      break

Measured memory_bytes: 3064
while True:
    H,W = [int(i) for i in input().split()]
    if H == 0 and W == 0:
        break
    for x in range(0,H):
        if x % 2 == 0:
            for y in range(0,W):
                if y % 2 == 0:
                    print("#",end="")
                else:
                    print(".",end="")
            print()
        else:
            for y in range(0,W):
                if y % 2 == 0:
                    print(".",end="")
                else:
                    print("#",end="")
            print()
    print()


Measured memory_bytes: 7012
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    double x1 = sc.nextDouble();
    double y1 = sc.nextDouble();
    double x2 = sc.nextDouble();
    double y2 = sc.nextDouble();
    double answer1 = Math.pow(x2-x1,2) + Math.pow(y2-y1,2);
    double answer2 = Math.sqrt(answer1);
    System.out.println(answer2);
  }
}


Measured memory_bytes: 27988
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int arr[4],n=3,ans=0,cnt=0,tt,uu,mm,nn;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ans=(arr[2]-arr[0]);
     cnt=(arr[2]-arr[1]);
     if((ans+cnt)%2==0)
     {
         cout<<(ans+cnt)/2<<endl;
         return 0;
     }
     else
     {
     /* if((ans%2==0)&&(cnt%2!=0))
      {
          tt=ans/2;
          mm=cnt/2;
          uu=cnt%2;
          cout<<tt+mm+uu<<endl;
      }
       else if((ans%2!=0)&&(cnt%2==0))
       {
           tt=cnt/2;
           mm=ans/2;
           uu=
       }
       {

       }*/
     tt=ans/2;
     mm=cnt/2;
        cout<<tt+mm+2<<endl;
     }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  int n = a.size();
  int ans = 0;
  REP(i, n/2){
    if(a[i] != a[n - i - 1]){
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque

n = int(input())
a = list(map(int, input().split()))

if n == 2:
    print(max(a))
    exit()

a.sort(reverse=True)

d = deque([a[1]]*2)

ans = a[0]
for i in a[2:]:
    d.append(i)
    d.append(i)
    ans += d.popleft()

print(ans)


Measured memory_bytes: 33264
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin>>N;
    vector<int> t(N+1), x(N+1), y(N+1);
    for(int i=0; i<N; i++) cin>>t[i+1]>>x[i+1]>>y[i+1];

    bool can=true;
    for(int i=0; i<N; i++) {
        int elapse=t[i+1]-t[i];
        int x_dist=abs(x[i+1]-x[i]);
        int y_dist=abs(y[i+1]-y[i]);
        int dist=x_dist+y_dist;

        if(elapse<dist) can=false; 
        if(dist%2!=elapse%2) can=false;
    }
    
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1408
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            string ans = str[1] + str[0];
            Console.WriteLine(ans);
        }
       
    }
}
/*
long a, b, c;
a = long.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = long.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
Member = ReadLine().Split(' ').Select(long.Parse).ToArray();

string[] str = Console.ReadLine().Split(' ');
long[] a = new long[N];
for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]);
 */
/*
      static long func(long n)
      {
          long d = 0;
          for (long i = 0; i < 10; i++)
          {
              if (n / longPow(10, i) == 0)
              {
                  d = i;
                  break;
              }
          }
          long ret = A * n + B * d;
          return ret;
      }
      static long longPow(long a, long n)
      {
          long b = 1;
          for (long i = 0; i < n; i++) b = b * a;
          return b;
      }
      */


Measured memory_bytes: 11092
from math import sqrt

def factorization(n):
    l = set()
    for i in range(1, int(sqrt(n))+1):
        if not n % i:
            l.add(i)
            l.add(n//i)
    return l

N, M = map(int, input().split())
f = factorization(M)
ans = 1
for i in f:
    if (M / i) >= N:
        ans = max(i, ans)
print(ans)


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

typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mkmap;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vv;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
const ll mod=1000000007;
const int sz=1000001;
#define endl "\n"
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(i=a;i<b;++i)
#define rrep(i,a,b) for(i=a;i>=b;--i)
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db(x) cout << (#x) << " = " << x << endl;

inline ll mult(ll a, ll b) {return (((a % mod) * (b % mod)) % mod);}

int dp[100001];

int fun(vi &a,int i){
    if(i>=a.size()-1) return 0;
    if(dp[i]!=-1) return dp[i];
    if(i==a.size()-2) return dp[i]=abs(a[i]-a[i+1]);
    return dp[i]=min(abs(a[i]-a[i+1])+fun(a,i+1), abs(a[i]-a[i+2])+fun(a,i+2));
}

int main(){
    fast;
    int i,n;
    cin>>n;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    memset(dp,-1,sizeof(int)*(n+1));
    cout<<fun(a,0)<<endl;
    // rep(i,0,n) cout<<dp[i]<<" ";
}

/*
    
*/

Measured memory_bytes: 4224
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		execute3();
	}
	
	private static void execute3() {
		try (Scanner sc = new Scanner(System.in)) {
			int M = sc.nextInt();
			int N = sc.nextInt();
			
			int[] tryN = new int[M];
			boolean[] ac = new boolean[M];
			for(int j=0;j<M;j++) {
				tryN[j]=0;
				ac[j]=false;
			}
			
			for(int i=0;i<N;i++) {
				int p = sc.nextInt()-1;
				String r = sc.next();
				if(r.equals("AC")) {
					if(!ac[p]) {
						ac[p]=true;
					}
				} else {
					if(!ac[p]) {
						tryN[p]++;
					}
				}
				
			}
			
			int ansAc=0;
			int wa=0;
			for(int i=0;i<M;i++) {
				if(ac[i]) {
					ansAc++;
					wa+=tryN[i];
				}
			}
			System.out.println(ansAc+" "+wa);
		}
	}
}

Measured memory_bytes: 64316
#include<iostream>
#include<cmath>
using namespace std;
int p_MAX = 1100000;
int prime[1100000];
int num_prime;
// エラトステネスの篩
int calc_prime()
{
  bool notPrime[p_MAX];
  int n = sqrt(p_MAX)+1;
  notPrime[0]=1;
  notPrime[1]=1;
  for(int i=0;i<=n;i++){
    if(notPrime[i])
      continue;
    int m = p_MAX/i;
    for(int j=2;j<=m;j++)
      notPrime[j*i]=1;
  }
  num_prime = 0;
  for(int i=0;i<p_MAX;i++)
    if(!notPrime[i]){
      prime[num_prime] = i;
      num_prime++;
    }
  return 0;
}
// 互除法
long long gcd(long long m, long long n)
{
  while (m>0&&n>0){
    n = n % m;
    if (n>0)
      m = m % n;
  }
  if (n==0)
    return m;
  else
    return n;
}
int main()
{
  long long a,b,n,i,res=1;
  cin >> a >> b;
  calc_prime();
  for(i=0;i<num_prime;i++){
    if(a<prime[i]||b<prime[i]){
      cout << res << endl;
      return 0;
    }
    if(a%prime[i]==0&&b%prime[i]==0)
      res++;
    while(a%prime[i]==0)
      a/=prime[i];
    while(b%prime[i]==0)
      b/=prime[i];
  }
  n=gcd(a,b);
  if(n>prime[num_prime-1]) res++;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABiscuits solver = new ABiscuits();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABiscuits {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), p = in.ints();
            int f = 0;
            for (int i = 0; i < n; i++) {
                f |= in.ints() & 1;
            }
            if (f == 1) {
                out.println(1L << (n - 1));
            } else if (p == 0) {
                out.println(1L << n);
            } else {
                out.println(0);
            }
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

using namespace std;

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

int main(){
    int N;
    cin >> N;
    int A[N];
    int L[N];
    int R[N];
    int ans = 0;
    L[0] = R[N+1] = 0;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        
    }

    for(int i = 1; i <= N; i++){
        L[i] = gcd(L[i-1],A[i]);
    }
    for(int i = N; 1 <= i; i--){
        R[i] = gcd(R[i+1],A[i]);
    }
    for(int i = 1; i <= N; i++){
        ans = max(ans,gcd(L[i-1],R[i+1]));
    }

    cout << ans << endl;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n % 2) cout << "No" << endl;
    else{
        if(s.substr(0, n / 2) == s.substr(n / 2)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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

int main(){
  string S;
  cin >> S;
  int L = S.size();
  string ans;
  for(int i=0; i<(L+1)/2; i++){
    ans+= S.at(i*2);
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B);
  if (A == 1) {
    A = 14;
  }
  if (B == 1) {
    B = 14;
  }
  print(A == B ? "Draw" : A > B ? "Alice" : "Bob");
}


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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n; cin >> n;
    cout << (n+1)/2 << endl;

    return 0;
}


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

int main() {
  int N, M;
  int c = 0;
  cin >> N >> M;
  if(N > 1){
    c = N * (N - 1) / 2;
  }
  if(M > 1){
    c += M * (M - 1) / 2;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		String s = in.next();
		int n = s.length();
		long ans = 0;
		for (int i=0; i<1<<(n-1); i++) {
			long tmp = 0;
			int idx = 0;
			for (int j=1; j<n; j++) {
				if ((i>>(j-1)&1) == 1) {
					tmp += Long.parseLong(s.substring(idx, j));
					idx = j;
				}
			}
			tmp += Long.parseLong(s.substring(idx, n));
			ans += tmp;
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 10324
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int ans, n, a[101], money[101],t;

int main() {
	cin >> n;
	ans = 1e9;
	for (int i = 0; i < n; ++i)
		scanf("%d", &a[i]);
	for(int i=0;i<n-1;++i)
		for (int j = 0; j < n - 1 - i; ++j) {
			if (a[j] > a[j + 1]) {
				int t = a[j];
				a[j] = a[j + 1];
				a[j + 1] = t;
			}
		}
	for (int i = a[0]; i <=a[n - 1]; ++i) {
		for (int j = 0; j < n; ++j)
			money[t] += (i - a[j]) * (i - a[j]);
		t++;
	}
	for (int i = 0; i < t; ++i)
		if(ans>money[i])
            ans=money[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	while(cin >> n , n){
		int need , ans = 0;
		vector<int> d(n);
		rep(i,n) cin >> d[i];
		
		cin >> need;
		int l = 0 , r = n-1 , m;
		do{
			ans++;
			m = (l+r)/2;
			if(d[m] > need) r = m-1;
			else if(d[m] < need) l = m+1;
		}while(need != d[m] && m != r && m != l);
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        a = []
        if n % i == 0:
            a.append(i)
            # divisors.append(i)
            if i != n // i:
                a.append(n//i)
                # divisors.append(n//i)
            else:
                a.append(i)
        divisors.append(a)

    # divisors.sort()
    return divisors

n = int(input())
divisors = make_divisors(n)
min = 10 ** 12
for i in divisors:
    if i:
        if sum(i) < min:
            min = sum(i)

print(min-2)


Measured memory_bytes: 111300
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)4e6 + 123;

int fact[N];

int mult(int a, int b)
{
	return 1ll * a * b % mod;
}

int add(int a, int b)
{
	a += b;
	if(a < 0) a += mod;
	if(a >= mod) a %= mod;
	return a;
}

int Binpow(int a, int n)
{
	if(!n) return 1;
	if(n & 1) return mult(Binpow(a, n - 1), a);
	else
	{
		int b = Binpow(a, n / 2);
		return mult(b, b);
	}
}

int C(int n, int k)       
{
	if(k > n) return 0;
	int up = fact[n];
	int down = mult(fact[k], fact[n - k]);
	return mult(up, Binpow(down, mod - 2));
}

int Get(int n, int k, int z)
{
	int all = C(n + z + 1, z + k);
	int pre = C(n, k - 1);
	return add(all, -pre);
}

int r1, r2, c1, c2;
int ans;
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif	
	Fast_Read_Out();
	Random();   
	fact[0] = 1;
	for(int i = 1; i <= 3000000; i++) fact[i] = mult(fact[i - 1], i);
	cin >> r1 >> c1 >> r2 >> c2;
	for(int i = r1; i <= r2; i++) ans = add(Get(i + c1, c1, c2 - c1), ans);
	cout << ans;
}                                

Measured memory_bytes: 12544
# -*- coding:utf-8 -*-

#datas = [1 5 2 6 3 7 8 9 10 4]
#datas = [1 4 2 6 5 3 7 8 9 10]

def dfs(datas, b, c, count):
    if len(datas) == count: return 1
    if int(datas[count]) > b:
        return dfs(datas, int(datas[count]), c, count+1)
    if int(datas[count]) > c:
        return dfs(datas, b, int(datas[count]), count+1)
    return 0

def solve():
    b=0
    c=0
    count = 1
    q = dfs(datas, b, c, count)
    print("YES") if q==1 else print("NO")

counter = 0
while True:
    line = input()
    if not " " in line:
        nums = line
    else:
        datas = line.split(" ")
        q = solve()
        counter += 1
    if int(nums) == counter:
        break

Measured memory_bytes: 7536
#include<iostream>
#include<cstdio>
#include<algorithm>
using std::min;
const int MAXN=5e5+5;
 
int n,D,Q;
int d[MAXN],q[MAXN];
 
int f[MAXN],g[MAXN];
 
int main()
{
	int i;scanf("%d%d",&n,&D);
	for(i=1;i<=n;i++) scanf("%d",d+i);
	scanf("%d",&Q);
	for(i=1;i<=Q;i++) scanf("%d",q+i);
 
	f[1]=D;for(i=2;i<=n;i++) f[i]=min(f[i-1],abs(f[i-1]-d[i-1]));
	g[n]=1;for(i=n-1;i;i--) g[i]=g[i+1]+(d[i+1]<2*g[i+1]?d[i+1]:0);
	for(i=1;i<=Q;i++) puts(f[q[i]]>=g[q[i]]?"YES":"NO");
	return 0;
}

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

using namespace std;
long long dp[1<<15];
const int N = 1e6+100;
long long a[N],b[N],c[N];
int main(){
    int n,m,x;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>a[i]>>b[i];
        c[i]=0;
        for(int j=1;j<=b[i];j++){
            cin>>x;
            c[i]+=(1<<(x-1));
        }
    }
    long long s=(1<<(n))-1;
    //cout<<s<<endl;
    memset(dp,0x3f,sizeof(dp));
    dp[0]=0;
    for(int i=0;i<=s;i++){
        for(int j=1;j<=m;j++){
            dp[i|c[j]]=min(dp[i|c[j]],dp[i]+a[j]);
        }
    }
    if(dp[s]==4557430888798830399LL) puts("-1");
    else cout<<dp[s]<<endl;
    return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll R,C,k;
  cin>>R>>C>>k;
  vll r(k),c(k),v(k);
  map<pll,ll> p;
  rep(i,k){
    cin>>r[i]>>c[i]>>v[i];
    p[pll(r[i]-1,c[i]-1)]=v[i];
  }
  vector<vector<vector<ll>>> dp(3005,vector<vector<ll>>(3005,vector<ll>(4,-1)));
  dp[0][0][0]=0;
  rep(i,R)rep(j,C){
    if(p.count(pll(i,j))){
      vll f(3);
      rep(u,3){
        if(dp[i][j][u]==-1){
          f[u]=-1;
          continue;
        }
        f[u]=dp[i][j][u]+p[pll(i,j)];
      }
      rep(u,3){
        chmax(dp[i][j][u+1],f[u]);
      }
    }
    rep(z,4){
    if(dp[i][j][z]==-1) continue;
    if(z==3){
      chmax(dp[i+1][j][0],dp[i][j][z]);
      chmax(dp[i][j+1][z],dp[i][j][z]);
      continue;
    }
    chmax(dp[i+1][j][0],dp[i][j][z]);
    chmax(dp[i][j+1][z],dp[i][j][z]);
    }
  }
  ll ans=0;
  rep(i,4){
    ans=max(ans,dp[R-1][C-1][i]);
  }
  COUT(ans);
  
}

Measured memory_bytes: 655592
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define mod 998244353
using namespace std;
void solve()
{
	string s;
	cin >> s;
	if(s[2]!=s[3] || s[4]!=s[5])
		cout << "No";
	else cout <<"Yes";
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<double> a(N);
  for (int i=0; i<N; i++) cin >> a[i];
  int ave1 = floor(accumulate(a.begin(), a.end(), 0.0)/N);
  int ave2 = ceil(accumulate(a.begin(), a.end(), 0.0)/N);
  int cost1=0, cost2=0;
  for (int i=0; i<N; i++) {
    cost1 += (a[i]-ave1)*(a[i]-ave1);
    cost2 += (a[i]-ave2)*(a[i]-ave2);
  }
  cout << min(cost1, cost2) << endl;
}

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

int main(){
	double n,exc=1;
	int t;
	vector <int> x,y;
	double route=0;
	cin>>n;
	for(int i=n;i>0;i--){
		exc*=i;
	}
	for(int i=0;i<n;i++){
		cin>>t;
		x.push_back(t);
		cin>>t;
		y.push_back(t);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			route+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	cout<<setprecision(30)<<route*(n-1)/(n*(n-1)/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

ll N;
int A[SIZE];
int max_digit = 19;
int POW[20],table[SIZE][20],work[20];

bool isOK(){

	for(int i = 0; i <= max_digit; i++){

		if(work[i] >= 2)return false;
	}
	return true;
}


int main(){

	scanf("%lld",&N);

	for(ll i = 1; i <= N; i++){

		scanf("%d",&A[i]);
	}

	POW[0] = 1;
	for(int i = 1; i <= max_digit; i++){

		POW[i] = POW[i-1]*2;
	}


	for(int k = 0; k <= max_digit; k++){

		table[0][k] = 0;
	}

	for(ll i = 1; i <= N; i++){

		for(int k = 0; k <= max_digit; k++){

			table[i][k] = table[i-1][k];
			if(A[i]&POW[k]){

				table[i][k]++;
			}
		}
	}

	ll ans = 0;

	ll left,right,mid,R;

	for(ll L = 1; L <= N; L++){

		left = L,right=N,mid=(left+right)/2;
		R = -1;

		while(left <= right){

			for(int i = 0; i <= max_digit; i++){

				work[i] = table[mid][i]-table[L-1][i];
			}

			if(isOK()){

				R = mid;
				left = mid+1;
			}else{

				right = mid-1;
			}
			mid = (left+right)/2;
		}

		if(R == -1)continue;

		ans += (R-L+1);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 20232
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m];
    int b[m];
    int c[n];
    
    for(int i=0;i<n;i++){
        c[i] = 0;
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            c[i] = c[i] + a[i][j] * b[j];
        }
        cout << c[i] <<endl;
    }
}

Measured memory_bytes: 1200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
int dp[2005][2005]={};
bool comp(const pair<int,int> &p1,const pair<int,int> &p2)
{
    return p1.F>p2.F;
}

void solve()
{
    int n;cin>>n;
    vector<pair<int,int>> v;
    v.push_back({1e9+5,1e9+5});
    for(int i=1;i<=n;i++)
    {
        int x;cin>>x;
        v.push_back({x,i});
    }
    sort(v.begin()+1,v.begin()+n+1,comp);
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<i;j++)
        {
            int L=j;int R=i-j-1;
            dp[L+1][R]=max(dp[L+1][R],dp[L][R]+v[i].F*abs(v[i].S-(L+1)));
            R=j,L=i-j-1;
            dp[L][R+1]=max(dp[L][R+1],dp[L][R]+v[i].F*abs(v[i].S-(n-R)));
        }
    }
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        ans=max(ans,dp[i][n-i]);
    }
    cout<<ans<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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


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


int main()
{
    
    int n;
    cin>>n;
    bool flag=0;
    int c=0;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            c++;
        }
        else
        {
            c=0;
        }
        if(c>=3)
        {
            flag=1;
        }
        
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    

    return 0;
}

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

int n, m, q;
vector<int> a, b, c, d;
int ans;

void dfs(vector<int> A) {
    if (A.size() == n+1) {
        int now = 0;
        rep(i,q) {
        if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
        }
        ans = max(ans, now);
        return;
    }

    A.push_back(A.back());
    while (A.back() <= m) {
        dfs(A);
        A.back()++;
    }
}

int main() {
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

long long int GCD(long long int a, long long int b) {
    if(a<b) {
        long long int tmp=a;
        a = b;
        b = tmp;
    }

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

int main() {
    int N;
    cin >> N;
    
    long long int A[N];
    long long int gcd=0;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        gcd = GCD(gcd, A[i]);
    }
    
    cout << gcd << endl;

    return 0;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int A[1000000];
int p(int A,int B){
  if(!B)return 1;
  if(B%2)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
signed main(){
  int N;
  cin>>N;
  vector<int> B(N);
  for(int &i:B){
    cin>>i;
    int n=i;
    for(int j=2;j<=n/j;j++){
      int cnt=0;
      for(;n%j==0;n/=j)cnt++;
      A[j]=max(A[j],cnt);
    }
    if(n!=1)A[n]=max(A[n],1LL);
  }
  int n=1,ans=0;
  for(int i=1;i<1000000;i++)n=n*p(i,A[i])%mod;
  for(int i:B)ans=(ans+n*p(i,mod-2)%mod)%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 7228
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 210000

#define MAX_VAL MAX

long long fac[MAX_VAL], mmi[MAX_VAL];

void factorial_mod(){
	 fac[0]=fac[1]=1;
	for(long long i = 2; i < MAX_VAL; fac[i]%=MOD,i++)
		fac[i] = fac[i-1]*(i%MOD);
}

long long power_mod(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

void exgcd(int a, int b, int &x, int &y){
	if(b == 0){
		x = 1;
		y = 0;
		return ;
	}
	exgcd(b,a%b,y,x);
	y -= a/b * x;
}

void modular_multiplicatibe_inverse(){
	int x, y;  
	exgcd(fac[MAX_VAL-1],MOD,x,y);
	mmi[MAX_VAL-1] = x;
	for(long long i = MAX_VAL-2; i >= 0; mmi[i]%=MOD,i--)
		mmi[i] = mmi[i+1]*((i+1)%MOD);
}

long long combination(long long n, long long r){
	return fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, K;
	int sum = 0;
	int com = 0;
	
	factorial_mod();
	modular_multiplicatibe_inverse();
	
	cin>>N>>M>>K;
	
	com = combination(N*M-2,K-2);
	
	// cout<<com<<endl;
	
	for(int i = 1; i <= N; i++){
		sum += com*(N-i)%MOD*M*M%MOD*i;
		sum %= MOD;
	}
	for(int i = 1; i <= M; i++){
		sum += com*(M-i)%MOD*N*N%MOD*i;
		sum %= MOD;
	}
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 3584
import copy
def exception_handling(n, ali):

    sortali = copy.copy(ali)
    sortali.sort(reverse=True)

    alimax = sortali[0]
    alimax2 = sortali[1]

    ans = []

    for i in ali:
        if i != alimax:
            ans.append(alimax)
        else:
            ans.append(alimax2)

    return ans

def main():
    n = int(input())
    ali = [int(input())for i in range(n)]
    ans = exception_handling(n, ali)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15264
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

int main(){
    ll n; cin >> n;
    auto b=v<mint>(60,0);
    auto c=v<mint>(60,n);
    
    for(ll i=1;i<=n;i++){
        ll a;cin >> a;
        for(ll j=0;a>>j;j++){
            if((a>>j)&1) {
                b[j]++;
                c[j]--;
            }
        }
    }

    mint ans = 0;
    rep(i,60){
        ans+=(b[i]*c[i])<<i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def find_parent(x):
    y=parent[x]
    if y<0:
        return x
    parent[x]=find_parent(y)
    return parent[x]

def connect(a,b):
    c=find_parent(a)
    d=find_parent(b)
    if c==d:
        return
    if parent[c]<parent[d]:
        parent[c]+=parent[d]
        parent[d]=c
    else:
        parent[d]+=parent[c]
        parent[c]=d
    return

N,M,Q=map(int,input().split())
data=[[],[]]
for i in range(Q):
    a,b,c=map(int,input().split())
    data[c].append((a,b))
    
parent=[-1]*N
for a,b in data[0]:
    connect(a,b)

cnt=0
for u in parent:
    if u<0:
        cnt+=1

for a,b in data[1]:
    if find_parent(a)==find_parent(b):
        print("No")
        sys.exit()

if M==N-1:
    if not data[1]:
        print("Yes")
    else:
        print("No")
else:
    M-=N
    if M<=cnt*(cnt-1)//2-cnt:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 19496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    string S, T; cin >> S >> T;
    string ans = "No";
    if(S == T.substr(0, S.size()) && S.size()+1 == T.size()) ans = "Yes";
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define t int t ; cin>>t; while(t--)
#define u(x,a,b) for(int x=a;x<b;x++)
#define what(x) cerr << #x << "=" << x<<endl;
#define lli long long int
#define endl "\n"
lli Mod = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	lli r;
	cin>>r;
	cout<< 3 *r*r<<endl;
    return 0;
}
                                                                                                                                 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll a, g, b;
  cin >> a >> g >> b;
  ll x = g * 10 + b;
  if(x%4==0){
    print("YES");
  }
  else{
    print("NO");
  }
}

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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	INPUT(a);
	FOR(i,n) a[i]--;

	bool p[n];
	bool c[n-1];
	INIT(p, false);
	INIT(c, false);
	FOR(i,n) {
		p[a[i]] = true;
		if (a[i] && p[a[i]-1]) c[a[i]-1] = true;
	}

	int res = 1;
	int last = 0;
	FOR(i,n-1) {
		if (!c[i]) {
			res = max(res, i-last+1);
			last = i + 1;
		}
	}
	if (last != n-1) res = max(res, n-last);
cout << n-res << endl;

    return 0;
}


Measured memory_bytes: 1408
def check(arr,x,y)
  if arr.include?(x) || arr.include?(y)
    unless arr.include?(x) && arr.include?(y)
      puts "No"
      exit
    end
  end
end
sarr=gets.chomp.split("").uniq
check(sarr,"N","S")
check(sarr,"E","W")
puts "Yes"


Measured memory_bytes: 3836
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>

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

using namespace std;



#define LOCAL 1

#define pv(val) cerr << #val << " = " << (val) << endl
#define pvn(name, val) cerr << name << " = " << (val) << endl
#define pl cerr << '@' << __LINE__ << endl

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}

template <class T, class U>
ostream& operator<<(ostream& os, pair<T, U> const& p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}

template <class T, class U>
pair<T, U> operator+(pair<T, U> const& lhs, pair<T, U> const& rhs) {
  return {lhs.first + rhs.first, lhs.second + rhs.second};
}

template <class T, class U>
pair<T, U> operator-(pair<T, U> const& lhs, pair<T, U> const& rhs) {
  return {lhs.first - rhs.first, lhs.second - rhs.second};
}

template <class T, class U>
U lowerBound(function<T(U)> f, T const& val, U l, U r) {
  while (l < r) {
    auto m = l + (r - l) / 2;
    auto fm = f(m);
    if (fm < val) {
      l = m;
    } else {
      r = m;
    }
  }
}

int main(void) {
  int64_t A, B, C, K;
  cin >> A >> B >> C >> K;

  if(abs(A - B) > 1e18) cout << "Unfair" << endl;
  else cout << ((K % 2 == 0) ? (A - B) : (B - A)) << endl;

  return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
list<int> L;
stack<int> S;
queue<int> Q;
deque<int> dq;
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
static const int MAX=100000;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int N,x;
ll sum;
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    cin>>N>>x;
    int a[2];
    a[0]=0;
    for(int i=0;i<N;i++){
        cin>>a[1];
        sum+=a[1]-min(x-a[0],a[1]);
        a[1]=min(x-a[0],a[1]);
        swap(a[0],a[1]);
    }
    cout<<sum<<"\n";
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int a, b, s;
int main() {
	cin>>a>>b;
	for(int i=a; i<=b; i++) {
		if(i/10000 == i%10 && i/1000%10 == i%100/10) s++;
	}
	cout<<s;
	return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)


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

    deque<u64> r, w;

    r.push_front(0);

    rep(i, n){
        char c;
        cin >> c;
        if(c=='R'){
            r.push_back(i+1);
        }
        else if(c=='W'){
            w.push_back(i+1);
        }
    }

    w.push_back(n+1);

    u64 ans=0;

    while(r.back() >= w.front()){
        r.pop_back();
        w.pop_front();
        ans++;
    }
    cout << ans;

  return 0;
}


Measured memory_bytes: 5264