akhauriyash/Code-Regression huggingface dataset:
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10; 
vector<int> adj[maxn];
int dist[2][maxn];

void dfs(int u, int par, int r) {
	if(par + 1) 
		dist[r][u] = dist[r][par] + 1;
	for(int v : adj[u]) if(v - par) dfs(v, u, r); 
}
int main(int argc, char const *argv[]) {
#ifdef LOCAL_TESTING
	freopen("in", "r", stdin);
#endif
	int n; cin>>n; 
	for(int i = 0; i < n-1; i++) {
		int u, v; 
		cin>>u>>v; 
		adj[u].push_back(v);
		adj[v].push_back(u); 
	} 
	dfs(1, 0, 0); 
	dfs(n, 0, 1); 
	int x = 0, y = 0;
 	for(int i = 1; i <= n; i++) {
 		if(dist[0][i] <= dist[1][i]) x++;
 		else y++; 
 	} 
 	if(x > y) puts("Fennec");
 	else puts("Snuke"); 

}

Measured memory_bytes: 11136
# BFS

n, x, y = (map(int, input().split()))

pic = [[] for _ in range(n+1)] #[]:dummy
for _ in range(1,n):
    pic[_].append(_+1)
    pic[_+1].append(_)
pic[x].append(y)
pic[y].append(x)
#print(pic)

ptns = [0 for _ in range(n)] # 0:dummy

from collections import deque

for i in range(1,n+1): #'i'を開始位置として各頂点までの最短距離を探索
    queue = deque([i]) # dequeオブジェクト、初期値は開始位置の'i'のみ
    dis = [None] * (n+1) # 'i'からの最短距離を初期化, 0:dummy含む
    dis[i] = 0 # 開始位置なので'0'
    
    while queue:
        v = queue.popleft() # v:探索元のノード 
        for j in pic[v]: # pic[v]: 探索元のノードに隣接するノード
            if dis[j] is None:
                dis[j] = dis[v] + 1
                queue.append(j)
    #print(dis)
    for k in dis[1:]: # 最短距離を集約
        ptns[k] += 1

for l in ptns[1:]: # 1以上の最短距離を出力
    print(l//2) # 往復分が記録されているため2で割る


Measured memory_bytes: 9872
n = int(input())
s = input()
r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

count=0
for i in range(n):
    a = s[i]
    for j in range(i+1,n):
        if (2*j-i)>(n-1):
            continue
        b=s[j]
        c=s[2*j-i]
        if a!=b and b!=c and a!=c:
            count+=1
print(r_count*g_count*b_count-count)


Measured memory_bytes: 68388
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, m, x, y, a[101], b[101], l, r;

signed main() {
	cin >> n >> m >> x >> y;
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];
	l = *max_element(a,a+n)+1, r = *min_element(b,b+m);
	reps(z,l,r+1) if (x<z && z<=y) return cout << "No War" << endl, 0;
	cout << "War" << endl;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
ha = 0
for i in reversed(range(h)):
    if set(a[i])=={"."}:
        a.pop(i)
        ha+=1
for i in reversed(range(w)):
    if set([s[i] for s in a])=={"."}:
        for j in range(h-ha):
            a[j].pop(i)
for ai in a:
    print("".join(ai))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
char s[100];
char orgS[100];

int shim(char x){
  int ans = 101;
  int L = strlen(s);
  int check=0;
  for (int i=1;i<strlen(s);i++){
    if (s[0] !=s[i]){
      check = 1;
      break;
    }
  }if (check == 0)return 0;
  for (int i=0;i<100;i++){
    if (check == 0){
      ans = i;
      break;
    }
    check = 0;
    for (int j=0;j<L-1;j++){
      if (s[j+1] == x)s[j] = s[j+1];
      if (s[j+1] != x&&s[j] !=x){
        check++;
      }
    }
    L--;
  }
  for (int i=0;i<100;i++){
    s[i]=orgS[i];
  }
  return ans;
}


int main(){
  scanf("%s",s);
  for (int i=0;i<100;i++){
    orgS[i] = s[i];
  }
  int best = 101;
  for (char x = 'a';x <= 'z';x++){
    if (best > shim(x))best = shim(x);
  }
  printf("%d\n",best);
}



Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    vector<pair<int, int>> edges(M);

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        edges[i] = pair<int, int>(b, a);
    }

    sort(edges.begin(), edges.end());

    int ans = 1;
    int right = edges[0].first;
    for (int i = 1; i < M; i++) {
        if (right <= edges[i].second) {
            ans++;
            right = edges[i].first;
        }
    }

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


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

int main() {

	int N;
	cin >> N;


	long long sum = 0;
	for(int i = 1;i<=N;i++){
		if((i % 3 == 0)&&(i % 5 == 0));
		else if(i % 3 == 0);
		else if(i % 5 == 0);
		else
			sum += i;

		//cout << i << " ";
	}

	cout << sum << endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;

bool fac(ll n) {
	ll c = 0;
	for (ll i = n; i >= 1; i--) {
		if (n % i == 0) c++;
		if (c >= 100) return true;
	}
	return false;
}

int main() {
	/*ll test;
	cin >> test;
	while (test--) {
		
	}*/
	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);
	for (ll i = 0; i < n; i++) {
		cin >> p[i];
	}
	sort(p.begin(), p.end());
	ll ans{};
	for (ll i = 0; i < k; i++) {
		ans += p[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N, M; cin >> N >> M;
  
  vector<int> vecA(M);
  vector<int> vecB(M);
  
  for(int i=0;i<M;i++){
    cin >> vecA.at(i) >> vecB.at(i);}
  
  int sum =0;
  
  for(int j=0;j<N;j++){
    for(int k=0;k<M;k++){
      if(j+1 == vecA.at(k) || j+1 == vecB.at(k)){
        sum++;}
      }
      cout << sum << endl;
      sum=0;
  }
}    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int) n;i++)
typedef long long ll;
int n;
string s;
ll m;
map<string,ll> mp;
string ret,res;

int main (){
  cin>>n>>s;
  m=(1<<n);
  rep0(i,m){
    ret={};
    res={};
    rep0(j,n){
      if(i&(1<<j)) ret+=s[j];
      else res+=s[j];
    }
    if(res.size()) reverse(res.begin(),res.end());
    mp[ret+'+'+res]++;
  }
  ll ans=0;
  rep0(i,m){
    ret={};
    res={};
    rep0(j,n){
      if(i&(1<<j)) ret+=s[j+n];
      else res+=s[j+n];
    }
    if(ret.size()) reverse(ret.begin(),ret.end());
    ans+=mp[ret+'+'+res];
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 67200
#include<iostream>
#include<algorithm>
using namespace std;
#define LIMIT 45
int n; long double x[100], y[100], l[100];
long double dst(long double ax, long double ay, long double az, long double bx, long double by, long double bz) {
	return sqrtl((ax - bx)*(ax - bx) + (ay - by)*(ay - by) + (az - bz)*(az - bz));
}
long double max_amari(long double ax, long double ay, long double az) {
	long double maxn = 1000000000.0l;
	for (int i = 0; i < n; i++) {
		maxn = min(maxn, l[i] - dst(ax, ay, az, 0, x[i], y[i]));
	}
	return maxn;
}
long double solve2(long double h, long double X) {
	long double L1 = -200.0l, R1 = 200.0l, c1, c2, maxn = -1000000000.0l;
	for (int i = 0; i < LIMIT; i++) {
		c1 = (L1 + L1 + R1) / 3.0l;
		c2 = (L1 + R1 + R1) / 3.0l;
		long double m1 = max_amari(h, X, c1);
		long double m2 = max_amari(h, X, c2);
		if (m1 >= m2)R1 = c2;
		if (m1 < m2)L1 = c1;
		maxn = max(maxn, max(m1, m2));
	}
	return maxn;
}
bool solve(long double h) {
	long double L1 = -200.0l, R1 = 200.0l, c1, c2, maxn = -1000000000.0l;
	for (int i = 0; i < LIMIT; i++) {
		c1 = (L1 + L1 + R1) / 3.0l;
		c2 = (L1 + R1 + R1) / 3.0l;
		long double m1 = solve2(h, c1);
		long double m2 = solve2(h, c2);
		if (m1 >= m2)R1 = c2;
		if (m1 < m2)L1 = c1;
		maxn = max(maxn, max(m1, m2));
	}
	if (maxn > -1e-14)return true;
	return false;
}
int main() {
	while (true) {
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> l[i];
		long double L = 0.0l, R = 400.0l, M;
		for (int i = 0; i < LIMIT; i++) {
			M = (L + R) / 2;
			bool a1 = solve(M);
			if (a1 == true)L = M;
			if (a1 == false)R = M;
		}
		printf("%.15Lf\n", M);
	}
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 1000000000
#define MOD 1000000007
#define LOG 20
#define EPS 0.000000001
#define M 305
using namespace std;

int to;
int n;
ll k;
int a[N];

ll cmp(ll val) {

	int ptr=to+1;
	ll cnt=0;
	for(int i=to;i>=1 && ptr<=n;i--) {
		while(val<0 && ptr<=n && abs((ll)a[i]*a[ptr])<abs(val))
			ptr++;
		cnt+=max(0,n-ptr+1);
	}
	return cnt;

}

ll in(int l,int r,ll val) {

	int ptr=r;
	ll cnt=0;
	for(int i=l;i<ptr;i++) {
		while(ptr>0 && (ll)a[i]*a[ptr]>val) 
			ptr--;
		cnt+=max(0,ptr-i);
	}
	return cnt;

}

ll cnt(ll val) {

	return in(1,to,val)+in(to+1,n,val)+cmp(val);

}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(to=1;to<=n;to++) 
		if(a[to]>=0)
			break ;
	reverse(a+1,a+to);
	to--;
	ll bas=-(ll)inf*inf;
	ll son=-bas;
	while(bas<=son) {	
		if(cnt(orta)>=k) 
			son=orta-1;
		else bas=orta+1;
	}
	cout<<bas;

}

Measured memory_bytes: 1024
import sys
import math
import statistics
import itertools
from collections import deque

#n=int(input())
l,r,d=map(int,input().split())
#lis=list(map(int,input().split()))
ans=0
for i in range(l,r+1):
    if i%d==0:
        ans+=1

print(ans)

Measured memory_bytes: 72828
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
int mp[50+1][(50*50/2 +1)*(50+1)];
        signed main() {
        int n,k;
        cin>>n>>k;
        if(k%2){
            cout<<0;
            return 0;
        }
       
       for(int i=0;i<(n*n/2 +1)*(n+1);i++)mp[0][i]=0;
       mp[0][0]=1;
        for(int i=1;i<=n;i++){
            for(int j=0;j<=n*n/2;j++){
                for(int q=0;q<=n;q++){
                    if(j<q){
                     mp[i][j*(n+1)+q]=0;
                   //   cerr<<mp[i][j*(n+1)+q]<<' ';
                     continue;   
                    }
                    mp[i][j*(n+1)+q]=mp[i-1][(j-q)*(n+1)+q]*(2*q+1)%MOD;
                    if(q!=0)mp[i][j*(n+1)+q]=(mp[i][j*(n+1)+q]+mp[i-1][(j-q)*(n+1)+q-1])%MOD;
                    if(q!=n)mp[i][j*(n+1)+q]=(mp[i][j*(n+1)+q]+mp[i-1][(j-q)*(n+1)+q+1]*(q+1)*(q+1))%MOD;
                   // cerr<<mp[i][j*(n+1)+q]<<' ';
                }
              // cerr<<endl;
            }
            //cerr<<' ';
        }
        cout<<mp[n][k*(n+1)/2];
         return 0;

        }


Measured memory_bytes: 25728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int shuffle_times, shuffle;
		String str;
		try (Scanner sc = new Scanner(System.in)) {
			while(true) {
				str = sc.next();
				if(str.equals("-")) {
					break;
				}
				shuffle_times = sc.nextInt();
				for(int i = 0; i < shuffle_times; i++) {
					shuffle = sc.nextInt();
					str = str.substring(shuffle) + str.substring(0,shuffle);
				}
				System.out.println(str);
			}
		}
	}
}



Measured memory_bytes: 26516
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    int ans=max({a,b,c});

    for(int i=1;i<=k;i++)
         ans *= 2;

    printf("%d\n",ans+(a+b+c-max({a,b,c})));


}



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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i=0; i<N; i++) cin >> h.at(i);
  sort(h.begin(), h.end());
  
  int ans=1000000001;
  for(int i=0; i<N-K+1; i++){
    ans=min(ans, h.at(i+K-1)-h.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys
S = input()
T = input()
used = set()
siz = len(S)

def swap_str(strin, str1, str2, tmp='34343434'):
  return strin.replace(str1,tmp).replace(str2, str1).replace(tmp, str2)

for i in range(siz):
  if S[i] == T[i]:
    continue
  if T[i] in used or S[i] in used:
    print('No')
    sys.exit()
  S = swap_str(S, S[i], T[i])
  used.add(T[i])
print('Yes')

Measured memory_bytes: 5296
#include <iostream>
#include <map>
#include <vector>
 
using namespace std;
 
int main( void )
{
  /* ボール数入力 */
  int n;
  cin >> n;
  
  /* ボールの番号と番号の数を入力 */
  map<long, long>	mpNum;
  vector<int>	v;
  for ( int i = 0; i < n; i++ ) {
    int a;
    cin >> a;
    
    v.push_back(a);
    mpNum[a]++;
  }
  
  /* コンビネーション計算 */
  long	combi = 0;
  for ( auto itr = mpNum.begin(); itr != mpNum.end(); itr++ ) {
    combi += ((itr->second * (itr->second - 1)) >> 1);
  }

  /* 方法の数計算 */
  for ( auto itrV = v.begin(); itrV != v.end(); itrV++ ) {
    cout << (combi - mpNum[*itrV] + 1) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 10228
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    static int N;
    static long A;
    static long B;
    static long C;
    static String[] map;



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

        N = scanner.nextInt();
        A = scanner.nextInt();

        map = new String[N];
        for (int i = 0; i < N; i++) {
            map[i] = scanner.next();
        }

        int[] dx = {1, -1, 0, 0};
        int[] dy = {0, 0, 1, -1};


        int ans = 0;

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < A; j++) {
                if(map[i].charAt(j) == '#'){
                    boolean ok = false;
                    for (int k = 0; k < 4; k++) {

                        if(i + dy[k] < 0 || i + dy[k] >= N || j + dx[k] < 0 || j + dx[k] >= A)continue;
                        if(map[i + dy[k]].charAt(j + dx[k]) == '#')ok = true;
                    }
                    if(ok == false)ans = 1;
                }
            }
        }

        if(ans == 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }



    }

}



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

int main()
{
    string S;
    cin >> S;
    auto r = unique(S.begin(), S.end());
    S.erase(r, S.end());
    if(S.size()==4) cout<<"Good"<<endl;
    else            cout<<"Bad"<<endl;

    return 0;
}

Measured memory_bytes: 256
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define rep(i,a,b) for(int i=a; i<=b; ++i)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define nl '\n'
#define pb push_back
#define all(a) a.begin(),a.end()
#define P pair<ll,ll> 
#define F first
#define S second
const ll N=1e6+9;
const ll mod=1e9+7;
ll powerk(ll x, ll y);
ll mul(ll x, ll y);
ll add(ll x, ll y);
ll sub(ll x, ll y);

ll a[N];
ll dp[500][500];

ll go(ll left, ll right){
	//cout<<left<<" "<<right<<nl;
	if(left==right)return 0;
	if(dp[left][right]!=1e18)return dp[left][right];
	rep(i,left,right-1){
		dp[left][right] = min(dp[left][right],a[right]-a[left-1]+go(left,i)+go(i+1,right));
	}
	//cout<<left<<" "<<right<<" "<<dp[left][right]<<nl;
	return dp[left][right];
}

void solve()
{    
  ll n,m;
  cin>>n;
  rep(i,1,n)cin>>a[i],a[i]+=a[i-1];
  //rep(i,1,n)rep(j,1,n)dp[i][j]=1e18;
  //cout<<go(1,n)<<nl;
  memset(dp,0x3f,sizeof dp);
  rep(i,1,n)dp[i][i]=0;
  rep(i,2,n){
  	rep(j,i,n){
  		ll k = j-i+1 ;
  		rep(l,k,j-1){
  			if(dp[k][j]>a[j]-a[k-1]+dp[k][l]+dp[l+1][j]){
  				dp[k][j] = dp[k][l]+dp[l+1][j]+a[j]-a[k-1];
  			}
  			//if(k==1 && j==4)cout<<dp[k][j]<<" "<<dp[k][j]<<nl;
  		}
   	}
  }
  cout<<dp[1][n];
 
}


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}
ll mul(ll x, ll y){return (x*y)%mod;}
ll add(ll x, ll y){return (x+y)%mod;}
ll sub(ll x, ll y){return (x-y+mod)%mod;}
ll powerk(ll x, ll y)
{
  if(y==0)return 1;
  if(y==1)return x%mod;
  if(y&1)
    return ((powerk((x*x)%mod, y/2)%mod)*x)%mod;
  else return powerk((x*x)%mod,y/2)%mod;
}

// Xorawar

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * 不安なら ll を使う.
 * 小数は double を忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/

/* ===== コーナーケースに気をつけろ ===== */

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll sum = (N / (A + B)) * A;
    sum += min(N % (A + B), A);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, m;
int D[20][20];
int V;
const int INF = 1 << 20;

void solve()
{
	for (int k = 0; k < V; k++)
	{
		for (int i = 0; i < V; i++)
		{
			for (int j = 0; j < V; j++)
			{
				D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
			}
		}
	}
}

int main()
{
	fill(D[0], D[0] + 400, INF);
	char comma;
	cin >> n;
	V = n + 1;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b, c, d;
		cin >> a >> comma >> b >> comma >> c >> comma >> d;
		D[a][b] = c;
		D[b][a] = d;
	}
	int x1, y1, x2, y2;
	cin >> x1 >> comma >> x2 >> comma >> y1 >> comma >> y2;
	solve();
	cout << y1 - D[x1][x2] - D[x2][x1] - y2 << endl;
	cin >> n;
	return 0;
}

Measured memory_bytes: 1160
N = int(input())
multiple_4 = [x*4 for x in range(101) if x >= 1 and x <= 25]
multiple_7 = [x*7 for x in range(101) if x >= 1 and x <= 14]
multiple_4_7 = [x*4+7 for x in range(101) if x >= 1 and x <= 23]
multiple_7_4 = [x*7+4 for x in range(101) if x >= 1 and x <= 23]
tmp = []
for i in range(10):
  for j in range(10):
    solve = (4*(i+1))+(7*(j+1))
    if solve <= 100:
      tmp.append(solve)
multiple_other = sorted(list(set(tmp)))
if N in multiple_4 or N in multiple_7 or N in multiple_4_7 or N in multiple_7_4 or N in multiple_other:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int a = sc.nextInt();// A
		int b = sc.nextInt();// B
		int c = sc.nextInt();// C

		// 計算
		String result = "";
		if(check(a,b,c)){
			result = "YES";
		}else{
			result = "NO";
		}

		// 出力
		System.out.println(result);
	}

	static boolean check(int a, int b, int c){
		for(int i = 1; i <= b; i++){
			if((i * a)%b == c) return true;
		}
		return false;
	}
}




Measured memory_bytes: 25300
#include<stdio.h>

int main(void){
	int a,b,c,d;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	
	if (a>b){
		a=b;
	}
	if(c>d){
		c=d;
	}
	
	printf("%d", a+c);
	return 0;
}

Measured memory_bytes: 128
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll n,x,prev,cnt=1;
    cin>>n;

    cin>>x;
    prev=x;
    while(--n){
    cin>>x;
        if(x<=prev){
            prev=x;cnt++;
        }
    }


        cout<<cnt<<endl;


    return 0;
}





Measured memory_bytes: 3624
/*
 * Problem Description: Tree Walk
 * Category: Tree
 * Author: Khan
 * Date: 23th October, 2017
 */

#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node
{
    int parent, left, right;
};

Node T[MAX];
int n, D[MAX], H[MAX];

void Preorder(int u)
{
    printf(" %d", u);
    if(T[u].left != NIL)
        Preorder(T[u].left);
    if(T[u].right != NIL)
        Preorder(T[u].right);
}

void Inorder(int u)
{
    if(T[u].left != NIL)
        Inorder(T[u].left);
    printf(" %d", u);
    if(T[u].right != NIL)
        Inorder(T[u].right);
}

void Postorder(int u)
{
    if(T[u].left != NIL)
        Postorder(T[u].left);
    if(T[u].right != NIL)
        Postorder(T[u].right);
    printf(" %d", u);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int v, l, r, root = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        T[i].parent = NIL;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d %d %d", &v, &l, &r);
        T[v].left = l;
        T[v].right = r;
        if(l != NIL)
            T[l].parent = v;
        if(r != NIL)
            T[r].parent = v;
    }

    for (int i = 0; i < n; ++i)
    {
        if(T[i].parent == NIL)
            root = i;
    }

    printf("Preorder\n");
    Preorder(root);
    printf("\nInorder\n");
    Inorder(root);
    printf("\nPostorder\n");
    Postorder(root);
    printf("\n");
    return 0;
}

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

string s;

int main(void)
{
	bool yymm = false, mmyy = false;
	int yplace, mplace;

	cin >> s;

	yplace = (s[0] - '0') * 10 + (s[1] - '0');
	mplace = (s[2] - '0') * 10 + (s[3] - '0');

	if (yplace >= 1 && yplace <= 12)
		mmyy = true;
	if (mplace >= 1 && mplace <= 12)
		yymm = true;

	if (mmyy && yymm)
		cout << "AMBIGUOUS";
	else if (mmyy)
		cout << "MMYY";
	else if (yymm)
		cout << "YYMM";
	else
		cout << "NA";
	return 0;
}

Measured memory_bytes: 256
L, R = map(int, input().split())

if R-L >= 2019:
    print(0)
    exit()

ans = 2018
for i in range(L,R+1,1):
    for j in range(i+1,R+1,1):
        x = (i*j)%2019
        if x<ans:
            ans = x

print(ans)


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

string reverse(string str){
    string nstr="";
    for(string::reverse_iterator it=str.rbegin();it!=str.rend();++it){
        nstr += *it;
    }
    return nstr;
}
int main(){
    int m;
    string str;
    cin >> m;
    for(int i=0;i<m;++i){
        set<string> train;
        cin >> str;
        train.insert(str);
        for(int j=1;j<str.size();++j){
            string a, b, ra, rb;
            a = str.substr(0,j);
            b = str.substr(j);
            ra = reverse(a);
            rb = reverse(b);
            train.insert(b+a);
            train.insert(ra+b);
            train.insert(b+ra);
            train.insert(a+rb);
            train.insert(rb+a);
            train.insert(ra+rb);
            train.insert(rb+ra);
        }
        cout << train.size() << endl;
    }
}

Measured memory_bytes: 1304
# coding: utf-8
# Here your code !
n=input()
N=int(n)
a=0
ans=[]
for i in range(N):
    I=i+1
    a=0
    if I%2==0:
        a=a+1
        P=I/2
        for w in range(100):
            if P%2==0:
                a=a+1
                P=P/2
            else:
                ans.append(a)
                break
    else:
        ans.append(0)
max_idx = ans.index(max(ans))
print(max_idx+1)

Measured memory_bytes: 3064
#include <stdio.h>

int max(int a, int b)
{
	if(a > b) return a;
	else return b;
}

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

int main(void)
{
	int n;
	scanf("%d", &n);
	
	int i, r[n];
	for(i=0; i<n; i++){
		scanf("%d", &r[i]);
	}
	
	int maxpt = -2000000000;
	int minpt = r[0];
	for(i=1; i<n; i++){
		maxpt= max(maxpt, r[i]-minpt);
		minpt = min(minpt, r[i]);
	}
	printf("%d\n", maxpt);
	
	return 0;
}



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

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

  string s;
  cin >> s;

  int a = 0,b = 0;

  if(s[0] == 'A')
  {
    a++;
  } 
  else
  {
    b++;
  }

  if(s[1] == 'A')
  {
    a++;
  } 
  else
  {
    b++;
  }

  if(s[2] == 'A')
  {
    a++;
  } 
  else
  {
    b++;
  }

  if(a && b)
  {
    cout << "Yes" << '\n';
  }
  else
  {
    cout << "No" << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    cout<<modpow(n,m)<<endl;
    return 0;
}



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

int main(){
  int i,a[3],k,m=0;
  cin>>a[0]>>a[1]>>a[2];
  cin>>k;
  for(i=1; i<3; i++){
    if(a[i]>a[m]) m=i;
  }
  for(i=0; i<k; i++){
    a[m]*=2;
  }
  cout<<a[0]+a[1]+a[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll x;cin>>x;
    rep(i,n){
        cin>>a[i];
    }
    vector<vector<ll> >t(n,vector<ll>(n));
    rep(i,n){
        ll mi=inf*inf;
        rep(j,n){
            ll xx=i-j;
            if(xx<0)xx+=n;
            mi=min(mi,a[xx]);
            t[i][j]=mi;
        }
    }
    ll ans=inf*inf;
    rep(i,n){
        ll sum=0;
        rep(j,n){
            sum+=t[j][i];
        }
        ans=min(ans,sum+x*i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 31616
#ABC052-C

N = int(input())

fact = {}
for i in range(1, N+1):
    tmp = i
    w = 2
    while tmp != 1:
        if tmp % w == 0:
            add = w
            tmp //= w
        elif w**2 > tmp:
            add = tmp
            tmp = 1
        else:
            w += 1
            continue
        if add in fact:
            fact[add] += 1
        else: fact[add] = 1
ans = 1
for k in fact.values():
    ans = ans*(k+1)%(10**9 + 7)
print(ans)

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

using namespace std;
const int mod = 1e9 + 7;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;i++)
long long H,W,K,N,D,X;
long long A=0;
int main()
{
  cin>>X>>K>>D;
  X=abs(X);
  long long X2=X%D;
  long long K2=K-X/D;
  if(K>X/D){
    if(K2%2==0)cout<<X2;
    else cout<<D-X2;
  }else{
    cout<<X-K*D;
  }
  return 0;
}





Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    V<> a(n);
    V<> pos(n);
    set<int> s;
    rep(i, n) {
        cin >> a[i];
        a[i]--;
        pos[a[i]] = i;
    }
    ll ans = 0;
    s.insert(-1);
    s.insert(n);
    rep(i, n) {
        int now = pos[i];
        auto p = s.lower_bound(now);
        int num1 = *p - now;
        p--;
        int num2 = now - *p;
        ans += (ll)(i + 1) * num1 * num2;
        s.insert(now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 14224
N, Y = list(map(int, input().split()))

impossible = "-1 -1 -1"
flag = False

if Y % 1000 != 0:
    print(impossible)

else:
    # A: 10,000円札の枚数
    # B: 5,000円札の枚数
    # C: 1,000円札の枚数

    max_A = int(Y/10000)

    for num_A in range(max_A + 1):
        left_BC = Y
        left_BC -= num_A * 10000

        max_B = int(left_BC/5000)

        for num_B in range(max_B + 1):
            left_C = left_BC - num_B * 5000
            num_C = int(left_C/1000)

            if num_A + num_B + num_C == N:
                flag = True

                break

        if flag:
            break

    if flag:
        print("{} {} {}".format(num_A, num_B, num_C))
    else:
        print(impossible)


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
int a[100000];

int main()
{
    int n;cin>>n;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
             for(int k=1;k<=100;k++){
                  int x=i*i+j*j+k*k+i*j+j*k+k*i;
                  a[x]+=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<a[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>

int main(void) {
	char S[8], T[8];
	if (scanf("%7s", S) != 1) return 1;
	if (scanf("%7s", T) != 1) return 1;
	printf("%d\n", (S[0] == T[0]) + (S[1] == T[1]) + (S[2] == T[2]));
	return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)
 
struct eg{
    int a,b,c;
};
 
#define int ll
 
#define MAX_V 500
#define MAX_B 50
 
struct edge{pii to;int cost;};
 
void dijkstra(pii s, vector<vector<int>> &d, vector<edge> G[MAX_V][MAX_B]){
    priority_queue< pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>> > que;
    rep(i,MAX_V)rep(j,MAX_B)d[i][j]=INF;
    d[s.first][s.second]=0;
    que.push(make_pair(0,s));
     
    while(que.size()){
        pair<int,pii> p=que.top();
        que.pop();
         
        int v=p.second.first;
        int b=p.second.second;
        if(d[v][b]<p.first)continue;
         
        rep(i,G[v][b].size()){
            edge e=G[v][b][i];
            if(d[e.to.first][e.to.second]>d[v][b]+e.cost){
                d[e.to.first][e.to.second]=d[v][b]+e.cost;
                que.push(make_pair(d[e.to.first][e.to.second],e.to));
            }
        }
    }
}
 
 
signed main(){
    int v,e;
    cin>>v>>e;
    vector<pii> gr[MAX_V];
    rep(i,e){
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        gr[a].pb(pii(b,c));
        gr[b].pb(pii(a,c));
    }
     
    int v0;
    cin>>v0;
    int a,b,c;
    cin>>a>>b>>c;
     
    vector<edge> G[MAX_V][MAX_B];
    rep(i,v){
        rep(vid,c){
            int vi = (a*vid+b)%c;
            for(auto e:gr[i]){
                G[i][vid].pb(edge{pii(e.first,vi),e.second*vid});
            }
        }
    }
     
    vector<vector<int>> d1(MAX_V,vector<int>(MAX_B));
    dijkstra(pii(0,v0),d1, G);
 
    int ans = INF;
    rep(i,c){
        vector<vector<int>> d2(MAX_V,vector<int>(MAX_B));
        dijkstra(pii(v-1,i),d2,G);
        int t = INF;
        rep(j,c){
            t = min(t,d1[v-1][i] + d2[0][j]);
        }
        ans = min(ans, t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17832
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  lli a, b, c, d;
  while (scanf("%lld %lld %lld %lld", &a, &b, &c, &d) != EOF)
  {
    lli ans = max({a * c, a * d, b * c, b * d});
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int> v1, v2;
    a*=100, b*=100;
    for (int i = 0; i <= f/a; ++i) {
        v1.emplace_back(i*a);
    }
    for (int i = 0; i <= f/a; ++i) {
        for (int j = 0; j <= (f-v1[i])/b; ++j) {
            v1.emplace_back(v1[i]+j*b);
        }
    }
    sort(v1.begin(), v1.end());
    v1.erase(unique(v1.begin(), v1.end()), v1.end());
    for (int i = 0; i <= f/c; ++i) {
        v2.emplace_back(i*c);
    }
    for (int i = 0; i <= f/c; ++i) {
        for (int j = 0; j <= (f-v2[i])/d; ++j) {
            v2.emplace_back(v2[i]+j*d);
        }
    }

    sort(v2.begin(), v2.end());
    v2.erase(unique(v2.begin(), v2.end()), v2.end());
    double up = (((double)e*100)/((double)(100+e)));
    double ans = 0;
    int maxx = 0, maxy = 0;
    for (auto &&x : v1) {
        for (auto &&y : v2) {
            if(x+y != 0){
                double k = (double)100*y/(double)(x+y);
                if(ans <= k && k <= up && x+y <= f ){
                    ans = k;
                    maxx = x;
                    maxy = y;
                }
            }
        }
    }
    cout << maxx+maxy << " " << maxy << "\n";
    return 0;
}


Measured memory_bytes: 1400
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unsafe"
)

func main() {
	AB := sc.nextInts()
	A := AB[0]
	B := AB[1]
	if B == 1 {
		fmt.Println(0)
		return
	}
	// fmt.Println(int(math.Ceil(float64(B) / float64(A))))
	var cnt int
	for {
		B = B - A
		cnt++
		if B <= 0 {
			break
		}
		B++
	}
	fmt.Println(cnt)
}

var (
	sc scanner
)

func init() {
	sc = scanner{
		buf: make([]string, 0, 0),
		cur: 0,
		r:   bufio.NewReader(os.Stdin),
	}
}

type scanner struct {
	buf []string
	cur int
	r   *bufio.Reader
}

func (s *scanner) readln() {
	rbuf := make([]byte, 0, 0)
	for {
		line, prefix, err := s.r.ReadLine()
		if err != nil {
			panic(err)
		}
		rbuf = append(rbuf, line...)
		if prefix == false {
			break
		}
	}
	s.cur = 0
	s.buf = strings.Split(*(*string)(unsafe.Pointer(&rbuf)), " ")
}
func (s *scanner) isFull() bool {
	if s.cur == len(s.buf) {
		return true
	}
	return false
}
func (s *scanner) resetCur() {
	s.cur = 0
}
func (s *scanner) next() string {
	if s.cur == 0 {
		s.readln()
	}
	res := s.buf[s.cur]
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nexts() []string {
	s.readln()
	s.resetCur()
	return s.buf
}
func (s *scanner) nextInt() int {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.Atoi(s.buf[s.cur])
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextInts() []int {
	s.readln()
	res := make([]int, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.Atoi(s.buf[i])
	}
	s.resetCur()
	return res
}
func (s *scanner) nextFloat() float64 {
	if s.cur == 0 {
		s.readln()
	}
	res, _ := strconv.ParseFloat(s.buf[s.cur],
		64)
	s.cur++
	if s.isFull() {
		s.resetCur()
	}
	return res
}
func (s *scanner) nextFloats() []float64 {
	s.readln()
	res := make([]float64, len(s.buf))
	for i := range s.buf {
		res[i], _ = strconv.ParseFloat(s.buf[i],
			64)
	}
	s.resetCur()
	return res
}
func digits(x int) int {
	return len(strconv.Itoa(x))
}
func powInt(x, p int) (result int) {
	result = 1
	for i := 0; i < p; i++ {
		result *= x
	}
	return
}
func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}
func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}
func abs(x int) int {
	return int(math.Abs(float64(x)))
}
func varDump(value ...interface{}) {
	for _, v := range value {
		fmt.Fprintf(os.Stderr, "%#v\n", v)
	}
}
func yes() {
	fmt.Println("Yes")
}
func no() {
	fmt.Println("No")
}

// Pair a
type Pair struct {
	first  int
	second int
}

// Queue a
type Queue struct {
	v []Pair
}

// Push for queue
func (q *Queue) Push(v Pair) {
	q.v = append(q.v, v)
}

// Pop for queue
func (q *Queue) Pop() Pair {
	r := q.v[0]
	q.v = q.v[1:]
	return r
}

// Front for queue
func (q Queue) Front() Pair {
	return q.v[0]
}

// Empty return true if empty
func (q Queue) Empty() bool {
	return len(q.v) == 0
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;


typedef long long int lli;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<float, float> ff;
typedef vector<ii> vii; 
typedef vector<ff> vff;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vi ab(n);
    for (int i=0;i<n;i++) { cin >> ab[i]; }
    int x = ab[0];
    for(int i =1;i<n;i++){
        
        x  = x^ab[i];
        // cout<<x<<" ";
    }
    // cout<<x<<endl;
    if(!x){
        cout<<"Yes"<<endl;
    }else{cout<<"No\n";}
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>


int main(){
  char s[1006], t[1006];
  
  scanf("%s", s);
  scanf("%s", t);
  int v = strlen(s) - strlen(t) + 1;
  int min =1007;
  
  for (int i = 0; i < v; ++i){
    int a = 0, cont = 0;
    for (int j = i; j < strlen(t) +i; ++j){
      if (s[j] != t[a])
        cont +=1;
      a += 1;
    }
    if (cont < min)
      min = cont;
  }
  
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 1704
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    static String T = "";

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int nums[] = new int[3];
        for(int i = 0; i < 3; i++){
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(nums[0] * nums[1] / 2);

    }
}

Measured memory_bytes: 21588
#create date: 2020-04-26 21:00

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s, w = na()
    print("unsafe" if s <= w else "safe")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
n, q = [int(i) for i in input().split()]
s = input()
l_list = []
r_list = []
for i in range(q):
    l, r = [int(i) for i in input().split()]
    l_list.append(l)
    r_list.append(r)

ac_map = [0 for i in range(n+1)]
for i in range(1, n+1):
    if s[i-1:i+1] == "AC":
        ac_map[i] = ac_map[i-1] +1
    else:
        ac_map[i] = ac_map[i-1]
for i in range(q):
    ans = ac_map[r_list[i]-1] - ac_map[l_list[i]-1]
    print(ans)

Measured memory_bytes: 14228
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める

int main(){
	ll a,b,k;
	cin >> a >> b >> k;
	int count = 0;
	for(int i = 0 ; i < k ; i ++){
		if(a % 2 == 1){
			a --;
		}
		a /= 2;
		b += a;
		count++;
		if(count == k) break;

		if(b % 2 == 1){
			b--;
		}
		b /= 2;
		a += b;
		count++;
		if(count == k) break;
	}
	cout<<a<<" "<<b<<endl;

}


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

using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> C;
	vector<int> S;
	vector<int> F;
	for(int i = 0; i < N - 1; ++i) {
		int c, s, f;
		cin >> c >> s >> f;
		C.push_back(c);
		S.push_back(s);
		F.push_back(f);
	}
	vector<long long> answer;
	for(int i = 0; i < N - 1; ++i) {
		long long t = 0;
		for(int j = i; j < N - 1; ++j) {
			if(t <= S[j]) {
				t = S[j];
			} else {
				t = (((t - 1) / F[j]) + 1) * F[j];
			}
			t += C[j];
		}
		answer.push_back(t);
	}
	answer.push_back(0);
	for(int i = 0; i < N; ++i) {
		cout << answer[i] << '\n';
	}
	return 0;
}



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

int main(){
    char string1[100];
    int i, length;
    int flag = 0;
    
    cin >> string1;
    
    length = strlen(string1);
    
    for(i=0;i < length ;i++){
        if(string1[i] != string1[length-i-1]){
            ++flag;
   }
}
    
    cout<<flag/2;
    return 0;
}

Measured memory_bytes: 256
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop

# from itertools import accumulate
# from collections import deque
import random


def main():
    n,p = map(int, input().split())
    print((int((n*3+p)/2)))



if __name__ == '__main__':
    main()


Measured memory_bytes: 7748
#include <iostream>

int main(void)
{

    int tmp;
    std::cin >> tmp;
    int min = tmp, max = tmp;
    for (int i = 1; i < 3; ++i)
    {
        std::cin >> tmp;
        if (tmp < min)
            min = tmp;
        if (tmp > max)
            max = tmp;
    }

    std::cout << max - min << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int n,f;
  cin >> n >> f;
  int i;
  long double sump=0.0;
  for(i=1;i<=n;i++){
    long double p=1.0;
    int ci;
    ci=i;
    while(ci<f){
      ci*=2;
      p/=2;
    }
    sump+=p;
  }
  cout << fixed << setprecision(10) << sump/n << endl;
  return(0);
}

Measured memory_bytes: 256
#include <stdio.h>

int n, A[50];

int solve (int i, int m) {
	if(m == 0){
		return 1;
	}
	if(i >= n){
		return 0;
	}
	int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	int q, M, i;

	scanf("%d", &n);
	for ( i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for ( i = 0; i < q; i++) {
		scanf("%d", &M);
		if(solve(0, M)){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int ans = 1;
    for (int i = 1; i < N; i++)
    {
        int judge = 1;
        for (int j = 0; j < i; j++)
        {
            if (H[j] > H[i])
            {
                judge = 0;
            }
        }
        if (judge == 1)
        {
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int a, b;

    cin >> a >> b;

    int diff = abs(a-b);

    if (diff%2) cout << "IMPOSSIBLE";
    else cout << max(a, b)-diff/2;

    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int A[N];
    int max_num = 0;
    int max_i = 0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(max_num < A[i]){
            max_num = A[i];
            max_i = i;
        }
        //cout << "A[" << i << "] = " << A[i] << endl; 
        //cout << "MAX:" << max_num << " " << max_i << endl; 
    }
    bool flags = false;
    for(int i=0; i<N; i++){
        if(i == max_i) continue;
        if(A[i] == max_num){
            flags = true;
            break;
        }
    }
    for(int i=0; i<N; i++){
        /*
        int ans = 0;
        for(int j=0; j<N; j++){
            if(i == j) continue;
            ans = max(ans, A[j]);
        }
        cout << ans << endl;
        */
        if(A[i] != max_num){
            cout << max_num << endl;
        }else if(flags == true){
            cout << max_num << endl;
        }else{
        int ans = 0;
        for(int j=0; j<N; j++){
            if(i == j) continue;
            ans = max(ans, A[j]);
        }
        cout << ans << endl;
        }
        //cout << (A[i]!=max_num)? max_num:
    }
    return 0;
}

Measured memory_bytes: 2432