akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
#define DEBUG

typedef struct node{
  struct node* parent;
  struct node* left;
  struct node* right;
  int k;
}Node;

Node* tree;

void insert(int);
void inorder(Node*);
void preorder(Node*);
void delete(Node*);
Node* find(Node*,int);
Node* Minimum(Node*);
Node* Successor(Node*);

int main(){
  int m,i,k;
  char hairetu[10];
  Node* f;

  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%s",hairetu);
    if(hairetu[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(hairetu[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
    
    else if(hairetu[0]=='f'){
      scanf("%d",&k);
      f=find(tree,k);
      if(f!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(hairetu[0]=='d'){
      scanf("%d",&k);
      if((f=find(tree,k))!=NIL) delete(f);
    }
  }

  return 0;
}

void insert(int k){
  Node* y = NIL;
  Node* x = tree;
  Node* z;
  z=(Node *)malloc(sizeof(Node));
  z->k=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->k < x->k ){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;

  if(y==NIL) tree=z;
  else if(z->k < y->k) y->left=z;
  else y->right=z;
  
  return;
}

void inorder(Node* tree){
  if(tree != NIL){
    inorder(tree->left);
    printf(" %d",tree->k);
    inorder(tree->right);
  }
  
  return;
}

void preorder(Node* tree){
  if(tree != NIL){
    printf(" %d",tree->k);
    preorder(tree->left);
    preorder(tree->right);
  }
  
  return;
}

Node* find(Node* tree,int f){
  if(tree != NIL){
    if(tree->k == f) return tree;
    if(tree->k > f) return find(tree->left,f);
    else return find(tree->right,f);
  }
  
  else return NIL;
}

void delete(Node* z){
  Node* y;
  Node* x;

  if(z->left == NIL || z->right == NIL) y=z;
  else y=Successor(z);

  if(y->left!=NIL) x = y->left;
  else x=y->right;
  if(x!=NIL) x->parent = y->parent;

  if(y->parent==NIL) tree=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right = x;

  if(y!=z){
    z->k = y->k;
  }
  
  return;
}

Node* Minimum(Node* x){
  while(x->left != NIL){
    x=x->left;
  }
  
  return x;
}

Node* Successor(Node* x){
  Node* y;

  if(x->right != NIL) return Minimum(x->right);

  y = x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  
  return y;
}

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

using namespace std;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
        cout << "YES" << endl;
    else 
        cout << "NO" << endl;

    return 0;
}

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

int gcm(int i, int j){
    if(i<j) return gcm(j, i);
    else if(i%j) return gcm(j, i%j);
    else return j;
}

int main() {
    int A, B, C; cin >> A >> B >> C;
    if(C%gcm(A, B)) cout << "NO" << endl;
    else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * N
dp[0] = 0
for i in range(1,N):
    H = h[i]
    dp[i] = min( [dp[j] + abs(h[j] - H) for j in range(max(0, i-K),i)])
print(dp[-1])


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

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

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

  string s;
  ll k;
  cin >> s >> k;

  ll l1 = 0;
  char c;
  rep(i, s.size()) {
    if(s[i] == '1') l1++;
    else {
      c = s[i];
      break;
    }
  }

  if(k <= l1) cout << 1 << '\n';
  else cout << c << '\n';
  return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**7)
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a-=1; b-=1
    g[a].append((b, c))
    g[b].append((a, c))
q, k = map(int, input().split())

# 前処理
dist = [-1] * n

def dfs(st, depth=0):
    dist[st] = depth
    for to, c in g[st]:
        if dist[to] >= 0: continue
        dfs(to, depth+c)

dfs(k-1, 0)

for i in range(q):
    x, y = map(int, input().split())
    x-=1; y-=1
    print(dist[x]+dist[y])



Measured memory_bytes: 161012
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

const int INF = 1e9;

int main() {
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    REP(i, n){
        cin >> c[i];
        REP(j, m)
            cin >> a[i][j];
    }

    int ans = INF;
    for(int bit = (1<<n)-1; bit >= 0; bit--){
        vector<int> rikai(m, 0);
        int cost = 0;
        REP(i, n){
            if((bit >> i) & 1){
                cost += c[i];
                REP(j, m)
                    rikai[j] += a[i][j];
            }
        }
        bool ok = true;
        REP(i, m)
            if(rikai[i] < x) ok = false;
        if(ok) ans = min(ans, cost);
    }
    
    cout << (ans == INF ? -1 : ans) << endl;

    return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
int main(){
  double x;
  while(scanf("%lf",&x)!=EOF){
    if(x<=48.00)printf("light fly\n");
    else if(x>48.00 && x<=51.00)printf("fly\n");
    else if(x>51.00 && x<=54.00)printf("bantam\n");
    else if(x>54.00 && x<=57.00)printf("feather\n");
    else if(x>57.00 && x<=60.00)printf("light\n");
    else if(x>60.00 && x<=64.00)printf("light welter\n");
    else if(x>64.00 && x<=69.00)printf("welter\n");
    else if(x>69.00 && x<=75.00)printf("light middle\n");
    else if(x>75.00 && x<=81.00)printf("middle\n");
    else if(x>81.00 && x<=91.00)printf("light heavy\n");
    else printf("heavy\n");
  }
  return 0;
}

Measured memory_bytes: 608
N, X, Y = map(int, input().split())
result = [0] * (N)
for i in range(1, N):
    for j in range(i + 1, N + 1):
        if i <= X:
            if j <= X:
                len = j - i
            elif X < j < Y:
                if (j - X) < (Y - j + 1):
                    len = j - i
                else:
                    len = (X - i) + (Y - j + 1)
            elif Y <= j:
                len = (X - i) + 1 + (j - Y)
        elif X < i < Y:
            if j < Y:
                if (j - i) < (i - X) + 1 + (Y - j):
                    len = j - i
                else:
                    len = (i - X) + 1 + (Y - j)
            elif Y <= j:
                if (i - X + 1) < (Y - i):
                    len = (i - X) + 1 + (j - Y)
                else:
                    len = j - i
        elif Y <= i:
            len = j - i
        result[len] += 1
for i in range(1, N):
    print(result[i])


Measured memory_bytes: 3444
#include<stdio.h>
int main(){
  int n,i;
  scanf("%d",&n);
  long long a[n+2],b[n+1],count=0;
  for(i=0;i<=n;i++)
    scanf("%lld",&a[i]);
  for(i=0;i<n;i++)
    scanf("%lld",&b[i]);
  for(i=0;i<n;i++){
    if(a[i]>b[i])
      count+=b[i];
    else{
      if((a[i]+a[i+1])>b[i]){
        count+=b[i];
        a[i+1]-=b[i]-a[i];
      }
      else{
        count+=a[i]+a[i+1];
        a[i+1]=0;
      }
    }
  }
  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 333333, B = 60;
int a[N];
int n;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    int ans = 0;
    rep(b, 0, B - 1) {
        int c0 = 0, c1 = 0;
        rep(i, 1, n) {
            if(a[i] & (1LL << b)) {
                c1++;
            } else {
                c0++;
            }
        }
        int cnt = c0 * c1 % MOD;
        int mult = (1LL << b) % MOD;
        ans = (ans + cnt * mult % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

void solve(){
    
    int n; cin>>n;
    string s; cin>>s;
    int count=0;
    for(int i=0;i<=n-3;i++){
        if(s.substr(i,3) == "ABC") count++;
        //debug(s.substr(i,3));
    }

    cout << count << endl;


    

}


int main(){
    solve();
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
ll dp[2001][2001];	// dp[length][sum]
ll mod = 1e9 + 7;
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll s, i, j;
    cin >> s;
    for(i = 3; i < 2001; i++) {
    	dp[1][i] = (1 + dp[i][i-1])%mod;
    }
    for(i = 2; i < 2001; i++) {
    	for(j = 3; j < 2001; j++) {
    		dp[i][j] = dp[i-1][j-3];
    	}
    	for(j = 1; j < 2001; j++) {
    		dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
    	}
    }
    ll ans = 0;
    for(i = 1; i < 2001; i++) {
    	ans = (ans + dp[i][s])%mod;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 34900
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i, 0, n - 1){
        if(x >= a[i]){
            ans++; x -= a[i];
        }
    }
    if(x == a[n - 1]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,r,g,b;
ll ans;
string s;
int main()
{
   cin>>n>>s;
   for(int i=0;i<n;i++)
   {
   	  if(s[i]=='R')r++;  
	  if(s[i]=='G')g++;  
	  if(s[i]=='B')b++;
	} 
   ans=r*g*b;
   for(int i=0;i<n;i++)
     for(int j=i+1;j<n,2*j-i<n;j++)
     {
     	if(s[i]!=s[j]&&s[j]!=s[2*j-i]&&s[i]!=s[2*j-i]) ans--;
	 }
   cout<<ans;
return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n;
    cin>>n;
    long long l = n*9;
    if (n%7==0) l /= 7;
    long long ans = -1;
    if (n%2!=0 && n%5!=0) {
        long long left =1;
        for (int i=0;i<l;i++) {
            left =(left*10)%l;
            if (left == 1) {
                ans = i+1;
                break;
            }

        }
    }
    cout<<ans<<endl;


}

Measured memory_bytes: 3608
def gcd(a, b):
    global queue
    r = a % b
    if r:
        d = a // b
        sb = queue.pop()
        sa = queue.pop()
        queue.append(sb)
        queue.append(tuple(map(lambda x, y: x - d * y, sa, sb)))
        return gcd(b, r)
    else:
        return b


a, b = map(int, input().split())
queue = [(1, 0), (0, 1)]
g = gcd(a, b)
print(*queue.pop())

Measured memory_bytes: 7760
#include<iostream>
using namespace std;
int main(void){
    int a,b,c,d = 0;
    cin >> a>>b >> c >> d;
    int left = a+b;
    int right = c+d;
    if(left < right){
        cout << "Right";
    }else if(left > right){
        cout << "Left";
    }else
    {
        cout << "Balanced";
    }
    
}

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

int main()
{
    string a, b;
    cin >> a;
    cin >> b;
    int dp[3001][3001];
    for (int i = 0; i <= (int) a.length(); i++) dp[i][0] = 0;
    for (int i = 0; i <= (int) b.length(); i++) dp[0][i] = 0;
    for (int i = 1; i <= (int) a.length(); i++) {
        for (int j = 1; j <= (int) b.length(); j++){
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    //cout << dp[(int)a.length()][(int)b.length()];
    int i = (int) a.length(), j = (int) b.length();
    stack <char> st;
    while (dp[i][j] != 0){
        if (dp[i][j] > max(dp[i - 1][j], dp[i][j - 1])) {
            st.push(a[i - 1]);
            i--;
            j--;
        }
        else {
            if (dp[i - 1][j] > dp[i][j - 1]) {
                i--;
            }
            else j--;
        }
    }
    while (!st.empty()){
        cout << st.top();
        st.pop();
    }
}

Measured memory_bytes: 35456
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

a,b,c,d = miinps()

if a >= 0 and b >= 0:
    if c >= 0 and d >= 0:
        print(b*d)
    elif c < 0 and d >= 0:
        print(b*d)
    elif c < 0 and d < 0:
        print(a*d)
elif a < 0 and b >= 0:
    if c >= 0 and d >= 0:
        print(b*d)
    elif c < 0 and d >= 0:
        print(max(a*c,b*d))
    elif c < 0 and d < 0:
        print(a*c)
elif  a< 0 and b < 0:
    if c >= 0 and d >= 0:
        print(b*c)
    elif c < 0 and d >= 0:
        print(a*c)
    elif c < 0 and d < 0:
        print(a*c)


Measured memory_bytes: 9148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split("");
			int a = Integer.parseInt(chr[0]);
			int c = Integer.parseInt(chr[2]);
			System.out.println(a==c?"Yes":"No");

		}
	}
}

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

static const int N=100;

static const int WHITE=0;

static const int GRAY=1;

static const int BLACK=2;





//用栈实现深度优先搜索


/**
 * color 标记访问状态的数组，
 * M[N][N] 邻接矩阵 如果存在定点i到顶点j的边，则M[i][j]=trul
 * Stack 栈，暂存访问过程中的顶点
**/
int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];


//按序号，获取和u相邻的v
int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v]) return v;
    }
    return -1;
}

//用栈实现深度优先搜索
void dfs(int r){
    for(int i=0;i<n;i++) nt[i]=0;

    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);

        if(v!=-1){
            if(color[v]==WHITE){
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }else{
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }

}

void dfs(){
    //初始化
    for(int i=0;i<n;i++){
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;

    for(int u=0;u<n;u++){
        if(color[u]==WHITE)
            dfs(u);
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
    return;
}
int main(){
    int u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;

        u--;
        for(int i=0;i<k;i++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }

    dfs();
    return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
 
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
 
    int ans = 100;
    rep(i, n){
        int cnt = 0;
        while(a[i] % 2 == 0){
            cnt++;
            a[i] /= 2;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#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 main(){
    int n;
    double k = 0;
    cin >> n;
    if(n%2 == 0){
        k = n;
        cout << k/2/n << endl;
    }else{
        k = (n+1)/2;
        cout << k/n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,m>>=1;
	}
	return res;
}
const int N = 1e6+5,mod = 1e9+7;
int n,ans,lcm=1,val[N],mx[N];
vector<int> vec[N];
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
il Solve(int id){
	int t=val[id];
	for(ri i=2;i*i<=t;++i){
		if(t%i) continue;
		int cnt=0,res=1;
		while(t%i==0) t/=i,res=mul(res,i),++cnt;
		mx[i]=max(mx[i],cnt);
		vec[id].push_back(res);
	}
	if(t!=1) mx[t]=max(mx[t],1),vec[id].push_back(t);
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i)
		read(val[i]);
	for(ri i=1;i<=n;++i)
		Solve(i);
	for(ri i=2;i<=1000000;++i)
		if(mx[i]) lcm=mul(lcm,qpow(i,mx[i],mod));
	for(ri i=1;i<=n;++i){
		int res=lcm;
		for(ri j=0;j<(int)vec[i].size();++j){
			res=mul(res,qpow(vec[i][j],mod-2,mod));
		}
		inc(ans,res);
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 29184
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)

long long MOD;

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long calc(long long L, long long A, long long B, long long d){
    long long lb = 0;
    long long ub = L-1;
    if(to_string(A).size() > d) return -1;
    if(to_string(A+(L-1)*B).size() <= d) return L-1;
    while(ub - lb > 1){
        long long mid = (lb + ub) / 2;
        if(to_string(A+mid*B).size() <= d) lb = mid;
        else ub = mid;
    }
    return lb;
}

template <class X>
vector<vector<X>> matmul(const vector<vector<X>> &mat1, const vector<vector<X>> &mat2) {
    int n = mat1.size();
    vector<vector<X>> ret(n, vector<X>(n, 0));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            for (int k = 0; k < n; k++){
                ret[i][j] += (mat1[i][k] * mat2[k][j]) % MOD;
                ret[i][j] %= MOD;
            }
    return ret;
}

template <class X>
vector<vector<X>> bipow(const vector<vector<X>> &mat, long long m) {
    int n = mat.size();
    vector<vector<X>> ret(n, vector<X>(n, 0));
    if (m == 0) {
        for (int i = 0; i < n; i++) ret[i][i] = 1;
        return ret;
    }
    if (m % 2 == 0) {
        ret = matmul(mat, mat);
        return bipow(ret, m / 2);
    } else
        return matmul(mat, bipow(mat, m - 1));
}

long long bipow(long long n, int m) {
    if (m == 0) return 1;
    if (m % 2 == 0) {
        n = (n * n) % MOD;
        return bipow(n, m / 2) % MOD;
    } else
        return (n * bipow(n, m - 1)) % MOD;
}

int main(){
    long long L, A, B;
    cin >> L >> A >> B >> MOD;
    vector<long long> C(19, -1), D(19);
    for(int d=1; d<=18; d++)
        C[d] = calc(L, A, B, d);
    for(int d=1; d<=18; d++)
        D[d] = C[d] - C[d-1];

    vector<long long> v(3);
    v[0] = 0;
    v[1] = A;
    v[2] = 1;
    for(int d=1; d<=18; d++){
        vector<vector<long long>> mat(3, vector<long long>(3));
        mat[0][0] = bipow(10, d);
        mat[0][1] = mat[1][1] = mat[2][2] = 1;
        mat[1][2] = B;
        auto mat2 = bipow(mat, D[d]);

        vector<long long> v2(3);
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                v2[i] += (mat2[i][j] * v[j]) % MOD;;
                v2[i] %= MOD;
            }
        }

        v = v2;
    }
    cout << v[0] % MOD << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

// 四方向への移動ベクトル
const int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

// 入力
int H, W;
vector<vector<ll> > field;

// 探索
bool seen[51][51]; // seen[h][w] := マス (h, w) が検知済みかどうか
void dfs(int h, int w) {
    seen[h][w] = true;

    // 四方向を探索
    for (int dir = 0; dir < 8; ++dir) {
        int nh = h + dx[dir];
        int nw = w + dy[dir];

        // 場外アウトしたり、移動先が壁の場合はスルー
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (field[nh][nw] == 0) continue;

        // 移動先が探索済みの場合
        if (seen[nh][nw]) continue;

        // 再帰的に探索
        dfs(nh, nw);
    }
}

int main(){
  vector<ll> ans;
  while(1){
    cin >> W >> H;
    if(H == 0 and W == 0) break;
    field.clear();
    field.resize(H); rep(j,H) field[j].resize(W);
    rep(i,H) rep(j,W) cin >> field[i][j];

    rep(i,51) rep(j,51) seen[i][j] = false;
    ll tmp = 0;
    rep(i,H){
      rep(j,W){
        if(field[i][j] == 1 and seen[i][j] == false){
          dfs(i,j);
          tmp++;
        }
      }
    }
    ans.pb(tmp);
  }
  rep(i,ans.size()) cout << ans[i] << endl;
}



Measured memory_bytes: 3188
function main()
    n,q=myreads(Int)
    # -----------Union-Find-----------
    par=Vector{Int}([i for i=1:n])
    siz=ones(Int,n)
    function root(x::Int)
        index=par[x]
        while par[index]!=index
            index=par[index]
        end
        return index
    end
    function unite(x::Int,y::Int)
        rx,ry=root(x),root(y)
        if rx==ry
            return 0
        elseif rx>ry
            rx,ry=ry,rx
        end
        par[ry]=rx
        siz[rx]+=siz[ry]
    end
    function same(x::Int,y::Int)
        isequal(root(x),root(y))
    end
    # --------------------------------
    for i=1:q
        t,u,v=myreads(Int).+=1
        if t==1
            unite(u,v)
        else
            println(same(u,v) ? 1 : 0)
        end
    end
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=parse.(ty,sreads())
main()

Measured memory_bytes: 222808
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int s,w;
	cin >> s >> w;
	if(w>=s)cout << "unsafe" << endl;
	else cout << "safe" << endl;

	return 0;
}  
 

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
set<int> fact(int n){
    set<int> ans;
    while (n % 2 == 0)  {  
        ans.insert(2);
        n = n/2;  
    }  
 
    for (int i = 3; i <= sqrt(n); i = i + 2)  {  
        while (n % i == 0)  {  
            ans.insert(i);
            n = n/i;  
        }  
    }  
    if (n > 2) {
        ans.insert(n);
    }
    return ans;
}
void solve(){
    int n; cin>>n;
    int a[n];
    FOR(i, 0, n) {
        cin>>a[i];
    }
    int g=a[0];
    bool F=1;
    vector<int> m(1000002);
    FOR(i, 0, n) {
        set<int> s = fact(a[i]);
        for(int x:s) {
            m[x]++;
            if(m[x]>1) {
                F=0;
            }
        }
        if(i>0) {
            g = __gcd(g, a[i]);
        }
    }
    if(F){
        cout<<"pairwise coprime";
    }
    else if(g<=1){
        cout<<"setwise coprime";
    }
    else{
        cout<<"not coprime";
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 18792
n, m = map(int, input().split())
ans_ac = 0
ans_wa = 0
lst = []
for i in range(n):
  lst.append([False, 0])
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if lst[p][0]:
    continue
  if s == 'WA':
    lst[p][1] += 1
  else:
    ans_ac += 1
    ans_wa += lst[p][1]
    lst[p][0] = True
print(ans_ac, ans_wa)

Measured memory_bytes: 13172
use std::cmp::max;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}

fn main() {
    input! {
        n: usize, w: usize,
        items: [(i64, i64); n]
    }
    // dp_table[i][j] => 品物をi個選んだ状態で重さjを超えない中での価値の最大値
    let mut dp_table: Vec<Vec<i64>> = vec![vec![0; w + 1]; n + 1];
    for i in 0..n + 1 {
        for j in 0..w + 1 {
            dp_table[i][j] = 0;
        }
    }

    for item_num in 0..n {
        for weight_limit in 0..w + 1 {
            let (value, weight) = items[item_num];
            if weight <= weight_limit as i64 {
                dp_table[item_num + 1][weight_limit] = max(dp_table[item_num][weight_limit], dp_table[item_num][weight_limit - weight as usize] + value);
            } else {
                dp_table[item_num + 1][weight_limit] = dp_table[item_num][weight_limit];
            }
        }
    }

    println!("{}", dp_table[n][w]);
}


Measured memory_bytes: 13112
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (ll)c.size()
#define fr first
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
const ll INF = __LONG_LONG_MAX__;
#define rall(a) (a).rbegin(),(a).rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

void solve()
{
  string s;
  cin>>s;
  string ans=s;
  if(s.back()!='s') ans+='s';
  else ans+="es";
  cout<<ans;
}

int main()
{
  fastio
  ll tt=1;
  // cin>>tt;
  while(tt--)
  {
      solve();
      cout<<"\n";
  }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int a[8];
int cnt;
int sum;

int main(){
	ll n;
	cin >> n;
	int tmp;
	rep(i,n){
		cin >> tmp;
		if(tmp<3200)
			a[tmp/400]=1;
		else
			cnt++;
	}
	rep(i,8)sum+=a[i];
	if(sum>=1)
		cout << sum << ' ' << sum+cnt << endl;
	else
		cout << 1 << ' ' << cnt << endl;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n, i, j, k, s=0;
    cin>>n;
    if(n%2==1)cout<<0<<endl;
    else{
        for(i=5, j=1;j<=25; j++, i*=5){
            k=n/i;
            s+=(k/2);
        }
        cout<<s<<endl;
    }
}


Measured memory_bytes: 256
N,A = map(int,input().split())

X = list(map(int,input().split()))

ma = max(X)

dp = [[[0 for s in range(ma*N+1)] for k in range(N+1)] for i in range(N+1)]

dp[0][0][0] = 1

for i in range(1,N+1) :
    for k in range(i+1) :
        for s in range(ma*N+1) :
            if (k >= 1) and (s >= X[i-1]) :
                dp[i][k][s] = dp[i-1][k][s] + dp[i-1][k-1][s-X[i-1]]
            else :
                dp[i][k][s] = dp[i-1][k][s]

ans = 0

for k in range(1,N+1) :
    if k*A > ma*N :
        break
    ans += dp[N][k][k*A]

print(ans)


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

int main(){
  int n; cin>>n;
  long long sum=0;
  vector<int > a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(i==n-1) break;
    sum+=a[i];
  }
  long long ans=100000000000000,s2=a[n-1];
  for(int i=n-2;i>=0;i--){
    ans=min(ans,abs(sum-s2));
    sum-=a[i];
    s2+=a[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define range(i, a, n) for(int (i) = (a); (i) < (n); (i)++)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
using namespace std;
typedef bool B;
typedef long double D;
typedef complex<D> P;
typedef vector<P> VP;
typedef struct {P s,t;} L;
typedef vector<L> VL;
typedef struct {P c;D r;} C;
typedef vector <C> VC;

const D eps=1.0e-10;
const D pi=acos(-1.0);
template<class T> bool operator==(T a, T b){return abs(a-b)< eps;}
template<class T> bool operator< (T a, T b){return a < b-eps;}
template<class T> bool operator<=(T a, T b){return a < b+eps;}
template<class T> int sig(T a,T b = 0) {return a < b ? -1 : b > a ? 1 : 0;}
#define X real()
#define Y imag()

D ip(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D ep(P a, P b) {return a.X * b.Y - a.Y * b.X;}
D sq(D a) {return sqrt(max(a, (D)0));}
P vec(L l){return l.t-l.s;}
inline P input(){D x,y;cin >> x >> y; return P(x,y);}
D area(VP pol){
	int n=pol.size();
	D sum=0.0;
	rep(i,n){
		D x=pol[i%n].X-pol[(i+1)%n].X;
		D y=pol[i%n].Y+pol[(i+1)%n].Y;
		sum+=x*y;
	}
	return abs(sum/2.0);
}
int main(void){
    VP p;
    D x, y; char c;
    while(cin >> x >> c >> y){
        p.push_back(P(x, y));
    }

    printf("%.12Lf\n", area(p));

	return 0;
}

Measured memory_bytes: 1236
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int []a = new int [n];
		
		for(int i = 0;i < n ; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		
		int p = a[n-1]/2;
		
		int min = a[n-1] ;
		int b = 0;
		for(int i = 0; i < n-1 ;i++) {
			if(min >= Math.abs(a[i] - p)){
				min = Math.abs(a[i] - p);
				b = a[i];
			}
		}
			
		if(b == a[n-1]) {
			System.out.println(a[n-1] +" "+0);
		}
		
		else {
		    System.out.println(a[n-1]+" "+ b);
		}
		
	}
	}


Measured memory_bytes: 50948
from fractions import gcd

def prime_factorize(n):
    ans = []
    while n % 2 == 0:
        ans.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        ans.append(n)
    return ans

A, B = map(int, input().split())

x = gcd(A, B)
prime = prime_factorize(x)

primeset = set()
for p in prime:
    primeset.add(p)

print(len(primeset)+1)

Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    string s,t;
    cin>>s>>t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0;i<=s.length();i++) dp[i][0]=0;
    for(int i=0;i<=t.length();i++) dp[0][i]=0;
    for(int i=1;i<=s.length();i++)
    {
        for(int j=1;j<=t.length();j++)
        {
            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]);
        }
    }
    // for(int i=0;i<=s.length();i++)
    // {
    //     for(int j=0;j<=t.length();j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    int i=s.length(),j=t.length();
    string str="";
    while(i>0&&j>0&&str.length()<dp[s.length()][t.length()]) 
    {
        if(s[i-1]==t[j-1]) str+=s[i-1],i--,j--;
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    }
    reverse(str.begin(),str.end());
    cout<<str;
    // cout<<dp[s.length()][t.length()];
    return 0;
}

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

int main(){
    
    int H,W,N;cin>>H>>W>>N;
    vector<int> S(N);
    vector<int> T(H*W);
    
    for(int i=0;i<N;i++){
        int a;cin>>a;
        if(i==0) S[i]=a;
        else S[i]=S[i-1]+a;
    }
    int a=0;
    for(int i=1;i<=H*W;i++){
        if(i>S[a]) a++;
        T[i-1]=a+1;
    }
    for(int i=0;i<H;i++){
        vector<int> H;
        for(int j=0;j<W;j++){
            H.push_back(T[i*W+j]);
        }
        if(i%2==0){
            for(int j=0;j<W;j++){
                if(j) cout<<" ";
                cout<<H[j];
            }
            cout<<endl;
        }else{
            for(int j=W-1;j>=0;j--){
                if(j!=W-1) cout<<" ";
                cout<<H[j];
            }
            cout<<endl;
        }
    }
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
	int x; cin>>x;
	cout << !x << endl;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
using lld = long long int ;

int main(){
    int N,M,K;
    cin >> N>> M >> K;
    lld a[N+1],b[M+1];
    a[0]=0;b[0]=0;
    lld temp=0;
    for(int i=1;i<N+1;i++){
        lld t=0;
        cin >> t;
        temp+=t;
        a[i]=temp;

    }
    temp=0;
    for(int i=1;i<M+1;i++){
        lld t=0;
        cin >> t;
        temp+=t;
        b[i]=temp;
    }
    int ans=0;
    int bestj=M;
    for(int i=0;i<N+1;i++){
        for(int j=bestj;j>=0;j--){
            if(a[i]+b[j]<=K){
                bestj=j;
                if(i+j>ans){
                    ans=i+j;
                }
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, m;
    cin >> n >> m;
    map<ll, ll, greater<ll>> ma;
    rep(i, n) {
        ll temp;
        cin >> temp;
        ma[temp]++;
    }
    rep(i, m) {
        ll b, c;
        cin >> b >> c;
        ma[c] += b;
    }
    ll cnt = n;
    ll ans = 0;
    for (auto iter = ma.begin(); iter != ma.end(); iter++) {
        auto key = iter->first;
        auto val = iter->second;
        // debug(key);
        // debug(val);
        ans += key * val;
        cnt -= val;
        if (cnt <= 0) {
            ans -= abs(cnt) * key;
            break;
        }
    }
    out(ans);
    return 0;
}


Measured memory_bytes: 12800
(defun sum (a b c)
  (+ (* 10000 a) (* 5000 b) (* 1000 c)))

(defun solver ()
  (let ((n (read)) (y (read)) (flag 0) (money 0) k)
    (loop named outer for i from n downto 0 do
          (loop named inner for j from (- n i) downto 0 do
                (setf k (- n i j) money (sum i j k))
                (when (= y money)
                  (incf flag)
                  (return-from outer (format t "~a ~a ~a~%" i j k)))))
    (when (= flag 0) (format t "-1 -1 -1~%"))))

(solver)


Measured memory_bytes: 15588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> x(n),y(n);
    rep(i,n) {
        cin >> a[i];
        x[i] = vector<int>(a[i]);
        y[i] = vector<int>(a[i]);
        rep(j, a[i]) {
            cin >> x[i][j];
            cin >> y[i][j];
            x[i][j]--;
        }
    }
    int max_honest=0;
    rep(bits,1<<n){
        bool ok_flag = true;
        rep(i, n) {
            if((bits & (1<<i)) == false) continue;
            rep(j, a[i]) {
                if(y[i][j] != (bits>>x[i][j]&1)) {
                    ok_flag = false;
                    //cout << i << y[i][j] << x[i][j] << " " << bitset<8>(bits)<<endl;
                }
            }
        }
        if(ok_flag) {chmax(max_honest, __builtin_popcount(bits));}
    }
    cout << max_honest << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n;
		cin >> n;
		vector<int> x(n), y(n);
		rep (i, n) {
			cin >> x[i] >> y[i];
		}
		auto dist = [&](int i, int j) {
			double dx = x[i] - x[j];
			double dy = y[i] - y[j];
			return sqrt(dx*dx + dy*dy);
		};
		vector<int> p(n);
		rep (i, n) {
			p[i] = i;
		}
		double len = 0;
		int cnt = 0;
		do {
			rep (i, n - 1) {
				len += dist(p[i], p[i + 1]);
			}
			cnt++;
		} while (next_permutation(p.begin(), p.end()));
		double ans = len / cnt;
		printf("%.10f\n", ans);
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256