akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#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 mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int n, y;
  cin >> n >> y;

  rep(i, n+1) {
    rep(j, n+1) {
      if(i + j > n) continue;
      if( (y - (10000 * i + 5000 * j)) == ((n - (i + j)) * 1000) ) {
        printf("%d %d %d\n", i, j, n-(i+j));
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String s=sc.next();
            if(s.equals("-")) break;
            int tt=sc.nextInt();
            String tmp=s;
            while(tt>0){
                int n=sc.nextInt();
                
                tmp=tmp.substring(n)+tmp.substring(0,n);
                tt--;
            }
            System.out.println(tmp);
        }
        
    }
}


Measured memory_bytes: 26392
H, W, M = map(int, input().split())
hlist = [0] * H
wlist = [0] * W
hw = set()
for i in range(M):
    h, w = map(int, input().split())
    hlist[h - 1] += 1
    wlist[w - 1] += 1
    hw.add((h - 1, w - 1))

hmax = max(hlist)
wmax = max(wlist)
hmaxlist = [i for i, v in enumerate(hlist) if v == hmax]
wmaxlist = [i for i, v in enumerate(wlist) if v == wmax]
cnt = -1
for i in hmaxlist:
    bf = False
    for j in wmaxlist:
        if not (i, j) in hw:
            cnt = 0
            bf = True
            break
    if bf:
        break

print(hmax + wmax + cnt)

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

int main(){
  string s;
  unsigned int i,j,len;
  cin>>s;
  int ans=0;
  for( i=0,len=s.length()/2;i<len;i++ ){
    j=s.length()-i-1;
    switch( s[i] ){
    case 'w': if( s[j]!='w' ) ans++; break;
    case 'i': if( s[j]!='i' ) ans++; break;
    case '(': if( s[j]!=')' ) ans++; break;
    case ')': if( s[j]!='(' ) ans++; break;
    }
  }
  if( s.length()%2==1 ){
    if( s[len]=='(' || s[len]==')' ) ans++;
  }

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

Measured memory_bytes: 0
#include <map>
#include <queue>
#include <set>
#include <string>
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main(void){
    set<string> words;
    map<string,priority_queue<int, vector<int>,greater<int> > > indeces;
    char wd[32];
    int page;
    
    while (cin >> wd >> page){
        string strWd(wd);
        
        words.insert(strWd);
        if (indeces.find(strWd) == indeces.end()){
            priority_queue<int,vector<int>, greater<int> > pq;
            indeces.insert(make_pair(strWd, pq));
        }
        indeces[strWd].push(page);
    }
    for (set<string>::iterator itr = words.begin(); itr != words.end(); itr++){
        string wd = *itr;
        cout << wd << endl;
        cout << indeces[wd].top();
        indeces[wd].pop();
        while (!indeces[wd].empty()){
            cout << " " << indeces[wd].top();
            indeces[wd].pop();
        }
        cout << endl;
    }
  
    return 0;
}

Measured memory_bytes: 3032
// atcoder/abc139/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s, t;
  while (cin >> s >> t) {
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
      cnt += (s[i] == t[i]);
    }
    cout << cnt << endl;
  }

  return 0;
}


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

int sumDigits(int num) { return num / 10000 + num % 10000 / 1000 + num % 1000 / 100 + num % 100 / 10 + num % 10; }
int main() {
    string S;
    cin >> S;
    int cCnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if (i == 0) {
            if (S[i] != 'A') {
                cout << "WA" << endl;
                return 0;
            }
        }
        if (i >= 2 && i <= S.length() - 2) {
            if (S[i] == 'C') {
                cCnt++;
            }
        }
        if (S[i] != 'A' && S[i] != 'C') {
            if (isupper(S[i])) {
                cout << "WA" << endl;
                return 0;
            }
        }
    }
    if (cCnt != 1) {
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define vmax 10000
constexpr ll inf = 1e18+7;
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/

int main(){
  cout<<fixed<<setprecision(20);
  cin.tie(0);ios::sync_with_stdio(false);
  string s;
  int q;
  cin>>s>>q;
  int t,f;
  int flag=1;
  char c;
  deque<char> ans;
  rep(i,s.size()){
    ans.push_back(s[i]);
  }
  rep(i,q){
    cin>>t;
    if(t==1){
      flag^=1;
    }else{
      cin>>f>>c;
      f--;
      if(flag^f){
        ans.push_front(c);
      }else{
        ans.push_back(c);
      }
    }
  }
  int n=ans.size();
  if(flag){
    rep(i,n){
      cout<<ans[i];
    }
  }else{
    repr(i,n){
      cout<<ans[i];
    }
  }
  cout<<endl;
  return 0;
}



Measured memory_bytes: 976
# include<bits/stdc++.h>
# define ll long long
# define fo(i,n)for(int i=0;i<n;i++)
# define fo1(i,n)for(int i=1;i<=n;i++)
# define pb push_back
# define endl "\n"
# define mod 1000000007ll
# define pi  3.1415926535897932384626
using namespace std;

vector<vector<long long>>adj(100005);
vector<long long >vis(100005,0);

void bfs(int i)
{
  queue<int>q;
  q.push(i);

  if(!vis[i])
  {
    vis[i]=1;
    while(!q.empty())
   {
      int u=q.front();
      q.pop();
     for(auto a:adj[u])
     {
       if(!vis[a])
       {
         vis[a]=1;
         q.push(a);
       }
     }
   }
  }
}
void solve()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int x,y;
    cin>>x>>y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  int cnt=0;
   for(int i=1;i<=n;i++)
   {
     if(!vis[i])
     {
       cnt++;
       bfs(i);
     }
   }
   cout<<cnt-1;
}
int main()
{
 # ifndef ONLINE_JUDGE
   freopen("input1.txt","r",stdin);
   freopen("output1.txt","w",stdout);
 #endif
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();
    cout<<endl;
    return 0;
}

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

using namespace std;

int main(void)
{
    bool s = false,e = false,n = false,w = false;
    string str;

    cin>>str;

    for(int i = 0;i < str.size();i++)
    {
	if(str[i] == 'N')
	    n = true;
	else if(str[i] == 'S')
	    s = true;
	else if(str[i] == 'W')
	    w = true;
	else
	    e = true;
    }

    if((s == n) && (w == e))
	cout<<"Yes"<<endl;
    else
	cout<<"No"<<endl;

    return 0;
}


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 N;
    cin >> N;

    vector<long long> height(N+1);
    for(int i=1;i<=N;i++) cin >> height[i];

    vector<long long> dp(N+1,0);
    dp[2] = abs(height[1]-height[2]);

    for(int i=3;i<=N;i++) {
        dp[i] = min(dp[i-1]+abs(height[i]-height[i-1]),
        dp[i-2]+abs(height[i]-height[i-2]));
    }

    cout << dp[N] << endl;

    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<long,long>> A;
  for(int i = 0; i < N; i++){
    long temp;
    cin >> temp;
    A.push_back(make_pair(temp, temp));
  }
  
  sort(A.begin(), A.end());
  vector<pair<long, long>> B;
  A.at(N-1).first /= 2;
  A.at(N-1).second /= 2.0;
  B.push_back(A.at(N-1));
  A.pop_back();
  int Bi = 0;
  for(int i = 0; i < M-1; i++){
    if(A.size() != 0){
      if(B.at(Bi).second > A.at(A.size()-1).second){
        B.at(Bi).first = int(B.at(Bi).second / 2);
        B.at(Bi).second /= 2.0;
        B.push_back(B.at(Bi));
        Bi++;
      }else{
        A.at(A.size()-1).first /= 2;
        A.at(A.size()-1).second /= 2.0;
        B.push_back(A.at(A.size()-1));
        A.pop_back();
      }
    }else{
      B.at(Bi).first = int(B.at(Bi).second / 2);
      B.at(Bi).second /= 2.0;
      B.push_back(B.at(Bi));
      Bi++;
    }
  }
  long ans = 0;
  for(int i = 0; i < A.size(); i++) ans += A.at(i).first;
  for(int i = Bi; i < B.size(); i++) ans += B.at(i).first;
  cout << ans << endl;
}

Measured memory_bytes: 4848
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

map<ll, ll> ms;

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

    ll acc = 0;

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        ms[a]++;
        acc += a;
    }

    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        int b, c;
        cin >> b >> c;
        acc -= b * ms[b];
        acc -= c * ms[c];
        ms[c] += ms[b];
        ms[b] = 0;
        acc += c * ms[c];
        cout << acc << endl;
    }

    return 0;
}


Measured memory_bytes: 9368
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000LL;
constexpr auto MOD = 1000000007;

ll gcd(ll i, ll j) { return i % j ? gcd(j, i % j) : j; }

int main() {
	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll cd = c * d / gcd(c, d);
	ll div_c, div_d, div_cd;
	div_c = b / c - (a - 1) / c;
	div_d = b / d - (a - 1) / d;
	div_cd = b / cd - (a - 1) / cd;

	cout << (b - a + 1) - (div_c + div_d - div_cd) << endl;

}

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


int main(){
    ll a,b,c;
    cin>>a>>b;
    c = __gcd(a,b);
    int ans = 0;
    for(ll i=2;i*i<=c;i++){
        if(c%i==0) ans++;
        while(c%i==0) c/=i;
    }
    if(c>1)ans++;
    cout<<ans+1<<endl;
    return 0;
    
}



Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * Elementary Number Theory - Least Common 
 */
public class Main {

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

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line);

			StringTokenizer st = new StringTokenizer(br.readLine());
			int m = 1;
			for (int i = 0; i < n; i++) {
				m = lcm(m, parseInt(st.nextToken()));
			}
			System.out.println(m);

		}//end while
	}//end main

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

	static int lcm(int a, int b) {
		return a * b / gcd(a, b);
	}

}

Measured memory_bytes: 24404
import java.util.*;

public class Main {
	static final long MODULO = 1_000_000_000 + 7;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int C = sc.nextInt() - 1;
		int T = sc.nextInt();
		int[] a = new int[K];
		int[] b = new int[K];
		int[] t = new int[K];
		for (int i = 0; i < K; ++i) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			t[i] = sc.nextInt();
		}
		long[][][] A = new long[6][N][N];
		for (int i = 0; i < K; ++i) {
			for (int j = 0; j < b[i]; ++j) {
				A[t[i]][j][(a[i] - 1) + j] += 1;
			}
			for (int j = 0; j < a[i] - 1; ++j) {
				A[t[i]][b[i] + j][j] += 1;
			}
			for (int j = a[i] + b[i] - 1; j < N; ++j) {
				A[t[i]][j][j] += 1;
			}
		}
		long[][] dp = new long[6][N];
		dp[0][C] = 1;
		for (int i = 1; i <= 5; ++i) {
			for (int j = 0; j < i; ++j) {
				dp[i] = addVec(dp[i], mulVec(A[i - j], dp[j]));
			}
		}
		long[] v = new long[N * 5];
		for (int i = 0; i < 5; ++i) {
			for (int j = 0; j < N; ++j) {
				v[j + i * N] = dp[i][j];
			}
		}
		long[][] mx = new long[5 * N][5 * N];
		for (int i = N; i < 5 * N; ++i) {
			mx[i - N][i] = 1;
		}
		for (int i = 1; i <= 5; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k < N; ++k) {
					mx[4 * N + j][N * (5 - i) + k] = A[i][j][k];
				}
			}
		}

		v = mulVec(pow(mx, T), v);
		System.out.println(v[0]);
	}

	static long[][] mul(long[][] a, long[][] b) {
		int n = a.length;
		long[][] ret = new long[n][n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k) {
					ret[i][j] += a[i][k] * b[k][j] % MODULO;
					ret[i][j] %= MODULO;
				}
			}
		}
		return ret;
	}

	static long[] mulVec(long[][] a, long[] v) {
		int n = v.length;
		long[] ret = new long[n];
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				ret[i] += a[i][j] * v[j] % MODULO;
				ret[i] %= MODULO;
			}
		}
		return ret;
	}

	static long[] addVec(long[] a, long[] b) {
		int n = a.length;
		long[] ret = new long[n];
		for (int i = 0; i < n; ++i) {
			ret[i] = (a[i] + b[i]);
			if (ret[i] >= MODULO)
				ret[i] -= MODULO;
		}
		return ret;
	}

	static long[][] pow(long[][] a, long n) {
		int len = a.length;
		long[][] ret = new long[len][len];
		for (int i = 0; i < len; ++i)
			ret[i][i] = 1;
		for (; n > 0; n >>= 1, a = mul(a, a)) {
			if (n % 2 == 1) {
				ret = mul(ret, a);
			}
		}
		return ret;
	}

}

Measured memory_bytes: 44116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
const int N = 1e5 + 5;
const int inf = 1e18;
pi a[N],d[N];
int n;
double okk(double m){
	double xmax = -inf,ymax = -inf;
	double xmin = inf,ymin = inf;

	for(int i=0;i<n;i++){
		double x = a[i].ff + m*d[i].ff;
		double y = a[i].ss + m*d[i].ss;
		xmax = max( xmax , x );
		xmin = min( xmin , x );
		ymax = max( ymax , y );
		ymin = min( ymin , y );
	}
	double ans = (xmax - xmin) * (ymax - ymin);
	return ans;
}


int32_t main(){
	boost;
	cout<<setprecision(20)<<fixed;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i].ff>>a[i].ss;
		char c;cin>>c;
		if(c == 'R')
			d[i] = {1,0};
		else if(c == 'L')
			d[i] = {-1,0};
		else if(c == 'U')
			d[i] = {0,1};
		else
			d[i] = {0,-1};
	}


	double l = 0,r = 2e8;
	for(int i=0;i<500;i++){
		double m1 = (2*l + r)/3;
		double m2 = (l + 2*r)/3;
		double t1 = okk(m1);
		double t2 = okk(m2);
		if(t1 <=t2)
			r = m2;
		else
			l = m1;
	}

	double ans = min(okk(l),okk(r));
	cout<<ans<<endl;

}



Measured memory_bytes: 6868
import sys
S = list(input())
S_odd = S[::2]
S_even = S[1::2]
easy_odd = ['R','U','D']
easy_even = ['L','U','D']

print('Yes') if set(S_odd).issubset(easy_odd) and set(S_even).issubset(easy_even) else print('No')

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int ans=(n*(n-1))/2;
        cout << ans << '\n';
        

}

Measured memory_bytes: 384
mod=10**9+7
N=int(input())
Fact=[1 for i in range(N+1)]
Finv=[1 for i in range(N+1)]
for i in range(N):
    Fact[i+1]=(Fact[i]*(i+1))%mod
Finv[N]=pow(Fact[N],mod-2,mod)
for i in range(N-1,-1,-1):
    Finv[i]=((i+1)*Finv[i+1])%mod
ans=0
SGL=[0 for i in range(N)]
for K in range(N):
    if 2*K-N<0:
        continue
    SGL[K]=(((Fact[K]*Finv[2*K-N])%mod)*Fact[K-1])
for K in range(1,N):
    ans+=((SGL[K]-SGL[K-1])*K)%mod
    ans%=mod
print(ans)


Measured memory_bytes: 106048
#include<stdio.h>

int main(void){
  
  int N;
  scanf("%d", &N);
  char s[N];
  for (int i = 0; i<N; i++) {
    scanf("%s", &s[i]);
  }
  
  int p = 0;
  int w = 0;
  int g = 0;
  int y = 0;
  
  for (int i = 0; i<N; i++) {
    if (s[i] == 'P') p++;
    if (s[i] == 'W') w++;
    if (s[i] == 'G') g++;
    if (s[i] == 'Y') y++;
  }
  
  
  if (p != 0 && w != 0 && g != 0 && y != 0) {
    printf("Four");
  } else {
    printf("Three");
  }
  
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

int n,x,y;

void bfs(vector<vector<int>> &adj, int i, vector<int> &dist){
    bool vis[n]={0};
   

    queue<int> q;
    dist[i] = 0;
    q.push(i);
    vis[i] = 1;
    while(!q.empty()){
        int parent = q.front();
        q.pop();
        for(auto x : adj[parent]){
            if(!vis[x]){
                vis[x] = 1;
                dist[x] = dist[parent]+1;
                q.push(x);
            }
        }

    }
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n>>x>>y;
    vector<vector<int>> adj(n);
    
    for(int i = 0; i<n-1; i++){
        adj[i].pb(i+1);
        adj[i+1].pb(i);
    }
    adj[x-1].pb(y-1);
    adj[y-1].pb(x-1);
    
    vector<int>ans(n-1);
    
    for(int i = 0; i<n; i++){
        vector<int> dist(n);
        bfs(adj,i,dist);
        for(int j = i+1; j<n; j++){
            ans[dist[j]-1]++;
        }

    }
    for(int i = 0; i<n-1; i++){
        cout<<ans[i]<<"\n";
    }

}

Measured memory_bytes: 384
def solve():
    N,H = list(map(int, input().split()))
    az = []
    bz = []
    for i in range(N):
        a,b = list(map(int, input().split()))
        az.append(a)
        bz.append(b)
        
    amax = max(az)
    bz.sort(reverse=True)
    cnt = 0
    for b in bz:
        if amax < b:
            H -= b
            cnt += 1
        if H <= 0:
            return cnt
    if H <= 0:
        return cnt
    cnt += int(H / amax)
    cnt += min(H % amax, 1)
    return cnt
        
print(solve())

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s;cin>>s;
  if(s<="2019/04/30")puts("Heisei");
  else puts("TBD");
  
  return 0;
}


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

int main(){

	char c;
	cin >> c;
	
	if(c == 'a'){
		cout << "vowel" << endl;
	}else if(c == 'i'){ 
		cout << "vowel" << endl;
	}else if(c == 'u'){
		cout << "vowel" << endl;
	}else if(c == 'e'){
		cout << "vowel" << endl;
	}else if(c == 'o') {
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
	return 0;

}

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

    int n;
    cin >> n;

    for (int i = 3; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            while (x != 0) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                } else {
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3212
"use strict";

const main = arg => {
  const input = arg.trim();

  const [N, a] = input.split('\n').map(y => y.split(' ').map(x => parseInt(x)));

  const ans = a.filter((e, i) => e * (i + 1) % 2).length

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29660
from functools import reduce

stdin = open(0)
N, A, B = map(int, stdin.read().split())
MOD = 10 ** 9 + 7


def f(A):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


answer = pow(2, N, MOD) - f(A) - f(B) - 1
answer %= MOD
print(answer)


Measured memory_bytes: 38896
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  ll ans=0,cnt;
  cin >> s;
  for(int i=0; i<(1<<s.size()-1); i++) {
    cnt=s[0]-'0';
    for(int j=0; j<s.size()-1; j++) {
      if(i&(1<<j)) {
        ans+=cnt;
        cnt=s[j+1]-'0';
      }
      else {
        cnt=cnt*10+s[j+1]-'0';
      }
    }
    ans+=cnt;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
use proconio::input;
use proconio::marker::Chars;
use std::cmp;

fn main() {
    input! {
        h: usize,
        w: usize,
        limit: isize,
        boards: [Chars; h],
    }

    let mut min = std::usize::MAX;
    'outer: for bit in 0..1 << h-1 {
        let mut v = vec![];
        let mut count = 0;
        v.push(0);
        for i in 0..h-1 {
            if (bit >> i) & 1 != 0 {
                v.push(i + 1);
                count += 1;
            }
        }
        v.push(h);
        //println!("vertical bit {} count {}", bit, count);
        let mut sections: Vec<isize> = vec![0; v.len() - 1];
        for i in 0..w {
            let mut focuses: Vec<isize> = vec![0; v.len()-1];
            for j in 0..v.len() - 1 {
                for k in v[j]..v[j + 1] {
                    if boards[k][i] == '1' {
                        focuses[j] += 1;
                    }
                }
            }
            if focuses.iter().any(|x| *x > limit) {
                continue 'outer;
            }
            for j in 0..sections.len() {
                sections[j] += focuses[j];
            }
            if sections.iter().any(|x| *x > limit) {
                count += 1;
                for j in 0..sections.len() {
                    sections[j] = focuses[j]; 
                }
            }
        }
        if sections.iter().all(|x| *x <= limit) {
            min = cmp::min(min, count);
        }
    }
    println!("{}", min);
}


Measured memory_bytes: 2184
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int k = int.Parse(input[2]);
            var xu = Enumerable
                .Range(1, Math.Max(a, b))
                .Where(i => a % i == 0 && b % i == 0)
                .OrderByDescending(i => i)
                .Skip(k-1)
                .First();

            Console.WriteLine(xu);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using Int = long long;
int main() {
    Int N;
    cin >> N;
    vector<Int> a(N), s(N + 1, 0), ans;
    for (Int i = 0; i < N; i++) {
        cin >> a[i];
        s[i + 1] = s[i] + a[i];
    }
    for (Int i = 0; i < N - 1; i++) {
        Int x = s[i + 1] - s[0];
        Int y = s[N] - s[i + 1];
        ans.push_back(abs(x - y));
    }
    cout << *min_element(ans.begin(), ans.end()) << endl;
}


Measured memory_bytes: 5492
#include <stdio.h>
int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            cnt++;
        }
    }
    printf("%f\n", float(cnt) / n);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      ll n, k;
      cin >> n >> k;
      ll t = n/k;
      n -= k*t;
      if(abs(n - k) < n){
            n = abs(n-k);
      }
      cout << n;
      return 0;
}

int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

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

int main() {
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n) {
        string s;
        cin >> s;
        m[s]++;
    }

    int mx = -1;
    for(auto i : m) {
        mx = max(mx, i.second);
    }

    //cout << mx << endl;

    vs s;
    for(auto i : m) {
        if(i.second == mx) s.push_back(i.first);
    }

    for(auto i : m) {
        if(i.second == mx) cout << i.first << endl;
    }

    return 0;
}


Measured memory_bytes: 26868
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {

    static int a;
    static int b;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();

        solve();
    }

    public static void solve() {
        int bHeight = IntStream.rangeClosed(1, b - a).sum();
        System.out.println(bHeight - b);
    }
}


Measured memory_bytes: 28628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    char a;cin>>a;
    if(a>='A' && a<='Z')cout<<"A";
    else cout<<"a";
    return 0;  
} 





Measured memory_bytes: 3632
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double H = sc.nextDouble();
    double W = sc.nextDouble();
    if (H != 1 && W != 1)
			System.out.println((long) Math.ceil(H * W / 2));
		else
			System.out.println(1);
  }
}
    

Measured memory_bytes: 37308
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

const int MAX = 2100;
int main(){
  Int res = 0;
  int n;cin >> n;
  vector<Int> l(n);
  rep(i,n) cin >> l[i];

  //c,s
  vector<Int> c(MAX,0),s(MAX+1,0);
  for(int i=0;i<n;i++) c[l[i]]++;
  for(int x=0;x<MAX;x++) s[x+1] = s[x] + c[x];//累積和

  //aとbを固定
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j) continue;//同じものは選ばない

      //cの満たすべき値の区間を[left,right]で表す
      int left = abs(l[i]-l[j]) + 1;
      int right = l[i] + l[j];
      //累積和で個数を求める
      int count = s[right] - s[left];
      if(left<=l[i]&&l[i]<right) --count;
      if(left<=l[j] && l[j]<right) --count;
      res+=max(count,0);
    }
  }
  cout << res/6 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int[] Solve(int N, int[][] P)
        {
            var q = new Queue<int[]>();
            {
                int x0 = P[0][0];
                int y0 = P[0][1];
                int h0 = P[0][2];
                for (int x = 0; x <= 100; ++x)
                {
                    for (int y = 0; y <= 100; ++y)
                    {
                        int max = h0 + Math.Abs(x0 - x) + Math.Abs(y0 - y);
                        int min = (h0 == 0) ? 1 : max;
                        q.Enqueue(new[] { x, y, min, max });
                    }
                }
            }
            for (int i = 1; i < N && q.Count > 1; ++i)
            {
                int x1 = P[i][0];
                int y1 = P[i][1];
                int h1 = P[i][2];
                int c = q.Count;
                for (int j = 0; j < c; ++j)
                {
                    var p = q.Dequeue();
                    int x2 = p[0];
                    int y2 = p[1];
                    int min1 = p[2];
                    int max1 = p[3];
                    int max2 = h1 + Math.Abs(x2 - x1) + Math.Abs(y2 - y1);
                    int min2 = (h1 == 0) ? 1 : max2;
                    int min = Math.Max(min1, min2);
                    int max = Math.Min(max1, max2);
                    if (min <= max) { q.Enqueue(new[] { x2, y2, min, max }); }
                }
            }
            return q.First().Take(3).ToArray();
        }
        static void Main(string[] args)
        {
            int N = ReadInt();
            var P = new int[N][];
            for (int i = 0; i < N; ++i) { P[i] = ReadInts(); }
            Console.WriteLine(string.Join(" ", Solve(N, P)));
        }
    }
}


Measured memory_bytes: 25492
Base = [[1, 2, 3, 4, 5, 6], [1, 3, 5, 2, 4, 6], [1, 5, 4, 3, 2, 6], [1, 4, 2, 5, 3, 6], [5, 1, 3, 4, 6, 2], [5, 3, 6, 1, 4, 2], [5, 6, 4, 3, 1, 2], [5, 4, 1, 6, 3, 2], [6, 5, 3, 4, 2, 1], [6, 3, 2, 5, 4, 1], [6, 2, 4, 3, 5, 1], [6, 4, 5, 2, 3, 1], [2, 6, 3, 4, 1, 5], [2, 3, 1, 6, 4, 5], [2, 1, 4, 3, 6, 5], [2, 4, 6, 1, 3, 5], [4, 1, 5, 2, 6, 3], [4, 5, 6, 1, 2, 3], [4, 6, 2, 5, 1, 3], [4, 2, 1, 6, 5, 3], [3, 5, 1, 6, 2, 4], [3, 1, 2, 5, 6, 4], [3, 2, 6, 1, 5, 4], [3, 6, 5, 2, 1, 4]]

class Dice

def initialize(arr)
@all = []
Base.each{|b|
temp = Array.new(6)
for j in 1..6
temp[j-1] = arr[ b[j-1] -1 ]
end
@all.push(temp)
}
end

def getall()
    return @all
  end

end


first = Dice.new(gets.split.map(&:to_i)).getall()

if first.include?(gets.split.map(&:to_i))
puts "Yes"
else
puts "No"
end





Measured memory_bytes: 6880
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll A, B, C;
    cin >> A >> B >> C;

    cout << B + min(A+B+1, C) << "\n";
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.range, std.conv, std.string;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] a = new int[n];
	int[] b = new int[n];
	foreach (i; 0..n) scanf("%d", &a[i]);
	foreach (i; 0..n) scanf("%d", &b[i]);
	int ans = 0;
	foreach (k; 0..29) {
		int mask = (1<<k)-1;
		int s = 0;
		if (n&1) {
			foreach (x; a) s ^= x>>k&1;
			foreach (x; b) s ^= x>>k&1;
		}
		int[] c = new int[n];
		c[] = b[]&mask;
		sort(c);
		auto sorted = assumeSorted(c);
		foreach (x; a) {
			x &= mask;
			int l = n - to!int(sorted.lowerBound((1<<k)-x).length);
			s ^= l&1;
		}
		ans |= s<<k;
	}
	writeln(ans);
}



Measured memory_bytes: 11260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9;
const long long INF = 1e15;


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

    ll n;
    cin >> n;
    vector<long double> a(n);
    vector<ll> b(n);
    for(ll i = 0; i < n; i++) cin >> a[i];
    for(ll i = 0; i < n; i++){
        b[i] = a[i]*mod+0.5;
        //cout << b[i] << endl;
    }

    auto pf = [&](ll n,ll k){
        ll ret = 0;
        while(n%k == 0) ret++, n /= k;
        return min(ret,18ll);
    };

    ll ans = 0;
    map<pair<ll,ll>,ll> p;


    for(ll i = 0; i < n; i++){
        p[make_pair(pf(b[i],2),pf(b[i],5))]++;
    }

    const int k = 19;
    
    for(int i = 0; i < k; i++){
        for(int j = 0; j < k; j++){
            for(int l = 0; l < k; l++){
                for(int m = 0; m < k; m++){
                    if(i+l >= 18 && j+m >= 18){
                        if(i != l || j != m) ans += p[make_pair(i,j)]*p[make_pair(l,m)];
                        else ans += p[make_pair(i,j)]*(p[make_pair(i,j)]-1);
                    }
                }
            }
        }
    }

    //cout << ans << endl;
    cout << ans/2 << endl;

    return 0;
}

Measured memory_bytes: 7928
#include <iostream>
using namespace std;
int a[123456];
int main(){
  int n;cin>>n;
for(int i=0;i<n;++i){cin>>a[i];a[i]--;}
int inf = 200000;
int mi=inf;
int pos=0;
for (int i=0;i<inf;++i){
if(pos==1) mi = min(mi, i);
pos=a[pos];
}
cout<<(mi==inf?-1:mi) << endl;
}

Measured memory_bytes: 640
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		//StringBuilder sb = new StringBuilder();
		String str;
		char[] c;
		int sum;
		while((str = buf.readLine()) != null){
			if(str.equals("0"))
				break;
			sum = 0;
			c = str.toCharArray();
			for(int i=0; i<c.length ; i++){
				sum += Integer.parseInt(Character.toString(c[i]));
			}
			System.out.println(sum);
		}

	}
}

Measured memory_bytes: 24668
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    if a >= 10 || b >= 10 {
        println!("{}", -1);
    } else {
        println!("{}", a * b);
    }
}


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

using namespace std;

typedef pair<int, int> P;
typedef unsigned long long int LL;

int main() {
    LL n;
    cin >> n;
    if (n % 4 == 0) {
        int a = 3 * n / 4;
        cout << a << " " << a << " " << a << endl;
        return 0;
    }

    for (int a = 1; a <= 3500; a++) {
        for (int b = 1; b <= 3500; b++) {
            int d = 4 * a * b - n * b - n * a;
            if (d == 0) continue;
            int r = (n * a * b) % d;
            int c = (n * a * b) / d;
            if (r == 0 && c != 0) {
                cout << a << " " << b << " " << c << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdin=new Scanner(System.in);
		int n=stdin.nextInt();
		int flag=n%2;
		int a[]=new int[n];
		int alice=0;
		int bob=0;
		int max=0;
		int i=0,j=0;
		int h=0;
		int index=0;
		for( i=0;i<n;i++){
			a[i]=stdin.nextInt();
		}
		for(h=0;h<n/2+flag;h++){
			for(i=0;i<n;i++){
				if(max<a[i]){
					max=a[i];
					index=i;
				}
			}
			alice=alice+max;
			a[index]=0;
			max=0;
			for(j=0;j<n;j++){
				if(max<a[j]){
					max=a[j];
					index=j;
				}
			}
			bob=bob+max;
			a[index]=0;
			max=0;
		}
		System.out.println(alice-bob);
	}
}



Measured memory_bytes: 21716
#include<stdio.h>
#include<math.h>
int main(){
  int i,j,n,prime[1000000]={0},count=1;
  for(i=2;i<1000000;i++){
    if(prime[i]==0){
      for(j=i+i;j<1000000;j+=i){
	prime[j]=1;
      }
    }
  }
  while(scanf("%d",&n)!=EOF){
    if(n<=1){
      printf("0\n");
    }
    else if(n==2){
      printf("1\n");
    }
	else{
    for(i=3;i<=n;i+=2){
      if(prime[i]==0){
	count++;
      }
    }
    printf("%d\n",count);
    count=1;
    }
  }
  return 0;
}

Measured memory_bytes: 4520
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
static const ll mod = 1000000007;
# define INF (1 << 29)
/* ちゃんと考えて実装して問題なくACできた時嬉しいよ！！ */

int main(void){
    int n;
    cin >> n;
    if(n==99) cout << "Yes";
    else if(90 <= n && n <= 98) cout << "Yes";
    else if (n%10 == 9) cout << "Yes";
    else cout << "No";
    return 0;
}

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



int main() {

	ll N, A, B;
	cin >> N >> A >> B;
	if (A == 0) {
		cout << A << endl;
		return 0;
	}
	if (N <= A) {
		cout << N << endl;
		return 0;
	}
	else {
		ll i = A * (N / (A + B));
		ll tmp = (N % (A + B));
		if (tmp > A)tmp = A;

		cout << i + tmp << endl;
	}
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    vector<int64_t> B(N + 1);
    for (int i = 0; i < N; i++) {
        B[A[i]]++;
    }

    int64_t all = 0;
    for (int i = 1; i <= N; i++) {
        all += (B[i] * (B[i] - 1)) / 2;
    }

    for (int i = 0; i < N; i++) {
        int x = A[i];
        int64_t ans = all - (B[x] - 1);
        printf("%ld\n", ans);
    }

    return 0;
}

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

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

  string r = "Yes";
  rep(i,s.length()) {
    if (s[i] != t[i]) r = "No";
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3628
/* ABC143-C
   Takatan */

#include<stdio.h>
int main(void){
    int number, answer, i;
    char slime[100001];
    answer = 1;

    scanf( "%d" , &number); /* 個数の入力 */
    scanf( "%s" , slime); /* 色の情報 */
    for(i=1; i < number; i++){
        if(slime[i]!=slime[i-1]){ /* 隣り合っている時 */
            answer++; /* カウント */
        }
    }
    printf( "%d\n" , answer);
    return 0;
}

Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 1e4 + 5, Mod = 1e9 + 7, P = 727, Lg = 22, TOF = 1900;

int A[N][105], B[N][105], Pw[N];

int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      string s; cin >> s;
      int d; cin >> d;
      int n = s.size(), Ans = 0;
      for(int i = 1; i < 10; i++)
            A[1][i % d]++, B[1][i % d]++;
      B[1][0]++, B[0][0] = 1;
      for(int i = 2; i <= n; i++){
            for(int j = 0; j < 10; j++){
                  for(int x = 0; x < d; x++){
                        int rem = j % d, nd = (x - rem + d) % d;
                        A[i][x] = (A[i][x] + A[i - 1][nd]) % Mod;
                        B[i][x] = (B[i][x] + B[i - 1][nd]) % Mod;
                  }
            }
      }
      for(int i = 1; i < n; i++)
            Ans = (Ans + A[i][0]) % Mod;
      for(int i = 1; i < (s[0] - '0'); i++)
            Ans = (Ans + B[n - 1][(d - i % d) % d]) % Mod;
      int now = 0;
      for(int i = 0; i < n - 1; i++){
            now = (now + (s[i] - '0')) % d;
            for(int j = 0; j < (s[i + 1] - '0'); j++){
                  int cur = (now + j % d) % d;
                  int nd = (d - cur) % d;
                  Ans = (Ans + B[n - i - 2][nd]) % Mod;
            }
      }
      now = (now + (s[n - 1] - '0')) % d;
      if(!now)
            Ans = (Ans + 1) % Mod;
      cout << Ans;
      return 0;
}



Measured memory_bytes: 16640
N=input()
M=len(raw_input())
O=10**9+7
D=[pow(-~O/2,M,O)]+[0]*N
for _ in'_'*N:D=[D[0]+D[1]]+[(i+2*j)%O for i,j in zip(D[2:]+[0],D[:-1])]
print D[M]

Measured memory_bytes: 73244
import itertools

H, W, K = map(int, input().split())
c = [['.' for j in range(6)] for i in range(6)]
for i in range(H):
    tmp = str(input())
    for j in range(len(tmp)):
        c[i][j] = tmp[j]
    
hp = list(itertools.product([0,1], repeat=H))
wp = list(itertools.product([0,1], repeat=W))

hl = []
for elem in hp:
    hl.append([i for i, x in enumerate(list(elem)) if x == 1])
wl = []
for elem in wp:
    wl.append([i for i, x in enumerate(list(elem)) if x == 1])

def func(hli, wli, c):
    tmp = 0
    for i in range(len(hli)):
        for j in range(len(wli)):
            if c[hli[i]][wli[j]] == '#':
                tmp += 1 
            
    return tmp

ans  = 0
for hli in hl:
    for wli in wl:
        if func(hli, wli, c) == K:
            ans += 1

print(ans)

Measured memory_bytes: 9268
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

class Flow{
private:
    struct edge{
        ll to;
        ll cap;
        ll rev;
    };
    
    ll INF;
    ll v;
    vector<vector<edge>> e;
    vector<bool> used;
    
    void reset_used(){
        for(int i=0;i<used.size();i++){used[i]=false;}
    }
    
    ll dfs(ll where,ll to,ll flow){
        if(where==to){return flow;}
        used[where]=true;
        for(int i=0;i<e[where].size();i++){
            edge &E=e[where][i];
            if(!used[E.to] && E.cap>0){
                ll d=dfs(E.to,to,min(flow,E.cap));
                if(d>0){
                    E.cap-=d;
                    e[E.to][E.rev].cap+=d;
                    return d;
                }
            }
        }
        return 0;
    }
    
public:
    Flow(ll v):v(v){
        e.resize(v);
        used.resize(v,false);
        INF=1e18+7;
    }
    
    void add_edge(ll from,ll to,ll cap){
        e[from].push_back((edge){to,cap,(ll)e[to].size()});
        e[to].push_back((edge){from,0,(ll)e[from].size()-1});
    }
    
    ll max_flow(ll s,ll t){
        vector<vector<edge>> ed=e;
        ll flow=0;
        while(1){
            reset_used();
            ll f=dfs(s,t,INF);
            if(f==0){break;}
            flow+=f;
        }
        e=ed;
        return flow;
    }
};



int main(){
    ll x,y,e;
    cin>>x>>y>>e;
    Flow F(x+y+2);
    for(int i=1;i<=x;i++){
        F.add_edge(0,i,1);
    }
    for(int i=x+1;i<=x+y;i++){
        F.add_edge(i,x+y+1,1);
    }
    for(int i=0;i<e;i++){
        ll s,t;
        cin>>s>>t;
        s++; t++;
        F.add_edge(s,x+t,1);
    }
    cout<<F.max_flow(0,x+y+1)<<endl;
    
    
    return 0;
}


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


using namespace std;

vector<int> v[100005];
bool processado[100005];
int tab[100005];

int dfs(int s)
{

    //processado[s] = true;
    int soma, max = 0, entrou = 0;
    
    if(tab[s] >= 0)
    {
        return tab[s];
    }
    for (int i = 0; i < v[s].size(); ++i)
    {

        entrou = 1;
        soma = dfs(v[s][i]) + 1;
        if(soma > max)
        {
            max = soma;
            tab[s] = max;
        }
    }
    if(entrou == 1)
    {
        return max;
    }

    return tab[s] = 0;

}
 


int main(){

    int n, m;
    cin >> n >> m;
    memset(tab, -1, sizeof(tab));

    /*for (int i = 1; i <= n; ++i)
    {
        processado[i] = false;
    }*/

    int x, y;
    for (int i = 0; i < m; ++i)
    {
        cin >> x >> y;
        v[x].push_back(y);
    }

    int soma = 0;
    for (int i = 1; i <= n; ++i)
    {
        soma = max(dfs(i), soma);
    }

    cout << soma << endl;





    

    
    return 0;
}


Measured memory_bytes: 8192