akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<cassert>

using namespace std;

template< typename T>
struct edge { 
   int from, to; 
   T cost; 
   edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template< typename T>
using EDGE = vector< edge< T > >;

template< typename T>
vector< T > bellman_ford(EDGE< T > &es, int V, int s) {
   const auto INF = numeric_limits< T >::max();
   vector< T > dist(V, INF);
   dist[s] = 0;
   for (int i = 0; i < V - 1; i++) {
      for (auto &e : es) {
         if (dist[e.from] == INF) continue;
         dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
   }
   for (auto & e : es) {
      if (dist[e.from] == INF) continue;
      if (dist[e.from] + e.cost < dist[e.to]) return vector< T >();
   }
   return dist;
}

const int MAXN = 2501;
bool used1[MAXN];
bool used2[MAXN];
vector<int> G1[MAXN], G2[MAXN];

void bfs1(int s) {
   used1[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G1[cur]) {
         if (used1[g]) continue;
         used1[g] = true;
         q.push(g);
      }
   }
}

void bfs2(int s) {
   used2[s] = true;
   queue<int> q;
   q.push(s);
   while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto &g : G2[cur]) {
         if (used2[g]) continue;
         used2[g] = true;
         q.push(g);
      }
   }
}

int main() {
   int N, M, P;
   cin >> N >> M >> P;
   int A[M], B[M], C[M];
   for (int i = 0; i < M; i++) {
      cin >> A[i] >> B[i] >> C[i];
      A[i]--;
      B[i]--;
      C[i] = -1 * (C[i] - P);
      G1[A[i]].push_back(B[i]);
      G2[B[i]].push_back(A[i]);
   }
   memset(used1, false, sizeof(used1)); 
   memset(used2, false, sizeof(used2)); 

   bfs1(0);
   bfs2(N - 1);
   /*
   for (int i = 0; i < N; i++) {
      cout << i << " " << used1[i] << " " << used2[i] << endl;
   }
   */
   EDGE< int > edges;
   
   for (int i = 0; i < M; i++) {
      if (!used1[A[i]]) continue;
      if (!used1[B[i]]) continue;
      if (!used2[A[i]]) continue;
      if (!used2[B[i]]) continue;
      // cout << A[i] << " " << B[i] << " " << C[i] << endl;
      if (A[i] == B[i] && C[i] < 0) {
         cout << "-1" << endl;
         return 0;
      }
      edges.emplace_back(A[i], B[i], C[i]);
   }
   
   auto res = bellman_ford(edges, N, 0);
   if (res.empty()) cout << "-1" << endl;
   else {
      assert(res[N - 1] != numeric_limits<int>::max());
      cout << max(0, -1 * res[N - 1]) << endl;
   }
   return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
typedef  long long ll;
using namespace std;
const int maxn = 2e5 + 100;
const int inf = 2e9;
int a[maxn];
int main() {
	map<int, int>m;
	ios::sync_with_stdio(0);
	ll n, D, A;
	cin >> n >> D >> A;
	for (int i = 1, x; i <= n; i++)
		cin >> a[i] >> x, m[a[i]] = x;
	sort(a + 1, a + 1 + n);
	ll ans = 0, j = 1;
	for (int i = 1; i <= n; i++) {
		int Max = a[i] + 2 * D;
		while (j < n && a[j + 1] <= Max) {
			m[a[j + 1]] += ans * A;
			j++;
		}
		m[a[i]] -= ans * A;
		ll num = m[a[i]] / A + (m[a[i]] % A == 0 ? 0 : 1);
		if (m[a[i]] > 0)
			ans += num;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10368
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	c := 0
	cnt := 0
	if s[0] == 65 {
		for i :=1; i< len(s); i++ {
			if i != 1 && i != len(s)-1 && s[i] == 67 {
				c++
			}
			if 97 <= s[i] && s[i] <= 122 {
				cnt++
			}
		}
		if cnt == len(s)-2 && c == 1{
			fmt.Println("AC")
			return
		}
	}
	fmt.Println("WA")
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string str;
  cin >> str;
  int q,i;
  cin >> q;
  string s1,s2;
  int a,b;
  for(i=0;i<q;i++){
    //cout << str << endl;
    cin >> s1 >> a >> b;
    if(s1=="print"){
      cout << str.substr(a,b-a+1) << endl;
    }else if(s1=="reverse"){
      string s3=str.substr(a,b-a+1);
      reverse(s3.begin(),s3.end());
      str=str.substr(0,a)+s3+str.substr(b+1,str.size()-b-1);
    }else{
      cin >> s2;
      str=str.substr(0,a)+s2+str.substr(b+1,str.size()-b-1);
    }
  }
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    ll N;
    cin >> N;
    vector<ll> a;
    for (ll i = 2; i*i <= N && i < N; i++) {
        if (N % i == 0) {
            a.push_back(i);
            if (N/i > i) {
                a.push_back(N/i);
            }
        }
    }
    ll ans = 0;
    a.push_back(N);
    for (auto x: a) {
        ll k = N;
        while (k%x == 0) {
            k /= x;
        }
        k %= x;
        if (k == 1) {
            ans++;
        }
    }
    ll r = 1;
    ll k = N-1;
    for (ll i = 2; i*i <= N; i++) {
        ll x = 0;
        while (k % i == 0) {
            k /= i;
            x++;
        }
        r *= (x+1);
    }
    if (k != 1) {
        r *= 2;
    }
    r--;
    ans += r;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
int n,i;
int a,b,c;

scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&a,&b,&c);
if(a*a==b*b+c*c){
printf("YES\n");
}
else if(b*b==a*a+c*c){
printf("YES\n");
}
else if(c*c==a*a+b*b){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

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

  u32 ans = n % 1000;
  if (ans == 0) {
    cout << 0;
  } else {
    cout << 1000 - ans;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
using namespace std;

int main(){
  int N; scanf("%d", &N);

  int s = 0;

  for(; N--; ){
    int A, K; scanf("%d%d", &A, &K);

    for(;;){
      int x = (A + K - 1) / K, y = A % K;
      if(y % x == 0){ A -= y; break; }
      A -= (y + x - 1) / x * x;
    }
    s ^= A / K;
  }

  puts(s == 0 ? "Aoki" : "Takahashi");
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  int a[100];
  int count=0;
  int i;
  int j;
  int tmp;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf(" %d",&a[i]);
  }

  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(a[j] < a[j-1]){
	tmp = a[j];
	a[j] = a[j-1];
	a[j-1] = tmp;
	count++;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}



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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int d,t,s;
  cin>>d>>t>>s;
  cout<<(d<=t*s?"Yes":"No")<<newl;
  return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  a*=b;
  a%=2;
  if (a==1){
    cout <<"Odd" << endl;
  }
  else if (a==0){
    cout <<"Even" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())

score = N
counter_tmp = 0
ans = 0


for i in range(N):
    counter_tmp = 0
    score = i + 1
    while score < K:
        score = score * 2
        counter_tmp += 1
    ans += 1 / (N * (2 ** counter_tmp))

print(ans)

Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(void) {

	int a, b;
	cin >> a >> b;

	a *= 10;
	b *= 10;
	int c = (a + b) / 2;
	int mod = c % 10;
	if (mod > 0) {
		c += 10;
	}

	cout << (c / 10) << endl;

	return 0;
}



Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int num = 1;
        int ans = 0;
        while(num < B) {
            ans++;
            num += (A - 1);
        }

        System.out.println(ans);
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int,int> ii;

const int N = 1e5 + 5;

int n,m,ans = 1;

bool check(int x) {
  if (m / x >= n)
    return true;
  return false;
}

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

  cin >> n >> m;

  for (int i = 1 ; 1ll * i * i <= m ; i++) {
    if (m % i == 0) {
      if (check(i)) ans = max(ans,i);
      if (check(m / i)) ans = max(ans, m / i);
    }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define in(x) int x; cin>>x;
#define ll long long int 
#define din(a) double a; cin>>a;
#define lin(x) ll x; cin>>x;
#define vi vector<int>
#define si set<int>
#define pb push_back
#define re(i,n) for(ll i=0; i<n; i++)
#define pe(i,a,b) for(ll i=a; i<b; i++)
#define rre(i,n) for(ll i=n-1; i>=0; i--) 
#define ppe(i,a,b) for(ll i=b-1;i>=a;i--)
#define mp make_pair
#define pii pair<ll,ll>
#define endl "\n"
#define pi 3.1415926536 
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
  in(n)
  map<int, int> m;
  int v[n];
  int sum=0;
  re(i, n)
  {
   cin>>v[i];
    m[v[i]]++;
    
  }
  re(i, n)
  {
    if(m[v[i]]>v[i])
    {
      sum+=(m[v[i]]-v[i]);
      m[v[i]]=v[i];
    }
    if(m[v[i]]<v[i])
    {
      sum+=m[v[i]];
        m[v[i]]=v[i];
    }
  }
  cout<<sum;
  return 0;
 
  }

Measured memory_bytes: 8380
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
/*
struct dice {
	int s[6];
	void roll(char c) {
		int b;
		if (c == 'E') {
			b = s[0];
			s[0] = s[3];
			s[3] = s[5];
			s[5] = s[2];
			s[2] = b;
		}
		if (c == 'N') {
			b = s[0];
			s[0] = s[1];
			s[1] = s[5];
			s[5] = s[4];
			s[4] = b;
		}
		if (c == 'S') {
			b = s[0];
			s[0] = s[4];
			s[4] = s[5];
			s[5] = s[1];
			s[1] = b;
		}
		if (c == 'W') {
			b = s[0];
			s[0] = s[2];
			s[2] = s[5];
			s[5] = s[3];
			s[3] = b;
		}
		if (c == 'R') {
			b = s[1];
			s[1] = s[3];
			s[3] = s[4];
			s[4] = s[2];
			s[2] = b;
		}
	}
	int top() {
		return s[0];
	}
	int right() {
		return s[2];
	}
	int left() {
		return s[3];
	}
	int front() {
		return s[1];
	}

};

int main() {
	dice d;
	for (int i = 0; i < 6; i++) {
		cin >> d.s[i];
	}
	int order;
	cin >> order;
	while(order--) {
		int top, front;
		cin >> top >> front;
		if (d.left() == top) {
			d.roll('E');
		}
		if (d.right() == top) {
			d.roll('W');
		}
		while (d.top() != top) {
			d.roll('N');
		}
		while (d.front() != front) {
			d.roll('R');
		}
		cout << d.right() << endl;
	}
}
*/

int main() {
	int n, x[100] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	int m, a;
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (x[a] != x[a - 1] + 1 && x[a-1] != 2019) {
			x[a - 1]++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << x[i] << endl;
	}
}


Measured memory_bytes: 3112
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const int error=1e9-7;
#define F first
#define S second
#define MK make_pair
int b[10][10][10]={};
int ansp[10][10]={};

int dfs_ans(int x,int y,int c){
    int ans=0;
    ansp[x][y]=-1;
    ans++;
    if(x!=9 && ansp[x+1][y]==c){ans+=dfs_ans(x+1,y,c);}
    if(y!=9 && ansp[x][y+1]==c){ans+=dfs_ans(x,y+1,c);}
    if(x!=0 && ansp[x-1][y]==c){ans+=dfs_ans(x-1,y,c);}
    if(y!=0 && ansp[x][y-1]==c){ans+=dfs_ans(x,y-1,c);}
    return ans;
}

int ans(int c){
    int mx=0;
    for(int i=0;i<10;i++){
        for(int t=0;t<10;t++){
            ansp[i][t]=b[5][i][t];
        }
    }
    for(int i=0;i<10;i++){
        for(int t=0;t<10;t++){
            if(ansp[i][t]==c){mx=max(mx,dfs_ans(i,t,c));}
        }
    }
    return mx;
}

void dfs_change(int x,int y,int t,int k,int c){
    if(k==c){return;}
    b[t][x][y]=c;
    if(x!=9 && b[t][x+1][y]==k){dfs_change(x+1,y,t,k,c);}
    if(y!=9 && b[t][x][y+1]==k){dfs_change(x,y+1,t,k,c);}
    if(x!=0 && b[t][x-1][y]==k){dfs_change(x-1,y,t,k,c);}
    if(y!=0 && b[t][x][y-1]==k){dfs_change(x,y-1,t,k,c);}
}

void change(int t,int c){
    for(int i=0;i<10;i++){
        for(int h=0;h<10;h++){
            b[t+1][i][h]=b[t][i][h];
        }
    }
    dfs_change(0,0,t+1,b[t+1][0][0],c);
}

int search(int t,int c){
    if(t==5){return ans(c);}
    int mx=0;
    for(int i=1;i<=6;i++){
        change(t,i);
        mx=max(mx,search(t+1,c));
    }
    return mx;
}





int main(){
    while(1){
    
    
    
    int h,w,c;
    cin>>h>>w>>c;
        if(h==0 && w==0 && c==0){break;}
    for(int i=0;i<10;i++){
        for(int t=0;t<10;t++){
            b[0][i][t]=0;
        }
    }
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            cin>>b[0][i][t];
        }
    }
    cout<<search(0,c)<<endl;
    
    }
    
    return 0;
}


Measured memory_bytes: 3072
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	Long N = Long.parseLong(stdIn.next());
	Long A = Long.parseLong(stdIn.next());
	Long B =  Long.parseLong(stdIn.next());
	Long k = N/(A+B)*A;
	Long n =N%(A+B);
	Long j=Math.min(n,A);
	System.out.println(k+j);
    }
}


Measured memory_bytes: 22868
/*
	Failure is not the reason for you to stop trying 
	   it is actually a remainder that you should 
			KEEP GOING 
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int a,b;
		cin>>a>>b;
		int x = __gcd(a,b);
		cout << (a*b)/x  << endl;
	
	
	}
	
	cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}



Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASumOfTwoIntegers solver = new ASumOfTwoIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASumOfTwoIntegers {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong();

            if (n % 2 == 0)
                out.println(n / 2 - 1);
            else
                out.println(n / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> X >> Y>> N;
  cout << N << " " << X << " " << Y;
  

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return 1;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k%2 == 1){
		ret *= x;
		ret %= M;
	}
	return ret;
}
ll FAC[200010];
ll FAC_inv[200010];
ll POW[200010];
ll POW_inv[200010];
ll inv2;
void math_init(){
	FAC[0] = 1;
	rep1(i,200000){
		FAC[i] = FAC[i-1]*i;
		FAC[i] %= M;
	}
	rep(i,200001){
		FAC_inv[i] = modpow(FAC[i],M-2);
	}
	inv2 = modpow(2,M-2);
	POW[0] = 1;
	POW_inv[0] = 1;
	rep1(i,200000){
		POW[i] = POW[i-1]*2;
		POW[i] %= M;
		POW_inv[i] = modpow(POW[i],M-2);
	}
}
ll C(ll n,ll k){
	ll ret = FAC[n];
	ret *= FAC_inv[k]; ret %= M;
	ret *= FAC_inv[n-k]; ret %= M;
	return ret;
}

int main(){
	math_init();
	ll B,W;
	cin >> B >> W;
	
	ll b = 0, w = 0;
	rep(i,B+W){
		if(i >= B){
			ll _b = C(i-1,B-1)*inv2;
			_b %= M;
			_b *= POW_inv[i-1];
			b += _b;
			b %= M;
		}
		if(i >= W){
			ll _b = C(i-1,W-1)*inv2;
			_b %= M;
			_b *= POW_inv[i-1];
			w += _b;
			w %= M;
		}
		//cout << i << " " << b << " " << w << endl;
		ll ret = w+(1+2*M-b-w)*inv2;
		ret %= M;
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 8448
#include<iostream>
#include<cstdio>
using namespace std;
int n;
void Counting_Sort(int A[],int B[],int k){
  int *C = new int[k+1];
  for(int i=0;i<=k;i++)C[i]=0;
  for(int j=1;j<=n;j++)C[A[j]] = C[A[j]] + 1;
  for(int i=1;i<=k;i++)C[i]=C[i]+C[i-1];
  for(int j=n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  delete [] C;
}

int main(){
  while(scanf("%d",&n) != EOF){
    int k=0;
    int *A = new int[n+2];
    int *B = new int[n+2];
    for(int i=1;i<=n;i++){
      scanf("%d",&A[i]);
      if(k<A[i])k=A[i];
    }
    Counting_Sort(A,B,k);

    for(int i=1;i<=n;i++){

      cout << B[i];

      if(i != n)cout << " ";

    }
    cout << endl;
    delete [] A;
    delete [] B;

  }

  return 0;

}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            for(int i = 0; i < 3; i++) {
                int start = encode(scn.nextInt(), scn.nextInt(), scn.nextInt());
                int end   = encode(scn.nextInt(), scn.nextInt(), scn.nextInt());
                System.out.println(decode(end - start));
            }
        }
    }

    private static int encode(int h, int m, int s) {
        return h * 3600 + m * 60 + s;
    }

    private static String decode(int s) {
        return s / 3600 + " " + s % 3600 / 60 + " " + s % 60;
    }
}

Measured memory_bytes: 25832
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:>
 ?????????============================================================
 
 =================================================================
 
 ?§£??¬=============================================================
 
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    ll G[10][10];
    bool used[10];
    while(cin >> n){
        if(n==0) break;
        for(int i = 0; i < 10;i++)for(int j = 0;j < 10;j++) G[i][j] = INF;
        for(int i = 0; i < 10;i++){
            used[i] = false;
            G[i][i] = 0;
        }
        for(int i = 0; i < n;i++){
            ll a,b,c; cin >> a >> b >> c;
            G[a][b] = min(G[a][b],c);
            G[b][a] = min(G[b][a],c);
            used[a] = used[b] = true;
        }
        for(int i = 0; i < 10;i++){
            for(int j = 0;j <10;j++){
                for(int k = 0;k < 10;k++){
                    G[j][k] = min(G[j][k],G[j][i]+G[i][k]);
                }
            }
        }
        ll id = -1,sum = INF;
        for(int i = 0; i < 10;i++){
            if(used[i] == false)continue;
            ll tmp = 0;
            for(int j = 0; j < 10;j++){
                if(i == j)continue;
                if(used[j] == false)continue;
                tmp += G[i][j];
            }
            if(tmp < sum){
                sum = tmp;
                id = i;
            }
        }
        cout << id << " " << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#pragma region Template
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define COL(x) cout << x << endl
#define CO(x) cout << x
//#define int long long

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX >> 1;
const int INF = INT_MAX >> 1;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b) * (static_cast<int>(a > b)*2 - 1); }
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数
#pragma endregion

signed main()
{	
	int A, B, C, K;
	cin >> A >> B >> C >> K;

	int ans = 0;

	if (A >= K) {
		ans = K;
	}
	else {
		ans += A;
		K -= A;
		if (B < K) {
			K -= B;
			if (C < K) {
				ans -= C;
			}
			else {
				ans -= K;
			}
		}
	}

	COL(ans);
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int l[n],M=-1;
	for(int i=0;i<n;i++)cin>>l[i];
	sort(l,l+n);
	int sum = 0;
	for(int i=0;i<n-1;i++){
		sum+=l[i];
	}
	if(sum>l[n-1]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
char s[100010];
int n,f[100010],sum[100010],last[3],nxt[100010][3],tmp[3],ans;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=0;
	for(int i=1;i<n;++i)flag|=s[i]==s[i+1];
	if(!flag)return printf("1"),0;
	for(int i=1;i<=n;++i)sum[i]=sum[i-1]+(s[i]=='a'?1:2);
	last[0]=last[1]=last[2]=n+1;
	for(int i=n;i;--i)
	{
		for(int j=0;j<=2;++j)tmp[(s[i]-'a'+1+j)%3]=last[j];
		for(int j=0;j<=2;++j)last[j]=tmp[j];
		last[s[i]-'a'+1]=i;
		for(int j=0;j<=2;++j)nxt[i][j]=last[j];
	}
/*	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=2;++j)printf("%d ",nxt[i][j]);
		printf("\n");
	}*/
	f[0]=1;
	for(int i=0,r=0;i<n;++i)
	{
		if(r<i+2)
		{
			r=i+2;
			while(r<=n&&s[r]!=s[r-1])++r;
		}
	//	printf("%d %d %d %d\n",i,r,nxt[r][((1+sum[i]-sum[r-1])%3+3)%3],nxt[r][((2+sum[i]-sum[r-1])%3+3)%3]);
		if(s[i+1]=='a')add(f[i+1],f[i]);
		else if(r<=n)add(f[nxt[r][((1+sum[i]-sum[r-1])%3+3)%3]],f[i]);
		if(s[i+1]=='b')add(f[i+1],f[i]);
		else if(r<=n)add(f[nxt[r][((2+sum[i]-sum[r-1])%3+3)%3]],f[i]);
	}
	for(int i=1;i<=n;++i)if((sum[n]-sum[i])%3==0)add(ans,f[i]);
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 2176
using System;

class Program
{
    static void Main(string[] args)
    {
        int[] aryCount = new int[26];
        string alpha = "abcdefghijklmnopqrstuvwxyz";

        while (true)
        {
            string inputData = Console.ReadLine();

            if (inputData == null || inputData.Length == 0)
            {
                break;
            }

            for (int i = 0; i < inputData.Length; i++ )
            {
                if (char.IsLower(inputData[i]))
                {
                    int num = inputData[i] - 'a';
                    aryCount[num]++;
                }
                else if (char.IsUpper(inputData[i]))
                {
                    int num = inputData[i] - 'A';
                    aryCount[num]++;
                }
            }
        }

        for (int i = 0; i < aryCount.GetLength(0); i++)
        {
            Console.WriteLine(alpha[i] + " : " + aryCount[i]);
        }

    }
}

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

int lcd(int p, int q) {
	int upper, lower, r;

	if (p >= q) upper = p, lower = q;
	else upper = q, lower = p;
	r = upper % lower;
	if (r)return lcd(lower, r);
	else return lower;
}

int main(void) {
	long long n, m;
	char s[100001] = { 0 }, t[100001] = { 0 };
	long long lcm;
	int flag = 1;

	scanf("%lld %lld", &n, &m);
	scanf("%s", s);
	scanf("%s", t);

	lcm = n * m / lcd(n, m);
	for (int i = 0; i < n; i++) {
		if (m * i % n == 0 && s[i] != t[m * i / n]) {
			flag = 0;
			break;
		}
	}
	if (flag)printf("%lld", lcm);
	else printf("-1");
	return 0;
}

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

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;
}

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

ll h[101000], dp[101000];

int main() {
  int N, K;
  cin >> N >> K;
  rep(i, N) cin >> h[i];

  rep(i, 101000) dp[i] = INFL;
  dp[0] = 0;
  FOR(i, 0, N) FOR(j, 1, K + 1) {
    chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
  }

  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> v(n + 1, 1);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        v[i + 1] = v[i] + a[i];
    }

    ll t1;
    ll t2 = v[k];

    for (ll i = k + 1; i <= n; i++)
    {
        t1 = t2;
        t2 -= a[i - k - 1];
        t2 += a[i - 1];;

        if (t1 < t2)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int W, H, N, S;
    cin >> W >> H >> N;
    S = 0;
    int x[N], y[N], a[N];
    int lx = 0, rx = W, by = 0, uy = H;
    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> y[i] >> a[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (a[i] == 1)
        {
            if(lx < x[i])
                lx = x[i];
        }
        else if (a[i] == 2)
        {
            if(rx>x[i])
                rx = x[i];
        }
        else if (a[i] == 3)
        {
            if(by<y[i])
                by = y[i];
        }
        else
        {
            if (uy > y[i])
                uy = y[i];
        
        }
    }
    if (uy>by&&rx>lx){
        S = (uy - by) * (rx - lx);
    }else{
        S = 0;
    }
    cout << S << endl;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int M;
	cin >> M;

	lint sum = 0, dig = 0;
	for (int i = 0; i < M; i++) {
		lint d, c;
		cin >> d >> c;
		sum += d * c;
		dig += c;
	}

	cout << dig - 1 + (sum - 1) / 9 << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int MAX = 25;
const int NIL = -1;
struct Node
{
	int parent;
	int left;
	int right;
}T[MAX];
void preorder(int u)
{
	if (u == NIL)
		return;
	printf(" %d", u);
	preorder(T[u].left);
	preorder(T[u].right);
}
void inorder(int u)
{
	if (u == NIL)
		return;
	inorder(T[u].left);
	printf(" %d", u);
	inorder(T[u].right);
}
void postorder(int u)
{
	if (u == NIL)
		return;
	postorder(T[u].left);
	postorder(T[u].right);
	printf(" %d", u);
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		T[i].parent = T[i].left = T[i].right = -1;
	}
	for (int i = 0; i < n; i++)
	{
		int p, l, r, d = 0;
		cin >> p >> l >> r;
		T[p].left = l;
		T[p].right = r;
		if (l != NIL)
			T[l].parent = p;
		if (r != NIL)
			T[r].parent = p;
	}
	int r;
	for (int i = 0; i < n; i++)
		if (T[i].parent == NIL)
		{
			r = i;
			break;
		}
	cout << "Preorder\n";
	preorder(r);
	cout << endl;
	cout << "Inorder\n";
	inorder(r);
	cout << endl;
	cout << "Postorder\n";
	postorder(r);
	cout<<endl;
}


Measured memory_bytes: 3192
import sys

N, K = map(int, sys.stdin.readline().split())
d = []
A = []
for i in range(K):
    temp_d = int(sys.stdin.readline())
    temp_A = list(map(int, sys.stdin.readline().split()))
    d.append(temp_d)
    A.append(temp_A)

temp = [i for i in range(1, N+1)]

sss = []
for i in A:
    for j in i:
        sss.append(j)

print(N - len(set(sss)))

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

typedef pair<int, int> P;
const int INF = 1e9;

int N, M;
vector<int> G[700];

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

  bool edges[N][N] = {{0}};
  fill_n(*edges, N*N, 0);  
  for ( int i = 0; i < M; i++ ) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    edges[a][b] = edges[b][a] = true;
  }

  // 補グラフ生成
  for ( int i = 0; i < N; i++ ) {
    for ( int j = 0; j < N; j++ ) { 
      if ( i == j ) continue;
      if ( !edges[i][j] ) {
	G[i].push_back(j);
      }
    }
  }
  
  vector<P> bi_graphs;
  bool flag = true;
  vector<int> used(N, -1);  
  for ( int i = 0; i < N; i++ ) {
    if ( used[i] >= 0 ) continue;
    int cnt[2] = {0};
    queue<P> Q;
    Q.push(P(i, 0)); // node, color
    while ( !Q.empty() ) {
      P p = Q.front(); Q.pop();
      int v = p.first, c = p.second;

      if ( used[v] >= 0 ) {
	if ( used[v] != c ) {
	  flag = false;
	  break;
	} else {
	  continue;
	}
      }

      used[v] = c;
      cnt[c]++;      
      for ( int u: G[v] ) {
	Q.push(P(u, !c));	
      }
    }
    
    if ( !flag ) break;
    bi_graphs.push_back(P(cnt[0], cnt[1]));    
  }

  if ( !flag ) {
    cout << -1 << endl;
    return 0;
  }

  int n = bi_graphs.size();
  vector<int> dp(N+1, 0), nxt(N+1, 0);
  dp[0] = 1;  
  for ( int i = 0; i < n; i++ ) {
    int a = bi_graphs[i].first, b = bi_graphs[i].second;
    nxt = vector<int>(N+1, 0);    
    for ( int j = N; j >= 0; j-- ) {
      if ( !dp[j] ) continue;
      if ( j+a <= N ) nxt[j+a] = true;
      if ( j+b <= N ) nxt[j+b] = true;
    }
    swap(dp, nxt);    
  }

  int ans = INF;
  for ( int i = 0; i <= N; i++ ) {    
    if ( !dp[i] ) continue;
    int a = 0, b = 0;
    if ( i >= 2 ) a = i*(i-1)/2;
    if ( N-i >= 2 ) b = (N-i)*(N-i-1)/2;          
    ans = min(ans, a+b);
  }

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


Measured memory_bytes: 7552
package main

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

const (
  InputSize = 500000 // 10^5
)
var (
  rdr = bufio.NewReaderSize(os.Stdin, InputSize)
)

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


func getStringArray() []string {
  return strings.Split(readLine(), " ")
}


func nextLineValue() int {
  v, _ := strconv.Atoi(readLine())
  return v
}

func nextLineValues() []int {
  return getIntArray(readLine())
}

func getInt(s string) int {
  v, _ := strconv.Atoi(s)
  return v
}

func getIntArray(s string) []int {
  var v []int
  valstr := strings.Split(s, " ")
  for _, c := range valstr {
    va, _ := strconv.Atoi(c)
    v = append(v, va)
  }
  return v
}

func digitTotal(v int) int {
  total := 0
  d := strings.Split(strconv.Itoa(v), "")
  for _, c := range d {
    dv, _ := strconv.Atoi(c)
    total += dv
  }
  return total
}

func sortDesc(v *[]int) {
  sort.Sort(sort.Reverse(sort.IntSlice(*v)))
}

func removeDupIntSlice(values *[]int) []int {
  m := make(map[int]bool)
  uniq := []int{}
  for _, v := range *values {
    if !m[v] {
      uniq = append(uniq, v)
      m[v] = true
    }
  }
  return uniq
}

func removeDupStringSlice(values *[]string) []string {
  m := make(map[string]bool)
  uniq := []string{}
  for _, v := range *values {
    if !m[v] {
      uniq = append(uniq, v)
      m[v] = true
    }
  }
  return uniq
}

func countUniqIntInSlice(values *[]int) map[int]int {
  uniq := make(map[int]int)
  for _, v := range *values {
    if _, ok := uniq[v]; !ok {
      uniq[v] = 1
    } else {
      uniq[v] += 1
    }
  }
  return uniq
}

func countUniqStringInSlice(values *[]string) map[string]int {
  uniq := make(map[string]int)
  for _, v := range *values {
    if _, ok := uniq[v]; !ok {
      uniq[v] = 1
    } else {
      uniq[v] += 1
    }
  }
  return uniq
}


func main() {
  vals := nextLineValues()

  n, a, b := vals[0], vals[1], vals[2]

  cnt := n / (a+b)
  rest := n % (a+b)

  if rest < a {
    ans := cnt * a + rest
    fmt.Println(ans)
  } else {
    ans := (cnt + 1) * a
    fmt.Println(ans)
  }
}


Measured memory_bytes: 640
# ARC069D - Menagerie (ABC055D)
def check(a: str, b: str, S: str) -> str:
    ret, cur, prev = "", a, b
    for i in S:
        ret += cur
        if (cur == "S" and i == "o") or (cur == "W" and i == "x"):
            prev, cur = cur, prev  # both neighbors are the same
        elif (cur == "S" and i == "x") or (cur == "W" and i == "o"):
            x = "W" if prev == "S" else "S"  # both are different
            prev, cur = cur, x
    flg = cur == a and prev == b  # check the consistency of input and result
    return ret if flg else ""


def main():
    N = int(input())
    S = input().rstrip()
    for a in ("S", "W"):
        for b in ("S", "W"):
            ans = check(a, b, S)
            if ans:
                print(ans)
                return
    print(-1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
a, b = map(int, input().split())

if a != 1 and b != 1:
    if a > b:
        print('Alice')
    elif a < b:
        print('Bob')
    else:
        print('Draw')
elif a == 1 and b != 1:
    print('Alice')
elif a != 1 and b == 1:
    print('Bob')
else:
    print('Draw')

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

void maxHeapify(int *,int,int);
void buildMaxHeap(int *,int);

int main()
{
  int i,H;
  int *A;
  
  scanf("%d",&H);
  A=(int *)malloc(sizeof(int)*H+1);


  for(i=1;i<H+1;i++)
    {
      scanf("%d",&A[i]);
    }

  buildMaxHeap(A,H);

  for(i=1;i<H;i++)
    {
      printf(" %d",A[i]);
    }
  printf(" %d\n",A[H]);
  

  

  return 0;
}

void maxHeapify(int *A,int i,int H)
{
  int largest,a,l,r;
  l=2*i;
  r=2*i+1;

  if(i>H) return;
  if(H>=l && A[l]>A[i]) largest=l;
  else largest=i;

  if(r<=H && A[r]>A[largest]) largest=r;

  if(largest!=i)
    {
      a=A[i];
      A[i]=A[largest];
      A[largest]=a;
      maxHeapify(A,largest,H);
    }
}

void buildMaxHeap(int *A,int H)
{
  int i;
  for(i=H/2;i>0;i--) maxHeapify(A,i,H);

}



Measured memory_bytes: 3688
from collections import defaultdict
from copy import copy
n = int(input())
a = [int(i) for i in input().split()]
count_a = defaultdict(int)
diff_a = [0] * n
for ai in a:
        count_a[ai] += 1

for i in range(n):
    diff_a[i] = (count_a[a[i]] - 1)

count = 0    
for v in count_a.values():
    count += v*(v - 1) // 2
for i in range(n):
    count_copy = copy(count)
    print(count_copy - diff_a[i])

Measured memory_bytes: 26860
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 55;
ll dp[maxN * maxN][maxN][maxN];
int a;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> a;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        for (int sum = 0; sum <= 50 * n; sum++) {
            for (int cnt = 0; cnt <= i - 1; cnt++) {
                dp[sum + x][cnt + 1][i] += dp[sum][cnt][i - 1];
                dp[sum ][cnt][i] += dp[sum][cnt][i - 1];
            }
        }
    }
    ll ans = 0;
    for (int cnt = 1; cnt <= n; cnt++) {
        ans += dp[cnt * a][cnt][n];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 61696
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define rint register int
#define INF ((1 << 30) - 1)
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define Pair pair < int, int >
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i, k, j) for(rint i = (k); i >= (j); i--)
#define For(i, k, j) for(rint i = (k); i <= (j); i++)
#define Foe(i, u) for(rint i = lst[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
#define int long long
int P = 998244353; //
using namespace std;
inline void ckmax(int &a, int b) {a = max(a, b);}
inline void ckmin(ll &a, ll b) {a = min(a, b);}
inline void mulmod(int &a, int b) {a = 1ll * a * b % P;}
inline void addmod(int &a, int b) {int t = a + b; a = (t >= P ? t - P : t); }
inline int ksm(int a, int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline int inv(int a) {return ksm(a, P-2);}
const int MAXN = 2e5 + 5;
int n, x, a[MAXN], lst[MAXN];
signed main()
{
  ios::sync_with_stdio(false),cin.tie(0);
	cin >> n >> x >> P;
	if(n <= P) {
		int res = x;
		For(i, 2, n) {
			x = 1ll * x * x % P; res += x;
		}
		cout<< res <<endl;
	} else {
		a[1] = x % P; lst[x] = 1;
		int st = 0, len = 0, res = 0, t = 0, f = 0;
		For(i, 2, 2 * P) {
			a[i] = 1ll * a[i-1] * a[i-1] % P;
			if(!lst[a[i]]) lst[a[i]] = i;
			else {
				if(f) continue;
				f = 1;
				st = lst[a[i]], len = i - lst[a[i]]; 
				For(j, lst[a[i]] + 1, i) t += a[j];
			}
		}
		For(i, 1, st) res += a[i];
		res += ((n - st) / len) * t;
		foR(i, n, n - (n - st) % len + 1) {
			res += a[st + ((i - st) % len)];
		}
		cout << res <<endl;
	}
}

Measured memory_bytes: 5892
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    ll n,k;
    cin >> n  >> k;
    vl vec(n);
    rep(i,n) cin >> vec[i];
    ll cnt = 0;

    rep(i,n){
        reps(j,i+1,n){
            if(i == j) continue;
            if(vec[i] > vec[j]) cnt++;
        }
    }
    //cout << cnt << endl;
    ll mod = 1e9+7;
    ll sum1 = (cnt * k) % mod;
    
    ll cnt2 = 0;
    rep(i,n){
        rep(j,n){
            if(i == j)continue;
            if(vec[i] > vec[j]) cnt2++;
        }
    }

    ll sum2 = 0;
    if(k % 2 == 0){
        sum2 = k/2;
        sum2 = (sum2*(k-1)) % mod;
    }else{
        sum2 = (k-1)/2;
        sum2 = (sum2*k) % mod;
    }
    
    sum2 = (sum2*cnt2) % mod;
    ll ans = (sum1 + sum2) % mod;

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


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
void insert(int k);
typedef struct node * Node;
void inorder(Node u);
void preorder(Node u);
Node find(Node u, int k);
#define NIL NULL
Node root;
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      // printf("\n");
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
    }
  }
  return 0;
}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key < y->key)y->left=z;
  else y->right=z;
}
void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
Node find(Node u, int k){
  //printf("test\n");
  if(u->key==k)return u;
  if(u->key==NIL)return NIL;
  if(k < u->key){
    if(u->left!=NIL)
    u=find(u->left,k);
    else return NIL;
  }
  else if(u->right!=NIL)u=find(u->right,k);
  else return NIL;
  //return u;
}



Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b;
    cin >> a >> b;
    int X = a * b;
    if ( X % 2 == 0){
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl; 
    }
}

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

int maxtime(int x){
	return (x+9)/10*10;
}

int remtime(int x){
	return maxtime(x)-x;
}

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

	int ans = maxtime(a)+maxtime(b)+maxtime(c)+maxtime(d)+maxtime(e);
	ans -= max({remtime(a),remtime(b),remtime(c),remtime(d),remtime(e)});
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636