akhauriyash/Code-Regression huggingface dataset:
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int v[] = new int[3];
		int cnt[] = new int[3];
		for (int i = 0; i < n; i++) {
			int a = scanInt();
			for (int j = 0;; j++) {
				if (j == 3) {
					out.print("No");
					return;
				}
				if (a == v[j]) {
					++cnt[j];
					break;
				}
				if (cnt[j] == 0) {
					v[j] = a;
					cnt[j] = 1;
					break;
				}
			}
		}
		if (v[0] == 0 && cnt[1] == 0) {
			out.print("Yes");
			return;
		}
		if (n % 3 != 0) {
			out.print("No");
			return;
		}
		if (cnt[2] == 0 && ((v[0] == 0 && cnt[0] == n / 3) || (v[1] == 0 && cnt[1] == n / 3))) {
			out.print("Yes");
			return;
		}
		if (cnt[0] == n / 3 && cnt[1] == n / 3 && (v[0] ^ v[1]) == v[2]) {
			out.print("Yes");
			return;
		}
		out.print("No");
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 35420
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef priority_queue<int> Pr; typedef vector<int> Vi; typedef vector<P> Vp; typedef map<int,int> MP; typedef vector<Int> VI;
const int mod = 1000000007; const Int INF = 1145141919810893931;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

  Int n,k; cin>>n>>k; Int a[n],e;
  for (int i = 0; i < n; i++)cin>>a[i];
  e=a[0];
  for (int i = 1; i < n; i++)e=__gcd(e,a[i]);
  for (int i = 0; i < n; i++){
    if(a[i]>=k&&!((a[i]-k)%e)){cout<<"POSSIBLE"<<'\n'; return 0;}
  }
  cout<<"IMPOSSIBLE"<<'\n';
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

res = 0
for i in range(2 ** N):
    is_ok = True
    for j in range(M):
        bit_sum = 0
        r_bin = list(map(int, reversed(bin(i)[2:].rjust(N, '0'))))
        for s in ks[j][1:]:
            bit_sum += r_bin[s - 1]
        if bit_sum % 2 != p[j]:
            is_ok = False
    if is_ok:
        res += 1

print(res)

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

int main() {
  string b;
  cin >> b;

  if (b == "A") {
    cout << "T" << endl;
  }
  else if (b == "C") {
  cout << "G" << endl;
  }
  else if (b == "G") {
  cout << "C" << endl;
  }
  else if (b == "T") {
  cout << "A" << endl;
  }
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
 
def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
 
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

def main():
    x, y = MAP()
    if (x + y) % 3 != 0:
        print(0)
        sys.exit()
    m = x - (x + y) // 3
    n = y - (x + y) // 3
    if n < 0 or m < 0:
        print(0)
        sys.exit()
    print(comb(n + m, n, mod))

if __name__=='__main__':
    main()


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

bool solve() {
    vector<vector<ll>> A(3, vector<ll>(3));
    for ( int i = 0; i < 3; i++ ) {
        for ( int j = 0; j < 3; j++ ) {
            cin >> A[i][j];
        }
    }
    ll N;
    cin >> N;
    ll b;
    for ( int i = 0; i < N; i++ ) {
        cin >> b;
        for ( int j = 0; j < 3; j++ ) {
            for ( int k = 0; k < 3; k++ ) {
                if ( A[j][k] == b ) {
                    A[j][k] = 0;
                }
            }
        }
    }

    for ( int i = 0; i < 3; i++ ) {
        ll z = true;
        for ( int j = 0; j < 3; j++ ) {
            if ( A[i][j] != 0 ) {
                z = false;
                break;
            }
        }
        if ( z )  return true;
    }
    for ( int i = 0; i < 3; i++ ) {
        ll z = true;
        for ( int j = 0; j < 3; j++ ) {
            if ( A[j][i] != 0 ) {
                z = false;
                break;
            }
        }
        if ( z )  return true;
    }
    ll z = true;
    for ( int i = 0; i < 3; i++ ) {
        if ( A[i][i] != 0 ) {
            z = false;
            break;
        }
    }
    if ( z )  return true;
    z = true;
    for ( int i = 0; i < 3; i++ ) {
        if ( A[i][2-i] != 0 ) {
            z = false;
            break;
        }
    }
    if ( z )  return true;

    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
fn solve() {
    let c: char = read();
    if c.is_ascii_lowercase() {
        println!("a");
    } else {
        println!("A");
    }
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

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

// =========


Measured memory_bytes: 2200
A, B = map(int, input().split())


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if not arr and n != 1:
        arr.append([n, 1])

    return arr


print(len(factorization(gcd(A, B))) + 1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<ll> h(n+1,0);
    rep(i,n) cin>>h[i];
    ll ans=0;
    rep(i,n) ans+=max((ll)0,h[i]-h[i+1]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		boolean p = false;
		if (!(a==b & b==c)) {
			if (a==b || b==c || a==c) {
				p = true;
			}
		}
		if (p) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(int, A);
  invar(int, B);
  
  //cout << (0.08 * 25) << ", " << (0.1 * 25 == ) << endl;
  for(int i = 1; i <= 2000; i++) {
    if((int)(0.08 * i) == A && (int)(0.1 * i) == B) {
      fin(i);
      return 0;
    }
  }
  
  fin("-1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll x;
	ll ans = 0;
	cin >>x;
	ans += x / (11) * 2;
	x %= 11;
	if(x!=0){
		ans++;
		if(x> 6){
			ans++;
		}
	}
	cout << ans << endl;
//	cout<<ans<<endl;
}

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

int main(){
    int H,W;
    cin>>H>>W;
    char bord[H][W];
    set<int> x;
    set<int> y; 
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cin>>bord[i][j];
            if(bord[i][j] == '#'){
                x.insert(i);
                y.insert(j);
            }
        }
    }
    int a[x.size()];
    int b[y.size()];
    int i = 0;
      for(auto itr = x.begin(); itr != x.end(); ++itr) {
        a[i] = *itr;
        i++;
    }
    i = 0;
    for(auto itr = y.begin(); itr != y.end(); ++itr) {
        b[i] = *itr;
        i++;
    }
   for(int i = 0;i < x.size();i++){
       for(int j = 0;j < y.size();j++){
           cout<<bord[a[i]][b[j]];
       }
       cout<<endl;
   }
}



Measured memory_bytes: 256
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
a=max(x)
a=max(a,X)
b=min(y)
b=min(b,Y)
if a<b:
  print("No War")
else:
  print("War")


Measured memory_bytes: 3060
import Control.Applicative
import Control.Monad
import Data.List

main = do
    n <- readLn
    if n == 0 then return ()
              else showGoodEmployee n >> main

showGoodEmployee :: Int -> IO ()
showGoodEmployee n = do
      set <- replicateM n $ (\[a,b,c] -> (a,b*c)).map read.words<$>getLine
      let sales = addsales set
      showID $ map fst.filter (\x -> snd x >= 1000000) $ sales

showID :: Show a => [a] -> IO ()
showID [] = putStrLn "NA"
showID xs = mapM_ print xs

addsales :: [(Int,Int)] -> [(Int,Int)]
addsales xs = map (addsale xs) ids
    where
        ids = nub $ map fst xs
        addsale list employeeID = (employeeID, sum.map snd $ filter (\x -> fst x == employeeID) list)

Measured memory_bytes: 5296
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> mas(H, vector<char>(W));
	REP(i, H) {
		REP(j, W) {
			cin >> mas[i][j];
		}
	}

	vector<bool> row(H, false);
	vector<bool> col(W, false);

	REP(i, H) {
		REP(j, W) {
			if (mas[i][j] == '#') {
				row[i] = true;;
				col[j] = true;;
			}
		}
	}

	REP(i, H) {
		if (!row[i]) continue;
		REP(j, W) {
		if (!col[j]) continue;
			cout << mas[i][j];
		}
		cout << endl;
	}

	return 0;
}


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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        string answer = s.Replace("2017", "2018");

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main() {
	int n,k;
	queue<int> q;
	cin >> n >> k;
	vector<int> d;
	vector<bool> f(10,true);
	rep(i,k) {
		int tmp;
		cin >> tmp;
		d.push_back(tmp);
		f[tmp] = false;
	}
	vector<int> number;
	rep(i,10) {
		if (f[i]) {
			number.push_back(i);
			if (i!=0) q.push(i);
		}
	}

	while(1) {
		int now_price = q.front();
		q.pop();
		if (now_price >= n) {
			cout << now_price << endl;
			return 0;
		}
		for (ll x : number) {
			ll next_price = 10 * now_price + x;
			q.push(next_price);
		}
	}

	return 0;
}


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




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

    int h[n+5];

    rep(i,n){
        cin >> h[i];
    }

    int a[n+5]={};

    a[1]=abs(h[1]-h[0]);

    for(int i=1;i<n-1;i++){
        a[i+1]=min(a[i-1]+abs(h[i+1]-h[i-1]),a[i]+abs(h[i+1]-h[i]));
    }


    cout << a[n-1] << endl;
    return 0;
}

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n)
        cin >> a[i];
    sort(a, a + n);
    reverse(a, a + n);
    ll ans = 0;
    while (true)
    {
        if (a[0] < 1000)
            break;
        int p = 0;
        while (p < n && (a[0] - a[p]) < (n + 1))
            p++;
        if (p == n)
        {
            ll cnt = max(0LL, a[0] - 1000);
            ans += cnt * n;
            rep(i, 0, n)
                a[i] -= cnt;
            break;
        }
        ll cnt = (a[0] - a[p]) / (n + 1);
        ans += p * cnt;
        rep(i, 0, n)
            if (i < p)
                a[i] -= (n - p + 1) * cnt;
            else
                a[i] += p * cnt;
    }
    while (true)
    {
        int p = 0;
        rep(i, 0, n)
            if (a[i] > a[p])
                p = i;
        if (a[p] < n)
            break;
        ans++;
        rep(i, 0, n)
            if (i != p)
                a[i]++;
            else
                a[i] -= n;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }else if(s=="ARC"){
    cout<<"ABC"<<endl;
  }else{
    cout<<"No Data"<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    ll n, k;
    cin >> n >> k;
    n %= k;

    ll m = abs(n-k);
    if(n < m){
        printf("%lld\n", n);
    }else{
        printf("%lld\n", m);
    }
    return 0;
}

Measured memory_bytes: 3680
H, W, K = map(int, input().split())

choco_array = [[int(s) for s in input()] for _ in range(H)]
# print(choco_array)

ans = 100000

for i in range(1 << (H-1)):
    cut_h = 0
    cut_array = [0] * H
    for h in range(H-1):
        if i >> (h) & 1:
            cut_h += 1
        cut_array[h+1] = cut_h
    # print(cut_array)
    cut_w = 0
    now_count = [0] * (cut_h+1)
    for w in range(W):
        new_count = [0] * (cut_h+1)
        for h in range(H):
            new_count[cut_array[h]] += choco_array[h][w]
        ng_flag = 0
        # print(now_count, new_count)
        for i in range(cut_h+1):
            if new_count[i] > K:
                ng_flag = -1
                break
            if now_count[i] + new_count[i] > K:
                ng_flag = 1
                break
        if ng_flag == -1:
            cut_w = 10000
            break
        if ng_flag == 1:
            cut_w += 1
            for i in range(cut_h+1):
                now_count[i] = new_count[i]
        else:
            for i in range(cut_h+1):
                now_count[i] += new_count[i]
    ans = min(ans, cut_h+cut_w)

print(ans)


Measured memory_bytes: 46428
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 102, mod = 1e9 + 7, inf = 1e18;

string A, B;
int n, dp[N][2][2][5];
int k;

int go(int pos, bool bigA, bool smallB, int cnt){
    if(cnt > k) return 0;
    if(pos >= n)
        return cnt == k;

    int &ans = dp[pos][bigA][smallB][cnt];
    if(~ans)
        return ans;
    ans = 0;
    for(int i = 0; i < 10; i++){
        if(!bigA && i < A[pos] - '0')   continue;
        if(!smallB && i > B[pos] - '0') continue;

        ans += go(pos + 1, bigA || (i > A[pos] - '0'), smallB || (i < B[pos] - '0'), cnt + (i != 0));
    }
    return ans;
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 

    memset(dp, -1, sizeof(dp));
    cin >> B >> k;
    A = "1";
    reverse(A.begin(), A.end());
    while(sz(A) < sz(B))
        A.push_back('0');
    reverse(A.begin(), A.end());
    n = sz(B);
    int ans = 0;

    for(int i = 0; i < 10; i++){
        if(i < A[0] - '0')  continue;
        if(i > B[0] - '0')  continue;

        ans += go(1, i > A[0] - '0', i < B[0] - '0', i != 0);
    }
    cout << ans << '\n';
    
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);

  string S;
  cin >> S;
  
  cout << S.substr(0,3) << endl;

}

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

struct ModInt{
    ll a;
    ModInt() : a(0) {}
    ModInt(ll x) {
        x%=MOD;
        if(x<0) x+=MOD;
        a=x;
    }

    ModInt operator+=(const ModInt p){
        a+=p.a;
        if( a>=MOD ) a-=MOD;
        return *this;
    }
    ModInt operator-=(const ModInt p){
        a-=p.a;
        if(a<0) a+=MOD;
        return *this;
    }
    ModInt operator*=(const ModInt p){
        a=(a*p.a)%MOD;
        return *this;
    }
    ModInt operator/=(const ModInt p){
        *this*=p.inverse();
        return *this;
    }

    ModInt operator+(const ModInt p){
        ModInt x(a);
        return x+=p;
    }
    ModInt operator-(const ModInt p){
        ModInt x(a);
        return x-=p;
    }
    ModInt operator*(const ModInt p){
        ModInt x(a);
        return x*=p;
    }
    ModInt operator/(const ModInt p){
        ModInt x(a);
        return x*=p.inverse();
    }

    ModInt operator=(ll p){
        p%=MOD;
        if(p<0) p+=MOD;
        a=p;
        return *this;
    }

    bool operator==(const ModInt p){
        return a==p.a;
    }

    bool operator!=(const ModInt p){
        return a!=p.a;
    }

    ModInt pow(ll N) const{
        ModInt ans(1),p(a);
        while(N>0){
            if(bit(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    ModInt inverse() const{
        return pow(MOD-2);
    }

};

ModInt Mr(ll p){
    p%=MOD;
    if(p<0) p+=MOD;
    ModInt x(p);
    return x;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    vector<ll> C(N);
    ll sum=0;
    for(int i=0;i<N;i++) cin>>C[i],sum+=C[i];
    sort(C.rbegin(),C.rend());
    ll x=0;
    ModInt ans(0);
    for(int i=0;i<N;i++){
        ans+=Mr(C[i]*2);
        sum-=C[i];
        ans+=Mr(sum);
    }
    //cout<<x<<endl;
    ans*=Mr(2).pow(2*N-2);
    cout<<ans.a<<endl;
}

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

int a, b;

int main() {
  cin >> a >> b;
  if (a >= 13){
    cout << b << endl;
  }else if(a >= 6){
    cout << b / 2 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

f = l[0]
t = l[1:]
s = 0
max = f
for i in t:
    diff = max - i
    if diff > 0:
        s += diff
        
    if(max < i):
        max = i 
        
print(s)

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

signed main(){
    int N, W;
    cin >> N >> W;
    vector<int> vs(N), ws(N);
    rep(i, N) cin >> vs[i] >> ws[i];
    vector<int> dp(W+1);

    rep(i, N) {
        inc(j, ws[i], W+1) {
            dp[j] = max(dp[j], dp[j-ws[i]]+vs[i]);
        }
    }
    cout << *max_element(be(dp)) << nl;
}



Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int x,y;
    cin>>x>>y;
    if(y%2==1)
        cout<<"No";
    else
    {
        long long int m=2*x-(y/2);
        if(m>=0 && m<=x)
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

const ll MOD=1e9+7;
ll f[200005];

ll fpow(ll a,ll p){
	ll res=1LL;
	while(p){
		if(p&1LL) (res*=a)%=MOD;
		a=(a*a)%MOD;
		p>>=1LL;
	}
	return res;
}

ll nCk(int n,int k){
	ll res=f[n];
	(res*=fpow(f[k],MOD-2)*fpow(f[n-k],MOD-2)%MOD)%=MOD;
	return res;
}

ll solve(int sx,int sy,int ex,int ey){
	return nCk(ex-sx+ey-sy,ex-sx);
}

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	f[0]=1;
	for(ll i=1;i<=200000;++i) f[i]=(f[i-1]*i)%MOD;
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	ll res=0LL;
	for(int i=0;i<h-a;++i){
		ll tmp=solve(0,0,i,b-1);
		(tmp*=solve(i,b,h-1,w-1))%=MOD;
		(res+=tmp)%=MOD;
	}
	cout<<res;
}

Measured memory_bytes: 1792
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll N, D;
  cin >> N >> D;
  ll ans = 0;
  ll X, Y;

  for (int i = 0; i < N; i++) {
    cin >> X >> Y;
    ll d2 = X * X + Y * Y;
    if (d2 <= D * D) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;
bool visit(const vector<vector<tuple<int,int,int>>> &g, int v, vector<int> &order, vector<int> &color) {
  color[v] = 1;
  for(auto i: g[v]) {
  	int e = get<0>(i);
    if (color[e] == 2) continue;
    if (color[e] == 1) return false;
    if (!visit(g, e, order, color)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
vi topologicalSort(const vector<vector<tuple<int,int,int>>> &g) {
  int n = g.size();
 vi order;
	vector<int> color(n);
  rep(u, n) if (!color[u] && !visit(g, u, order, color)) assert(0);
  reverse(all(order));
  return order;
}
int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	vector<vector<tuple<int,int,int>>> e(n);
	rep(i, m){
		int a, b, c, d; cin >> a >> b >> c >> d; a--; b--;
		e[a].emplace_back(b, c, d);
	}
	vi ord = topologicalSort(e);
	vi where(n);
	rep(i, n) where[ord[i]] = i;
	
	vector<vi> dp(n, vi(n, inf));
	dp[0][0] = 0;
	for(int i : ord) for(int j : ord) if(where[i] <= where[j] && dp[i][j] < inf){
		if(i == j){
			for(auto k : e[i]) for(auto l : e[j]) if(where[get<0>(k)] <= where[get<0>(l)]){
				int &next = dp[get<0>(k)][get<0>(l)];
				if(get<0>(k) != get<0>(l)) next = min(next, dp[i][j] + get<1>(k) + get<1>(l));
				else next = min(next, dp[i][j] + get<1>(k) + get<2>(k));
			}
		}
		else{
			for(auto k : e[i]){
				int l = get<0>(k), r = j;
				if(where[l] > where[r]) swap(l, r);
				dp[l][r] = min(dp[l][r], dp[i][j] + get<1>(k));
			}
		}
	}
	cout << dp[n - 1][n - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 6972
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    COMinit();
    int n,k;
    cin >> n >> k;
    ll ans = 0;
    for(int i=0;i<=min(n-1,k);i++){
        ans += COM(n,i)*COM(n-1,i);
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
AC;
int a,b,c;
cin>>a>>b>>c;
if(a==b){
    printf("%d",c);
}
else if(b==c){
    printf("%d",a);
}
else{
    printf("%d",b);
}




    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define d lld
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

main() {
    int i,j;
    string N;
    cin >> N;

    int tt = 0;
    for (auto it: N) {
        tt += it - '0';
    }
    if (tt % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 3748
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    int k;
    cin>>s>>k;
    
    set<string> st;
    rep(i,s.size()){
        for(int j=1;j<=5;j++){
            st.insert(s.substr(i,j));
        }
    }
    cout<<*next(st.begin(),k-1)<<endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<int, int> P;

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

    vector<int> s_sumA(s.size()+1, 0), s_sumB(s.size()+1, 0);
    vector<int> t_sumA(t.size()+1, 0), t_sumB(t.size()+1, 0);

    REP(i, s.size()) {
        if(s[i] == 'A') s_sumA[i+1] = s_sumA[i] + 1, s_sumB[i+1] = s_sumB[i]; 
        else s_sumA[i+1] = s_sumA[i], s_sumB[i+1] = s_sumB[i] + 1;
    }

    REP(i, t.size()) {
        if(t[i] == 'A') t_sumA[i+1] = t_sumA[i] + 1, t_sumB[i+1] = t_sumB[i]; 
        else t_sumA[i+1] = t_sumA[i], t_sumB[i+1] = t_sumB[i] + 1;
    }

    int q;
    cin >> q;
    REP(query, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, c--;

        int sA, sB, tA, tB;
        sA = s_sumA[b] - s_sumA[a];
        sB = s_sumB[b] - s_sumB[a];
        tA = t_sumA[d] - t_sumA[c];
        tB = t_sumB[d] - t_sumB[c];

        sA %= 3, sB %= 3, tA %= 3, tB %= 3;

        int tmp = min(sA, sB);
        sA -= tmp, sB -= tmp;
        tmp = min(tA, tB);
        tA -= tmp, tB -= tmp;

        if(sA == tA && sB == tB) {
            cout << "YES" << endl;
        } else if ((sA + tB) % 3 == 0 && (sB + tA) % 3 == 0) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int mo=998244353;
const int N=100005;
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int n,ans,D[N],S[N];
int main(){
	ans=1;
	scanf("%d%d",&n,&D[1]);
	if (D[1]) return puts("0"),0;
	For(i,2,n) scanf("%d",&D[i]);
	For(i,1,n) ++S[D[i]];
	if (S[0]>1) return puts("0"),0;
	For(i,1,n) ans=1ll*ans*power(S[i-1],S[i])%mo;
	printf("%d\n",ans);
}

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

int Sort(int arr[],int N){
int sw=0;
bool flag=1;
for(int i=0;flag;i++){
flag=0;
for(int j=N-1;j>=i+1;j--){
if(arr[j]<arr[j-1]){
swap(arr[j],arr[j-1]);
flag=1;
sw++;
}
}
}
return sw;
}

int main(){
int arr[100],N,sw;
cin>>N;
for(int i=0;i<N;i++)cin>>arr[i];

sw=Sort(arr,N);
for(int i=0;i<N;i++){
if(i)cout<<" ";
cout<<arr[i];
}
cout<<endl;
cout<<sw<<endl;

return 0;
}

Measured memory_bytes: 3076
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
ll power(ll n,ll k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}

int main(){
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    ll div=b+c;
    ll ans=a/div;
    ans=ans*b;
    ll ans1=a%div;
    if(ans1>b)ans1=b;
    cout<<ans+ans1;



	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

func main() {
	rd := bufio.NewReaderSize(os.Stdin, 1000000)

	s := readLine(rd)

	var r []rune
	for _, v := range s {
		if unicode.IsUpper(v) {
			r = append(r, unicode.ToLower(v))
		} else {
			r = append(r, unicode.ToUpper(v))
		}
	}
	fmt.Println(string(r))
}

func readLine(rd *bufio.Reader) string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rd.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}



Measured memory_bytes: 1228
#D問題
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N, K = map(int, input().split())
red = N - K
for i in range(1,K+1):
        if N-K+1 < i:
            print(0)
        else:
            divide_line = combinations_count(red+1, i)
            case =combinations_count(K-1,i-1) * divide_line
            ans = case%(10**9+7)
            print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(void){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    int cnt=0;
    rep(i,n){
        int tmp=a.at(i);
        if(a.at(tmp-1)==i+1)cnt++;
    }
    cout<<cnt/2<<endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n = int(input())
mod = 10**9+7
a = list(map(int,input().split()))
a.sort()
ans = 0
const = pow(2,n,mod)
if n == 1:
  print(a[0]*2%mod)
  exit()
for i in range(n):
  ans = (ans + a[i]*const*(pow(2,n-1,mod)+pow(2,n-2,mod)*(n-i-1))%mod)%mod
print(ans)

Measured memory_bytes: 27116
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    let mut cnt = 0;
    for i in 1..n-1 {
        let s1: HashSet<char> = s[0..i].iter().cloned().collect::<HashSet<char>>();
        let s2: HashSet<char> = s[i..n].iter().cloned().collect::<HashSet<char>>();
        cnt = std::cmp::max(cnt, s1.intersection(&s2).count());
    }
    println!("{}", cnt);
}


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

# define x first
# define y second
# define mp make_pair
// everything goes according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

# ifdef Local
# define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
# else
# define debug(...) (__VA_ARGS__)
# define cerr if(0)cout
# endif

using namespace std;

typedef pair <int, int> pii;
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") {
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}


int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p;
    return 0;
  }
  
  ll ans = 1;
  for (ll x = 2; x * x <= p; x++) {
    ll y = x;               
    for (int j = 1; j <= n && y <= p && p % y == 0; j++, y *= x) {
      if (j == n)
        ans = x;
    }
  }
  cout << ans; 


  return 0;
}






// Coded by Z..


Measured memory_bytes: 256
import itertools
m = 0
a = 0
r = 0
c = 0
h = 0

n=int(input())

for _ in range(n):
    s=input()
    if s[0] == 'M':
        m += 1
    if s[0] == 'A':
        a += 1
    if s[0] == 'R':
        r += 1
    if s[0] == 'C':
        c += 1
    if s[0] == 'H':
        h += 1
ans = 0
memo = [m,a,r,c,h]

for v in itertools.combinations(memo, 3):
    ans += v[0]*v[1]*v[2]
    #print(v)
print(ans)

Measured memory_bytes: 49896
s=input()
import collections
p=collections.Counter(s)
#print(p[max(p)])
if len(p)==3:
    if p[max(p,key=p.get)]-p[min(p,key=p.get)]<2:
        print("YES")
    else:
        print("NO")
if len(p)==2:
    if p[max(p,key=p.get)]>1:
        print("NO")
    else:
        print("YES")
if len(p)==1:
    if p[max(p,key=p.get)]==1:
        print("YES")
    else:
        print("NO")

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

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

using namespace std;

int main(){
	int n,h,w; scanf("%d%d%d",&n,&h,&w);

	int ans=0;
	rep(i,n){
		int a,b; scanf("%d%d",&a,&b);
		if(a>=h && b>=w) ans++;
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 256