akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main (){
  
    int N,x;
  
    scanf("%d", &N);
  
    if(100 <= N && N <= 111){
      x = 111;
    }
  
    else if (112 <= N && N <= 222){
      x = 222;
    }
  
    else if (223 <= N && N <= 333){
      x = 333;
    }
  
    else if (334 <= N && N <= 444){
      x = 444;
    }
  
    else if (445 <= N && N <= 555){
      x = 555;
    }
  
    else if (556 <= N && N <= 666){
      x = 666;
    }
  
    else if (667 <= N && N <= 777){
      x = 777;
    }
  
    else if (778 <= N && N <= 888){
      x = 888;
    }
  
    else {
      x = 999;
    }
  
    printf("%d\n", x);
  
return 0;
}


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

int main(){
     int N,X,T;
    cin >> N >> X >> T;
    int ans = T*(N/X);
    if( N%X>0 ) ans += T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
int main(){
    int n,k,y,x;
    while(scanf("%d",&n)!=EOF){
        scanf("%d",&k);
        scanf("%d",&x);
        scanf("%d",&y);
        ll sum = 0;
        if(n>=k){
            for(int i=1; i<=k; i++){
            sum +=x;
        }
            for(int i=k+1; i<=n; i++){
                sum +=y;
            }
        }
        else if(n<k){
            for(int i=0; i<n; i++){
                sum += x;
            }
        }
        printf("%lld\n",sum);

        }




    return 0;
}


Measured memory_bytes: 128
N = int(input())
brick = [int(x) for x in input().split()]
if 1 not in brick:
  print(-1)
else:
  num, brk = 1, 0
  for i in range(N):
    if brick[i] == num:
      num += 1
    else:
      brk += 1
  print(brk)

Measured memory_bytes: 26268
n,k = map(int,input().split())
d = []
for i in range(k):
    a = int(input())
    d.append((map(int, input().split())))
# print(d)
have = [-1]*n
# print(have[n-1])
for i in d:
    for j in i:
        # print(have[j-1])

        have[j-1]+=1

ans=0
for i in range(n):
    if have[i]==-1:
        ans +=1
print(ans)

Measured memory_bytes: 9408
class Heap
  def initialize(compare_symbol = :<, storage = [], &compare_fn)
    @heap = storage
    @size = 0
    initialize_compare(compare_symbol, &compare_fn)
  end

  attr_reader :size

  def empty?
    size == 0
  end

  def peak
    @heap[0]
  end

  def pop
    result = peak

    if size > 1
      @size -= 1
      @heap[0] = @heap[@size]
      rebalance_down(0)
    else
      @size = 0
    end

    @heap[@size] = nil

    result
  end

  def add(element)
    @heap[@size] = element
    @size += 1
    rebalance_up(size - 1)
    self
  end

  alias :<< :add

  def replace(element)
    @heap[0] = element
    rebalance_down(0)
  end

  def offer(element)
    if compare(peak, element)
      result = peak
      replace(element)
      result
    else
      element
    end
  end

  def clear
    @heap = []
    @size = 0
  end

  def to_a
    @heap.dup
  end

  private

  def initialize_compare(symbol, &fn)
    @compare = if block_given?
      fn
    elsif symbol == :< or symbol.nil?
      lambda{|a, b| a < b}
    elsif symbol == :>
      lambda{|a, b| a > b}
    else
      raise ArgumentError.new("The comparison symbol needs to be either :> or :<")
    end
  end

  def compare(a, b)
    @compare.call(a, b)
  end

  def rebalance_up(i)
    parent_i = parent(i)

    if has_parent(i) and compare(@heap[i], @heap[parent_i])
      @heap[i], @heap[parent_i] = @heap[parent_i], @heap[i]
      rebalance_up(parent_i)
    end
  end

  def rebalance_down(i)
    left_i = left(i)
    right_i = right(i)

    if has_left(i) and compare(@heap[left_i], @heap[i]) and (not has_right(i) or compare(@heap[left_i], @heap[right_i]))
      @heap[i], @heap[left_i] = @heap[left_i], @heap[i]
      rebalance_down(left_i)
    elsif has_right(i) and compare(@heap[right_i], @heap[i])
      @heap[i], @heap[right_i] = @heap[right_i], @heap[i]
      rebalance_down(right_i)
    end
  end

  def has_parent(i)
    i >= 1
  end

  def parent(i)
    ((i - 1) / 2).floor
  end

  def has_left(i)
    left(i) < size
  end

  def left(i)
    i * 2 + 1
  end

  def has_right(i)
    right(i) < size
  end

  def right(i)
    i * 2 + 2
  end
end

n,m = gets.split(' ').map(&:to_i)
as = gets.split(' ').map(&:to_i)
heap = Heap.new(:>)

as.each {|a| heap << a}
m.times do
  heap << heap.pop/2
end

puts heap.to_a.inject(:+)

Measured memory_bytes: 11492
#include <stdio.h>
    #include <string.h>
    #include <queue>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    const int maxn=10050;
    const int maxe=2005000;
    const int INF=1e9;
    struct note
    {
        int to;
        int w;
        int c;
        int next;
    };
    note edge[maxe];
    int head[maxn];
    int ip;
    void init()
    {
        memset(head,-1,sizeof(head));
        ip=0;
    }
    void addedge(int u,int v,int w,int c)
    {
        edge[ip].to=v;
        edge[ip].c=c;
        edge[ip].w=w;
        edge[ip].next=head[u];
        head[u]=ip++;
    }
    int cost[maxn];
    int dis[maxn];
    bool vis[maxn];
    queue<int>q;
    void spfa(int s,int n)
    {
        while(!q.empty())q.pop();
        for(int i=1;i<=n;i++)
            cost[i]=dis[i]=INF;
        memset(vis,false,sizeof(vis));
        dis[s]=0;
        cost[s]=0;
        vis[s]=true;
        q.push(s);
        while(!q.empty())
        {
            int u=q.front();
            q.pop();
            vis[u]=false;
            for(int i=head[u];i!=-1;i=edge[i].next)
            {
                int to=edge[i].to;
                int val=edge[i].w;
                if(dis[to]>dis[u]+val||(dis[to]==dis[u]+val&&cost[to]>edge[i].c))//????????????????????¶????????±?´?????°????
                {
                    dis[to]=dis[u]+val;
                    cost[to]=edge[i].c;
                    if(!vis[to])
                    {
                        q.push(to);
                        vis[to]=true;
                    }
                }
            }
        }
    }
    int main()
    {
       // freopen("cin.txt","r",stdin);
        int n,m;
        int u,v,w,c;
        while(~scanf("%d%d",&n,&m))
        {
            if(n==0&&m==0) break;
            init();
            for(int i=0;i<m;i++)
            {
                scanf("%d%d%d%d",&u,&v,&c,&w);
                addedge(u,v,c,w);
                addedge(v,u,c,w);
            }
            spfa(1,n);
            int ans=0;
            for(int i=1;i<=n;i++)
                ans+=cost[i];
            printf("%d\n",ans);
        }
        return 0;
    }

Measured memory_bytes: 3932
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
int X;
int ans=0;
int main(){
  cin >> X;
  int i;
  for(i=1;i<X;i++){
    ans+=i;
    if(ans>=X)break;
  }
  cout << i;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

double distance( PII a, PII b )
{
	return sqrt( pow( a.fst - b.fst, 2. ) + pow( a.snd - b.snd, 2. ) );
}

struct Edge
{
	int from, to;
	double cost;

	Edge( int f, int t, double c ) : from( f ), to( t ), cost( c )
	{
		return;
	}

	bool operator > ( const Edge &a ) const
	{
		return cost > a.cost;
	}
};

class UnionFind
{
private:
	vector<int> ary;
	vector<int> rank;

public:
	UnionFind( int n ) : ary( n ), rank( n, 0 )
	{
		REP( i, 0, n )
		{
			ary[i] = i;
		}

		return;
	}

	int find( int x )
	{
		if ( ary[x] == x )
		{
			return x;
		}
		else
		{
			return ary[x] = find( ary[x] );
		}
	}

	bool same( int x, int y )
	{
		return find( x ) == find( y );
	}

	void unite( int x, int y )
	{
		x = find( x );
		y = find( y );

		if ( x == y )
		{
			return;
		}

		if ( rank[x] < rank[y] )
		{
			ary[x] = y;
		}
		else
		{
			ary[y] = x;

			if ( rank[x] == rank[y] )
			{
				rank[x]++;
			}
		}

		return;
	}
};

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

	int n, m;
	cin >> n >> m;

	vector< PII > piles( n );

	EACH( pile, piles )
	{
		cin >> pile.fst >> pile.snd;
	}

	vector< Edge > E;

	REP( i, 0, m )
	{
		int p, q;
		cin >> p >> q;

		p--;
		q--;

		E.PB( Edge( p, q, distance( piles[p], piles[q] ) ) );
	}

	sort( ALL( E ), greater< Edge >() );

	UnionFind uf( n );

	double res = 0;

	REP( i, 0, E.size() )
	{
		if ( uf.same( E[i].from, E[i].to ) )
		{
			res += E[i].cost;
			continue;
		}

		uf.unite( E[i].from, E[i].to );
	}

	cout.precision( 5 );
	cout << fixed;

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1872
N,x = map(int,input().split())
a = list(map(int,input().split()))

def calc(A,x):
  res = 0
  for i in range(len(A)-1):
    if A[i] + A[i+1] > x:
      if A[i] < x:
        res += A[i+1] - (x - A[i])
        A[i+1] = x - A[i]
      else:
        res += A[i] - x + A[i+1]
        A[i] = x
        A[i+1] = 0
  return res

print(calc(a,x))

Measured memory_bytes: 63984
using System;
class Program
{
    static void Main(string[] args)
    {
        int a, b, c;
        string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);  //数値で受け取りたい場合は変換する
        c = int.Parse(str[2]);
        var min = a + b;
        var t1 = a + c;
        if (min > t1) min = t1;
        var t2 = b + c;
        if (min > t2) min = t2;
        Console.Write("{0}", min);
        //Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main(){
	int n;
  	cin>>n;
  	int wac=0,rec=0,acc=0,tlec=0;
  	string s;
  	for(int i=0;i<n;i++){
    	cin>>s;
      	if(s == "AC") acc++;
      	if(s == "WA") wac++;
      	if(s == "RE") rec++;
      	if(s == "TLE") tlec++;
      
    }
  	cout<<"AC"<<" x "<<acc<<endl;
  	cout<<"WA"<<" x "<<wac<<endl;
  	cout<<"TLE"<<" x "<<tlec<<endl;
   	cout<<"RE"<<" x "<<rec<<endl;
  
  	return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    int x=0, y=0, z=0, c=0, t;
    cin>>t;
    for(int i=0;i<t;i++)
    {
        cin>>a;
        if(a=="AC")
        {
            x++;
        }
        else if(a=="WA")
        {
            y++;
        }
        else if(a=="TLE")
        {
            z++;
        }
        else if(a=="RE")
        {
            c++;
        }
    }
    cout<<"AC x "<<x<<endl;
    cout<<"WA x "<<y<<endl;
    cout<<"TLE x "<<z<<endl;
    cout<<"RE x "<<c<<endl;
}


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

int main() {

  int N;
  cin >> N;
  vector<int> A(N);
  bool judge=true;
  
  for(int i=0; i<=N-1; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
    for(int i=1; i<=N-1; i++){
      if(A.at(i-1)==A.at(i)){
        judge=false;
      }
    }
  if(judge){
  cout << "YES" << endl;
  }else{
  cout << "NO" << endl;
  }
}


Measured memory_bytes: 1024
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
P, Q, R = map(int, input().split())
# S = input()

ps = [P, Q, R]
ps.sort()

print(ps[0] + ps[1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll P = 998244353;
ll f(ll b, ll n) {if (n <= 0) return 1; auto p = f(b, n / 2); return p * p % P * (n % 2 ? b : 1) % P;}
ll ms[200001];
int main()
  {int N, M, K; cin >> N >> M >> K;
  ms[0] = 1;
  for (int r = 1; r <= K; ++r) ms[r] = ms[r - 1] * (N - 1 - r + 1) % P * f(r, P - 2) % P;
  ll ans = 0;
  for (int i = 0; i <= K; ++i) ans = (ans + ms[i] * M % P * f(M - 1, N - i - 1) % P) % P;
  cout << ans << endl;}

Measured memory_bytes: 5108
C = [2,3,4,5,6,7,8,9,10,11,12,13,1]
A, B = map(int, input().split())
if C.index(A) > C.index(B):
    print("Alice")
elif C.index(A) < C.index(B):
    print("Bob")
else:
    print("Draw")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
typedef long long ll;
 
int main(void) {
	ll N, A, B;
	cin >> N >> A >> B;
 
	ll k = N / (A + B);
	ll m = N % (A + B);
	ll ans = (ll)0;
	if (m < A)
		ans = m;
	else
		ans = A;
	ans += k * A;
 
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	ll n,m,k,b,c,sum=0;
	scanf("%lld%lld",&n,&k); 
	n%=k;
	if(n>=abs(k-n)) printf("%lld",abs(k-n));
	else printf("%lld",n);
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int k,s,x,y,z,ans=0;
  cin>>k>>s;
  for (x=0;x<=k;++x)
    for (y=0;y<=k;++y)
      if (x+y<=s&&x+y+k>=s) ++ans;
  cout<<ans;
}

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

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

    string s;
    cin >> s;
    long long k;
    cin >> k;

    if(k == 1){
        cout << s[0] << endl;
        return 0;
    }

    for(int i = 0; i < min(k, (long long)s.size()); i++){
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }

    cout << '1' << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){

	for(int i = 0;i<4;i++){
		int n,m;
		cin >> n >> m;
		if(n == 1){
			cout << m * 6000 << endl;
		}else if(n == 2){
			cout << m * 4000 << endl;
		}else if(n == 3){
			cout << m * 3000 << endl;
		}else if(n == 4){
			cout << m * 2000 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3108
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: usize,
    }
    if (a - b).abs() > 1000000000000000000 {
        println!("Unfair");
    } else if k % 2 == 0 {
        println!("{}", a - b);
    } else {
        println!("{}", b - a);
    }
}


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,3)if(s[i]=='1') ++ans;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>   
using namespace std;
int main()
{
    long long n,min,l=0;    
    cin>>n;
    min=n;     
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)   
        {
            min=n/i;    
        }
    }
    while(min!=0)
    {
        min/=10;
        l++;
    }          
    cout<<l<<endl;
    return 0;
}

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

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif





ll n, a, b, aa, bb;
string s;

vector<int> va, vb;

bool test(){
	// 到達可能な位置を調べる
	for ( int i = aa-1; i >= a; i-- ){
		if ( s[i] != '#' && ( va[i+1] | va[i+2] ) )
			va[i] = 2;
	}
	for ( int i = bb-1; i >= b; i-- ){
		if ( s[i] != '#' && ( vb[i+1] | vb[i+2] ) )
			vb[i] = 2;
	}
	
	//cout << s << endl;
	//for ( auto it : va )
	//	cout << it;
	//cout << "  " << endl;
	//for ( auto it : vb )
	//	cout << it;
	//cout << "  " << endl;
	
	if ( !va[a] || !vb[b] )
		return false;
	
	if ( aa > bb ){
		// 追い越し可能か?
		for ( int i = b; i <= bb; i++ ){
			if ( vb[i] && va[i-1] && va[i+1] ){
				return true;
			}
		}
		return false;
	}
	
	return true;
}

int main(){
	cin >> n >> a >> b >> aa >> bb;
	cin >> s;
	
	a--;
	b--;
	aa--;
	bb--;
	
	va.resize(n+2);
	vb.resize(n+2);
	va[aa] = 1;
	vb[bb] = 1;
	
	
	if ( test() ){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	
	return 0;
}




Measured memory_bytes: 5216
<?php

fscanf(STDIN, "%d", $A);

//$map = array_fil(0, 100, array_fill(0, 100, -1));
$max_p =0;
while($A--){

    fscanf(STDIN, "%d%d%d", $x, $y, $p);
    $map[$x][$y] = $p;
    $max_p = max($max_p, $p);

    if($max_p == $p){
        $max_x = $x;
        $max_y = $y;
    }

}

for($hx = 0; $hx<=100; $hx++){
    for($hy =0;$hy<=100;$hy++){
        if(isset($map[$hx][$hy])){
            $height = $map[$hx][$hy];
        }else{
            $height = -1;
        }
        $k = 1;
        foreach($map as $x => $ydata){
            foreach($ydata as $y => $p){
                if($height == -1){
                    $height = $max_p + abs($hx - $max_x) + abs($hy - $max_y);
                    if($max_p == 0){
                       $height = 1;
                    }

                }
                if (($height != $p + abs($hx - $x) + abs($hy - $y) || $height < $p)) {
                    if($p == 0 && $height - abs($hx-$x) - abs($hy - $y) < 0) {
                        continue;
                    }
                    $k = 0;
                    break 2;
                }

            }
        }
        if($k == 1) {
            echo $hx . " " . $hy . " " . $height;
            exit;
        }
    }
}

Measured memory_bytes: 4604
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let (n, a, b): (i64, i64, i64) = input_three();
    let ans = n / (a + b) * a + min(a, n % (a + b));
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include<stdio.h>
#define MAX 100

int n;
int data[MAX];

void data_input(){
  int i;
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&data[i]);
}

void print(){
  int i;
  for(i = 0; i < n; i++){
    if(i) printf(" ");
    printf("%d",data[i]);
  }
  printf("\n");
}

void insertion_sort(){
  print();
  int i,j;
  for(j = 1; j < n; j++){
    int key = data[j];
    i = j-1;
    while(i >= 0 && data[i] > key){
      data[i+1] = data[i];
      i=i-1;
    }
    data[i+1] = key;
    print();
  }
}

int main(){
  data_input();
  insertion_sort();
  return 0;
}



Measured memory_bytes: 2052
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007
INF = float("inf")


class FactInv:
    def __init__(self, N, MOD=1000000007):
        fact = [1]*(N+1)
        for i in range(1, N+1):
            fact[i] = fact[i - 1] * i % MOD

        inv = [None]*(N+1)
        inv[N] = pow(fact[N], MOD - 2, MOD)

        for i in range(N)[::-1]:
            inv[i] = inv[i + 1] * (i + 1) % MOD

        self.N = N
        self.MOD = MOD
        self.fact = fact
        self.inv = inv

    def perm(self, a, b):
        if a > self.N or b > self.N:
            raise ValueError(
                "\nPermutaion arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[a-b] % self.MOD

    def comb(self, a, b):
        if a > self.N or b > self.N:
            raise ValueError(
                "\nCombination arguments are bigger than N\n N = {}, a = {}, b = {}".format(self.N, a, b))
        return self.fact[a] * self.inv[b] * self.inv[a-b] % self.MOD



def main():
    N, K = LI()
    A = sorted(LI())
    factinv = FactInv(N+1)
    ans = 0

    ans = 0
    for i, x in enumerate(A):
        maxc = factinv.comb(i, K - 1) if i >= K - 1 else 0
        minc = factinv.comb(len(A) - i - 1, K - 1) if len(A) - i - 1 >= K - 1 else 0
        ans = (ans + x * (maxc - minc)) % MOD

    print(ans % MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 95000
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, M;
    cin >> N >> M;
    int lmax = 0, rmin = INT_MAX;
    rep(i, M)
    {
        int l, r;
        cin >> l >> r;
        chmax(lmax, l);
        chmin(rmin, r);
    }
    cout << max(rmin - lmax+1,0);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int64_t N=0,x=0,y=0,sum=0;
  map<int64_t,int64_t> mp;
  cin>>N;
  vector<int64_t> A(N,0);
  rep(i,N){cin>>x;mp[x]++;A.at(i)=x;}
  for(auto p:mp)
  {
    auto key=p.first;auto value=p.second;
    sum+=value*(value-1)/2;
  }
  rep(i,N){x=A.at(i);y=mp.at(x);cout<<sum-y*(y-1)/2+(y-1)*(y-2)/2<<endl;}
}

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

int N, x, a[100];

int main() {
  cin >> N >> x;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int ans = 0, sum = 0;
  for (int i = 0; i < N; i++) {
    if (sum < x) {
      sum += a[i];
      ans = i + 1;
    }
  }
  if (sum != x) ans -= 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    int e = sc.nextInt();
    int arr[] = {a,b,c,d,e};
    Arrays.sort(arr);
    for (int i = 0; i < 4; i++) {
      System.out.print(arr[4-i] + " ");
    }
    System.out.println(arr[0]);
  }
  
}

Measured memory_bytes: 12000
#include <stdio.h>

void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}

Measured memory_bytes: 604
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

struct edge{int to, cost;};

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

double t[10];
vector<edge> g[35];
double d[35][1<<8];
signed main(void)
{
	while(true) {
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;
		if(!n && !m && !p && !a && !b) break;
		a--, b--;
		REP(i, n) cin >> t[i];
		REP(i, m) g[i].erase(ALL(g[i]));
		REP(i, p) {
			int x, y, z;
			cin >> x >> y >> z;
			g[x-1].PB({y-1, z});
			g[y-1].PB({x-1, z});
		}

		//?????????
		priority_queue<vector<double>, vector<vector<double>>, greater<vector<double>>> que;
		fill(d[0], d[35], INF);
		d[a][0] = 0;
		//??????????????????????????£????????±??????
		que.push(vector<double>{0.0, (double)a, 0});

		//dijkstra
		while(que.size()) {
			vector<double> v = que.top(); que.pop();
			if(d[(int)v[1]][(int)v[2]] < v[0]) continue;
			//cout << "cost:" << fixed << setprecision(9) << v[0] << " v:" << (int)v[1] << " ticket" << bitset<8>((int)v[2]) << endl;
			for(edge e: g[(int)v[1]]) {
				//?????£??????????????±????????????????????¨??¢?´¢
				REP(i, n) {
					//i??????????????±??????????????£???e.to?????????
					if(!(((int)v[2])>>i&1) && d[e.to][((int)v[2])|(1<<i)] > d[(int)v[1]][(int)v[2]] + e.cost/t[i]) {
						d[e.to][(int)v[2]|(1<<i)] = d[(int)v[1]][(int)v[2]] + e.cost/t[i];
						que.push({d[e.to][(int)v[2]|(1<<i)], (double)e.to, (double)((int)v[2]|(1<<i))});
					}
				}
			}
		}

		double ret = INF;
		REP(i, 1<<n) {
			ret = min(ret, d[b][i]);
		}
		if(ret == INF) cout << "Impossible" << endl;
		else cout << ret << endl;
	}

	return 0;
}

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

int main(){
  int n;
  cin >>n;
  
  vector<int>a(n);
  for(int i=0;i<n;i++){
  cin>>a.at(i);
    a.at(i)--;
  }
  
  vector<int>b(n);
  for(int i=0;i<n;i++){
    cin>>b.at(i);
  }
  
  vector<int>c(n-1);
  for(int i=0;i<n-1;i++){
    cin>>c.at(i);
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=b.at(a.at(i));
    if(i>0&&a.at(i)==a.at(i-1)+1){
      ans+=c.at(a.at(i-1));
    }
  }
  cout<<ans<<endl;

}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vector<ll> a(N), s(N+1, 0);
    rep(i, N) cin >> a[i];
    rep(i, N) s[i+1] = s[i] + a[i];
    unordered_map<ll, ll> m;
    rep1(i, N){
        m[s[i]]++;
    }
    ll res = 0;
    for(auto p: m){
        if(p.first == 0) res += p.second;
        res += p.second*(p.second-1)/2;
    }
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 15688
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;
using namespace std;

const ll inf = 2e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;

int n;

void code() {
    cin >> n;

    vector<pair<ll, ll>> v(n);
    for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;

    sort(all(v));

    v.resize(unique(all(v)) - v.begin());

    ll mx1 = -1e9, mx2 = -1e9, mn1 = 1e9, mn2 = 1e9;
    for (int i = 0; i < v.size(); i++) {
        mx1 = max(mx1, v[i].first + v[i].second);
        mx2 = max(mx2, v[i].first - v[i].second);
        mn1 = min(mn1, v[i].first + v[i].second);
        mn2 = min(mn2, v[i].first - v[i].second);
    }

    ll ans = 0;
    ans = max(ans, mx1 - mn1);
    ans = max(ans, mx2 - mn2);

    cout << ans << "\n";

}

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

    int t = 1;
    // cin>>t;

    while (t-- > 0) {
        code();
    }
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 n;
    constexpr i64 mod = 998244353;
    std::cin >> n;
    std::vector<int> a(n + 1);
    i64 s = 0, t = 1;
    for (int i = 1; i <= n; i++) {
        std::cin >> a[i];
        s += a[i];
        t = t * 3 % mod;
    }
    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(s + 1));
    std::vector<std::vector<i64>> dp2(n + 1, std::vector<i64>(s + 1));
    dp[0][0] = 1;
    dp2[0][0] = 1;
    for (int i = 1; i <= n; i++) for (int j = 0; j <= s - a[i]; j++) {
        dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i - 1][j]) % mod;
        dp[i][j] = (dp[i][j] + dp[i - 1][j] * 2) % mod;
        dp2[i][j + a[i]] = (dp2[i][j + a[i]] + dp2[i - 1][j]) % mod;
        dp2[i][j] = (dp2[i][j]+ dp2[i - 1][j]) % mod;
    }
    i64 ret = 0;
    for (int i = (s + 1) / 2; i <= s; i++) {
        ret = (ret + mod - dp[n][i]) % mod;
    }
    if (s % 2 == 0) ret = (ret + dp2[n][s / 2]) % mod;
    std::cout << (t + ret * 3) % mod << std::endl;

    return 0;
}


Measured memory_bytes: 423744
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

#include<ctime>
#include<random>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int culc(Ints &r, std::vector<Ints> &s, Ints &c){
    int res = 0;
    Ints last(26, 0);

    for(int i=0;i<(int)r.size();i++){
        last[r[i]-1] = i+1;
        for(int j=0;j<26;j++){
            if(r[i]-1==j) res+=s[i][j];
            else res-=c[i]*(i+1-last[j]);
        }
    }

    return res;
}

int main(void) {
    int t = std::clock();

    int D;
    std::cin >> D;
    Ints c;
    std::vector<Ints> s(D, Ints(26, 0));

    for(int i=0;i<26;i++){
        int _c;
        std::cin >> _c;
        c.push_back(_c);
    }

    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++){
            int _s;
            std::cin >> _s;
            s[i][j] = _s;
        }
    }

    Ints res(D, 1);

    for(int i=0;i<D;i++){
        Ints::iterator iter = std::max_element(s[i].begin(), s[i].end());
        size_t index = std::distance(s[i].begin(), iter);
        res[i] = (int)index + 1;
    }

    LL nowp = culc(res, s, c);

    std::random_device rnd;
    std::mt19937 mt(rnd());
    while(static_cast<int>((double)(std::clock() - t) / CLOCKS_PER_SEC * 1000.0) < 1900){
        int day = mt() % D;
        int contest = mt() % 26;
        Ints res_tmp = res;
        res_tmp[day] = contest + 1;
        LL tmpp = culc(res_tmp, s, c);
        if(nowp < tmpp){
            res = res_tmp;
            nowp = tmpp;
        }
    }

    for(auto r : res) std::cout << r << std::endl;

    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
    int i,j,n;
    cin >> n >> i;
    cout << n - i + 1 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int seq = 0;
  long int ans = 0;
  for (int i = 0; i < S.size() ; i++ ) {
    if ( S[i] == 'W' ) {
      ans += i;
      ans -= seq;
      seq++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>

using namespace std;

int A[3][3];

bool IsBingo() {
  for (int i = 0; i < 3; i++) {
    if (!A[0][i] && !A[1][i] && !A[2][i]) return true;
  }
  for (int i = 0; i < 3; i++) {
    if (!A[i][0] && !A[i][1] && !A[i][2]) return true;
  }
  if (!A[0][0] && !A[1][1] && !A[2][2]) return true;
  if (!A[2][0] && !A[1][1] && !A[0][2]) return true;

  return false;
}

int main() {
  map<int, pair<int, int>> m;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
      m[A[i][j]] = {i, j};
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    auto it = m.find(b);
    if (it != m.end()) {
      auto p = it->second;
      A[p.first][p.second] = 0;
    }
  }
  cout << (IsBingo() ? "Yes" : "No") << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> vec(4);
  for(int i=0; i<4; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  string ans = "YES";
  if(vec.at(0) != 1){
    ans = "NO";
  }
  if(vec.at(1) != 4){
    ans = "NO";
  }
  if(vec.at(2) != 7){
    ans = "NO";
  }
  if(vec.at(3) != 9){
    ans = "NO";
  }
  cout << ans << endl;
}

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

int main() {
    int n, d;
    cin>>n >>d;
    rep(i,n+1){
        if((2*d+1)*i>=n){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, ans = 1;
    seika s;
    cin >> n >> s;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] != s[i + 1])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
typedef struct{
    int t;
    P v;
}D;
int dist(P x, P y) {
    return abs(x.first-y.first) + abs(x.second-y.second);
}
int main() {
    int n; cin >> n;
    D prev = D{0,P{0,0}};
    bool ok = true;
    rep(i, n) {
        int t; P v;
        cin >> t >> v.first >> v.second;
        if(dist(prev.v, v) > (t-prev.t)) ok = false;
        if((t-prev.t)%2 != dist(prev.v, v)%2) ok = false;
        prev = D{t, v};
    }
    if(ok) cout << "Yes";
    else cout << "No";
}


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


void solve(std::vector<long long> A){
    if(accumulate(A.begin(), A.end(), 0) >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


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

using namespace std;

vector<vector<int>> a(200000);
vector<long long> ans(200000);

void dfs(int n, int p);

int main()
{
	int n, q;
	cin >> n >> q;
	int b, c;
	for (int i = 0; i < n - 1; i++) {
		cin >> b >> c;
		a[b - 1].emplace_back(c - 1);
		a[c - 1].emplace_back(b - 1);
	}

	for (int i = 0; i < q; i++) {
		cin >> b >> c;
		ans[b - 1]+= c;
	}

	dfs(0, 0);

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

	return 0;
}

void dfs(int n, int p)
{
	for (auto & i : a[n]) {
		if (i == p) {
			continue;
		}
		ans[i] += ans[n];
		dfs(i, n);
	}
}

Measured memory_bytes: 24320
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int chair[100],pos,n,m;

int d(char c){
	if(c == 'A'){
		for(int i=0;i<n;i++){
			if(chair[i] == -1) return i;
		}
	}else if(c == 'B'){
		for(int i=n-1;i>=0;i--){
			if(chair[i] == -1){
				if(i == 0){
					if(chair[i+1] != 'A') return i;
				}else if(i == n-1){
					if(chair[i-1] != 'A') return i;
				}else{
					if(chair[i-1] != 'A' && chair[i+1] != 'A') return i;
				}
			}
		}
		for(int i=0;i<n;i++){
			if(chair[i] == -1) return i;
		}
	}else if(c == 'C'){
		for(int i=0;i<n;i++){
			if(chair[i] != -1){
				if(i+1 < n && chair[i+1] == -1) return i+1;
				if(0 <= i-1 && chair[i-1] == -1) return i-1;
			}
		}
		return n/2;
	}else{
		int d_min_max = 0,d_pos=-1,tmp;
		for(int i=0;i<n;i++){
			//ó¢Ä¢éÖqÆÅàß¢lÌ£ðßé
			
			if(chair[i] == -1){
				int dist_min = 1 << 28;
				if(i != n-1){
					tmp = 1;
					while(i+tmp < n && chair[i+tmp] == -1) tmp++;
					if(i+tmp<n){
						dist_min = min(dist_min, tmp);
					}
				}
				if(i != 0){
					tmp = 1;
					while(i-tmp >= 0 && chair[i-tmp] == -1) tmp++;
					if(i-tmp >= 0){
						dist_min = min(dist_min, tmp);
					}
				}
				if(d_min_max < dist_min && dist_min != 1 << 28){
					d_min_max = dist_min;
					d_pos = i;
				}
			}
		}
		if(d_pos != -1) return d_pos;
		for(int i=0;i<n;i++){
			if(chair[i] == -1) return i;
		}
	}
}

int main(){
	while(cin >> n >> m){
		if(!(n|m)) break;
		char c;
		memset(chair, -1, sizeof(chair));
		for(int i=0;i<m;i++){
			cin >> c;
			chair[d(c)] = c;
		}
		for(int i=0;i<n;i++){
			if(chair[i] == -1){
				cout << "#";
			}else{
				cout << (char)chair[i];
			}
		}
		cout << endl;
	}
}

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

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  int sum = 0;
  rep(i, n) sum += a.at(i);
  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define mp make_pair
#define all(c) (c).begin() , (c).end()
#define sz(c) ((long long)((c).size()))
#define phb push_back
#define ppb pop_back
#define phf push_front
#define ppf pop_front

using namespace __gnu_pbds;
using namespace std;

#define int ll

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

template
<
    class key,
    class val=null_type,
    class comp=less<key>
>
using ord_set=tree
<
    key,
    val,
    comp,
    rb_tree_tag,
    tree_order_statistics_node_update
>;

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

    string s;
    cin>>s;
    string prev,cur;
    int k=0;
    for(char c:s)
    {
        cur+=c;
        if(prev!=cur)
            k++,prev=cur,cur.clear();
    }
    cout<<k;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b;
    cin >> a >> b;
    bool teika_is_exsist = false;
    int teika = 1001;
    for(int i = 0; i <= 1000; i++){
        if((a == (i * 8) / 100) && (b == (i * 10 ) / 100 )){
            teika_is_exsist = true;
            teika = min(teika, i); 
        }
    }
    if(teika_is_exsist) cout << teika << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a = 100000;
	int b = 0;
	int c = 0;
	int i = 0;
	int n = 0;
	
	scanf("%d",&n);
	
	
	for(i = 0;i < n;i++){
		b = a * 0.05;				//bは5250になる 5550
		c = b % 1000;				//cは250になる 550

		if(c > 0){
			b = (b - c + 1000);		//bは6000になる 
		}
		a += b;					//aはになる
	}
	printf("%d\n",a);	
	
	return 0;
}

Measured memory_bytes: 592