akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
struct var
{
    int s,t,x;
};
vector<var> v;
bool cmp(var a, var b)
{
    if(a.s==b.s) return a.t<b.t;
    return a.s<b.s;
}
typedef pair<int,int> pii;
int main()
{
    //freopen("inp","r",stdin);
    //freopen("out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,q;
    cin>>n>>q;
    v.resize(n);
    for(int i=0;i<n;++i)
    {
        int x,y;
        cin>>x>>y>>v[i].x;
        v[i].s=max(x-v[i].x,0);
        v[i].t=max(y-v[i].x,0);
    }
    sort(v.begin(),v.end(),cmp);
    priority_queue< pii, vector<pii> , greater<pii> >Q;
    int j=0;
    for(int i=0;i<q;++i)
    {
        int r;
        cin>>r;
        while(j<n&&v[j].s<=r)  Q.push(make_pair(v[j].x,v[j].t)),++j;
        while(!Q.empty())
        {
            pii t=Q.top();
            if(t.second<=r)
            {
                Q.pop();
                continue;
            }
            cout<<t.first<<endl;
            break;
        }
        if(Q.empty())  cout<<"-1"<<endl;
    }
    return 0;
}


Measured memory_bytes: 5360
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        String cnt;
        
        if( a > b )cnt = "No";
        else if( a <= c && c <= b )cnt = "Yes";
        else cnt = "No";
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <vector>
#include <iterator>
using namespace std;
int main(){
	double a;
	int i=0;
	vector<double> dat;
	while(cin>>a){
		dat.push_back(a);
		i++;}
	sort(dat.begin(),dat.end());
	cout<<dat[i-1]-dat[0]<<endl;
        return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>

int main(void){

  char s[11];
  int s_end;
  char t[11];
  int t_end;
  for (int i = 0; i < 11; i++) {
    scanf("%c", &s[i]);
    if (s[i] == ' ') {
      s[i] = '\n';
      s_end = i-1;
      break;
    }
  }
  for (int i = 0; i < 11; i++) {
    scanf("%c", &t[i]);
    if (t[i] == '\n') {
      t_end = i-1;
      break;
    }
  }
  int a,b;
  scanf("%d %d\n", &a, &b);
  char u[11];
  int u_end;
  for (int i = 0; i < 11; i++) {
    scanf("%c", &u[i]);
    if (u[i] == '\n') {
      u_end = i-1;
      break;
    }
  }

  int flag = 1;
  if (u_end != s_end) {
    flag = 0;
  } else {
    for (int i = 0; i <= u_end; i++) {
      if (u[i] != s[i]) {
        flag = 0;
        break;
      }
    }
  }

  if (flag == 1) {
    a--;
  } else {
    b--;
  }

  printf("%d %d\n", a, b);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <cmath>
#define rep(i,n) for(int i = 0; i < n; i++)
#define int long long
using namespace std;
int k;
int* a;

pair<int, int> solve(int mi, int ma, int i){
    // cout << mi << " " << ma << endl;
    if (i < 0){
        return make_pair(mi, ma-1);
    }
    if(mi < 0 or ma < 0){ return make_pair(-1, -1); }
    int nmi, nma;
    nmi = mi/a[i] + (mi%a[i]? 1 : 0);
    // nmi = ceil((float)mi / a[i]);
    nma = (ma-1) / a[i];
    if(nmi > nma){ return make_pair(-1, -1); }
    return solve(nmi*a[i], (nma+1)*a[i], i-1);
}
signed main(void){
    cin >> k;
    a = new int[k];
    rep(i, k){
        cin >> a[i];
    }
    if(a[k-1] != 2){
        cout << -1 << endl;
        return 0;
    }
    pair<int, int> ans = solve(2, 3, k-1);
    if(ans.first < 0) cout << -1 << endl;
    else cout << ans.first << " " << ans.second << endl;
    
}


Measured memory_bytes: 4096
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=1e17;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
// double dp[100005];
 
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main()
{
 // #ifndef ONLINE_JUDGE
 // freopen("input.txt", "r", stdin);
 // freopen("output.txt", "w", stdout);
 // #endif
 IO;
 OS;
 string s;
 cin>>s;
 if(s[2]==s[3]&&s[4]==s[5])
    cout<<"Yes";
else
    cout<<"No";
 
 
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2180
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			double[] x = new double[4];
			double[] y = new double[4];
			for(int i = 0; i < 4; ++i)
			{
				x[i] = stdIn.nextDouble();
				y[i] = stdIn.nextDouble();
			}
			if(Math.sqrt((x[1] - x[0]) * (x[3] - x[2]) + (y[1] - y[0]) * (y[3] - y[2])) < 1e-12)
			{
				System.out.println("YES");
			}
			else
			{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
using namespace std;
int main () {
  int D;
  cin >> D;
  switch(D) {
    case 22: cout << "Christmas Eve Eve Eve" << endl; break;
    case 23: cout << "Christmas Eve Eve" << endl; break;
    case 24: cout << "Christmas Eve" << endl; break;
    case 25: cout << "Christmas" << endl; break;
  }
}

Measured memory_bytes: 256
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    ans = False
    taro = sorted([int(input()) for _ in range(n)])
    hana = [int(input()) for _ in range(m)]
    diff = sum(taro) - sum(hana)
    hana = set(hana)
    for k in taro:
        if k - diff / 2 in hana:
            print(k, k - diff // 2)
            ans = True
            break
    if ans is False:
        print(-1)



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

const int INF = 1 << 30;
int H, W;
vector<vector<char>> grid;

bool in_grid(int i, int j) {
    return 0 <= i && i < H && 0 <= j && j < W;
}

bool can_step(int i, int j) {
    return grid[i][j] == '.';
}

int main() {
    cin >> H >> W;
    grid.resize(H, vector<char>(W));
    for (int i = 0; i < H; ++i) for (int j = 0; j < W; ++j) cin >> grid[i][j];

    int ans = 0;
    for (int sh = 0; sh < H; ++sh)
        for (int sw = 0; sw < W; ++sw) {
            if (!can_step(sh, sw)) continue;
            vector<vector<int>> dist(H, vector<int>(W, INF));
            int max_dist = 0;
            using T = tuple<int, int, int>;
            queue<T> q;
            q.push(T(sh, sw, 0));
            dist[sh][sw] = 0;
            while (!q.empty()) {
                T t = q.front();  q.pop();
                int i, j, d;  tie(i, j, d) = t;
                max_dist = max(max_dist, dist[i][j]);
                vector<int> dh{1, 0, -1, 0}, dw{0, 1, 0, -1};
                for (int k = 0; k < 4; ++k) {
                    int ni = i + dh[k], nj = j + dw[k];
                    if (!in_grid(ni, nj) || !can_step(ni, nj) || dist[ni][nj] != INF) continue;
                    q.push(T(ni, nj, d + 1));
                    dist[ni][nj] = dist[i][j] + 1;
                }
            }
            ans = max(ans, max_dist);
        }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main() {
    int N;
    cin >> N;
    map<int, int> classroom;
    for (int i=1; i<=N; i++) {
        int n;
        cin >> n;
        classroom[n] = i;
    }
    for (int i=1; i<=N; i++) {
        cout << classroom[i] << " ";
    }
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;
ll X,A,B;
int main(){
	in(X),in(A),in(B);
	ll ret = X-A+B;
	if(ret<=X) cout <<"delicious\n";
	if(ret>X) {
		if(ret-X <= X) cout << "safe\n";
		else cout << "dangerous\n";	
	}
	 
	
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

// s[0] s[1] s[2] s[3] s[4] s[5] s[6] s[7] s[8] s[9]


int main(void){

    string s;
    cin >> s;

    REP(i,s.size()-1)
        if(s.at(i) == s.at(i+1)){
            cout << i+1 << " " << i+2 << endl;
            return 0;
        }
    
    REP(i,s.size()-2)
        if(s.at(i) == s.at(i+2)){
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    
    cout << -1 << " " << -1 << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  vector<int> v(N);
  rep(i,N)cin >> v[i];

  int count = 1;
  //状態1で上昇，0で不定，-1で減少
  int stat = 0;
  int pre = v[0];
  rep(i,N){
    if(v[i] == pre)continue;
    if(v[i] > pre){
      if(stat == 0)stat = 1;
      if(stat == -1){
        stat = 0;
        ++count;
      }
    }
    if(v[i] < pre){
      if(stat == 0)stat = -1;
      if(stat == 1){
        stat = 0;
        ++count;
      }
    }
    pre = v[i];
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
import math
INF = float("inf")


def bitsum(n):
    wa = 0
    while n > 0:
        wa += n & 1
        n >>= 1
    return wa


def solve(L: int):
    N = int(math.log2(L))+1
    M = (N-1)*2

    # 不足パス数
    K = L-2**(N-1)

    # 各桁の数の和
    M += bitsum(K)

    print(N, M)
    # 重み0
    for i in range(1, N):
        print(i, i+1, 0)
    # 重み2**i
    for i in range(1, N):
        print(i, i+1, 2**(i-1))

    # 特殊
    # print(bitsum(K), K)
    i = 0
    while K >= 2**i:
        if K & 2**i:
            print(i+1, N, L-2**i)
            L -= 2**i
        i += 1

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    solve(L)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <stdio.h>

int main()
{
    int i,j,k,a=0,count,H,W;
    while(1 == 1){
        scanf("%d%d", &H, &W);
        if(H==0&&W==0){
            return 0;
        }
        for (j=0;j<H; j++){
            if(j % 2 == 0){
                count = 0;
            }
            else{
                count = 1;
            }
            for (k=0;k<W;k++){
                (count % 2 == 0) ? printf("#") : printf(".");
                count++;
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

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

int main(void){
    int n,d;
    cin >> n >> d;
    int a[n][d];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++)cin >> a[i][j];
    }
    int count = 0;
    for(int i = 0;i < n-1;i++){
        for(int j = i+1;j < n;j++){
            int c = 0;
            for(int k = 0;k < d;k++){
                int b = 0;
                b = abs(a[i][k] - a[j][k]);
                c += b*b;
            }
            bool check = false;
            for(int k = 0;k <= c;k++){
                if(k*k == c)check = true;
            }
            if(check == true)count++;
        }
    }
    cout << count;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define Size 9

using namespace std; 

int find_zero(string state) {
	for (int i = 0; i < Size; ++i) {
		if (state[i] == '0') {
			return i;
		}
	}
	return -1;
}

string move(string str, int p1, int p2) {
	string res = str;
	res[p1] = str[p2];
	res[p2] = str[p1];
	return res;
}

int main(void) {
	string state = "012345678";
	for (int i = 0; i < Size; ++i) {
		cin >> state[i];
	}

	int zi;
	map<string,int> memo;
	memo[state] = 1;
	pair<string,int> now;
	queue< pair<string,int> > q;
	q.push({state,1});
	while (!q.empty()) {
		now = q.front();
		q.pop();
		if (now.first == "123456780") {
			cout << now.second-1 << endl;
			break;
		}
		zi = find_zero(now.first);
		if (zi%3 != 2) {
			state = move(now.first,zi,zi+1);
			if (memo[state] == 0) {
				memo[state] = now.second+1;
				q.push({state,now.second+1});
			}
		}
		if (zi%3 != 0) {
			state = move(now.first,zi,zi-1);
			if (memo[state] == 0) {
				memo[state] = now.second+1;
				q.push({state,now.second+1});
			}
		}
		if (zi/3 > 0) {
			state = move(now.first,zi,zi-3);
			if (memo[state] == 0) {
				memo[state] = now.second+1;
				q.push({state,now.second+1});
			}
		}
		if (zi/3 < 2) {
			state = move(now.first,zi,zi+3);
			if (memo[state] == 0) {
				memo[state] = now.second+1;
				q.push({state,now.second+1});
			}
		}
	}
	return 0;
}



Measured memory_bytes: 23212
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length(), m=t.length();

    ll dp[n+1][m+1];
    memset(dp, 0, sizeof(dp));

    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            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]);
        }
    }
    
    string ans="";
    int len=dp[n][m]-1;
    int i=n, j=m;

    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }

    int str=0;
    while(str<len){
        swap(ans[str], ans[len]);
        str++;
        len--;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a=1,b=1;
  for(int i=0;i<n;i++){
    a*=3;
    int x;
    cin >> x;
    if(x%2==0) b*=2;
  }
  cout << a-b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n, m, c=0;
    int *foods;
    scanf("%d%d", &n, &m);
    foods = malloc(sizeof(int) * m);
    for(int i=0;i<m;i++) foods[i] = 0;
    for(int i=0;i<n;i++){
        int k;
        scanf("%d", &k);
        for(int j=0;j<k;j++){
            int p;
            scanf("%d", &p);
            foods[p-1]++;
        }
    }
    for(int i=0;i<m;i++){
        if(foods[i] == n) c++;
    }
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main(){
	int dp[3010][3010]={};
	string s,t,ans;
	cin>>s>>t;
	rep(i,1,s.size()+1)rep(j,1,t.size()+1){
		if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
		else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
	}
	int slen=s.size();
	int tlen=t.size();
	while(dp[slen][tlen]>0){
		if(s[slen-1]==t[tlen-1]){
			ans+=s[slen-1];
			slen--,tlen--;
		}else if(dp[slen][tlen]==dp[slen-1][tlen]){
			slen--;
		}else{
			tlen--;
		}
	}
	reverse(ALL(ans));
	print(ans);
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const string CF = "AKIHABARA";
int p[4];
bool f[9];

string s;

int main() {
	int now = 0;
	rep(i, CF.size()) if (CF[i] == 'A') {
		p[now] = i;
		now++;
	}

	cin >> s;
	bool ok=0;
	rep(i,1<<4) {
		string t;
		rep(j,9) f[j]=1;
		rep(j,4) if ((i>>j)&1) {
			f[p[j]] = 0;
		}
		rep(j, 9) {
			if (f[j]) {
				t.pb(CF[j]);
			}
		}
		if (s==t) {
			ok = 1;
		}
	}
	puts(ok?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	string s;
	cin >> s;
	vector<string>a(7);
	if (s == "SAT") {
		cout << 1 << endl;
	}
	else if (s == "FRI") {
		cout << 2 << endl;
	}
	else if (s == "THU") {
		cout << 3 << endl;
	}
	else if (s == "WED") {
		cout << 4 << endl;
	}
	else if (s == "TUE") {
		cout << 5 << endl;
	}
	else if (s == "MON") {
		cout << 6 << endl;
	}
	else if (s == "SUN") {
		cout << 7 << endl;
	}
	



}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long n = sc.nextLong();
        sc.close();

        int mod = 1000000007;
        long p = 1;
        
        for(long i=1; i<=n; i++) {
            p = p * i % mod;
        }
        System.out.println(p);
    }
}


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

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    UnionFind uf(n);
    rep(_, q) {
        int t, u, v;
        cin >> t >> u >> v;
//        u--;
//        v--;
        if (t == 0) {
            uf.connect(u, v);
        } else {
            cout << uf.is_union(u, v) << endl;
        }
    }
}

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

int x, y, z, k;
int a[1000];
int b[1000];
int c[1000];
int bc[1000000];

signed main() {
	int i, j;
	
	cin >> x >> y >> z >> k;
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];
	rep(i, y) rep(j, z) bc[i * z + j] = b[i] + c[j];
	sort(bc, bc + y * z, greater<int>());
	
	vector<int> vec;
	rep(i, x) {
		rep(j, min(y * z, k)) {
			vec.push_back(a[i] + bc[j]);
		}
	}
	sort(vec.begin(), vec.end(), greater<int>());
	
	rep(i, k) cout << vec[i] << endl;
	return 0;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> mii;
typedef map<ll,int> mli;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;  ///1e9+7

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,a;
    bool ok=true;
    cin>>n;
    map<ll,ll> m;
    while(n--){
        cin>>a;
        if(m[a]) ok=false;
        m[a]++;
    }
    if(ok) cout<<"YES" el;
    else cout<<"NO" el;
}

main()
{
//    fastio();
//    test _case();
//    while(1) _case();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main()
{
  int n, m, x;
  vector<vector<int>> a(13, vector<int>(13));
  vector<int> sum_temp(13);
  vector<int> ans(13);
  bool flag;

  cin >> n >> m >> x;
  ans[0] = 100000000;
  for (int i = 1; i <= n; i++)
  {
    for (int j = 0; j <= m; j++)
      cin >> a[i][j];
  }
  for (int tmp = 0; tmp < (1 << n); tmp++)
  {
    bitset<12> s(tmp);
    for (int i = 0; i <= m; i++)
      sum_temp[i] = 0;
    flag = true;
    for (int i = 1; i <= n; i++)
    {
      if (s.test(i - 1))
      {
        for (int j = 0; j <= m; j++)
        {
          sum_temp[j] += a[i][j];
        }
      }
    }
    for (int i = 1; i <= m; i++)
    {
      if (sum_temp[i] < x)
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      if (sum_temp[0] < ans[0])
      {
        for (int i = 0; i <= m; i++)
          ans[i] = sum_temp[i];
      }
    }
  }
  if (ans[0] != 100000000)
    cout << ans[0] << endl;
  else
    cout << -1 << endl;
}

Measured memory_bytes: 3592
N, P = map(int, input().split())
S = input()

def smallSol():
    dp = [0] * P
    ans = 0
    for s in map(int, S):
        newDp = [0] * P
        newDp[s % P] += 1
        for p in range(P):
            newDp[(p * 10 + s) % P] += dp[p]
        dp = newDp
        ans += dp[0]
    return ans

def largeSol():
    cnt = [0] * P
    cnt[0] += 1
    ret = 0
    now = 0
    for i, s in enumerate(map(int, S[:: -1])):
        now = (pow(10, i, P) * s + now) % P
        ret += cnt[now - P]
        cnt[now] += 1
    return ret

print(smallSol() if N * P <= 10**6 else largeSol())


Measured memory_bytes: 3500
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define quickIO()	{cin.tie(0);	cout.sync_with_stdio(false);}
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<((int)n);i++)
#define REP(i,n)	for(int i=0;i<=((int)n);i++)
#define srep(i,a,n)	for(int i=a;i<((int)n);i++)
#define SREP(i,a,n)	for(int i=a;i<=((int)n);i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
template<typename T> istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec)	is >> x;
	return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
	os << "[";
	rep(i, vec.size())	os << (i ? ", " : "") << vec[i];
	os << "]";
	return os;
}
template<typename T> istream& operator >> (istream& is, pair<T, T>& p) {
	is >> p.first >> p.second;
	return is;
}
template<typename T> ostream& operator << (ostream& os, pair<T, T>& p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll sqrtll(ll x) {
	ll left = 0, right = x;
	rep(i, 100) {
		ll mid = (left + right) >> 1;
		if (mid*mid <= x)	left = mid;
		else	right = mid;
	}
	return left;
}
ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a%b);
}
#define debug(x)	printf("Case #%d: ", x)
#define DEBUG 0
const ll inf = 1e9;
const ld infl = 1e100;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0,0 };
const int dy[] = { 0,1,0,-1,0 };

int main() {
	int n;	cin >> n;
	vll a(n), b(n);
	rep(i, n)	cin >> a[i] >> b[i];
	ll ret = 0;
	rep(i, n)	ret -= b[i];
	vll c(n);
	rep(i, n)	c[i] = a[i] + b[i];
	sort(all(c));
	reverse(all(c));
	rep(i, n) {
		if ((i & 1) == 0)	ret += c[i];
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll X;

void solve()
{
    ll now = 100;
    cin >> X;
    for (int i = 1;; ++i)
    {
        now += now * 0.01;
        if(now>=X)
            return printf("%d\n", i), void();
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b) swap(a, b);
	while (b > 0){
		a %= b;
		swap(a, b);
	}
	cout << (c % a == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod
 
 
 
signed main(){
 
    int A, B; cin >> A >> B;
    Out(max(0LL, A - 2 * B));
 
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    d = list(map(int, input().split()))
    mod = 998244353

    if d.count(0) >= 2 or d[0] != 0:
        print(0)
        exit()

    cnt = [0] * (max(d) + 1)

    for e in d:
        cnt[e] += 1

    ans = 1
    l = len(cnt)
    for i in range(l - 1):
        ans *= cnt[i] ** cnt[i+1] % mod

    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14396
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

int main() {
  // cout << fixed << setprecision(10);

  int S, W;
  cin >> S >> W;
  cout << (W >= S ? "unsafe":"safe") << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> C(N); vector<int> S(N); vector<int> F(N);
 for(int i = 1; i <= N - 1; i++){ cin >> C[i] >> S[i] >> F[i];}
  
  for(int i = 1; i <= N; i++){ //depatures iterators
   int t = 0;
    if( i == N ){ cout << 0 << endl; return 0;}
    for(int j = i; j <= N - 1 ; j++){ // in this region, i is under N
      if( t < S[j]){ t = S[j];}
      else{ int k = ( t - S[j] + F[j] - 1) / F[j]; t = S[j] + k * F[j];}
      t += C[j];} // move to the N-1 station as soon as possible
    cout << t << endl;}
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define all(a) a.begin(),a.end()
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;

int main(){
    int n,k;
    cin >> n >> k;
    vi x(n);
    rp(i,n){
        cin >> x.at(i);
    }
    if(x.at(0)>=0){
        cout << x.at(k-1) << endl;
        return 0;
    }else if(x.at(n-1)<=0){
        cout << (-1)*x.at(n-k) << endl;
        return 0;
    }else{
        int j;
        rp(i,n){
            if(x.at(i)>=0){
                j=i;
                break;
            }
        }
        int Min=INT_MAX;
        rep(i,1,k){
            if(j-i>=0&&j+k-i<=n){
                Min = min(Min,min(2*x.at(j+k-i-1)-x.at(j-i),x.at(j+k-i-1)-2*x.at(j-i)));
            }
        }
        cout << Min << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
#define PI 3.14159265358979323846
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define endl '\n'
#define show(a) for(auto el:a)cout<<el<<" "
const ll INF=LLONG_MAX/2;
const ll N=2e5+1;
#define yesno(f) yes(f);no(f);
#define yes(f) if(f)cout<<"YES\n";
#define no(f) if(!f)cout<<"NO\n";
using  namespace std;
int main()
{
    fast;
   ll n;
   std::cin >> n;
   ll a[n],sum;
   map<ll,ll>mp;
   fr(i,0,n)
   {
       std::cin >> a[i];
       if(i==0)
       sum=a[i];
       else
       sum=sum^a[i];
   }
   fr(i,0,n)
   {
       ll c=sum^a[i];
       cout<<c<<" ";
   }
   cout<<"\n";
}

Measured memory_bytes: 5160
n,m=map(int,input().split())
MOD = 1000000007 
D=[0] * (n+2)
D[0] = 1
for _ in range(m):
    D[int(input())] = -1
for i in range(n):
    if D[i] == -1:
        continue
    if D[i+1] != -1:
        D[i+1] += D[i]
    if D[i+2] != -1:
        D[i+2] += D[i]
    D[i]%=MOD
print(D[n] % MOD)

Measured memory_bytes: 6900
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    C = [0 for _ in range(N - 1)]
    S = [0 for _ in range(N - 1)]
    F = [0 for _ in range(N - 1)]
    for i in range(N - 1):
        c, s, f = map(int, input().split())
        C[i] = c
        S[i] = s
        F[i] = f

    for i in range(N - 1):
        t = S[i]
        for j in range(i, N - 1):
            t += C[j]
            if j < N - 2:
                next_t = S[j + 1]
                while t > next_t:
                    next_t += F[j + 1]
                t = next_t
        print(t)
    print(0)


Measured memory_bytes: 44120
#include <stdio.h>

int main(){
    int a,b,c,d,p,s,t;
    scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
    s=a*p;
    if(p>c){
        t=b+(p-c)*d;
    }else{
        t=b;
    }
    if(s>=t){
        printf("%d\n",t);
    }else{
        printf("%d\n",s);
    }
    return 0;
}

Measured memory_bytes: 596
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	chars := strings.Split(s, "")

	var longest = ""
	var temp string
	for _, char := range chars {
		if strings.Contains("ATGC", char) {
			// pile chars up
			temp += char
		} else if len(temp) > len(longest) {
			longest = temp
			temp = ""
		} else {
			temp = ""
		}
	}

	if len(temp) > len(longest) {
		longest = temp
	}

	fmt.Println(len(longest))
}


Measured memory_bytes: 640
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d=[float("inf")]*n #各頂点への距離
    used=[False]*n
    d[s]=0
    
    while True:
        v=-1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v==-1): #その頂点が使われたかチェック
                v=i			            #まだなら仮確定
            elif (not used[i]) and d[i]<d[v]: #より距離が近いのがあればそちらから
                v=i
        if v==-1:
             break
        used[v]=True
               
        for j in range(n):
            d[j]=min(d[j],d[v]+cost[v][j])
    return d
    
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
now=0
ans=m
for _ in range(m):
    flag=True
    cost=[[10**9 for i in range(n)]for i in range(n)]
    for i in range(m):
        if i!=now:
            cost[a[i][0]-1][a[i][1]-1]=1
            cost[a[i][1]-1][a[i][0]-1]=1
    for j in dijkstra(0,n,m-1,cost):
        if j>100:
            flag=False
    if flag==True:
        ans-=1
    now+=1
print(ans)

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

int main() {
  cout<<setprecision(10)<<fixed;
  int n;
  cin>>n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n){
    cin>>x[i];cin>>y[i];
  }
  double to[10][10];
  rep(i,n){
    rep(j,n){
      to[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  vector<int> p;
  rep(i,n){
    p.push_back(i);
  }
  sort(p.begin(),p.end());
  double ans=0;
  do{
    rep(i,n-1){
      ans+=to[p[i]][p[i+1]];
    }
  }while(next_permutation(p.begin(),p.end()));
  rep(i,n){
    ans/=(i+1);
  }
  cout<<ans<<endl;
}

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

#define DEBUG

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M))
#define ALL(v) v.begin()+1, v.end()-9

int main(){
    int N;
    cin>>N;
    //vector<vector<ll>> C(N+10,vector<ll>(N));
    VEC2(ll,C,N,2);
    REP(i,N){
        cin>>C[i][1]>>C[i][2];
    }
    sort(ALL(C),[](auto& a, auto& b) {
        return a[2] < b[2];   
    });
    ll mint=INF,nowt=0;
    REP(i,N){
        nowt+=C[i][1];
        ll min=INF;
        if(nowt>C[i][2]){
            cout<<"No";return 0;
        }
    }
    cout<<"Yes";
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 11136
#include<cstdio>

int main()
{
	int n;
	double ans=0,a;
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
	{
		scanf("%lf",&a);
		ans+=1/a;
	}
	printf("%lf",1/ans);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,m,tmp=0;
    cin >> n >> m;
    vll x(m),sa(m-1);
    rep(i,m) cin >> x[i];
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    sort(all(x));
    rep(i,m-1){
        sa[i]=abs(x[i]-x[i+1]);
        tmp+=sa[i];
    }
    sort(rall(sa));
    rep(i,n-1) tmp-=sa[i];
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
  #define DUMP(i) 
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());

using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Edge{
public:
  int from,to,cost;
  Edge(){}
  Edge(int _from,int _to,int _cost){
    from = _from;
    to = _to;
    cost = _cost;
  }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


const int EPS = 1e-9;
const int MOD = 1e9+7;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  int ans = k;
  REP(i,n-1){
    ans *= k-1;
  }
  cout << ans << endl;
  return 0;
}



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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;
  cin >> x;
  int h = x / 100;
  int r = x % 100;
  if (h >= 20 || r <= 5*h) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 384