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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}



template<typename T, T MOD = 1000000007>
struct Mint {
	T v;

	Mint() : v(0) {}
	Mint(signed v) : v(v) {}
	Mint(ll t) { v = t % MOD; if (v < 0) v += MOD; }

	Mint pow(ll k) {
		Mint res(1), tmp(v);

		while (k) {

			if (k & 1) res *= tmp;

			tmp *= tmp;
			k >>= 1;
		}



		return res;
	}

	Mint inv() { return pow(MOD - 2); }

	Mint& operator=(Mint a) { if (a.v >= MOD) a.v %= MOD; v = a.v; return *this; }
	Mint& operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; }
	Mint& operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; }
	Mint& operator/=(Mint a) { return (*this) *= a.inv(); }
	Mint operator+(Mint a) const { return Mint(v) += a; }
	Mint operator-(Mint a) const { return Mint(v) -= a; }
	Mint operator*(Mint a) const { return Mint(v) *= a; }
	Mint operator/(Mint a) const { return Mint(v) /= a; }

	Mint operator-() { return v ? MOD - v : v; }
	bool operator==(const Mint a) const { return v == a.v; }
	bool operator!=(const Mint a) const { return v != a.v; }
	bool operator < (const Mint a) const { return a < a.v; }


};

using M = Mint<ll>;

M dp[100005], ans[2][100005], sum[100005], ruijou[100005];
int main() {
	string L;

	cin >> L;

	ruijou[0] = 1;
	rep(i, L.size() + 1) {
		ruijou[i+1] = M(3) * ruijou[i];
	}

	ll k = L.size();

	dp[1] = 3;
	sum[1] = 3;
	sum[0] = 1;
	for(int l = 1; l < L.size()+1; l++) {
		dp[l+1] = ruijou[l] * 2;
		sum[l + 1] = sum[l] + dp[l + 1];
	}


	M ans;
	ans.v = 0;
	ll num_1 = 0;
	rep(i, L.size()) {

		if (L[i] == '1') {
			ans += M(2).pow(num_1) * sum[L.size() - i - 1];
			num_1 += 1;
		}

	}
	
	ans += M(2).pow(num_1);

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int H,W,K; cin>>H>>W>>K;
    vector<vector<char>> M(H,vector<char>(W));
    rep(h,0,H)rep(w,0,W) cin>>M.at(h).at(w);

    int ans=0;
    rep(i,0,1<<H){
        bitset<6> bh(i);

        rep(j,0,1<<W){
            bitset<6> bw(j);

            int numB=0;
            rep(h,0,H)rep(w,0,W){
                if(bh.test(h) && bw.test(w) && M.at(h).at(w)=='#') numB++;
            }
            if(numB==K) ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
int ensyu,kensu,maxsa=0,i,k,first,before=0,now;
(void)scanf("%d %d",&ensyu,&kensu);
for(i=0;i<kensu;i++){
    (void)scanf("%d",&now);
    if(i==0)
    first=now;
    if(maxsa<(now-before))
    maxsa=(now-before);
    before=now;
}
if(first+ensyu-now>maxsa)
maxsa=first+ensyu-now;
printf("%d\n",ensyu-maxsa);
return 0;
}

Measured memory_bytes: 256
N=int(input())

A=[]
test = []
for i in range(N):
    A_i= int(input())
    A.append(A_i)
    testimony_i=[]
    for j in range(A_i):
        x,y= map(int,input().split())

        testimony_i.append([x,y])
    
    test.append(testimony_i)

total=0
for i in range(2**N):

    member = format(i,'0{}b'.format(N))

    flg = 0

    for j in range(N):
        if member[j]== '1':

            syogen = test[j]

            for s in syogen:
                if member[s[0]-1]==str(s[1]):
                    continue
                else:
                    flg+=1

    if flg ==0:
        total = max(total , member.count('1')) 

print(total)




Measured memory_bytes: 43484
s,t =input(),input()
inf = float('inf')
dp =[[0 for _ in range(3100)] for _ in range(3100)]
#DPループ
for i in range(len(s)):
    for j in range(len(t)):
        if (s[i] == t[j]):
            dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j] + 1)
        dp[i + 1][j + 1] = max(dp[i+1][j+1],dp[i+1][j])
        dp[i + 1][j + 1] = max(dp[i+1][j+1],dp[i][j+1])
#復元
res = ''
i,j = len(s),len(t)
while (i > 0 and j >0):
    # (i - 1, j) -> (i, j)と更新されていた場合
    if (dp[i][j] == dp[i - 1][j]):
        i -= 1  # DP の遷移を遡る
    # (i, j - 1) -> (i, j)と更新されていた場合
    elif (dp[i][j] == dp[i][j - 1]):
        j -= 1  # DP の遷移を遡る
    # (i - 1, j - 1) -> (i, j)と更新されていた場合
    else:
        res = s[i - 1] + res  # このときs[i - 1] == t[j - 1]なので、t[j - 1] + resでもOK
        i -= 1
        j -= 1  # DPの遷移を遡る
print(res)

Measured memory_bytes: 122588
#include <stdio.h>

int main(void)
{
    int h, w;
    int i, j;
    
    scanf("%d%d", &h, &w);
    
    while(h!=0 || w!=0){
        for(i=0; i<h; i++){
            for(j=0; j<w; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        
        scanf("%d%d", &h, &w);
    }
    
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

int main(){
  int D, E;
  while(cin >> D >> E && D) {
    double res = 1e7;
    for(int y = 0; y <= D; ++y) {
      int x = D - y;
      double tmp = abs(sqrt(x * x + y * y) - E);
      if(tmp < res) res = tmp;
    }
    cout << fixed << setprecision(10) << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;


int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;

    if (u == s) a--;
    else b--;

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int >
#define F first
#define S second
#define mod 1000000000

/// cout <<"Case #"<<it<<": ";
using namespace std;
bool solve(string s,string t){
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]) return false;
    }
    return true;
}
int main()
{   ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    string s,t; cin >> s>> t;
    if(solve(s,t)){
        cout <<"Yes"<< endl;
    }else{
        cout <<"No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N,x;
  cin >> N >> x;
  vector<int> vec(N);
  rep(i,N)
  {
    cin >> vec[i];
  }
  sort(ALL(vec));
  int ans = 0;
  for(int i=0;i<N-1;i++)
  {
    if(x>=vec[i]){
    x -= vec[i];
    ans ++;
    }
  }
  if(x==vec[N-1])
  {
    ans ++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

char s[100010];

int main() {
  int k;
  scanf("%s %d", s, &k);
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'a') {
      continue;
    }
    int z = 'z' - s[i] + 1;
    if (z > k) {
      continue;
    }
    k -= z;
    s[i] = 'a';
  }
  if (k > 0) {
    int len = strlen(s);
    s[len - 1] = 'a' + (s[len - 1] - 'a' + k) % 26;
  }
  printf("%s\n", s);
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int gcd(int a,int b){
    if(a<=0||b<=0){
        return 0;
    }
    if(a<b)swap(a,b);
    int r=a%b;
    while(r){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}
int lcm(int a,int b){
    return a / gcd(a,b) * b;
}



signed main(){
    int N,M;
    string S,T;
    cin >> N >> M;
    cin >> S >> T;
    int G=gcd(N,M);
    int L=lcm(N,M);
    for(int i=0;i<G;i++){
        if(S[i*N/G]!=T[i*M/G]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;;
    
    return 0;
}   


Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

static int watering(const vec<int> &h, vec<int> &f, int N) {
  bool is_changed = false;
  int res = 0;
  REP(i, N) {
    if (h[i] > f[i]) {
      if (!is_changed) {
        is_changed = true;
        res++;
      }
      f[i]++;
    } else {
      is_changed = false;
    }
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  vec<int> h(N);
  REP(i, N) cin >> h[i];

  vec<int> f(N, 0);
  int res = 0;
  REP(i, 101) res += watering(h, f, N);
  cout << res << endl;
  return 0;
}


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

using namespace std;

using int64 = long long;

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

  int sum = 0;
  for(int i = 1; i < N; i++) {
    if(S[i - 1] == 'x' && S[i] == 'x') {
      cout << i << endl;
      return 0;
    }
  }
  cout << N << endl;
}




Measured memory_bytes: 3336
N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
V=sum(v)

dp=[[float("inf") ]*(V+1) for _ in range(110)]
dp[0][0]=0

for i in range(0,N):
    for j in range(V+1):
        if j-v[i]>=0:
            dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i])
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
ans=0
for j in range(V+1):
    if dp[N][j]<=W:
        ans=j
print(ans)


Measured memory_bytes: 313232
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    //sr%m == sl%m
    int n,m;cin >>n >> m;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    map<int,int> mp;
    vector<int> s(n+1);
    rep(i,n)s[i+1] = (s[i] + a[i])%m;
    int ret = 0;
    rep(i,n+1){
        ret += mp[s[i]];
        mp[s[i]]++;
    }
    cout <<ret << endl;
    return 0;
}

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

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

        int n = Integer.parseInt(br.readLine());
        int[] s = new int[n];
        int[] l = new int[n];
        int[] p = new int[n];
        for(int i = 0; i < n; i++) {
            String[] in = br.readLine().split(" ");
            s[i] = Integer.parseInt(in[0]);
            l[i] = Integer.parseInt(in[1]);
            p[i] = Integer.parseInt(in[2]);
        }

        int m = Integer.parseInt(br.readLine());
        int[] w = new int[m];
        int maxw = 0;
        for(int i = 0; i < m; i++) {
            w[i] = Integer.parseInt(br.readLine());
            maxw = Math.max(maxw, w[i]);
        }

        int[][] dp = new int[n + 1][maxw + 1];
        for(int i = 0; i <= n; i++) {
            for(int j = 1; j <= maxw; j++) {
                dp[i][j] = -1;
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j <= maxw; j++) {
                dp[i + 1][j] = dp[i][j];
                int min = Math.max(0, j - l[i]);
                int max = j - s[i];
                for(int k = min; k <= max; k++) {
                    if(dp[i + 1][k] != -1) {
                        dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i + 1][k] + p[i]);
                    }
                }
            }
        }

        boolean flag = true;
        for(int i = 0; i < m; i++) {
            if(dp[n][w[i]] == -1) {
                flag = false;
                break;
            }
        }

        if(flag) {
            for(int i = 0; i < m; i++) {
                System.out.println(dp[n][w[i]]);
            }
        }else {
            System.out.println(-1);
        }

        br.close();
    }
}


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

int main(void){
    // Your code here!
    int A, B, C, X, Y;
    int sum;
    cin >> A >> B >> C >> X >> Y;
    
    if (A + B > (C * 2)) {
        if (X == Y){
            sum = X * C * 2;
        } else if (X > Y) {
            sum = Y * C * 2 + (X - Y) * A;
            if ((X * C * 2) < sum) sum = X * C * 2;
        } else if (Y > X) {
            sum = X * C * 2 + (Y - X) * B;
            if ((Y * C * 2) < sum) sum = Y * C * 2;
        }
    } else {
        sum = X * A + Y * B;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
from math import cos, pi

value = input().split()
for i in range(len(value)):
    value[i] = int(value[i])

if 0 <= value[0] <= 23 and 0 <= value[2] <= 23 and 0 <= value[1] <= 59 and 0 <= value[3] <= 59 and value[4] >= 1:
    W = (value[2] - value[0])*60 + value[3] - value[1] - value[4]
    print(W)
else:
    print("you enter value not in the valid range")

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef vector<pi> vp;

#define pb push_back
#define mp make_pair
#define fora(i, a, n) for(int i = a; i < n; i++)
#define forb(i, a, n) for (int i = a; i >= (n); --i)
#define PI 3.1415926535897932384626433832795
#define INF 1e9

int main(){ 
ios::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);

double n, m;
cin >> n >> m;
vi v;
double sum = 0;
fora(i, 0, n){
    double p; cin >> p;
    v.pb(p);
    sum+=p;
}
//cout << sum;
//sort(v.rbegin(), v.rend());
double ans = 0;
fora(i, 0, n){
    if(v[i] < (sum/(m*4))) continue;
    else ans++;  
}

if(m <= ans) cout << "Yes" << endl;
else cout << "No" << endl; 

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int input;
    const int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
    bool check[10];

    while (cin >> input) {
        for (int i = 0; i < 10; i++)
            check[i] = false;

        int tmp = input;
        for (int i = 0; tmp != 0; i++) {
            if (tmp % 2)
                check[i] = true;
            tmp /= 2;
        }

        int max = 0;
        for (int i = 0; i < 10; i++)
            if (check[i] && i > max)
                max = i;

        for (int i = 0; i < max; i++)
            if (check[i])
                cout << weight[i] << " ";
        cout << weight[max] << endl;
    }

    return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n;
  cin >> n;
  gram g(n+1);
  ll a,b,c;
  rep(i,n-1){
    cin >> a >> b >> c;
    g[a][b]=c;
    g[b][a]=c;
  }
  ll q, k;
  cin >> q >> k;
  ll klist[n+1];

  ll co =0;
  function<void(const gram&,ll, ll,ll)> dfs = [&](const gram &g, ll p,ll v,ll cost) {
      co++;
      klist[v]=cost;
      for(auto next_v:g[v]){
          if(next_v.first==p)continue;
          dfs(g,v,next_v.first,cost + next_v.second);
      }
  };
  dfs(g,-1,k,0);
  ll x,y;
  rep(i,q){
    cin >> x >> y;
    pri(klist[x]+klist[y]);
  }
  return 0;
}


Measured memory_bytes: 28416
// Problem : C - Distinct or Not
// Contest : AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_c
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
    KAMEHAMEHA
//    #ifdef _soumik
//        freopen("input.txt", "r", stdin);
//    #endif
	int n;
	cin>>n;
	vi a;
	for(int i=0,temp;i<n;i++)
	{
		cin>>temp;
		a.eb(temp);
	}
	sort(all(a));
	for(int i=0;i<n-1;i++)
	{
		if(a[i]==a[i+1])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll X;
    cin >> X;
    ll ans = X / 500 * 1000 + (X%500)/5 * 5;
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
...........__________    							 |										    ___  __
.............|       |     						     |											 |   /
.............|       |     						     |									  		 |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
.........  __|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int 				long long
#define ull 				unsigned long long int
#define ld 					long double
#define vi 					vector<int>
#define vii 				vector<pair<int,int>>
#define vvi 				vector<vector<int>>
#define pf 					push_front
#define popb 				pop_back
#define pb 					push_back
#define eb 					emplace_back
#define pii 				pair<int,int>
#define prec(x) 			fixed<<setprecision(15)<<x
#define all(x) 				x.begin(),x.end()
#define rall(x) 			x.rbegin(),x.rend()
#define mset(a,b) 			memset(a,b,sizeof(a))
#define mcpy(a,b) 			memcpy(a,b,sizeof(a))
#define fo0(i,n) 			for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n) 			for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b) 			for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)			for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)			for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define inf 1e18
const int mod=1e9+7;
const int N=4e5+10;

void raushan_kumar(){
	int n,a,b;cin>>n>>a>>b;
	int s=a+b;
	int q=n/s;
	int r=n%s;
	int ans=q*a+(r>=a?a:r);
	cout<<ans;
}

int32_t main()
{
	
	fast;int t=1;
	//cin>>t;
	while(t--){
		raushan_kumar();
	}

}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i)=0; (i)<n; ++(i))
#define rep1(i,n) for(int (i)=1; (i)<=n; ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))

typedef long long ll;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

vector<long long> frac;

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	//vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long nextsub(unsigned long long sub){
	unsigned long long tem = sub + (sub & -sub);
	unsigned long long btm = (~(tem) & sub) / (sub & -sub);
	return btm | tem;
}

inline void solve(){
	int p1,p2,n,a[200001],b[200001]={};
	cin>>n; frac=Frac(n+1);
	rep(i,1+n){
		cin>>a[i];
		if(b[a[i]]){ p1=b[a[i]]; p2=1+i; }
		b[a[i]] = i+1; 
	} 
	rep1(k,1+n){
		cout<<(Comb(1+n,k)-Comb(p1+n-p2,k-1)+MOD)%MOD<<endl;
	}
	return;
}

inline void input(){

	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}





Measured memory_bytes: 3316
import sys
N, A, B, C, D = map(int, input().split())
S = list(input())

tmp = 0
for i in range(A-1, C):
    if S[i] == "#":
        tmp += 1
    if S[i] == ".":
        tmp = 0
    if tmp == 2:
        print("No")
        sys.exit()

tmp = 0
for i in range(B-1, D):
    if S[i] == "#":
        tmp += 1
    if S[i] == ".":
        tmp = 0
    if tmp == 2:
        print("No")
        sys.exit()


tmp = 0
if C < D:
    print("Yes")
else:
    for i in range(B-2, D+1):
        if S[i] == ".":
            tmp += 1
        if S[i] == "#":
            tmp = 0
        if tmp == 3:
            print("Yes")
            sys.exit()
    print("No")

Measured memory_bytes: 4916
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;

  int res=0;
  rep(i,n-1){
    if(s[i]!=s[i+1]) res++;
  }
  res++;
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

int main(void) {
    int n, x;
    read(n);
    vector <int> a, rol;
    rep (i, n) read(x), a.push_back(--x);
    rep (k, n) {
        int p = -1;
        re0 (i, a.size())
            if (a[i] == i) {
                if (p == -1 || a[p] < a[i]) p = i;
            }
        if (p == -1) return cout << -1 << "\n", 0;
        rol.push_back(a[p] + 1);
        a.erase(a.begin() + p);
    }
    reverse(rol.begin(), rol.end());
    for (int i : rol) cout << i << "\n";
}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val list = readLine()!!.split(" ").map { it.toLong() }
    val a = mutableListOf<Long>()
    val b = mutableListOf<Long>()
    (0 until n).forEach {
        if(it % 2 == 0) {
            a.add(list[it])
        } else {
            b.add(list[it])
        }
    }
    val ans = mutableListOf<Long>()
    if(n % 2 == 0) {
        ans.addAll(b.reversed())
        ans.addAll(a)
    } else {
        ans.addAll(a.reversed())
        ans.addAll(b)
    }
    println(ans.joinToString(" "))
}

Measured memory_bytes: 100996
N = int(input())
import math
def devision(N):
    i = int(math.sqrt(N))
    a = list()
    for j in range(1,i+1):
        if N % j == 0:
            a.append(j)
    return a[len(a)-1]
def move(N):
    return (devision(N) + N//devision(N) - 2)
print(move(N))

Measured memory_bytes: 3188
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;
 
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int l[200000];
int r[200000];
int p[100000];
int q[100000];
int dp[501][501];
int main() {
  int n;
  cin >> n;
  char t;
  rep(i,n){
    cin >> t;
    if(t =='Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
    cout << "Three" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,x,count=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            int rem  = x -( 500*i + 100*j);
            if(rem>=0 && rem/50 <=c )
            {
                count++;
            }
        }
    }
    cout<<count<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int x,t; cin>>x>>t;
    if(x>=t) cout<<x-t<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
N = list(range(1,n+1))
c = []
a = 0
for i in N:
  if N[i-1] != p[i-1]:
    a += 1
if a == 2 or a==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll a, ll b){ return b? gcd(b, a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}

int main(){
    int h, a;
    cin >> h >> a;
    cout << (h+a-1) / a << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = list(filter(lambda x: x % 2 == 0, a))
a = [True if (i % 3 == 0 or i % 5 == 0) else False for i in a]
if all(a):
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 38384
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
    if(b==1){
      cout<<0<<endl;
      return 0;
    }
	int i = 0;
	int ans = 0;
	while (a + (a - 1)*i < b) {
		i++;
		if (a + (a - 1)*i >= b) {
			ans = i;
			break;
		}
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    if add < A:
        print(A * s + add)
    elif add < A + B:
        print(A * s + A)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == "__main__":
    main()


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

int main() {
  int N, K, A, B, C, cnt=0;
  cin >> N >> K;
  if(N==K){
    cout << 1 << endl;
    return 0;
  }
  rep(i, N){
    cin >> A;
    if(A==1){
      B=i+1;
      break;
    }
  }
  while(B>1){
    B=B-K+1;
    cnt++;
  }
  C=cnt*K-cnt+1;
  while(C<N){
    C=C+K-1;
    cnt++;
  }
  cout << cnt << endl;
}

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

int loop (){


}
int main() {
  int N,a,b,c,count;
  cin >> N;
  vector<int> edge(N);
  for(int i = 0;i < N;i++) {
    cin >> edge.at(i);
  }
  sort(edge.begin(), edge.end());
  for(int i = 0;i < N-2;i++) {
    a = edge.at(i);
    for(int j = i+1;j < N-1;j++) {
      b = edge.at(j);
      for(int k = j+1;k < N;k++) {
        c = edge.at(k);  
        if( c < a + b) {
           count = count + 1;
         }
      }   
    }
  }
  cout << count << endl;
}


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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int dp[8]={0};
  dp[1]=9;
  dp[2]=0;
  dp[3]=900;
  dp[4]=0;
  dp[5]=90000;
  dp[6]=0;
  dp[7]=9000000;
  int n;
  cin>>n;
  int res,diff,sum=0,num=0,c=0;
  int x=n;
  while(x)
  {
      c++;
      x=x/10;
  }
  if(c%2!=0)
  {
      int k=c-1;
      for(int i=1;i<k;i++)
      sum+=dp[i];
      
      num=pow(10,k);
      diff=n-num+1;
      res=diff+sum;
  }
   if(c%2==0)
  {
      //int k=c-1;
      for(int i=1;i<c;i++)
      sum+=dp[i];
      
      //num=pow(10,k);
      //diff=n-num;
      res=sum;
  }
  
  cout<<res;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
    int n,ans=1,m;
    cin >> n ;
    cin >> m ;
    for(int i=1;i<n;i++)
    {
        int x ;
        cin >> x ;
        if(m>x){ans++;m=x;}
    }
    cout << ans << endl;
    return 0 ;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
const ll mod=1000000007;
ll mul(ll x, ll y){
    return (x*y)%mod;
}
int main(){
    long long N;
    string S;
    cin>>N>>S;
    vector<ll>alph('z'-'a'+1);
    for(auto c: S){
        alph[c-'a']++;
    }
    ll ans=1;
    for(auto count:alph){
        ans=mul(ans, count+1);
    }
    cout<<ans-1<<endl;
}

Measured memory_bytes: 512
use io::*;
use std::cmp;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let s = sc.next_vec_char();
    let k: usize = sc.next();
    for i in 0..cmp::min(k,s.len()) {
        if s[i] == '1' {
            continue;
        }
        println!("{}", s[i]);
        return;
    }
    println!("1");
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}



Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int n,m;
int x,y,z;
int fa[100010];
int g[100010],cnt=0;

int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}

int main() {
   	scanf("%d %d",&n,&m);
   	for(int i=1;i<=n;i++) fa[i]=i;
   	for(int i=1;i<=m;i++){
   		scanf("%d %d %d",&x,&y,&z);
   		int u=find(x);
		int v=find(y);
		if(u!=v){
			if(u<v) fa[v]=u;
			else fa[u]=v;
		}
	}
	for(int i=1;i<=n;i++){
		fa[i]=find(i);
		if(g[fa[i]]==0){
			g[fa[i]]=1;
			cnt++;
		}
	}
   	printf("%d\n",cnt);
   	
    return 0;
}

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

using namespace std;

using int64 = long long;
// const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

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

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, M;
  cin >> N >> M;
  if(N == M) cout << "Yes";
  else cout << "No";


}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int N, L, T;
int X[MX_N], W[MX_N];

vector<int> dir[2];
int Y[MX_N];

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> L >> T;
    FOR(i,0,N-1){
        cin >> X[i] >> W[i];
        Y[i] = ((X[i]+(W[i]==1?T:-T))%L + L)%L;
        dir[W[i]-1].push_back(i);
    }

    sort(Y,Y+N);
    int j = 0;
    if (!dir[0].empty()) {
        int a = dir[0][0], b = X[a];
        for (int c : dir[1]) {
            int d = X[c];
            a += 2*(T/L);
            if (2*(T%L) >= (d-b+L)%L) ++a;
            if (2*(T%L) >= (d-b+L)%L + L) ++a;
            a %= N;
        }
        b = (b+T)%L;
        //cout << a << " AT " << b << endl;

        RFOR(i,N-1,0) if (Y[i] == b) {
            j = (i-a+N)%N;
            break;
        }
    } else {
        int a = dir[1][0], b = ((X[a]-T)%L + L)%L;
        FOR(i,0,N-1) if (Y[i] == b) {
            j = (i-a+N)%N;
            break;
        }
    }
    FOR(i,j,N-1) cout << Y[i] << '\n';
    FOR(i,0,j-1) cout << Y[i] << '\n';
}



Measured memory_bytes: 2892
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        string s = Console.ReadLine();
        int count = 0;
        int res = 0;
        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] == 'R') count++;
            else count = 0;
            res = Max(count, res);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 25812
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define endl '\n'
using ll=long long;
 
const int INF=1e9+5;
const ll lim=(ll)3e16;
const int N=3e3+5;
const int mod=1e9+7;
const ll oo=1e18+5;


int main(){
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
	int n,m;
	cin>>n>>m;
	if(n==m) cout<<"Yes";
	else cout<<"No";
	return 0;
}


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

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


ll int lcm(ll int x, ll int y){
	return (x*y)/gcd(x,y);
}

int main(){
	int x;
	cin>>x;
	if(x >= 30)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

int main() {
    int n,d; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    REP(i,n) {
        REP(j,d) cin >> x[i][j];
    }
    int ans = 0;
    REP(i,n) {
        FOR(j,i+1,n) {
            double distance = 0;
            REP(k,d) {
                distance += pow(abs(x[i][k]-x[j][k]),2);
            }
            distance = sqrt(distance);
            ans += (ceil(distance) == floor(distance));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main() {

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0;
	int val = 0;
	for (int i = 1; i < n; i++) {
		if (h[i - 1] >= h[i]) val++;
		else val = 0;
		ans = max(ans, val);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 640
#include <cstdio>
const char map[4] = {'R', 'Y', 'G', 'B'};
int H, W, d, x, y;
int main() {
	scanf("%d %d %d", &H, &W, &d);
	for(int i = 1; i <= H; ++i) {
		for(int j = 1; j <= W; ++j) {
			x = (i + j + W) / d, y = (i - j + W) / d;
			putchar(map[((x&1)<<1) | (y&1)]);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 384
n=int(input())
node={i:[] for i in range(1,n+1)}
visited=[False for i in range(n+1)]
q=[]
for _ in range(n-1):
    a,b=map(int,input().split())
    node[a].append(b)
    node[b].append(a)
    q.append((a,b))

mother=q[0][0]
visited[mother]=True

d=[]
e=[]


paint={i:{} for i in range(1,n+1)}

mother_paint=[0 for i in range(n+1)]

#使う要素 node visited paint mother_paint の四つのリスト
c=1
for child in node[mother]:
    visited[child]=True
    paint[mother][child]=c
    paint[child][mother]=c
    mother_paint[child]=c
    c+=1
    d.append(child)
    
while d:
    for parent in d:
        p=1 
        for child in node[parent]:
            if visited[child]==False:
                visited[child]=True
                if p!=mother_paint[parent]:
                    paint[parent][child]=p
                    paint[child][parent]=p
                    mother_paint[child]=p
                    p+=1
                    e.append(child)
                else:
                    p+=1
                    paint[parent][child]=p
                    paint[child][parent]=p
                    mother_paint[child]=p
                    p+=1
                    e.append(child)
    if e:
        d=e.copy()
        e=[]
    else:
        d=[]
        e=[]
K=0
for i in range(1,n+1):
    K=max(K,len(node[i]))
print(K)
for i in range(n-1):
    s,t=q[i][0],q[i][1]
    print(paint[s][t])

Measured memory_bytes: 79660