akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    string s;
    long long n, i, ans=0, countb=0;

    cin >> s;

    n = s.size();

    for(i=0; i<n; i++){
        if(s[i]=='B'){
            countb++;
        }
        else{
            ans += countb;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		String A[] = new String[N];
		for(int i = 0; i < N; i++) {
			A[i] = sc.next();
		}
		String B[] = new String[N];
		for(int i = 0; i < M; i++) {
			B[i] = sc.next();
		}
		
		for(int i = 0; i < N; i++) {
			in : for(int j = 0; j < N; j++) {
				for(int h = 0; h < M; h++) {
					for(int w = 0; w < M; w++) {
						if(j + w >= N) continue in;
						if(i + h >= N) continue in;
						if(!A[i + h].substring(j + w, j + w + 1).equals(B[h].substring(w, w + 1))) continue in;						
					}
				}
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 24020
/* ファイル名：ITP1_10_B.c	*/
/* 内容：三角形の２辺 a, b とその間の角 C から、								*/
/*		 その三角形の面積 S、周の長さ L, a を底辺としたときの高さ h を求める	*/

/* include	*/
#include <stdio.h>
#include <math.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:三角形の２辺 a, b とその間の角 C から、面積、周の長さ、高さを求める	*/
int main( void )
{
	/* 内部変数定義	*/
	/* 入力	*/
	int a;	/* 辺1	*/
	int b;	/* 辺2	*/
	int C;	/* 辺1と辺2の間の角	*/
	
	/* 処理	*/
	double PI;	/* 円周率	*/
	double rad;	/* ラジアンにしたC	*/
	
	/* 出力	*/
	double S;	/* 面積	*/
	double L;	/* 周の長さ	*/
	double h;	/* 高さ	*/
	
	/* 円周率を定義	*/
	PI = acos(-1);
	
	/* a,b,Cの入力	*/
	scanf("%d %d %d",&a,&b,&C);
	
	/* Cをラジアンにする	*/
	rad = (double)C * (PI / 180);
	
	/* 面積の算出	*/
	S = (double)(a * b * sin(rad) / 2);
	
	/* 周の長さの算出	*/
	L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(rad));
	
	/* 高さの算出	*/
	h = (double)(2 * S / a);
	
	/* 結果(面積、周の長さ、高さ)の出力	*/
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,W; cin>>N>>W;
  int ans=0;
  vii A(4);
  int memo=0; cin>>memo;
  int X; cin>>X;
  A[0].push_back(X);
  rep(i,0,N-1){
    int X,Y; cin>>X>>Y;
    A[X-memo].push_back(Y);
  }
  vii S(4);
  rep(i,0,4){
    sort(ALL(A[i]),greater<int>());
    int sum=0;
    S[i].push_back(0);
    rep(j,0,A[i].size()){
      sum+=A[i][j];
      S[i].push_back(sum);
    }
  }
  REP(i,0,A[0].size()){
    REP(j,0,A[1].size()){
      REP(k,0,A[2].size()){
        REP(l,0,A[3].size()){
          int K=i*memo;
          K+=j*memo+j;
          K+=k*memo+k*2;
          K+=l*memo+l*3;
          if(K<=W){
            int sum=0;
            sum+=S[0][i];
            sum+=S[1][j];
            sum+=S[2][k];
            sum+=S[3][l];
            ans=max(ans,sum);
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { for(;b;swap(a,b))a%=b; return a; }

const int MAXN = 100055;

int A[MAXN];

int N, T;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int ev, od;;) {
		ev = od = 0;
		for(int i = 1; i <= N; i++) {
			if((A[i]&1) && 2 < A[i]) od++;
			if(!(A[i]&1)) ev++;
		}
		if(ev&1) break;
		if(1 != od) {
			T = !T;
			break;
		}
		for(int i = 1; i <= N; i++) if((A[i]&1) && 2 < A[i]) {
			A[i]--;
			break;
		}
		int G = A[1];
		for(int i = 2; i <= N; i++) G = gcd(G, A[i]);
		for(int i = 1; i <= N; i++) A[i] /= G;
		T = !T;
	}

	puts(T ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int fib_num(int number);

int main(void) {
	int n		= 0;
	int result	= 0;
	scanf("%d\n", &n );
	
	result = fib_num(n);
	
	printf("%d\n",result);
	
	return 0;
}

int fib_num(int number) {
	static int arr[45] = {};
	static int i = 0;
	
	if ( number < 0 ) {
		printf("error\n");
		return -1;
	}
	


	if ( i == number && i > 1) {
	    
	    arr[i-1] = fib_num(number-1);
	    i++;
	}
	
	if ( arr[number] > 0) {

	    return arr[number];
	}
	
	if ( number <= 1) {
		arr[0] = 1;
		arr[1] = 1;
		i = 2;
		return 1;
	}
	
	
	return fib_num( number -2 ) + fib_num( number - 1 );
}


Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
	int n, m;
	int x1, x2, y1, y2;
	char dummy;

	cin >> n;
	cin >> m;

	vector<int> a(m), b(m), c(m), d(m);
	vector< vector <int> > map(n + 1, vector<int>(n + 1, INT_MAX / 4));
	
	for(int i = 0; i < m; i++) {
		cin >> a[i] >> dummy >> b[i] >> dummy >> c[i] >> dummy >> d[i];
	}
	cin >> x1 >> dummy >> x2 >> dummy >> y1 >> dummy >> y2;

	for(int i = 0; i < m; i++) {
		map[a[i]][b[i]] = c[i];
		map[b[i]][a[i]] = d[i];
	}
	for(int i = 0; i < n; i++) {
		map[i][i] = 0;
	}

	for(int k = 0; k < n + 1; k++) {
		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < n + 1; j++) {
				map[i][j] = min(map[i][j], map[i][k] + map[k][j]);
			}
		}
	}

	y1 -= map[x1][x2] + map[x2][x1] + y2;

	cout << y1 << endl;

	return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll aa[10005];

int main(int argc, char* argv[])
{
    long n,a,b;
    scanf("%ld%ld%ld", &n, &a, &b);

    long i;
    for(i=1; i<=n; i++) {
        long sum=0;
        long x=i;
        while(x>0) {
            sum += (x%10);
            x = x/10;
        }
        aa[sum]+=i;
    }

    ll ans=0;
    for(i=a; i<=b; i++) {
        ans+=aa[i];
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 128
n = int(input())
w = input()
s = set()
s.add(w)
ans = "Yes"
for i in range(n - 1):
    tmp = w[len(w)-1]
    w = input()
    if (w[0] == tmp) and not (w in s):
        s.add(w)
    else:
        ans = "No"
        break

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	V<ll> A(N+1); rep(i,N+1) cin >> A[i];

	ll L = 1, R = 1;
	V<ll> Ls(N+1),Rs(N+1);
	const ll inf = 1e18;
	rep(i,N+1){
		Ls[i] = L, Rs[i] = R;
		if(R < A[i]){
			cout << -1 << endl;
			return 0;
		}
		L -= A[i], R -= A[i];
		if(L<0) L = 0;
		R *= 2;
		chmin(R,inf);
	}
	if(L == 0){
		ll ans = 0;
		ll x = 0;
		per(i,N+1){
			x = min(Rs[i],x+A[i]);
			ans += x;
		}
		cout << ans << endl;
	}else{
		cout << -1 << endl;
		return 0;
	}
}


Measured memory_bytes: 5576
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
int Q;
string S;
deque<char> D;
struct edge{bool mae; char c;};

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

  cin >> S;
  rep(i, S.size()) {
    D.push_back(S[i]);
  }
  cin >> Q;
  int a,f;
  int cnt = 0;
  char c;
  vector<edge> V;
  rep(i, Q) {
    cin >> a;
    if (a==1) {
      cnt++;
    } else {
      cin >> f >> c;
      f+=cnt%2;
      f%=2;
      V.push_back({f==0, c});
    }
  }
  rep(i, Q-cnt) {
    edge e = V[i];
    if (e.mae) D.push_back(e.c);
    else D.push_front(e.c);
  }
  cnt%=2;
  if (cnt>0) {
    while(!D.empty()) {
      char d = D.back(); D.pop_back();
      cout << d;
    }
  }else {
    while(!D.empty()) {
      char d = D.front(); D.pop_front();
      cout << d;
    }
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 1352
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		float v[] = new float[n];
		for(int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		Arrays.sort(v);
		
		float ans = v[0];

		for(int i = 0; i < n; i++) {
			ans = (ans + v[i]) / 2;
//			System.out.println(ans);
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
#pragma  warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <iomanip>
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;

int main()
{
	ll a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	ll ans1 = x*a + y*b;
	ll ans2 = (y * 2)*c + max(ll(0), x - y)*a;
	ll ans3 = (x * 2)*c + max(ll(0), y - x)*b;
	/*cout << ans1 << endl;
	cout << ans2 << endl;
	cout << ans3 << endl;*/
	cout << min(ans1, min(ans2, ans3)) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	try{
	    BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	    int i, n = Integer.valueOf(sc.readLine());
	    int[] map = new int[n];
	    String[] st = sc.readLine().split(" ");
	    for(i=0; i<n; i++)
		map[i] = Integer.valueOf(st[i]);
	    Arrays.sort(map);
	    long sum = 0;
	    for(i=0; i<=n; i++){
		if(i==n||map[i]>sum+1){
		    System.out.println(sum+1);
		    break;
		}
		sum += map[i];
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 12000
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			int n=in.nextInt();
			int p=in.nextInt();
			if((n|p)==0)
				return;
			int N[]=new int[n];
			int i=0;
			int r=p;
			for(;;)
			{
				if(r!=0)
				{
					N[i]++;
					r--;
				}
				else
				{
					r=N[i];
					N[i]=0;
				}
				if(N[i]==p)
					break;
				i++;
				i%=n;
			}
			System.out.println(i);
		}
	}
}

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

/*
bool is_true(ull a, ull b, ull c){
  ull temp = c - a - b;

  if(temp > 0 && temp*temp > 4*a*b)return true;
  else return false;
}



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

  ull temp = c - a - b;
  if(temp > 0 && temp*temp > 4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;

  
  if(is_true(a, b, c)) cout << "Yes" << endl;
  else cout << "No" << endl;
  

  return 0;
}
*/

typedef long long ll;

int main(void){
ll a,b,c;

cin >> a >> b >> c;

ll d = c - a - b;
if(d > 0 && d * d > 4 * a * b){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}

return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	printf("%d\n%d\n",(a+b+c+d)/60,(a+b+c+d)%60);
	return 0;
}


Measured memory_bytes: 2708
#A
def A():
    a, b, c = map(int, input().split())
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return



#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 38256
import java.util.*;


public class Main{

    public static int bubble(int A[],int N) {
        int flag=1,cnt=0;
        while(flag==1){
            flag=0;
            for(int j=N-1;j>0;j--){
                if(A[j]<A[j-1]){
                    int t=A[j];
                    A[j]=A[j-1];
                    A[j-1]=t;
                    cnt++;
                    flag=1;
                }
            }
        }
        return cnt;

    }

    public static void main( String[] args) {

        Scanner sc = new Scanner(System.in);

        int count=0;
        int N = sc.nextInt();
        int[] A;
        A = new int[100];

        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
        }
        count = bubble(A,N);

        for(int i=0;i<N;i++){
            System.out.print(A[i]);
            if(i!=N-1)  System.out.print(" ");
        }
        System.out.println("\n"+count);

        sc.close();
    }
}


Measured memory_bytes: 26320
n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
	for j in range(1,105):
		for k in range(1,105):
			v = i*i+j*j+k*k+i*j+j*k+k*i;
			if v<10050:
				ans[v]+=1

for i in range(n):
  	print(ans[i+1])


Measured memory_bytes: 9260
import java.util.*;

public class Main {

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

        int ans1 = 0;
        int ans2 = 0;
        for(int i = 0;i < s.length();i++){
            char c = i % 2 == 0 ? '1' : '0';
            if(s.charAt(i) == c){
                ans1++;
            } else {
                ans2++;
            }
        }
        System.out.println(Math.min(ans1,ans2));
    }
}


Measured memory_bytes: 25320
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#define N 5005
#define MOD 1000000007
using namespace std;
int n,len;
char s[N];
long long dy[N][N];
long long ex_func(long long x, long long ex) {
	long long ret=1;
	while (ex > 0) {
		if (ex % 2 == 1) {
			ret *= x; ret %= MOD;
		}
		x *= x; x %= MOD;
		ex /= 2;
	}
	return ret;
}
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	len = strlen(s);
	dy[0][0] = 1;
	int i, j;
	for (i = 1; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			if (j == 0) dy[i][j] = dy[i - 1][j] + dy[i - 1][j + 1];
			else dy[i][j] = dy[i - 1][j - 1] * 2 + dy[i - 1][j + 1];
			dy[i][j] %= MOD;
		}
	}
	long long div = 1;
	for (i = 1; i <= len; i++) {
		div *= 2; div %= MOD;
	}
	printf("%lld", dy[n][len] * ex_func(div, MOD - 2)%MOD);
	return 0;
}

Measured memory_bytes: 195712
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

int bubbleSort(int a[], int n)
{
    int ans = 0;
    int tmp = a[n];
    bool flg = true;

    for (int i = 0; flg; i++)
    {
        flg = false;
        for (int j = n - 1; j >= i + 1; j--)
        {
            if (a[j - 1] > a[j])
            {
                swap(a[j], a[j - 1]);
                ans++;
                flg = true;
            }
        }
    }

    for (int i = 0; i < n;i++){
        if(i)
            cout << " ";
        cout << a[i];
    }
    cout << endl;

    return ans;
}

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

    int a[105];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    cout << bubbleSort(a, n) << endl;
}


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

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

    long long a[N];
    map<long long, long long> mp;

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

    int res = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->second > itr->first){
            res = res + (itr->second - itr->first);
        }else if(itr->first > itr->second){
            res = res + itr->second;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

typedef long long int llint;

int main(void){
  int a, b;
  std::cin >> a >> b;
  std::cout << a*b << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll a,b,k;
    in>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b<<endl;
    }
    else{
        cout<<0<<" "<<max(0ll,b-k+a)<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
        int n;
        cin >> n;
        int *b = new int[n];
        int *a = new int[n];
        for(int i=0;i<n;i++){
                cin >> a[i];
        }

        int num_boll = 0;
        for(int i=n-1;i>=0;i--){
                int parity = 0;
                for(int j= 2 * (i+1) - 1; j<n;j+=i+1){
                        if(b[j] == 1){
                                parity = 1 - parity;
                        }
                }

                b[i] = (a[i] + parity) % 2;
                if(b[i] == 1){
                        num_boll++;
                }
        }

        cout << num_boll << endl;
        if(num_boll > 0){
        for(int i=0;i<n;i++){
                if(b[i] == 1){
                        cout << (i+1) << " ";
                }
        }
        cout << endl;
        }
}

Measured memory_bytes: 2432
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

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

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

ll mod_ = 1e9 + 7;
ll mod = 13;

ll pow_(ll x, long long int n){
	ll res(1);
	while(n){
		if(n&1){
			res = ((res%mod) * (x%mod))%mod;
		}
		n >>= 1;
		x = ((x%mod) * (x%mod))%mod;
	}
	return res%mod;
}


int main(){
	int n, d;
	cin >> n >> d;
	d = 2 * d + 1;
	cout << (n - 1 + d) / d << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

set<ll> ret;

void dfs(int depth, ll x){
  ret.insert(x);
  if(depth < 0) return;

  for(ll i=-1; i<=1; i++){
    if(0<=x%10+i && x%10+i<10) dfs(depth-1, 10*x + (x%10+i));
  }
}

int main(){

  REP(i,1,10){
    dfs(10,i);
  }

  int N;
  cin >> N;
  FOR(it,ret){
    N--;
    if(N==0){
      cout << (*it) << endl;
      break;
    }
  }
  
  return 0;
}



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

using namespace std;

int main(){
    int r,d,x;
    cin >> r >> d >> x;

    vector<long long int>v(10);
    v[0] = x;

    for(int i = 0;i < 10;i++){
        v[i+1] = r*v[i]-d;
        cout << v[i+1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
	"os"
	"strings"
)

//大量のデータを標準入力から受け取る時はnextLineを使うようにすると高速
var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func main() {
	var a string
	fmt.Scan(&a)
	b := strings.Count(a, "1")
	fmt.Println(b)
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 100010
/*------------------------------------------------------------*/
int d[maxn],bfs[maxn*100],u[maxn];
int main(){
	int n;
	in(n);d[0]=n;
	FOR(i,1,n-1)d[i]=i;
	int l=1,r=2;
	bfs[l]=0;u[0]=1;
	FOR(i,0,n-1)bfs[i+1]=i;
	r=n+1;
	while(l<r){
		int c=bfs[l];
		FOR(i,0,9){
			int q=(c*10+i)%n;
			if(d[c]+i<d[q]){
				d[q]=d[c]+i;
				if(!u[q]){
					u[q]=true;
					bfs[r++]=q;
				}
			}
		}
		u[c]=false;
		l++;
	}
	out(d[0]);
}

Measured memory_bytes: 6784
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>

using namespace std;

int main(void){
    int a[10][10]={0};
    int x,y,size;
    char z;
    
    while (cin>>x>>z>>y>>z>>size) {
        a[y][x]+=1;
        if (size==1)
        {
            if(x+1<10){a[y][x+1]+=1;}
            if(y+1<10){a[y+1][x]+=1;}
            if(0<=x-1){a[y][x-1]+=1;}
            if(0<=y-1){a[y-1][x]+=1;}
        }
        else if (size==2)
        {
            if(x+1<10){a[y][x+1]+=1;}
            if(y+1<10){a[y+1][x]+=1;}
            if(0<=x-1){a[y][x-1]+=1;}
            if(0<=y-1){a[y-1][x]+=1;}
            if(0<=y-1 && 0<=x-1){a[y-1][x-1]+=1;}
            if(0<=y-1 && x+1<10){a[y-1][x+1]+=1;}
            if(y+1<10 && 0<=x-1){a[y+1][x-1]+=1;}
            if(y+1<10 && x+1<10){a[y+1][x+1]+=1;}
        }
        else
        {
            if(y+1<10){a[y+1][x]+=1;}
            if(y+2<10){a[y+2][x]+=1;}
            if(x+1<10){a[y][x+1]+=1;}
            if(x+2<10){a[y][x+2]+=1;}
            if(0<=x-1){a[y][x-1]+=1;}
            if(0<=x-2){a[y][x-2]+=1;}
            if(0<=y-1){a[y-1][x]+=1;}
            if(0<=y-2){a[y-2][x]+=1;}
            if(0<=y-1 && 0<=x-1){a[y-1][x-1]+=1;}
            if(0<=y-1 && x+1<10){a[y-1][x+1]+=1;}
            if(y+1<10 && 0<=x-1){a[y+1][x-1]+=1;}
            if(y+1<10 && x+1<10){a[y+1][x+1]+=1;}
        }
    }
    int sum=0,age=0;
    for(int i=0; i<10; i++)
    {
        for (int j=0; j<10; j++)
        {
            if(a[i][j]==0){sum++;}
            if(age<a[i][j]){age=a[i][j];}
        }
    }
    
    printf("%d\n%d\n",sum,age);
    
    return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

vector <ll> T[5050];
ll S[5050];
ll F[5050], FI[5050], I[5050];
ll D[5050], E[5050];
ll n, p, ans;

ll pow(ll a, ll b)
{
	ll ret = 1;
	
	for(; b; b>>=1){
		if(b & 1) ret = ret * a % mod;
		a = a * a % mod;
	}
	
	return ret;
}

void dfs(ll p, ll r)
{
	S[p] = 1;
	
	for(ll &t: T[p]){
		if(t != r){
			dfs(t, p);
			S[p] += S[t];
		}
	}
}

int main()
{
	ll i, j, m, s, t, u, v;
	
	scanf("%lld", &n);
	
	F[0] = FI[0] = 1;
	
	for(i=1; i<=n; i++){
		F[i] = F[i - 1] * i % mod;
		I[i] = pow(i, mod - 2);
		FI[i] = FI[i - 1] * I[i] % mod;
	}
	
	for(i=1; i<n; i++){
		scanf("%lld%lld", &u, &v);
		T[u].push_back(v);
		T[v].push_back(u);
	}
	
	dfs(1, 0);
	
	for(p=1; ; ){
		m = -1;
		for(ll &t: T[p]){
			if(S[t] > S[p]) continue;
			if(m == -1 || S[m] < S[t]) m = t;
		}
		
		if(m == -1 || S[m] + S[m] <= n) break;
		p = m;
	}
	
	D[0] = 1;
	
	for(ll &t: T[p]){
		dfs(t, p); s = S[t];
		
		for(i=0; i<=s; i++){
			for(j=0; j<=n-i; j++){
				t = D[j] * F[s] % mod * FI[s - i] % mod;
				t = t * F[s] % mod * FI[s - i] % mod * FI[i] % mod;
				E[j + i] = (E[j + i] + t) % mod;
			}
		}
		
		for(i=0; i<=n; i++){
			D[i] = E[i]; E[i] = 0;
		}
	}
	
	for(i=0; i<=n; i++){
		if(i & 1) ans = (ans - D[i] * F[n - i] % mod + mod) % mod;
		else ans = (ans + D[i] * F[n - i]) % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
ll x[100010], v[100010], D[100010], E[100010], C;
int main() {
	scanf("%d%lld", &n, &C);
	for(int i=1; i<=n; i++)
		scanf("%lld%lld", x+i, v+i);
	ll res = 0;
	for(int i=1; i<=n; i++) {
		v[i] += v[i-1];
		D[i] = max(D[i-1], v[i] - x[i]);
		res = max(res, D[i]);
	}
	for(int i=n; i>=1; i--) {
		E[i] = max(E[i+1], v[n] - v[i-1] - (C - x[i]));
		res = max(res, v[n] - v[i-1] - (C - x[i]));
	}
	for(int i=1; i<=n; i++) {
		res = max(res, D[i] - x[i] + E[i+1]);
		res = max(res, E[i] - (C - x[i]) + D[i-1]);
	}
	printf("%lld", res);
	return 0;
}

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

using namespace std;

const int  N = 100;
typedef long long LL;

int mat[N][8];
int n, k;

bool ok(int x, int y){
    int sum = 0;
    for(int i=0; i<=2; i++){
        for(int j=0; j<=2; j++){
            sum += mat[x-i][y+j];
        }
    }
    sum %= 11;
    return sum == k;
}

int main(){
    for(int i=1; i<=22; i++){
        for(int j=1; j<=7; j++){
            mat[i][j] = 7 * (i - 1) + j;
        }
    }
    LL ans;
    while(~scanf("%d %d", &n, &k)){
        ans = 0;
        if(n <= 11){
            for(int i=3; i<=n; i++){
                for(int j=1; j<=5; j++){
                    ans += ok(i, j);
                }
            }
        } else {
            for(int i=3; i<=11; i++){
                for(int j=1; j<=5; j++){
                    ans += ok(i, j);
                }
            }
            int g = n / 11;
            ans = ans * g;
            if(g > 1){
                for(int i=12; i<=13; i++){
                    for(int j=1; j<=5; j++){
                        ans += ok(i, j) * (g - 1);
                    }
                }
            }
            n = n % 11;
            for(int i=12; i<=n+11; i++){
                for(int j=1; j<=5; j++){
                    ans += ok(i, j);
                }
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	x, n := intScanner(), intScanner()
	ps := make(map[int]struct{}, n)
	for i := 0; i < n; i++ {
		ps[intScanner()] = struct{}{}
	}
	a := mod
	ans := mod
	for i := 0; i < 102; i++ {
		if _, ok := ps[i]; !ok {
			if abs(i-x) < a {
				a = abs(i - x)
				ans = i
			} else if abs(i-x) == a {
				ans = smaller(ans, i)
			}
		}
	}
	fmt.Println(ans)
}


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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

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


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> sts{"KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA", "AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABAR", "AKIHABARA"};
    assert(sts.size() == 16);

    string st;
    cin >> st;
    for (int i = 0; i < 16; i++) {
        if (st == sts[i]) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define zero_pad(num) setfill('0') << std::right << setw(num)

// func declaration
template <class T> void printVec(vector<T>);
template <class T> void calcVec(vector<T>&, int, char);
bool checkMultiple(vector<int>&, int);
int ctoi(const char);

// const
const int INF = 10000000;

/*MEMO
辞書順
abc < abcd, atcoder < atlas
*/

int main() {
    int K;
    cin >> K;
    if (K%2 == 0) {
        cout << (K / 2) * (K / 2) << endl;
    } else {
        int num = (K / 2) + 1;
        cout << num * (num - 1) << endl;
    }


    return 0;
}


// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    if (ch == '+') REP(i, vec.size()) vec.at(i) += num;
    else if (ch == '-') REP(i, vec.size()) vec.at(i) -= num;
    else if (ch == '*') REP(i, vec.size()) vec.at(i) *= num;
    else if (ch == '/') REP(i, vec.size()) vec.at(i) /= num;
    else if (ch == '%') REP(i, vec.size()) vec.at(i) %= num;
}

bool checkMultiple(vector<int> &vec, int num) {
    // vecの中身が、全てnumの倍数かどうかのチェック
    int count = 0;
    REP(i, vec.size()) {
        if (vec.at(i)%num != 0) count++;
    }
    return (count == 0);
}

int ctoi(const char c) {
    if('0' <= c && c <= '9') return (c-'0');
    return -1;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int need[255];
bool is_need[255];


void solve(string &a,int num){
  pair<int,int> ans;
  int tlength=a.size()+1,cnt=0;
  int bef=0;
  
  rep(i,a.size()){
    if ( is_need[a[i]]==false)continue;
    

    if (  need[a[i]]==0){
      num--;
    }
    need[a[i]]++;
    if ( need[a[i]] ){      
      while(bef<i){
	if ( is_need[a[bef]]==0);
	else if (need[a[bef]]<=is_need[a[i]])break;
	else need[a[bef]]--;
	bef++;
      }
    }
    
    if ( num == 0 && 1+i-bef<=tlength){//update
      if ( 1+i-bef < tlength){
	cnt=0;
	ans=make_pair(bef,i+1);
      }
      tlength=1+i-bef;
      cnt++;
    }
  }


  cout << cnt << endl;
  if (cnt==0){puts("");return;}
  for(int i=ans.first,j=0;i<ans.second;j++,i++){
    if (j%72==0)puts("");
    putchar(a[i]);
  }
  puts("");
  puts("");
  return;
}



main(){
  string t,a,target;
  while(getline(cin,a) && a.size() !=0){
    while(getline(cin,t) && t.size() != 0)a+=t;
    getline(cin,target);
    getline(cin,t);
    rep(i,255)is_need[i]=0,need[i]=0;
    rep(i,target.size())is_need[target[i]]=true;
    
    solve(a,target.size());
  }

}

Measured memory_bytes: 1504
#include <iostream>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

int main()
{
    u int result;

    REP(i, 0, 5)
    {
        u int x;
        cin >> x;

        if (x == 0)
            result = i + 1;
    }

    cout << result << "\n";
}

Measured memory_bytes: 3528
import java.util.*;

 public class Main {

		public static void main(String[] args) {
			// TODO Auto-generated method stub
			Scanner sc = new Scanner(System.in);
			
			int N = sc.nextInt();
			String a = sc.next();
            int b = 0;
            int c;
            int d;
            int e;
            int f;
            int g;
            
            for( c = 0;N > c;c++ ){
                String t = sc.next();
                for( d = 0;t.length() > d;d++ ){
                    for( e = 1;; e++ ){
                        if( t.length() <= d + e*( a.length()-1 )){
                        break;
                        }
                        f = 1;
                        for( g = 0;g < a.length();g++ ){
                            if( a.charAt(g)!= t.charAt( d + e*g )){
                               f = 0;
                            break;
                            }
                        }
                        if( f==1 ){ b = b + 1;d = t.length();
                        break;
                        }
                        }
                    }
                } System.out.println(b);
                }
		}

Measured memory_bytes: 20556
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <typeinfo>
#include <stdlib.h>


using namespace std;

// std::vector<bool> isNotPrime(int max){
//   std::vector<bool> is_not_prime(max+1);
//   for(int i=2; i<=max/2; i++){
//     int j = i*2;
//     while(j <= max){
//       is_not_prime[j] = true;
//       j+=i;
//     }
//   }
//   return is_not_prime;
// }

bool isPrime(int target){
  // cout << "c" << endl;

  for(int i=2; i*i<=target; i++){
    // cout << i << endl;
    if (target % i == 0){
      // cout << "divide" << endl; 
      return false;
    }
  }
  // cout << "d" << endl;

  return true;
}


int main(int argc, char* argv[]){
  int n,cnt=0,num;
  cin >> n;
  // std::vector<int> a(n);
  // std::vector<bool> is_not_prime;
  for(int i=0; i<n; i++){
    cin >> num;
    if (isPrime(num) == true){
      cnt ++ ;
    }
    // cout << "b" << endl;
  }

  cout << cnt << endl;
  return 0;
}



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

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

    ll x = n / (a + b);
    ll y = n % (a + b);

    ll ans = x * a;
    ans += min(a, y);

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

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

void yes(){
    cout<<"Yes"<<endl;
}
void no(){
    cout<<"No"<<endl;
}

int main(){fastio
    ll a,b,c;cin>>a>>b>>c;
    if(c-a-b>0){
        if(4*a*b==(c-a-b)*(c-a-b)){
            no();return 0;
        }
    }
    dd sa,sb,sc;
    sa=(dd)sqrt((dd)a);
    sb=(dd)sqrt((dd)b);
    sc=(dd)sqrt((dd)c);
    if(sa+sb<sc){
        yes();
    }else{
        no();
    }
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s, )


def solve(s, ):

    n = len(s)
    ma = (n - 1) // 2 
    mb = (n + 3) // 2

    def test_text(text):
        if debug:
            log("text=%s" % text)
        n = len(text) 
        m = (n - 1) // 2
        result = True
        for i in range(m+1):
            if debug:
                log('(s[%d], s[%d])=(%s, %s)' % (i, -(i+1), s[i], s[-(i+1)]))
            if text[i] != text[-(i+1)]:
                result = False
                break

        return result

    if debug:
        log("s =%s" % s)
        log("ma=%d, sa=%s" % (ma, s[:ma]))
        log("mb=%d, sb=%s" % (mb, s[mb-1:]))

    result1 = test_text(s) 
    result2 = test_text(s[:ma]) 
    result3 = test_text(s[mb-1:]) 
    if debug:
        log('result1=%s, result2=%s, result3=%s' % (result1, result2, result3))

    result  = 'No'
    if result1 and result2 and result3:
        result = 'Yes'


    
    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    ll x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 256
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];
ll a[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
     cin>>n>>x>>y;
     if(x+y==0)
     {
       cout<<"0";
       return 0;
     }
     ll ans=n/(x+y);
     
     ans*=x;
     ans+=min(x,n%(x+y));
     cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s; cin >> s;
    string ans;
    REP(i,s.length()) {
        char c = s[i];
        REP(j,n) {
            if(c=='Z') c='A';
            else ++c;
        }
        ans += c;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    if(K == N){
        cout << 1 << endl;
        return 0;
    }
    
    int a;
    //vector<int> A(N);
    int index;
    for(int i=0; i<N; i++){
        cin >> a;
        //A[i] = a;
        if(a == 1){
            index = i;
            break;
        }
    }

    int num = 0;
    int left;
    for(left = index; left > 0; left-=(K-1)){
       num++; 
    }
    //cout << num << endl;

    for(int right = index - left; right < N-1; right+=(K-1)){
       num++; 
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int i,j;
	char n,m;
	cin>>n>>m;
	string st1,st2;
	int cnt=0;
	for(i=1;i<=n-'0';i++){
		st1=st1+m;
	}
	for(i=1;i<=m-'0';i++){
		st2=st2+n;
	}
	cout<<min(st1,st2)<<endl;
	return 0;
}


Measured memory_bytes: 256