akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<bool> cos(n + 1, false);

    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        cos[a] = true;
    }
    int c1 = 0, c2 = 0;
    for (int i = 1; i <= x - 1; i++) {
        if (cos[i])
            c1++;
    }
    for (int i = x + 1; i <= n; i++) {
        if (cos[i])
            c2++;
    }
    cout << min(c1, c2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n,r,rr=5,i0,i1,i2,i3,d[100010],ans[100010]={2,3,5,7,11};
  char p[100010]={1,1};
  
  scanf("%d",&n);
  for(i=2;i*i<60000;i++){
    if(p[i])continue;
    for(j=i*i;j<60000;j+=i)p[j]=1;
  }
  for(i=0;i<=55555;i++){
    d[r]=i;
    r+=1-p[i];
  }//printf("%d\n",r);
  for(i=rr=0;i<r;i++){
    if(d[i]%5-1)continue;
    rr++;
    if(rr>n)break;
    printf("%d%c",d[i],rr-n?' ':'\n');
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[110];
char t[110];

int main()
{       
        int n;
        cin >> n;
        cin >> s>> t;
        for(int i= 0; i< n; i++)
        {
                cout << s[i] << t[i];
        }
        cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, R, S, P; string T;
string grp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K >> R >> S >> P >> T;
	rep(i, 0, N) grp[i % K] += T[i];

	int ans = 0;
	rep(k, 0, K) {
		int r = 0, s = 0, p = 0;
		if (grp[k][0] == 'r') p = P;
		if (grp[k][0] == 's') r = R;
		if (grp[k][0] == 'p') s = S;

		int n = grp[k].size();
		rep(i, 1, n) {
			int rr = max(s, p);
			int ss = max(r, p);
			int pp = max(r, s);

			if (grp[k][i] == 'r') pp += P;
			if (grp[k][i] == 's') rr += R;
			if (grp[k][i] == 'p') ss += S;

			r = rr;
			s = ss;
			p = pp;
		}

		ans += max({ r, s, p });
	}
	cout << ans << endl;
}







Measured memory_bytes: 5328
#include<bits/stdc++.h>
#define R(n)for(L i=0;i<n;i++)
#define M make_pair
typedef long long L;
using namespace std;
int main(){
    L n,k,s,t,a[50];cin>>n>>k>>s>>t;
    R(n)cin>>a[i];
    map<pair<L,L>,L> p[50];
    R(n){
        for(L j=k-2;j+1;j--)for(auto&l:p[j])p[j+1][M(l.first.first&a[i],l.first.second|a[i])]+=l.second;
        p[0][M(a[i],a[i])]=1;
    }
    n=0;
    R(k)n+=p[i][M(s,t)];
    cout<<n;
}

Measured memory_bytes: 154028
#include<stdio.h>

int main(void){

    double r, s, l;
    
    scanf("%lf", &r);
    s = r * r * 3.141592653589793;
    l = 2 * r * 3.141592653589793;
    
    printf("%lf %lf\n", s, l);
    return 0;
}


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

struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
       if(d>0){
         e.cap-=d;
         G[e.to][e.rev].cap+=d;
         return d;
       }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
       fl+=f;
       lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
        if(e.cap==0&&flow(from,to,1)==0) {
          flow(from,s,1);
          flow(t,to,1);
          return 1;
        }
      }
    }
    return 0;
  }
};

int n,a[101][101],a1,a2,a3,p[1001],t[1001],m,m2;

int main(){
while(1){
  r(i,101)r(j,101)a[i][j]=(i==j?0:1e8);
  cin>>n>>m>>m2;
  if(n==0)return 0;
  r(i,m){
    cin>>a1>>a2>>a3;
    a[a2][a1]=a[a1][a2]=a3;
  }
  r(i,m2)cin>>p[i]>>t[i];
  r(k,n)r(i,n)r(j,n)a[i][j]=min(a[i][j],a[i][k]+a[k][j]);
  Dinic D(m2*2+2);
  r(i,m2){
    r(j,m2)if(i!=j){
      if(a[p[i]][p[j]]+t[i]<=t[j]){
        D.add_edge(i,j+m2,1);
      }
    }
  }
  r(i,m2)D.add_edge(m2*2,i,1);
  r(i,m2)D.add_edge(i+m2,m2*2+1,1);
  cout<<m2-D.flow(m2*2,m2*2+1,1e8)<<endl;
}
}


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

int calc(int x){
    if(x % 2 != 0) return 0;
    return calc(x/2) + 1;
}

int main(){
    int cnt = 0;
    int N;
    cin >> N;
    vector <int> a(N);
    for(int i = 0;i < N; i++) cin >> a[i];
    for(int i = 0;i < N; i++) cnt += calc(a[i]);
    cout << cnt << endl;

    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[2 << 20];
vector<int> que[2 << 20];

signed main() {
    cin >> N;
    for (int i = 0; i < 1 << N; i++) {
        cin >> A[i];
        que[i].push_back(A[i]);
    }
    rep(i, N) rep(b, 1 << N) {
        if (0 == (b & (1 << i))) {
            for (int j = 0; j < que[b].size(); j++) {
                que[b | (1 << i)].push_back(que[b][j]);
            }
            sort(que[b | (1 << i)].begin(), que[b | (1 << i)].end(), greater<int>());
            while (que[b | (1 << i)].size() > 2) {
                que[b | (1 << i)].pop_back();
            }
        }
    }
    int up = 0;
    for (int i = 1; i < 1 << N; i++) {
        up = max(up, que[i][0] + que[i][1]);
        cout << up << endl;
    }
}

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

const long long MOD = 1000000007;

// 入力
int H, W;
char a[1002][1002];

long long dp[1002][1002];

void solve(){
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			dp[i][j] %= MOD;
			if(a[i+1][j] == '.'){
				dp[i+1][j] += dp[i][j];
			}
			if(a[i][j+1] == '.'){
				dp[i][j+1] += dp[i][j];
			}
		}
	}
	cout << dp[H-1][W-1] << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W;
    for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
    		cin >> a[i][j];
    	}
    }
    solve();
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> w[i];
    sum += w[i];
  }
  int ans = 100000000;
  int buf = 0;
  for (int i = 0; i < n - 1; i++)
  {
    buf += w[i];
    ans = min(ans, abs((sum - buf) - buf));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <set>
#include <stack>
#include <bitset>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
#include <array>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b;
	cin >> a >> b;
	bool p=0;
	for(int i=0; i<=a; i++){
		if(i*2+(a-i)*4==b){
			p=1;
		}
	}
	if(p){
		cout << "Yes\n";
	}
	else{
		cout << "No\n";
	}
	return 0;
}

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

pair<int, int> store[200007];
int ans[200007];

int main()
{
    int N;
    cin >> N;

    for (int i = 1; i <= N; i++) {
        scanf("%d", &store[i].first);
        store[i].second = i;
    }

    sort(store+1, store+N+1);

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

        int L = N/2;
        if (L >= i) L++;
        ans[store[i].second] = store[L].first;
    }

    for (int i = 1; i <= N; i++) printf("%d\n", ans[i]);
}


Measured memory_bytes: 4480
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N = int(stdin.readline())
large = float('inf')
memo = {}
def cal_count(total):
    global memo
    if total in memo: return memo[total]
    if total < 0: return large
    if total == 0: return 0
    cans = []
    for i in range(1, 8):
        if 6 ** i > total: break
        cans.append(cal_count(total - 9 ** i))
        cans.append(cal_count(total - 6 ** i))
    cans.append(cal_count(total - 1))
    res = min(cans) + 1
    memo[total] = res
    return res
cnt = cal_count(N)
print(cnt)


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

vector<int> dp;
vector<vector<int>> to;
vector<int> deg; // 各頂点の入次数

int main() {
    int N, M;
    cin >> N >> M;
    dp.resize(N, 0);
    to.resize(N);
    deg.resize(N, 0);

    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        to[x].push_back(y);
        deg[y]++;
    }

    queue<int> q;
    rep(v, N) if (deg[v] == 0) q.push(v);

    while (!q.empty()) {
        int v = q.front();
        q.pop();

        for (auto nv : to[v]) {
            deg[nv]--;  // エッジ (v, nv) を破壊する
            if (deg[nv] == 0) {
                q.push(nv); // それによって入次数が 0 にあったならキューに突っ込む
                chmax(dp[nv], dp[v] + 1); // さらにソースから nv までの再長距離が確定する
            }
        }
    }

    int ans = 0;
    rep(v, N) chmax(ans, dp[v]);
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int INF = 1e9;
#define w first
#define h second
//#define DEBUG

int main() {
  int N, W, H;
  while(cin >>N >>W >>H && W){
    vector<P> cs;
    cs.push_back(P(W, H));
    REP(i, N){
      int L = (int)(cs.size());
      vector<P> tmp(L + 1, P(INF, INF));
      int p, s; cin >>p >>s;
      --p;
      REP(i, L) if(i != p) tmp[(i < p ? i : i - 1)] = cs[i];
#ifdef DEBUG
      cout <<"-----------" <<endl;
      cout <<s <<", " <<p <<endl;
      REP(j, L) cout <<"(" <<cs[j].w <<", " <<cs[j].h <<"), ";
      cout <<endl;
      REP(j, L + 1) cout <<"(" <<tmp[j].w <<", " <<tmp[j].h <<"), ";
      cout <<endl;
#endif
      //t = 0 ... w, t = 1 ... h
      int nwa = 0, nha = 0, t = 0;
      while(s > 0){
        if(t){
          int n = min(s, cs[p].h);
          s -= n;
          nha = (nha + n) % cs[p].h;
        } else{
          int n = min(s, cs[p].w);
          s -= n;
          nwa = (nwa + n) % cs[p].w;
        }
        t = (t + 1) % 2;
      }
      t = 1 - t;
      int nwb = cs[p].w, nhb = cs[p].h;
      if(t){
        nhb = cs[p].h - nha;
        nwa = cs[p].w;
      } else{
        nwb = cs[p].w - nwa;
        nha = cs[p].h;
      }
#ifdef DEBUG
      cout <<t <<" | " <<nwa <<", " <<nha <<" | " <<nwb <<", " <<nhb <<endl;
#endif
      if(nwa * nha > nwb * nhb){
        tmp[L - 1] = P(nwb, nhb);
        tmp[L] = P(nwa, nha);
      } else{
        tmp[L - 1] = P(nwa, nha);
        tmp[L] = P(nwb, nhb);
      }
      cs = tmp;
    }
    sort(cs.begin(), cs.end(), [](P a, P b) -> bool { return (a.w * a.h < b.w * b.h); });
    REP(i, cs.size()) cout <<(i == 0 ? "" : " ") <<cs[i].w * cs[i].h;
    cout <<endl;
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  int x, h, cnt = 0, ans = 0;
  for(int i=0; i<n; i++) {
    cin >> h;
    if(i==0) {
      x = h;
      continue;
    }
    
    else if(h <= x) cnt++;
    else if(h > x) {
      ans = max(ans, cnt);
      cnt = 0;
    }
    if(i==n-1) ans = max(ans, cnt);
    x = h;
  } 
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int n = Integer.parseInt(line);

        line = sc.nextLine();
        String[] l = line.split(" ");

        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
          a[i] = Integer.parseInt(l[i]);
        }

        for(int i = n - 1; 0 <= i; i--) {
          System.out.print(a[i]);
          if(i != 0) {
            System.out.print(" ");
          }
        }

        System.out.println();
    }
}

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

int main(){
  double m;
  int n;
  cin>>n>>m;
  double a[n];
  double cnt=0,sum=0;
  REP(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  REP(i,n){
    if (a[i]>=(sum/(4*m)))
    {
      /* code */
      cnt++;
    }
    
  }
  if (cnt>=m)
  {
    /* code */
    cout<<"Yes"<<endl;  }
    else
    {
      cout<<"No"<<endl;
    }
    
  
  }

Measured memory_bytes: 256
#include <math.h>
#include <iostream>

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(void){
  int N;
  std::cin >> N;
  for(int i=N; i<1000000;i++){
    if(IsPrime(i)){
      std::cout << i;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.*;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.InputStream;
import static java.lang.Math.*;

public class Main {

    public static void main(String[] args) {
        final String[] tasks = new String[]{"D","C","B","A"};
        for(final String task:tasks) {
            try {
                Class ca = Main.class.getClassLoader().loadClass(task);
                if (ca.getField("on").getInt(null) == 1) {
                    Object aTask = ca.newInstance();
                    Method m = ca.getMethod("S", null);
                    m.invoke(aTask, null);
                }
            } catch (Exception ex) { }
        }
    }

}

class A {
    public static int on = 1;

    public void run(){
        int n = ni();
        int a = ni();
        int b = ni();
        int d = Math.abs(a-b-1);

        if(d%2==0){
            pl("Borys");
        }else{
            pl("Alice");
        }









    }
    private InputReader in =  new InputReader(System.in);
    private PrintWriter out = new PrintWriter(System.out);
    public void S(){run();out.close(); }
    public int ni(){return Integer.parseInt(in.ns());}
    public long nl(){return Long.parseLong(in.ns());}
    public String ns(){return in.ns();}
    public void p(Object obj){out.print(obj);}
    public void ps(Object obj){p(obj);p(" ");}
    public void pl(Object obj){out.println(obj);}
    public int gcd(int a,int b){ while( b != 0 ) { int t = a % b;a = b;b = t; } return a; }
}

class B {
    public static int on = 0;

    public void run(){

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

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

}





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

int main(){
  int n;
  cin >> n;
  int h[n];
  int m =0,ret=0;
  for(int i=0;i<n;i++){
    cin >> h[i];
    if(m<=h[i])ret++;
    m = max(m,h[i]);
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}


double cross(complex<double>& a, complex<double>& b) {
  return a.real() * b.imag() - a.imag() * b.real();
}

int main() {
  int T; cin >> T;
  REP(t, T) {
    vector<double> in(8);
    REP(i, 8) cin >> in[i];
    
    complex<double> a(in[2]-in[0], in[3]-in[1]);
    complex<double> b(in[6]-in[4], in[7]-in[5]);
    double exter_product = cross(a, b);
    if (abs(exter_product) < EPS) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<iterator>
#include<cstdio>
#include<cstdlib>
#include<map>

using namespace std;
#define ll long long
#define pii pair<ll,ll>

const int MAX = 5e5+10;

vector<int>adj[MAX],adj1[MAX];

int col[MAX] , col1[MAX];
bool vis[MAX] , vis1[MAX];
int cur = 1;

void DFS(int src)
{
    col[src] = cur;
    vis[src] = 1;

    for(int j=0;j<adj[src].size();j++)
    {
        int i = adj[src][j];
        if(!vis[i])
            DFS(i);
    }
}
void DFS1(int src)
{
    col1[src] = cur;
    vis1[src] = 1;

    for(int j=0;j<adj1[src].size();j++)
    {
        int i = adj1[src][j];
        if(!vis1[i])
            DFS1(i);
    }
}

int main()
{
    int n,m1,m2;

    cin >> n >> m1 >> m2;

    int u,v;

    for(int i=0;i<m1;i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=0;i<m2;i++)
    {
        cin >> u >> v;
        adj1[u].push_back(v);
        adj1[v].push_back(u);
    }

    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            DFS(i);
            cur++;
        }
        if(!vis1[i])
        {
            DFS1(i);
            cur++;
        }
    }

    map<pii,int>mp;

    for(int i=1;i<=n;i++)
        mp[{col[i],col1[i]}]++;

    for(int i=1;i<=n;i++)
        cout << mp[{col[i],col1[i]}] << endl;
}


Measured memory_bytes: 44416
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define LL long long

const int MAXN = 2000000 + 5;

bool b[MAXN];

int main()
{
    int N, i, j, k;
    string S;
    cin >> N;
    cin >> S;
    for (i = k = 0, j = N - 1; i < j; k ++)
    {
        while (i < j && S[i] == 'R'){
            i ++;
        }
        while (i < j && S[j] == 'W' ){
            j --;
        }
        if (i >= j){
            break;
        }
        S[i] == 'R';
        i ++;
        S[j] = 'W';
        j --;
    }
    cout << k;
    system("pause");
    return 0;
}

Measured memory_bytes: 3772
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var W = new string[N];
        for (int i = 0; i < N; i++) {
            W[i] = ReadLine();
        }

        if (W.Length != W.Distinct().Count()) {
            WriteLine("No");
            return;
        }

        for (int i = 1; i < N; i++) {
            if (W[i-1].ToCharArray().Last() != W[i].ToCharArray().First()) {
                WriteLine("No");
                return;
            }
        }

        WriteLine("Yes");
    }
}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {

        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 13280
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
a = N // 100
N = N - a * 100
b = N // 10
N = N - b * 10
if a == 7 or b == 7 or N == 7:
    print("Yes")
else:
    print("No")

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 2e+5;

int main() {
  int N;
  ll T;
  std::cin >> N >> T;

  ll ans = 0, stop = 0;
  rep(i, N) {
    ll t;
    std::cin >> t;
    ans += std::min(T, t + T - stop);
    stop = t + T;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
n = gets.to_i
count = 0
(3..n.to_s.size).each do |i|
  sets = ['7', '5', '3'].repeated_permutation(i).to_a
  sets.each do |set|
    if set.include?('7') && set.include?('5') && set.include?('3') && set.join.to_i <= n
      count += 1
    end
  end
end

puts count

Measured memory_bytes: 8188
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative
import           Debug.Trace
import           Text.Printf


readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

solve a b k = if k <= a
              then (a-k,b)
              else if k - a <= b
                   then (0, b - (k-a))
                   else (0,0)

main = do
  [a,b,k] <- map read . words <$> getLine :: IO [Int]
  let (a',b') = solve a b k
  printf "%d %d\n" a' b'


Measured memory_bytes: 508
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- sort <$> readInts
	k <- readInt
	print $ a + b + c * 2 ^ k

Measured memory_bytes: 508
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    char c;
    cin >> c;
    
    if(c!='z')
    cout << (char)(c+1);
    else
    cout << "z";
    
	return 0;
    
}

Measured memory_bytes: 8832
#include <stdio.h>
int main(){
  int i,j,n,f,c=0,h[101]={0};
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    f=1;
    scanf("%d",&h[i]);
    for(j=0;j<i;j++)if(h[i]<h[j])f=0;
    if(f==1)c++;
  }
  printf("%d",c);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+10,MOD=1e9+7;
char a[N];
int n,D,num[N],dp[N][110];
int Search(int k,int sum,int lim,int preo)
{
	if ((!lim)&&(!preo)&&dp[k][sum]!=-1) return dp[k][sum];//´íÎó±Ê¼Ç£º¶¨¸ñºÍÓÐÇ°µ¼0µÄÇé¿ö²»ÄÜÖ±½Ó·µ»Ø 
	if (k>n) if (!sum) return 1; else return 0;
	int s=0,maxd=(lim?num[k]:9);
	for (register int i=0;i<=maxd;++i) s=(s+Search(k+1,(sum+i)%D,lim&&(i==num[k]),preo&&(i==0)))%MOD;
	if ((!lim)&&(!preo)) dp[k][sum]=s;
	return s;
}
int main()
{
	scanf("%s%d",a+1,&D);n=strlen(a+1);
	for (register int i=1;i<=n;++i) num[i]=a[i]-'0';
	memset(dp,-1,sizeof(dp));
	printf("%d\n",(Search(1,0,1,1)-1+MOD)%MOD);
	return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 2e5 + 10;

priority_queue<ll> lo;
priority_queue<ll, vector<ll>, greater<ll>> hi;
ll vallo, valhi;
ll bon;

void addlo(ll x){
	if(lo.size()){
		if(x > lo.top())
			vallo += lo.size() * (x - lo.top());	
		else 
			vallo += lo.top() - x;
	}
	lo.push(x);
}

void addhi(ll x){
	if(hi.size()){
		if(x < hi.top())
			valhi += hi.size() * (hi.top() - x);	
		else 
			valhi += x - hi.top();
	}
		
	hi.push(x);
}

ll remlo(){
	ll ret = lo.top();
	lo.pop();
	if(lo.size() > 0) vallo -= (ret - lo.top()) * lo.size();
	return ret;
}

ll remhi(){
	ll ret = hi.top();
	hi.pop();
	if(hi.size() > 0) valhi -= (hi.top() - ret) * hi.size();
	return ret;
}

int n;

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	int q;	
	cin >> q;
	while(q--){
		int typ; cin >> typ;
		if(typ == 1){
			ll a, b;
			cin >> a >> b;
			bon += b;

			if(hi.empty() || a <= hi.top()) addlo(a);
			else addhi(a);
			

			while(hi.size() > lo.size())
				addlo(remhi());
			while(lo.size() > hi.size() + 1)
				addhi(remlo());
		}	else {
			ll lov, hiv, losz=lo.size(), hisz=hi.size();
			if(losz) lov = lo.top();
			if(hisz) hiv = hi.top();
			cout << lov << " " << vallo + valhi + (hiv - lov) * hisz + bon << "\n";
		}
	}
}


Measured memory_bytes: 3828
n = int(input())
l = list(map(int, input().split()))
min_= sum(l)
r = []
for i in l:
    r.append(i)
    R = sum(r)
    L = sum(l)-R
    dif= abs(R-L)
    min_ = min(min_, dif)
print(min_)

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

uint64_t calc(uint64_t x) {
    uint64_t cnt = 0;
    uint64_t b = x;
    while (b % 2 == 0) {
        b /= 2;
        ++cnt;
    }

    return cnt;
}

int main() {
    uint64_t N;
    std::cin >> N;
   
    uint64_t cnt = 0, a;
    for (size_t i = 0; i < N; ++i) {
        std::cin >> a;
        cnt += calc(a);
    }

    std::cout << cnt << std::endl;

    return 0;
}


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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i,n) {
   cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n & 1) {
    int i = n / 2;
    cout << b[i] - a[i] + 1 << endl;
  } else {
    int i = n / 2 - 1, j = i + 1;
    int mi = a[i] + a[j], mx = b[i] + b[j]; 
    cout << mx - mi + 1 << endl;
  }
  return 0;
} 

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a > 12){
        cout << b << endl;
    }
    else if(a < 6){
        cout << 0 << endl;
    }
    else{
        cout << b/2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

int main() {
    ll r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;

  // ここにプログラムを追記
  if      (S == "a" ) {
      cout << "vowel" << endl;
     }
  else if (S == "i") {
        cout << "vowel" << endl;
     }
 else if (S == "u") {
        cout << "vowel" << endl;
     }
 else if (S == "e") {
        cout << "vowel" << endl;
     }
 else if (S == "o"){
        cout << "vowel" << endl;
     }
 else 
        cout << "consonant" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(a,b) a^=b^=a^=b
int main(){
  int x,y,r;
  scanf("%d%d",&x,&y);
  if(x<y)
    swap(x,y);
  while(y>0){
    r=x%y;
    x=y;
    y=r;
      }
    printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long s = sc.nextLong();
		long c = sc.nextLong();
		long scc = 0;
		
		if(s>=c/2) {
			scc = c/2;
		}else {
			scc += s;
			c -= 2*s;
			scc += c/4;
		}
		
		System.out.println(scc);

	}

}


Measured memory_bytes: 21844
#include<stdio.h>
#define N 40

int n,pos;
int a[N],b[N];

void solve(int, int);

void solve(int l,int r){
  int x,i;

  x = a[pos];
  if( l > r ) return;
  if( l == r ){
    if( b[l] == a[0] ) printf("%d", b[l]);
    else printf("%d ", b[l]);
    pos++;

    return;
  }
  pos++;

  for( i = l ; i <= r ; i++){
    if( b[i] == x ) break;
  }
  solve( l, i-1);
  solve( i+1, r);

  if( x == a[0]) printf("%d", x);
  else printf("%d ", x);
}


int main(){
  int i;

  scanf("%d", &n);
  for( i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
  }
  for( i = 0 ; i < n ; i++){
    scanf("%d", &b[i]);
  }
  pos = 0;
  solve( 0, n-1);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2092
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	int h, w;
	int count = 0;
	char a[9][9];
	cin >> h >> w;
	FOR(i, 1, h) {
		FOR(t, 1, w) {
			cin >> a[i][t];
			if (a[i][t] == '#') {
				count++;
			}
		}
	}
	if (count == h + w - 1) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.size();
	if (s[n - 1] != 's') s += 's';
	else s += "es";
	cout << s; 
	return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}

vector<vector<int>> solve_n3(int n, string s) {
  vector<vector<int>>dp(n + 1, vector<int>(n + 1, 0));
  dp[1][1] = 1;
  for (int len = 2; len <= n; ++len) {
    for (int b = 1; b <= len; ++b) { // curr number in perm
      for (int a = 1; a <= len - 1; ++a) { // prev number in perm
        if ((a >= b) != (s[len - 2] == '>')) { // unneccessary computation since looks at bad domain
          continue;
        }
        add_self(dp[len][b], dp[len-1][a]);
      }
    }
  }
  return dp;
}

vector<vector<int>> solve_n2(int n, string s) {
  vector<vector<int>>dp(n + 1, vector<int>(n + 1, 0));
  vector<vector<int>>pref(n + 1, vector<int>(n + 1, 0));  
  dp[1][1] = 1;
  for (int len = 2; len <= n; ++len) {
    for (int i = 1; i <= len; i++) {
      add_self(pref[len-1][i], pref[len-1][i-1] + dp[len-1][i]);
    }
    for (int b = 1; b <= len; ++b) { // curr number in perm
      int l, r; // boundaries for the value of previous position in perm
      if (s[len - 2] == '>') {
        l = b, r = len - 1;
      } else {
        l = 1, r = b - 1;
      }
      if (l <= r)
        add_self(dp[len][b], (pref[len-1][r] - pref[len-1][l-1] + mod) % mod);
    }
  }
  return dp;
}

int main() {
  int n; string s; 
  cin >> n >> s;
  auto dp = solve_n2(n, s);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    add_self(ans, dp[n][i]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 70784
n = int(input())
if n==1:
    print(0)
    exit(0)
primes = [True]*(n+1)
primes[0] = False
primes[1] = False
for i in range(2, n+1):
    if primes[i]:
        for j in range(i*2, n+1, i):
            primes[j] = False
primes = [i for i, j in enumerate(primes) if j]
factors = {2:0, 4:0, 14:0, 24:0, 74:0}
for i in primes:
    tmp = 0
    j = i
    while j<=n:
        tmp += n//j
        j *= i
    for k in factors:
        if tmp>=k:
            factors[k] += 1
ans = factors[4]*(factors[4]-1)*(factors[2]-2)//2
ans += factors[14]*(factors[4]-1)
ans += factors[24]*(factors[2]-1)
ans += factors[74]
print(ans)

Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! chmax {
    ($x:expr, $e:expr) => {
        if $x < $e {
            $x = $e;
        }
    };
}
macro_rules! chmin {
    ($x:expr, $e:expr) => {
        if $x > $e {
            $x = $e;
        }
    };
}

const INF: i64 = 1 << 60;

fn f(c: char, n: u8) -> char {
    let ret = (c as u8 + n) as u8;
    if ret > 'Z' as u8 {
        (ret - 26) as char
    } else {
        ret as char
    }
}

fn main() {
    input!{
        N: usize,
        S: chars,
    }
    let ans: String = S.into_iter().map(|c| f(c, N as u8)).collect();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int factorial(int n)
{
	int ret = 1;
	while (n > 0) {
		ret *= n;
		n--;
	}
	return ret;
}

int main()
{
	/*int r;
	cin >> r;
	cout << r * r;*/


	/*int n;
	string s;
	cin >> n >> s;
	if (n % 2 == 1) {
		puts("No");
		return 0;
	}
	if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
		puts("Yes");
		return 0;
	}
	else {
		puts("No");
	}*/


	int n;
	cin >> n;
	vector<pair<double, double>>p(n);
	rep(i, n)cin >> p[i].first >> p[i].second;
	double ans = 0;
	rep(i, n)rep(j, i) {
		ans += sqrt(pow(p[i].first - p[j].first, 2) + pow(p[i].second - p[j].second, 2));
	}
	int N = factorial(n);
	ans *= factorial(n - 1) * 2;
	ans /= N;
	cout << setprecision(9)<<ans;



	/*int x, y;
	cin >> x >> y;
	int mod = 1e9 + 7;
	vector<vector<ll>>dp(x+3, vector<ll>(y+3));
	dp[x][y] = 1;
	dp[x + 1][y + 1] = 0;
	dp[x + 1][y + 2] = 0;
	dp[x + 2][y + 1] = 0;
	dp[x + 2][y + 2] = 0;
	rep(i, x+1)rep(j, y+1) {
		if (x - i >= 0 && y - i >= 0) {
			dp[x - i][y - j] += dp[x - i + 1][y - j + 2] + dp[x - i + 2][y - j + 1];
			dp[x - i][y - i] %= mod;
		}
		else break;
	}
	cout << dp[0][0];*/
	return 0;
}

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

#define fi first
#define se second
#define mk(a,b) make_pair(a,b)

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

int N, D;
int X[20][20];

int main()
{
    cin >> N >> D;
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < D; j++)
        {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            int tmp = 0;
            for(int k = 0; k < D; k++)
            {
                tmp += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }

            double d = tmp;
            if(sqrt(d) == (double)((int)sqrt(d)))ans++;
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a)  (a).begin(),(a).end()



using Graph=V<V<int>>;

signed main(){
  int n,x,y;
  cin>>n>>x>>y;
  Graph G(n);
  fo(i,n-1){
    G[i+1].pb(i);
    G[i].pb(i+1);
  }
  G[x-1].pb(y-1);
  G[y-1].pb(x-1);

  V<int> ans(n+5,0);

  fo(i,n){
    V<int> dist(n,-1);
    queue<int> q;
    dist[i]=0;
    q.push(i);

    while(!q.empty()){
      int v=q.front();
      q.pop();
      for(int nv : G[v]){
        if(dist[nv]!=-1)
          continue;
        dist[nv]=dist[v]+1;
        q.push(nv);

      }
    }
    fo(j,n){
      ans[dist[j]]++;
    }
  }
  for(int i=1; i<n; i++){
    cout<<ans[i]/2<<endl;
  }
}


Measured memory_bytes: 384
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
    t = 0
    for j in range(i,n-1):
        if t <= ary[j][1]:t = ary[j][1]
        elif t % ary[j][2] == 0:t += 0
        else: t += ary[j][2] - (t % ary[j][2])
        t += ary[j][0]
    print(t)

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

int main(){
    int difmax = 0,ans = 0;
    for(int i=0;i<5;i++){
        int x;
        cin >> x;
        ans += x % 10 == 0 ? x : x + 10 - (x % 10);
        difmax = difmax >= (10 - (x % 10)) % 10 ? difmax : 10 - (x % 10);
    }
    ans -= difmax;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


	public class Main {
		
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int x = sc.nextInt();
			int n = sc.nextInt();
			ArrayList<Integer> p = new ArrayList<Integer>();
			
			for(int i=0;i<n;i++) {
				p.add(sc.nextInt());
			}
			
			for(int i=0;;i++) {
				if(!p.contains((x-i))) {
					System.out.println(x-i);
					return;
				}
				
				if(!p.contains((x+i))) {
					System.out.println(x+i);
					return;
				}
			}
			
		}
	}


Measured memory_bytes: 36024
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int a=0;a<n;a++){
		int k;
		cin>>k;
		if(k%2 == 0){
			if(k%3 != 0 && k%5 != 0){
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 256