akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
	double stack[80];
	int top;
	char in[82], *p;

	while (fgets(in, 81, stdin) != NULL) {
		top = -1;
		for (p = strtok(in, " \n"); p != NULL; p = strtok(NULL, " \n")) {
			if (strlen(p) == 1) {
				if (*p == '+') {
					stack[top-1] += stack[top];
					top--;
				} else if (*p == '-') {
					stack[top-1] -= stack[top];
					top--;
				} else if (*p == '*') {
					stack[top-1] *= stack[top];
					top--;
				} else if (*p == '/') {
					stack[top-1] /= stack[top];
					top--;
				} else {
					stack[++top] = strtod(p, NULL);
				}
			} else {
				stack[++top] = strtod(p, NULL);
			}
		}
		printf("%.6f\n", stack[top]);
	}
	return 0;
}

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

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

  string s;cin>>s;
  cout<<count(s.begin(), s.end(), '1')<<endl;

  return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int X;
    cin >> X;
    int rm = X % 500;
    cout << X / 500 * 1000 + rm / 5 * 5 << endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        m: usize,
        a: [[usize1]; n],
    }
    let mut dp = vec![0; m];
    for a in a {
        for a in a {
            dp[a] += 1;
        }
    }
    let mut cnt = 0;
    for i in 0..m {
        if dp[i] == n {
            cnt += 1;
        }
    }
    puts!("{}\n", cnt);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
use proconio::input;

fn main() {
    input! {
      n: usize,
      a_s: [usize; n],
    }
    let all = a_s.iter().fold(0, |acc, cur| acc ^ cur);
    for a in a_s {
        print!("{} ", a ^ all);
    }
    println!();
}


Measured memory_bytes: 6288
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

class Color {
public:
    double l, a, b;
};

double dist(const Color &c1, const Color &c2) {
    return (c1.l - c2.l) * (c1.l - c2.l)
        + (c1.a - c2.a) * (c1.a - c2.a)
        + (c1.b - c2.b) * (c1.b - c2.b);
}

int main() {
    int n, m;
    while (cin >> n >> m) {
        vector<Color> cs(n);
        for (int i = 0; i < n; i++) {
            cin >> cs[i].l >> cs[i].a >> cs[i].b;
        }
        double ans = 0.0;
        for (int s = 0, s_end = (1 << n); s < s_end; s++) {
            vector<Color> v;
            for (int i = 0; i < n; i++) {
                if (s & (1 << i)) {
                    v.push_back(cs[i]);
                }
            }
            if ((int) v.size() != m) {
                continue;
            }

            double sum = 0.0;
            for (vector<Color>::iterator it = v.begin(); it != v.end(); it++) {
                for (vector<Color>::iterator jt = it + 1; jt != v.end(); jt++) {
                    sum += dist(*it, *jt);
                }
            }
            ans = max(ans, sum);
        }
        printf("%.6f\n", ans);
    }
}

Measured memory_bytes: 1264
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = Read();
            var B = Read();
            var C = Read();
            var cnt = 0;
            for (int i = 0; i < N; i++)
            {
                var a = A[i];
                var b = B[i];
                var c = C[i];
                if (a == b && b == c) continue;
                else if (a != b && b != c && c != a) cnt += 2;
                else if (a == b || b == c || c == a) cnt++;
            }

            Console.WriteLine(cnt);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define MOD 1000000007

ll mod_inv(ll n)
{
    ll left=MOD-2;  // define MOD!
    ll num=n;
    ll ans=1;
    while(left!=0)
    {
        if(left%2==1)ans=(ans*num)%MOD;
        left/=2;
        num=(num*num)%MOD;
    }
    return ans;
}

int main()
{
  ll n,m,k;cin>>n>>m>>k;
  ll total=0;
  ll i,j;
  for(i=0;i<n;i++)
  {
    for(j=0;j<m;j++)
    {
      ll tpat=0;
      ll a=j;
      ll b=(n-i-1);
      tpat+=a*b*(a+b+2)/2;
      a=m-j-1;
      tpat+=a*b*(a+b+2)/2;
      a=n-i-1;
      tpat+=a*(a+1)/2;
      a=m-j-1;
      tpat+=a*(a+1)/2;
      total=(total+tpat)%MOD;
    }
  }
  ll pat=1;
  for(i=1;i<=k;i++)
  {
    pat=pat*((n*m+1-i)*mod_inv(i)%MOD);
    pat%=MOD;
  }
  ll kc2=k*(k-1)/2%MOD;
  ll nmc2=(n*m)*(n*m-1)/2%MOD;
  total=(total*kc2)%MOD;
  total=(total*pat)%MOD;
  total=(total*mod_inv(nmc2))%MOD;
  cout<<total<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, _) = (v[0], v[1]);
    let d = read_vec::<String>();
    let mut ngs = HashSet::new();
    for string in d {
        for ch in string.chars() {
            ngs.insert(ch);
        }
    }
    'outer: for i in n..100000 {
        let word = format!("{}", i).chars().collect::<Vec<_>>();
        for ch in word {
            if ngs.contains(&ch) {
                continue 'outer;
            }
        }
        println!("{}", i);
        break;
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383



int main (){
    fast;

	

		int n;
		cin>>n;
		ll a[n];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		ll temp = a[0];
		ll sum = 0;
		for(int i=1;i<n;i++){
			if(a[i] < temp){
				sum += (temp - a[i]);
			}else if(a[i] > temp){
				temp = a[i];
			}
		}

		cout<<sum<<endl;

	
	
	
}











Measured memory_bytes: 5168
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    int N;
    void solve()
    {
        N = cin.nextint;
        int A = cin.nextint;
        int B = cin.nextint;
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            int t = cin.nextint;
            if (A <= t && t < B) continue;
            cnt++;

        }
        WriteLine(cnt);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
import java.io.*;
import java.util.*;
import java.math.*;

public class Main{
	static final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static int tc;
	static final int MOD=1_000_000_007;
	public static int[] inputArray(String str){
		String[] s=str.split(" ");
		int[] array=new int[s.length];
		for(int i=0;i<s.length;i++) {
			array[i]=Integer.parseInt(s[i]);
		}
		return array;
	}
	public static void main(String[] args)throws IOException {
		//tc=Integer.parseInt(br.readLine());
		tc=1;
		while(tc-->0) {
			String[] s=br.readLine().split(" ");
			int A=Integer.parseInt(s[0]);
			int B=Integer.parseInt(s[1]);
			int counter=0;
			int emptySockets=1;
			while(emptySockets<B) {
				counter++;
				emptySockets=emptySockets-1+A;
			}
			System.out.println(counter);
		}
	}
}

Measured memory_bytes: 22612
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<usize> = get_vec();
    let n = v[0];
    let m = v[1];

    let mut im_n : Vec<Vec<char>> = Vec::new();
    for _i in 0..n {
        let l_n : Vec<char> = get_one::<String>().chars().collect();
        im_n.push(l_n);
    }
    let mut im_m : Vec<Vec<char>> = Vec::new();
    for _i in 0..m {
        let l_m : Vec<char> = get_one::<String>().chars().collect();
        im_m.push(l_m);
    }
    let mut ans = false;
    for i in 0..(n-m+1) {
        for j in 0..(n-m+1) {
            let mut is_matched = true;
            for k in 0..m {
                for l in 0..m {
                    if im_n[i+k][j+l] != im_m[k][l] {
                        is_matched = false;
                        break;
                    }
                }
                if !is_matched {break;}
            }
            if is_matched {
                ans = true;
                break;
            }
        }
        if ans {break;}
    }

    println!("{}", if ans {"Yes"} else {"No"});
}


Measured memory_bytes: 4352
#include <iostream>

 

using namespace std;

int main() 
{
    int i,x;
    
    for(i=1; i<=10000; i++)
   { 
    cin >> x;
    
    if (x==0)
      break;
  
  cout << "Case "<< i << ": " <<  x <<endl;
    }
}


Measured memory_bytes: 3000
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=3e5+1e2;
int n;
int a[maxn];

inline void file() {
	freopen("ARC102F.in","r",stdin);
	freopen("ARC102F.out","w",stdout);
}

inline int read() {
	int x=0,p=1;
	char c=getchar();
	while (!isdigit(c)) { if (c=='-') p=-1; c=getchar();}
	while (isdigit(c)) { x=(x<<1)+(x<<3)+(c-'0'); c=getchar();}
	return x*p;
}

inline bool check(int l,int r) {
	if (l==r) return 1;
	if ((r-l+1)%2==0) return 0;
	for (int i=l+1;i<=r-1;i+=2)
		if (a[i]!=i) return 0;
	int lst1=0,lst2=0;
	for (int i=l;i<=r;i+=2) {
		if (a[i]<i) {
			if (a[i]<lst1) return 0;
			lst1=a[i];
		}
		else {
			if (a[i]<lst2) return 0;
			lst2=a[i];
		}
	}
	return 1;
}

int main() {
//	file();
	n=read();
	For (i,1,n) {
		a[i]=read();
		if (((i&1)^(a[i]&1))==1) {
			puts("No"); return 0;
		}
	}
	int Maxx=0,lst=0;
	For (i,1,n) {
		chkmax(Maxx,a[i]);
		if (Maxx==i) {
			if (!check(lst+1,i)) {
				puts("No"); return 0;
			}
			lst=i;
		}
	}
	puts("Yes");
	return 0;
}

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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


using namespace std;




int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long long int n;
	cin >> n;
	vector<long long int>arr(n);
	for (long long int i = 0; i < n; i++)
		cin >> arr[i];
	long long int ans = 0;
	for (long long int i = 0; i < n; i++)
	{
		if (arr[i] % 2 != 0 && (i + 1) % 2 != 0)
		{
			ans++;

		}
	}
	cout << ans << endl;


	return 0;


}


Measured memory_bytes: 3620
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    int64_t n;
    cin >> n;
    string s;
    cin >> s;

    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    auto m = n / 2;

    for (int64_t i = 0; i < m; i++) {
        if (s[i] != s[m + i]) {
        cout << "No" << endl;
        return 0;
         }
    }
    cout << "Yes" << endl;
}


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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B){
    cout << C << endl;
  }
  else if(A==C){
    cout << B << endl;
  }
  else{
    cout << A << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
void aaa(char, int);
int tp[4][13]={{0}};

void aaa(char g, int x)
{
	if (g=='S')//0
	{
		tp[0][x]=1;
	}
	else if (g=='H')//1
	{
		tp[1][x]=1;
	}
	else if (g=='C')//2
	{
		tp[2][x]=1;
	}
	else if (g=='D')//3
	{
		tp[3][x]=1;
	}
	return ;
}

int main(void)
{
	
	int a, i, x;
	char g;
	int f, j;

	scanf("%d", &a);
	for (i=0;i<a;i++)
	{
		scanf("%c", &g);
		if (g == '\n') scanf("%c%d", &g, &x);
		else scanf("%d", &x);
		aaa(g, x-1);
	}

	for (f=0;f<4;f++)
	{
		for (j=0;j<13;j++)
		{
			if (tp[f][j]==0)
			{
				if (f==0)
				{
					printf("S %d\n", j+1);
				}
				else if (f==1)
				{
					printf("H %d\n", j+1);
				}
				else if (f==2)
				{
					printf("C %d\n", j+1);
				}
				else if (f==3)
				{
					printf("D %d\n", j+1);
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int N,K; int hbit[21][(1<<21)]; int *f[21][21];
int sta[MAXN+1],top; char str[(1<<21)]; bool V[21][(1<<20)];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); K=read();
	for(int i=0;i<=N;i++)
		for(int j=0;j<=N&&i+j<=N;j++){
			f[i][j]=new int[(1<<(i+j))];
			for(int k=0;k<(1<<(i+j));k++) f[i][j][k]=0;
		}
	for(int i=0;i<=N;i++){
		scanf("%s",str);
		for(int j=0;j<(1<<i);j++) f[0][i][j]=str[j]-'0',V[i][j]=str[j]-'0';
	} hbit[1][0]=hbit[1][1]=-1;
	for(int i=1;i<N;i++){
		for(int j=0;j<(1<<i);j++){
			for(int k=0;k<2;k++){
				if((((1<<(i-1))&j)>>(i-1))==k) hbit[i+1][j|(k<<i)]=hbit[i][j];
				else hbit[i+1][j|(k<<i)]=i-1;
			}
		}
	}
	for(int i=0;i<=N;i++){
		for(int j=1;j<=N;j++){
			for(int k=0;i+j<=N&&k<(1<<(i+j));k++){
				int ta=(k&(((1<<i)-1)<<j))>>j,tb=k&((1<<j)-1);
				//cout<<i<<" "<<j<<":"<<k<<" | "<<ta<<" "<<tb<<" |"<<f[3][0][0]<<endl;
				f[i][0][ta]+=f[i][j][k];
				if(i==N) continue;
				//cout<<"ed1\n";
				for(int c=0;c<2;c++){
					int pos=-1;
					if(((k&(1<<(j-1)))>>(j-1))==c) pos=j-1;
					else pos=hbit[j][k&((1<<j)-1)];
					if(pos==-1) continue;
					int tnsa=ta,tnsb=tb;
					tnsa<<=1; tnsa|=c;
					tnsb&=((1<<pos)-1);
					//cout<<"res:"<<tnsa<<" "<<tnsb<<endl;
					f[i+1][pos][(tnsa<<pos)|tnsb]+=f[i][j][k];
					//cout<<"pp:"<<i+1<<" "<<pos<<endl;
				} //cout<<"ed\n";
			}
		}
	} for(int i=N;i>=0;i--){
		for(int j=0;j<(1<<i);j++){
			if(f[i][0][j]>=K){
				int x=j; while(x){ sta[++top]=(x&1); x>>=1; }
				while(top<i) sta[++top]=0;
				for(int i=top;i>=1;i--) printf("%d",sta[i]);
				return 0;
			}
		}
	} return 0;
}




Measured memory_bytes: 179540
N = int(input())
A = list(map(int, input().split()))
c = 1000
s = 0

for i in range(N - 1):
    if A[i] < A[i + 1]:
        s += c // A[i]
        c %= A[i]
    else:
        c += s * A[i]
        s = 0

if A[N - 2] < A[N - 1]:
    c += s * A[N - 1]

print(c)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long long k;
  cin >> n >> k;
  int a[n];
  int b[n];
  int i;
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  vector<pair<int,int>> p(n);
  for(i=0;i<n;i++){
    p[i] = make_pair(a[i],b[i]);
  }
  sort(p.begin(),p.end());
  long cnt = 0;
  int tmp = 0;
  for(i=0;i<n;i++){
    cnt += p[i].second;
    tmp = i;
    if(cnt>=k)break;
  }
  cout << p[tmp].first;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin>>c;
  bool a=0;
  if(c=='a'){
  a=1;
  }
    if(c=='i'){
  a=1;
  }
  if(c=='u'){
  a=1;
  }
    if(c=='e'){
  a=1;
  }
  if(c=='o'){
  a=1;
  }
  if(a==1){
  cout<<"vowel"<<endl;
  }
  if(a==0){
  cout<<"consonant"<<endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin >> s;
    s.erase(sz(s) - 8);
    print(s);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long int n;
	cin >> n;
	long int d[200001];
	for(int i=0;i<n;i++){
		cin >> d[i];
	}
	long int m;
	cin >> m;
	long int t[200001];
	for(int i=0;i<m;i++){
		cin >> t[i];
	}
	string ans = "YES";
	if(n<m){
		ans = "NO";
	}
	sort(d,d+n);
	sort(t,t+m);
	int c = 0;
	int cc = 0;
	int k = -1;
	int l = -1;
	for(int j=0;j<m;j++){
		for(int i=k+1;i<n;i++){
			if(t[j]==d[i]){
				c++;
				k = i;
				break;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=l+1;j<m;j++){
			if(d[i]==t[j]){
				cc++;
				l = j;
				break;
			}
		}
	}
	if(c!=cc || c!=m){
		ans = "NO";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
const int maxn = 100035;

int n,k,m;
int vis[maxn],a[maxn];
std::set<int> s;

int read()
{
	char ch = getchar();
	int num = 0;
	bool fl = 0;
	for (; !isdigit(ch); ch=getchar())
		if (ch=='-') fl = 1;
	for (; isdigit(ch); ch=getchar())
		num = (num<<1)+(num<<3)+ch-48;
	if (fl) num = -num;
	return num;
}
int main()
{
	n = read(), k = sqrt(2*n);
	while (k*(k-1) < 2*n) k++;
	if (k*(k-1)/2!=n){
		puts("No");
		return 0;
	}
	printf("Yes\n%d\n",k);
	m = 2*n/k;
	for (int i=1; i<=k; i++)
	{
		s.clear(), printf("%d",m);
		for (int j=1, cnt=0; j<=n&&cnt<m; j++)
		{
			if (vis[j]==0){
				a[j] = i, vis[j]++, cnt++, printf(" %d",j);
			}else if ((vis[j]==1)&&(s.count(a[j])==0)){
				s.insert(a[j]);
				vis[j] = 2, cnt++, printf(" %d",j);
			}
		}
		puts("");
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, h, ma = 0, cnt = 0;
    cin >> n >> h;
    vector<int> b(n);
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a >> b.at(i);
        if (ma < a) ma = a;
    }
    sort(b.begin(), b.end());
    for (auto i = b.end() - 1; i >= lower_bound(b.begin(), b.end(), ma) && h > 0; --i) {
        if (*i > ma) {
            ++cnt;
            h -= *i;
        }
    }
    if (h > 0) cnt += h / ma + (h % ma != 0);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(X) (X).begin(),(X).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
bool is_integer(double x){
    return floor(x)==x;
}
int main(){
    int n, d;
    cin >> n >> d;
    int g[n][d];
    rep(i,n){
        rep(j,d){
            cin >> g[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n-1; ++i){
        for(int k = i+1; k < n; ++k){
            double temp = 0;
            double dist = 0;
            rep(h,d){
                temp+=pow(g[i][h]-g[k][h], 2.0);
            }
            dist = sqrt(temp);
            if(is_integer(dist)) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const double pi = acos(-1);
int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double th = double(h*60 + m)/720 * 2*pi;
    double tm = double(m)/60 * 2*pi;
    double t = abs (th - tm);
    double cc = a*a + b*b - 2* a*b*cos(t);
    printf("%.10f\n", sqrt(cc));
    return 0;
}

Measured memory_bytes: 4188
n,x=map(int,input().split())

B=[[1,1]]
for i in range(1,n+1):
    B.append([B[i-1][0]*2+3,B[i-1][1]*2+1])

#print(B)

def bur(a,b):
    if a==0 :
        if b==0 :
            return 0
        else :
            return 1
    elif b<=1 :
        return 0
    elif b<=1+B[a-1][0] :
        return bur(a-1,b-1)
    elif b<=1+B[a-1][0]+1 :
        return B[a-1][1]+1
    elif b<=1+B[a-1][0]+1+B[a-1][0] :
        return B[a-1][1]+1+bur(a-1,b-2-B[a-1][0])
    elif b<=1+B[a-1][0]+1+B[a-1][0]+1 :
        return B[a-1][1]*2+1
    print(a)
    

print(bur(n,x))


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
struct edge{ ll from, to, val; };
ll n, m, a, b, c, v[1100], res;
const ll INF = -1000000000000000000;
vector<edge> vec;
int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 2; i <= n; i++) v[i] = INF;
    for (ll i = 0; i < m; i++) {
        cin >> a >> b >> c;
        vec.push_back(edge{a, b, c});
    }
    for (ll i = 0; i < vec.size(); i++) {
        for (ll j = 0; j < vec.size(); j++) {
            edge e = vec[j];
            v[e.to] = max(v[e.to], v[e.from] + e.val);
        }
    }
    res = v[n];
    for (ll i = 0; i < vec.size(); i++) {
        for (ll j = 0; j < vec.size(); j++) {
            edge e = vec[j];
            v[e.to] = max(v[e.to], v[e.from] + e.val);
        }
    }
    if (res == v[n]) cout << res << endl;
    else cout << "inf" << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[n];
		long b = 0;
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			b += 2 * x[i] * Math.pow(-1, i);
		}


		b = b / 2;
		for (int i = 0; i < n; i++) {
			System.out.print(b);

			b = 2 * (x[i] - b / 2);
			
			if (i != n - 1) {
				System.out.print(" ");
			}
		}
	}
}


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

using namespace std;

int main(){
    vector<pair<int, int>> v(0);
    int N;
    cin >> N;
    for(int i = 1; i < N+1; ++i){
        int A;
        cin >> A;
        v.push_back(make_pair(A, i));
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < N; ++i) cout <<v[i].second <<" ";
}

Measured memory_bytes: 1780
even = str(input())
odd = str(input())
ans = ""
if len(even) == len(odd):
  for i in range(len(even)):
    ans += even[i] + odd[i]
  
else:
  for i in range(len(even)-1):
    ans += even[i] + odd[i]
  ans += even[-1]

print(ans)

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define ar array
#define pii pair<int, int>
#define all(s) s.begin(), s.end()

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

struct re {
    int l, r, cs, block;

    re(int l = 0, int r = 0, int cs = 0, int block = 0) : l(l), r(r), cs(cs), block(block) {}

    bool operator < (re other) const {
        if (block == other.block) return r < other.r;
        return block < other.block;
    }
};

const int N = 5e5 + 5;

vector<re> b;
int n, q, a[N], ans, cnt[N], res[N];

void them(int x) {
    ans += cnt[a[x]] == 0;
    cnt[a[x]]++;
}

void xoa(int x) {
    cnt[a[x]]--;
    ans -= cnt[a[x]] == 0;
}

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

    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int block_size = int(sqrt(n));
    int num_blocks = n / block_size + n % block_size;
    for (int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        b.push_back(re(l, r, i, l / num_blocks - (l % num_blocks == 0)));
    }
    sort(all(b));
    int L = 1, R = 1;
    cnt[a[1]]++;
    ans = 1;
    for (int i = 0; i < q; i++) {
        while (R > b[i].r) xoa(R--);
        while (R < b[i].r) them(++R);
        while (L < b[i].l) xoa(L++);
        while (L > b[i].l) them(--L);
        res[b[i].cs] = ans;
    }
    for (int i = 1; i <= q; i++) cout << res[i] << '\n';
}


Measured memory_bytes: 17564
#include<iostream>
//#include<string>

using namespace std;

int main(){
  //char a[3];
  int ans = 7;


 if (getchar()== 'o') ans++;
 if (getchar()== 'o') ans++;
 if (getchar()== 'o') ans++;

  cout <<ans*100<<endl;

  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>
using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<endl


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"


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

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

	string S;
	cin >> S;

	ll A = (ll)(S[0] - '0'), B = (ll)(S[1] - '0'),
		C = (ll)(S[2] - '0'), D = (ll)(S[3] - '0');

	if (A + B + C + D == 7) {
		cout << A << "+" << B << "+" << C << "+" << D << "=" << 7;
		return 0;
	}
	if (A - B + C + D == 7) {
		cout << A << "-" << B << "+" << C << "+" << D << "=" << 7;
		return 0;
	}

	if (A + B - C + D == 7) {
		cout << A << "+" << B << "-" << C << "+" << D << "=" << 7;
		return 0;
	}

	if (A + B + C - D == 7) {
		cout << A << "+" << B << "+" << C << "-" << D << "=" << 7;
		return 0;
	}

	if (A - B - C + D == 7) {
		cout << A << "-" << B << "-" << C << "+" << D << "=" << 7;
		return 0;
	}

	if (A - B + C - D == 7) {
		cout << A << "-" << B << "+" << C << "-" << D << "=" << 7;
		return 0;
	}

	if (A + B - C - D == 7) {
		cout << A << "+" << B << "-" << C << "-" << D << "=" << 7;
		return 0;
	}

	if (A - B - C - D == 7) {
		cout << A << "-" << B << "-" << C << "-" << D << "=" << 7;
		return 0;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

class UF {
private:
  vector<int> v;
public:
  UF (int n) {
    v.resize(n);
    REP (i, 0, n) v[i] = i;
  }

  int Find (int a) {
    if (v[a] == a) return a;
    else return v[a] = Find(v[a]);
  }  

  bool isSame (int a, int b) {
    return Find(a) == Find(b);
  }
  
  bool Union (int a, int b) {
    int pa = Find(a);
    int pb = Find(b);
    if (pa == pb) return false;
    v[pa] = pb;
    return true;
  }

};


int main(){
  int N, K, L;
  cin >> N >> K >> L;
  UF uf1(N);
  REP (i, 0, K) {
    int p, q;
    cin >> p >> q;
    uf1.Union(p - 1, q - 1);
  }
  UF uf2(N);
  REP(i, 0, L) {
    int r, s;
    cin >> r >> s;
    uf2.Union(r - 1, s - 1);
  }
  map<pair<int,int>, int> m;
  REP (i, 0, N) {
    m[make_pair(uf1.Find(i), uf2.Find(i))]++;
  }
  REP (i, 0, N) {
    cout << m[make_pair(uf1.Find(i), uf2.Find(i))] << ' ';
  }
  return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
//ll a[200007], b[200007];
//ll m[30][(2 * 100000)+7], M[200];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll i, j, k, l, test, r, a, b, c, d;
	ll n, m;
	cin >> a >> b >> c >> d;

	i = 1;
	bool flag = 1;
	while (a > 0 && c > 0) {
		if (i % 2 != 0) c -= b;
		else a -= d;
		if (a <= 0 ) flag=0;
        i++;
	}
	if (flag == 1) cout << "Yes";
	else cout << "No";
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main(){
  int A,B;
  cin>> A >> B;
  if(A % 2 == 0 || B % 2 == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 384
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	readln.chomp.to!int.iota.map!(a => readln.chomp.array).map!(a=> a.sort!("a > b")[0..8].text.to!int - a.sort[0..8].text.to!int).map!(to!string).array.join("\n").writeln;
}

Measured memory_bytes: 1132
//2017.12.10
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

const int max_v = 300;
const int INF = 1000000;



int main() {
	int n,ss, ans=0;
	cin >> n;
	vector <int> A(n);
	//string str;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
    ss=n;
    while (ss == n){
        ss=0;
        REP(k,n){
            if(A[k] % 2 !=0) break;
            A[k]/=2;
            ss+=1;
        }
        if(ss==n) ans++;
        
    }
	//sort(A.begin(), A.end());

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath> 
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d",&a,&b);
	if(b<10)
	a=a*10+b;
	else if(b<100)
	a=a*100+b;
	else
	a=a*1000+b;
	c=floor(sqrt(a)+0.5);
	if(c*c==a)
	printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;
typedef complex<double> base;
typedef complex<int> point;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

#define watch(x) cerr << (#x) << " = " << (x)    << endl;

const double PI = 2 * acos(0.0);

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}



void smain();

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

#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
}

void smain() {

    vi cnt = {0, 0, 0};
    int n, a, b;
    cin >> n >>  a >> b;
    fori (i, n) {
        int p;
        cin >> p;
        if (p <= a) cnt[0]++;
        if (p > a && p <= b) cnt[1]++;
        if (p > b) cnt[2]++;
    }
    cout << *min_element(ALL(cnt));
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

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

	vector<int>a(k + 1);
	a[1] = 7 % k;

	for (int i = 2; i <=k;i++) {
		a[i] = (a[i - 1] * 10 + 7)%k;
	}

	for (int i = 1; i <= k; i++) {
		if (a[i]==0) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 7212
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair < int,int > PII;
typedef pair < ll,ll > PLL;
#define pb push_back
//#all(x) (x).begin(),(x).end()

//int const N = 1;
int const MOD = 1e9 + 7;

ll bigmod(ll a, ll b)
{
    if(b==0)
        return 1 % MOD;
    ll x = bigmod(a,b/2);
    x = (x * x) % MOD;
    if(b%2)
        x = (x * a) % MOD;
    return x;
}

int const N = 3e5 + 10;

int dp[N] ;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    for(int i = 0; i < N; i++)
        dp[i] = 0;

    dp[0] = 0;
    int n,k;
    cin >> n >> k;
    vector < int > mov(n+1);

    for(int i = 1; i <= n; i++)
        cin >> mov[i] ;

    for(int i = 1; i <= k; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            if(i >= mov[j])
                dp[i] |= (!dp[i-mov[j]]);
        }
    }
    if(dp[k]){
        cout << "First";
    }
    else
        cout << "Second";
    cout << endl;
    return 0;
}




Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    char a,b;
    scanf("%c",&a);
    scanf("%c",&b);
    for(int i=0; i<3; i++){
        if(a==b){
            printf("Bad");
            return 0;
        }
        a=b;
        scanf("%c",&b);
    }
    printf("Good");
    return 0;
}


Measured memory_bytes: 128
from math import sqrt, ceil

n, q = map(int, input().split())
unit = ceil(sqrt(n))

l = [(0, [0] * unit) for _ in range(unit)]

while q:
    op, s, t = map(int, input().split())
    s -= 1
    sd, sm = s // unit, s % unit
    if op:
        t -= 1
        td, tm = t // unit, t % unit
        if sd == td:
            print(sum(l[sd][1][sm:tm + 1]))
        else:
            unit_sum = sum((tup[0] for tup in l[sd + 1:td]))
            s_sum = sum(l[sd][1][sm:])
            t_sum = sum(l[td][1][:tm + 1])
            print(unit_sum + s_sum + t_sum)
    else:
        tup = l[sd]
        tup[1][sm] += t
        l[sd] = (tup[0] + t, tup[1])
    q -= 1

Measured memory_bytes: 9472
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func min (a int, b int) int {
     if a > b {
     	return b
     } else {
        return a
     }
}

func main() {
    sc.Split(bufio.ScanWords)
    n := nextInt()
    a := nextInt()
    b := nextInt()

    div := n / (a + b)
    pow := n % (a + b)
    ans := div * a + min(pow, a)
    fmt.Println(ans)
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;


int main(){
    ll h,w,k; cin >> h >> w >> k;
    vs s(h); rep(i,h) cin >> s[i];
    ll ans = 0;
    rep(bi,1<<h){
        rep(bj,1<<w){
            ll cnt = 0;
            rep(i,h){
                if(bi>>i & 1) continue;
                rep(j,w){
                    if(bj>>j & 1) continue;
                    if(s[i][j] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
// ※※※ 解答不能 ※※※
// 正答者の解答を勉強する.
// pekempey氏.
// https://atcoder.jp/contests/abc137/submissions/6816685
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

int MOD;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modinv(mint n) {
  int a = (int)n;
  int b = MOD;
  int s = 1;
  int t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  if (s < 0) s += MOD;
  return s;
}

vector<mint> prod(vector<mint> a, vector<mint> b) {
  const int n = a.size();
  const int m = b.size();
  vector<mint> ans(n + m - 1);
  rep(i, n) {
    rep(j, m) {
      ans[i + j] += a[i] * b[j];
    }
  }
  return ans;
}

// a / (x - b)
vector<mint> quot(vector<mint> a, mint b) {
  const int n = a.size();
  vector<mint> ans(n - 1);
  for (int i = n - 1; i >= 1; i--) {
    ans[i - 1] = a[i];
    a[i - 1] += a[i] * b;
  }
  return ans;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> MOD;
  int N = MOD;
  vector<mint> a(N); rep(i, N) cin >> a[i];
  vector<mint> b(N);
  vector<mint> f(1);
  f[0] = 1;
  rep(i, N) {
    f = prod(f, vector<mint>{-mint(i), 1});
  }
  rep(i, N) {
    mint p = 1;
    rep(j, N) if (i != j) {
      p *= mint(i) - mint(j);
    }
    p = a[i] * modinv(p);
    // (x-0) ... (x-N+1)
    auto g = quot(f, i);
    rep(j, N) {
      b[j] += p * g[j];
    }
  }
  rep(i, N) cout << b[i] << ' ';
  cout << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll INF=1e15+4;
const int Nmax=2e5+1;
const int Nd=61;

int main(){
  ll h,w,m; cin>>h>>w>>m;
  ll th,tw;
  vector<ll>nh(h,0),nw(w,0);
  vector<pair<ll,ll>> b(m);
  ll maxh=0,maxw=0;
  ll n_maxh=0,n_maxw=0;
  rep(i,m){
    cin>>th; cin>>tw;
    th--; tw--;
    b[i].first=th; b[i].second=tw;
    nh[th]++;
    nw[tw]++;

    if(maxh<nh[th]) n_maxh=1;
    if(maxw<nw[tw]) n_maxw=1;
    if(maxh==nh[th]) n_maxh++;
    if(maxw==nw[tw]) n_maxw++;
    maxh=max(maxh,nh[th]);
    maxw=max(maxw,nw[tw]);
  }
  ll count_b=0;
  rep(i,m){
    if(nh[b[i].first]+nw[b[i].second]==maxh+maxw){
      count_b++;
    }
  }

  ll count_tot=n_maxh*n_maxw;

  if(count_b<count_tot || count_tot>300001){//bomb位置以外の最大値をとる箇所がある．
    cout<<maxh+maxw<<endl;
  }else{
    cout<<maxh+maxw-1<<endl;
  }


  return 0;
}


Measured memory_bytes: 12736
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	std::string str;
	std::cin >> str;
	std::vector<long long int> a(str.size() + 1, 0);
	for (auto i = 0; i < str.size(); ++i) {
		switch (str[i]) {
		case '<': a[i + 1] = a[i] + 1; break;
		default: break;
		}
	}
	for (auto i = 1; i <= str.size(); ++i) {
		switch (str[str.size() - i]) {
		case '>': a[a.size() - i - 1] = std::max(a[a.size() - i - 1], a[a.size() - i] + 1); break;
		default: break;
		}
	}
	std::cout << std::accumulate(a.begin(), a.end(), 0LL) << '\n';
}


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


int max_happy(int money){
    int exchange_500=0, exchange_5=0;
    exchange_500 = money/500;
    money -= 500*exchange_500;
    exchange_5 = money/5;
    return 1000*exchange_500+5*exchange_5;
}
int main(){
    int X; cin >> X;
    if(X<5){
        cout << 0 << endl;
    }
    else if(X<500){
        cout << 5*(X/5) << endl; 
    }
    else{
        cout << max_happy(X) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  cout << "ABC" << n << endl;
}

Measured memory_bytes: 3620
using System;
class Program {
    static void Main() {
        string[] str =  Console.ReadLine().Split(' ');
        int[] nums = new int[str.Length]; 
        for(int i = 0; i < nums.Length; i++) {
            nums[i] = int.Parse(str[i]);
        }

        Console.WriteLine(IsInRectangle(nums[0], nums[1], nums[2], nums[3], nums[4]) ? "Yes" : "No");
    }

    static bool IsInRectangle(int width, int height, int x, int y, int r) {
        if(x + r > width || x - r < 0 || y + r > height || y - r < 0) {
            return false;
        }
        else {
            return true;
        }
    }
}

Measured memory_bytes: 9016