akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	ans := Min(N, M/2)
	M -= 2 * ans
	ans += M / 4
	fmt.Println(ans)
}

func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1768
n=int(input())
l=list(map(int,input().split()))
a=0
b=abs(l[0]-l[1])
for i in range(2,n):
    h1=a+abs(l[i]-l[i-2])
    h2=b+abs(l[i]-l[i-1])
    a=b
    b=min(h1,h2)
print(b)

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

const int N = 3010;

typedef long long LL;

int mod;

inline int Pow(int x, int y, int mod = mod) {
	int res = 1;
	for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
	return res; 
}

int S[N][N], C[N][N];

inline void init(int n) {
	S[0][0] = 1;
	for (int i = 0; i <= n; i++) {
		C[i][0] = 1;
		for (int j = 1; j <= i; j++) 
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	for (int i = 1; i <= n; i++) {
		S[i][1] = 1;
		for (int j = 1; j <= i; j++)
			S[i][j] = (S[i - 1][j - 1] + (LL)S[i - 1][j] * j) % mod;
	}
}

int main() {
	int n, res = 0; cin >> n >> mod, init(n + 1);
	for (int i = 0; i <= n; i++) {
		int other = Pow(2, Pow(2, n - i, mod - 1)), tmp = (LL)C[n][i] * other % mod, base = Pow(2, n - i);
		for (int j = 1, t = base; j <= i; j++) {
			tmp = (tmp + (LL)C[n][i] * t % mod * other % mod * S[i + 1][j + 1]) % mod;
			t = (LL)t * base % mod;
		}
		if (i & 1) res = (res - tmp + mod) % mod;
		else res = (res + tmp) % mod;
	}
	cout << res << endl;
}

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

int main(){
  int N;
  string S;
  cin>>S;
  
  N=S.size();
  
  int num0=0;
  int num1=0;
  
  for(int i=0;i<N;i++){
    if (S.at(i)=='0') num0++;
    else num1++;
  }
  
  cout<<2*min(num0,num1)<<endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    vector<ll> x(n);
    x[0] = sum / 2;
    for (int i = 1; i < n; i += 2)
        x[0] -= a[i];
    for (int i = 1; i < n; i++)
    {
        x[i] = a[i - 1] - x[i - 1];
    }
    for (int i = 0; i < n; i++)
        x[i] *= 2;
    printv(x);
}


Measured memory_bytes: 2944
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
template <typename Abelian>
struct BIT {
  BIT(int n, const Abelian UNITY_ = 0) : n(n), UNITY(UNITY_), dat(n, UNITY_) {}

  void add(int idx, Abelian value) {
    while (idx < n) {
      dat[idx] += value;
      idx |= idx + 1;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    while (idx >= 0) {
      res += dat[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return res;
  }

  int lower_bound(Abelian value) {
    if (value <= UNITY) return 0;
    int res = 0, exponent = 1;
    while (exponent <= n) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask - 1 < n && dat[res + mask - 1] < value) {
        value -= dat[res + mask - 1];
        res += mask;
      }
    }
    return res;
  }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat;
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int q; cin >> q;
  vector<int> a;
  vector<int> query(q), q_a(q), q_b(q);
  REP(i, q) {
    cin >> query[i];
    if (query[i] == 1) {
      cin >> q_a[i] >> q_b[i];
      a.emplace_back(q_a[i]);
    }
  }
  sort(ALL(a));
  vector<int> doko(q);
  map<int, int> mp;
  REP(i, q) if (query[i] == 1) {
    int idx = lower_bound(ALL(a), q_a[i]) - a.begin();
    doko[i] = idx + mp[q_a[i]];
    ++mp[q_a[i]];
    // cout << doko[i] << '\n';
  }
  BIT<long long> bit(a.size()), cnt(a.size());
  long long b = 0;
  REP(i, q) {
    if (query[i] == 1) {
      bit.add(doko[i], q_a[i]);
      b += q_b[i];
      cnt.add(doko[i], 1);
      // cout << bit.sum(doko[i]) - bit.sum(doko[i] - 1) << '\n';
      // cout << q_a[doko[i]] << '\n';
    } else {
      int doredake = cnt.sum(a.size() - 1);
      int cen = (doredake % 2 == 0 ? doredake / 2 - 1 : doredake / 2);
      int idx = cnt.lower_bound(cen + 1);
      long long ans = b;
      ans += (long long)a[idx] * cnt.sum(idx - 1);
      ans -= bit.sum(idx - 1);
      ans += bit.sum(a.size() - 1) - bit.sum(idx);
      ans -= (long long)a[idx] * (cnt.sum(a.size() - 1) - cnt.sum(idx));
      cout << a[idx] << ' ' << ans << '\n';
    }
    // REP(i, a.size()) cout << bit.sum(i) - bit.sum(i - 1) << ' ';
    // cout << '\n';
    // REP(i, a.size()) cout << cnt.sum(i) - cnt.sum(i - 1) << ' ';
    // cout << '\n';
    // cout << "-----\n";
  }
  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int F[n][10], P[n][11];
    rep(i, n)
    {
        rep(j, 10) cin >> F[i][j];
    }
    rep(i, n)
    {
        rep(j, 11) cin >> P[i][j];
    }
    //以上入力まで

    //ビット全探索
    ll ans = -MOD;
    for (int i = 1; i < (1 << 10); i++)
    {
        ll res = 0;
        rep(j, n)
        {
            int cnt = 0;
            rep(k, 10)
            {
                if ((i & (1 << k)) && F[j][k])
                    cnt++;
            }
            res += P[j][cnt];
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A, B, C, D = gets.split.map(&:to_i)
E = C.to_i.lcm(D.to_i)

x = (B / C) - ((A-1) / C)
y = (B / D) - ((A-1) / D)
z = (B / E) - ((A-1) / E)

puts ((B - A + 1) - (x + y - z))

Measured memory_bytes: 1788
import scala.io.StdIn.{readLine,readInt}

object Main {

  def main(args: Array[String]) = {
    val n = readInt
    val a = Array.ofDim[Int](4,3,10)

    1 to n foreach { _ =>
      val Array(b,f,r,v) = readLine.split(" ").map(_.toInt)
      a(b-1)(f-1)(r-1) += v
    }

    for(i <- 0 to 3) {
      for(j <- 0 to 2) {
        for(k <- 0 to 9) {
          print(" "+a(i)(j)(k))
        }
        println()
      }
      if(i<3) {
        println("####################")
      }
    }
  }
}

Measured memory_bytes: 44272
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int i=1;

            while(x!=0){

                System.out.println("Case " + i++ + ": " + x);

                x = sc.nextInt();
            }

        }
    }


Measured memory_bytes: 45280
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    s=[[] for _ in range(H+2)]
    s[0]=s[H+1]=[-1]*(W+2)
    for i in range(1,H+1):
        s[i]=[-1]+list(map(lambda s:int(s.replace('.','0').replace('#','1')),list(input())))+[-1]
        s[i]
    
    dp=[[INF]*(W+2) for _ in range(H+2)]
    dp[1][1]=s[1][1]
    for column in range(1,H+1):
        for row in range(1,W+1):
            if s[column-1][row]!=-1:
                if s[column][row]==s[column-1][row]+1:
                    dp[column][row]=min(dp[column][row],dp[column-1][row]+1)
                else:
                    dp[column][row]=min(dp[column][row],dp[column-1][row])
            if s[column][row-1]!=-1:
                if s[column][row]==s[column][row-1]+1:
                    dp[column][row]=min(dp[column][row],dp[column][row-1]+1)
                else:
                    dp[column][row]=min(dp[column][row],dp[column][row-1])
    print(dp[H][W])
            
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 41840
// 7/4 Tuesday
#include <iostream>

using namespace std;

int main(){
	int r, g, b, t;
	bool m1 = true;

	cin >> r >> g >> b;
	t = r * 100 + g * 10 + b;

	while (t >= 0) {
		if (t == 0) {
			cout << "YES" << endl;
			m1 = false;
			break;
		}
		t = t-4;
	}
	if (m1) {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
a_1 = []
a_2 = []
for i in range(m):
    t = list(map(int,input().split()))
    if t[0] == 1:
        a_1.append(t[1])
    if t[1] == n:
        a_2.append(t[0])
    a.append(t)

a = a_1 + a_2
if len(set(a)) < len(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 152228
N,K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

flag = [0] * N
score = 0
for i in range(N):
    if i >= K and flag[i-K] == 0 and T[i] == T[i-K]:
        flag[i] = 1
        continue
    if T[i] == 'r':
        score += P
    if T[i] == 's':
        score += R
    if T[i] == 'p':
        score += S
print(score)

Measured memory_bytes: 42352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

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

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

      return tokenizer.nextToken("\n");
    }

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

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    Map<Integer, Integer> counters = new HashMap<>();
    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for (int j = 0; j < k; j++) {
        counters.merge(sc.nextInt(), 1, Integer::sum);
      }
    }
    int counter = 0;
    for (int c : counters.values()) {
      if (c == n) counter++;
    }
    System.out.println(counter);
  }
}

Measured memory_bytes: 26580
using System;

namespace AtCoder._20200613
{
    class A_Nickname
    {
        public class QuestionA
        {
            public static void Main(string[] args)
            {
                // 文字列の入力
                string s = Console.ReadLine();

                string res = s;

                //var res = s.Take(3).ToString();
                if (res.Length > 3)
                {
                    var astra = res.Remove(3, res.Length - 3);
                    res = astra;
                }

                string result = res;

                Console.WriteLine(result);
            }
        }
    }
}


Measured memory_bytes: 25880
#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 (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

const int MAX_N=1e5+10;

int N; ll M;
vector<vector<int>> G(MAX_N);
vector<ll> dat(MAX_N,1),ans(MAX_N,1);

void dfs1(int v,int p){
    for (int u:G[v]){
        if (u==p) continue;
        dfs1(u,v);
        dat[v]=dat[v]*((dat[u]+1)%M)%M;
    }
}

void dfs2(int v,int p,ll d_par){
    int n=G[v].size(),now=1,np;
    map<int,int> m1,m2;
    vector<ll> cs1(n+1),cs2(n+1,1);
    ans[v]=cs1[0]=(d_par+1)%M;
    rep(i,n){
        if (G[v][i]==p){np=i; continue;}
        m1[i]=now-1;
        cs1[now]=cs1[now-1]*((dat[G[v][i]]+1)%M)%M,++now;
        ans[v]=ans[v]*((dat[G[v][i]]+1)%M)%M;
    }
    now=1;
    rep(i,n){
        if (G[v][n-1-i]==p) continue;
        m2[n-1-i]=now-1;
        cs2[now]=cs2[now-1]*((dat[G[v][n-1-i]]+1)%M)%M,++now;
    }
    rep(i,n){
        if (G[v][i]==p) continue;
        dfs2(G[v][i],v,cs1[m1[i]]*cs2[m2[i]]%M);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i,N-1){
        int a,b; cin >> a >> b; --a,--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(0,-1);
    if (N>1) dfs2(0,-1,0);
    rep(i,N) cout << ans[i] << endl;
}

Measured memory_bytes: 40832
#include<stdio.h>
int N,i,x;
int main()
{
	scanf("%d",&N);
	for(i=1;i<=N;i++)
	{
		x=i;
		if(x%3==0)printf(" %d",i);
		else
		{
			for(;x&&x%10!=3;)
				x/=10;
			if(x%10==3)
				printf(" %d",i);
		}
	}
	puts("");
	return 0;
}

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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=1;i<=100;i++){
        if((a*i)%b==c){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
		System.out.println((int)Math.ceil((double)n/x)*t);
		sc.close();
	}
}

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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++) {
        cin >> b[i];
    }
    ans += b[0] + b[n - 2];
    for (int i = 0; i < n - 2; i++) {
        ans += min(b[i], b[i + 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int A,B;
  scanf ("%d %d",&A,&B);
  if (A==1&&B==2)
  printf ("3\n");
  if (A==2&&B==1)
  printf ("3\n");
  if (A==2&&B==3)
  printf ("1\n");
  if (A==3&&B==2)
  printf ("1\n");
  if (A==1&&B==3)
  printf ("2\n");
  if (A==3&&B==1)
  printf ("2\n");
  
  return 0;
}

Measured memory_bytes: 1560
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class AWeLoveGolf {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int k,a,b;
        in >> k >> a >> b;
        for(int i=a;i<=b;i++){
            if(i%k==0){
                out << "OK" << endl;
                return ;
            }
        }
        out << "NG" << endl;
	}
};


int main() {
	AWeLoveGolf solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    using triple = tuple<i64,i64,i64>;
    vector<triple> wsv(N);
    rep(i,0,N) {
        i64 wi,si,vi;
        cin >> wi >> si >> vi;
        wsv[i]=make_tuple(wi,wi+si,vi);
    }

    sort(begin(wsv),end(wsv),[](const triple& a, const triple& b){
       return get<1>(a)<get<1>(b);
    });

    vector<i64> w(N),s(N),v(N);
    rep(i,0,N){
        tie(w[i],s[i],v[i])=wsv[i];
    }

    const i64 maxws=20010;
    static i64 dp[maxws]; // (全体の重さ)
    fill_n((i64*)dp,maxws,-inf64);
    dp[0]=0;
    dp[w[0]]=v[0];

    rep(i,1,N){
        for(i64 j=s[i]; j>=w[i]; --j){;
            chmax(dp[j],dp[j-w[i]]+v[i]);
        }
    }

    i64 ans=-inf64;
    rep(i,0,maxws) chmax(ans,dp[i]);

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 512
import fractions

A, B, C, D = map(int, input().split())

lcm = C * D // fractions.gcd(C, D)

div_c = (B // C) - (A // C)
if A // C != 0 and A % C == 0:
    div_c += 1
div_d = (B // D) - (A // D)
if A // D != 0 and A % D == 0:
    div_d += 1
div_cd = (B // (lcm)) - (A // (lcm))
if A // (lcm) != 0 and A % lcm == 0:
    div_cd += 1

ans = (B - A + 1) - (div_c + div_d - div_cd)
print(ans)

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

namespace ConsoleApplication1
{
    struct Player : IComparable
    {
        internal int id;
        internal double time;

        public override string ToString()
        {
            return id + " " + time;
        }

        public int CompareTo(object obj)
        {
            Player other = (Player)obj;
            if (time < other.time) return -1;
            if (time == other.time) return 0;
            return 1;
        }
    }

    class Competition
    {
        StringBuilder sb;
        Player[] list1, list2, list3;
        List<Player> final;

        public Competition()
        {
            sb = new StringBuilder();
            list1 = new Player[8];
            list2 = new Player[8];
            list3 = new Player[8];
            final = new List<Player>();
        }

        public void Solve()
        {
            MakeList(list1);
            MakeList(list2);
            MakeList(list3);

            final.Sort();

            for (int i = 0; i < 2; i++)
            {
                sb.AppendLine(final[i].ToString());
            }
            Console.Write(sb);
        }

        private void MakeList(Player[] list)
        {
            for (int i = 0; i < 8; i++)
            {
                string[] input = Console.ReadLine().Split(' ');

                Player temp;
                temp.id = int.Parse(input[0]);
                temp.time = double.Parse(input[1]);
                list[i] = temp;
            }

            Array.Sort(list);

            for (int i = 0; i < 2; i++)
            {
                sb.AppendLine(list[i].ToString());
                final.Add(list[i + 2]);
            }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Competition c = new Competition();
            c.Solve();
        }
    }
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 1e5+10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


// Main Code

ll arr[N];
map<ll, ll> mp;

int main()
{
	int n, m;
	cin>>n>>m;
	ll ans = 0;
	ll sum = 0;
	rep(i, 0, n)
	{
		ll x;
		cin>>x;
		sum += x;
		ll mod = sum % m;
		ans += mp[mod];
		mp[mod]++;
		if(mod == 0) ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] p = new int[N];


            for (int i = 0; i < N; i++) {
                p[i] = int.Parse(Console.ReadLine());

            }

            Console.WriteLine(p.Sum() - p.Max() / 2);

        }
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),OUT(YES),OUT(NO))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
typedef pair<ld, ut> pld;
ut N, M, K, Q, D, H, W,R;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE]={0,3,2,1},B[SIZE]={0,3,2,1};
LL sum[SIZE];
LL solve(){
	cin >> M;
	LL a,b;
	LL keta=0,sum=0;
	REP(i,M){
		LL d,c;
		cin >> d >> c;
		sum+=d*c;
		keta+=c;
	}
	return (sum-1)/9+keta-1;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	string s;
	LL T;
	DEFAULT;
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}

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

int main() {
    int n;
    cin>>n;
    vector<pair<int,int>> A;
    int a,b;
    for(int i=0;i<n;i++){
        cin>>a >> b;
        A.push_back({a,b});
    }
    int as=A.size();
    for(int i=0;i<as-2;i++){
        if(A[i].first==A[i].second){
            if(A[i+1].first==A[i+1].second){
                if(A[i+2].first==A[i+2].second){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout <<"No" << endl;
    return 0;
}


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

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

    int max = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] > max) max = a[i];
    }

    bool dp[1000001];
    bool used[1000001];
    for (int i = 1; i <= max; i++) {
        dp[i] = false;
        used[i] = false;
    }

    sort(a, a + n);

    for (int i = 0; i < n; i++) {
        if (used[a[i]]) {
            dp[a[i]] = true;
            continue;
        }
        for (int j = 2; j <= max / a[i]; j++) {
            dp[a[i] * j] = true;
        }
        used[a[i]] = true;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (!dp[a[i]]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6300
N = gets.to_i
count = { AC: 0, WA: 0, TLE: 0, RE: 0 }
N.times do
  key = gets.chomp.to_sym
  count[key] +=1
end

puts "AC x #{count[:AC]}"
puts "WA x #{count[:WA]}"
puts "TLE x #{count[:TLE]}"
puts "RE x #{count[:RE]}"


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

using namespace std;

void hawawa()
{
	int a, b;
	cin >> a >> b;
	if (max(a, b) <= 8) {
		cout << "Yay!\n";
	}
	else {
		cout << ":(\n";
	}
}

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


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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int dx = c-a;
  int dy = d-b;
  int x3 = c - dy, y3 = d + dx, x4 = a - dy, y4 = b + dx;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << " " << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
	int total_n;
	int i;
	

		int A,B,T;
		cin >> A;
		cin >> B;
		cin >> T;
		
	cout << (T/A)*B << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
char a[8][8];
signed main(){
	int h,w,cnt=0;
	cin>>h>>w;
		rep(i,h){
			rep(j,w){
				cin>>a[i][j];
			}
		}
		rep(i,h){
			rep(j,w){
				if(a[i][j]=='#')cnt++;
			}
		}
		if(cnt==h+w-1)puts("Possible");
		else puts("Impossible");
}
		
		


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

using namespace std;
int main() {
    int A, B;
    string S;

    cin >> A >> B >> S;

    for (int i = 0; i < A+B+1; i++) {
        if (i == A) {
            if (S[i] != '-') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if ( !(S[i] >= '0' && S[i] <= '9') ) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int sum = 0;
			for(int i = 0 ; i < 4 ; i++){
				sum += sc.nextInt();
			}
			int min = sum/60;
			int sec = sum%60;
			System.out.println(min);
			System.out.println(sec);
		}
	}

}

Measured memory_bytes: 17360
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    List<Long> list=new ArrayList<>();
    Map<Long,Long> map=new TreeMap<>();
    for(int i=0;i<n;i++) {
    	long buff=sc.nextInt();
    	if(map.containsKey(buff)) {
    		map.put(buff, map.get(buff)+1);
    	}else {
    		map.put(buff, 1L);
    	}
    }
    for (Long key : map.keySet()){
    	if(map.get(key)>=2) {
    		long buff=map.get(key);
    		while(buff>=2) {
    			list.add(key);
    			buff-=2;
    		}
    	}
    }
    if(list.size()>=2)System.out.println(list.get(list.size()-1)*list.get(list.size()-2));
    else System.out.println(0);
  }
}


Measured memory_bytes: 64940
s = int(input())
i = 1
if s == 1 or s == 2:
  print(4)
  exit()
while True:
  if s == 4:
    print(i+3)
    exit()
  if s%2 == 0:
    s=s//2
  else:
    s=3*s+1
  i += 1

Measured memory_bytes: 9124
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys
N = int(sys.stdin.readline())

print(10-N//200)


Measured memory_bytes: 9136
package main
 
import (
	"fmt"
	"sort"
)
 
func main() {
	var N int
	var S string
	fmt.Scan(&N)
	max := 0
	m := map[string]int {}
	for i := 0; i < N; i++ {
	    fmt.Scan(&S)
		m[S] = m[S] + 1
		max = calcmax(max, m[S])
	}
	l := []string {}
	for k, v := range m {
		if v == max {
			l = append(l, k)
		}
	}
	sort.Slice(l, func(i, j int) bool { return l[i] < l[j] })
	for _, v := range l {
		fmt.Println(v)
	}
}

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


Measured memory_bytes: 35404
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
    using namespace std;
    #define pii pair<int,int>
    #define fir first
    #define sec second
    #define MP make_pair
    #define rep(i,x,y) for (int i=(x);i<=(y);i++)
    #define drep(i,x,y) for (int i=(x);i>=(y);i--)
    #define go(x) for (int i=head[x];i;i=edge[i].nxt)
    #define templ template<typename T>
    #define sz 633
    #define mod 1000000007ll
    typedef long long ll;
    typedef double db;
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
    templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
    templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
    templ inline void read(T& t)
    {
        t=0;char f=0,ch=getchar();double d=0.1;
        while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
        while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
        if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
        t=(f?-t:t);
    }
    template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
    char __sr[1<<21],__z[20];int __C=-1,__zz=0;
    inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
    inline void print(register int x)
    {
        if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
        while(__z[++__zz]=x%10+48,x/=10);
        while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
    }
    void file()
    {
        #ifdef NTFOrz
        freopen("a.in","r",stdin);
        #endif
    }
    inline void chktime()
    {
        #ifndef ONLINE_JUDGE
        cout<<(clock()-t)/1000.0<<'\n';
        #endif
    }
    #ifdef mod
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
    ll inv(ll x){return ksm(x,mod-2);}
    #else
    ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
    #endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
int p[sz],c[sz],d;
ll dp[sz][sz>>1][sz>>1];

int main()
{
    file();
	read(n);
	rep(i,1,n<<1) read(p[i]);
	rep(i,1,n)
		if (p[i*2-1]!=-1&&p[i*2]!=-1) c[p[i*2-1]]=c[p[i*2]]=2;
		else if ((p[i*2-1]!=-1)^(p[i*2]!=-1)) c[p[i*2-1]+p[i*2]+1]=1;
		else ++d;
	dp[0][0][0]=1;
	rep(i,1,n<<1)
	{
		if (c[i]==2) memcpy(dp[i],dp[i-1],sizeof(dp[i]));
		else if (c[i]==1)
		{
			rep(j,0,n) rep(k,0,n) (dp[i][j+1][k]+=dp[i-1][j][k])%=mod;
			rep(j,0,n) rep(k,1,n) (dp[i][j][k-1]+=dp[i-1][j][k]*k%mod)%=mod;
		}
		else
		{
			rep(j,1,n) rep(k,0,n) (dp[i][j-1][k]+=dp[i-1][j][k])%=mod;
			rep(j,0,n) rep(k,0,n) (dp[i][j+1][k]+=dp[i-1][j][k])%=mod;
			rep(j,0,n) rep(k,0,n) (dp[i][j][k+1]+=dp[i-1][j][k])%=mod;
		}
	}
	ll ans=dp[n<<1][0][0];
	rep(i,1,d) ans=ans*i%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 470528
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = (int) 2e5;

char str[MAXN + 1];

vector <int> g[MAXN + 1];
int fr[MAXN + 1][2];
bool vis[MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, m;
    ios::sync_with_stdio(false);
    cin >> n >> m >> str + 1;
    for(i = 1; i <= n; i++) {
        str[i] -= 'A';
    }
    for(i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
        fr[x][str[y]]++;
        fr[y][str[x]]++;
    }
    queue <int> Q;
    int cnt = 0;
    for(i = 1; i <= n; i++) {
        if(fr[i][0] && fr[i][1]) {
            continue;
        }
        vis[i] = 1;
        Q.push(i);
    }
    while(!Q.empty()) {
        cnt++;
        int nod = Q.front();
        Q.pop();
        for(auto it : g[nod]) {
            fr[it][str[nod]]--;
            if(fr[it][0] && fr[it][1]) {
                continue;
            }
            if(vis[it] == 0) {
                vis[it] = 1;
                Q.push(it);
            }
        }
    }
    if(cnt < n) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 12544
def get_ints():
    return list(map(int, input().split()))

n, m = get_ints()
digits = [-1 for i in range(n)]

for i in range(m):
    s, c = get_ints()
    s -= 1
    if digits[s] >= 0 and digits[s] != c:
        print(-1)
        exit(0)
    digits[s] = c

if digits[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
    exit(0)

if n > 1 and digits[0] == -1:
    digits[0] = 1

print(''.join(map(lambda x: str(max(0, x)), digits)))


Measured memory_bytes: 3064
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var n = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            var result = 0;
            for (var i = 0; i <= n; i++) {
                var istr = i.ToString();
                var val = 0;
                foreach (var s in istr) {
                    val += int.Parse(s.ToString());
                }
                if (a <= val && val <= b) {
                    result += i;
                }
            }
            WriteLine(result);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
char s[11];
string ss[200001];
bool issame(string a,string b){
	for(int i=0;i<10;++i){
		if(a[i]!=b[i])return false;
	} 
	return true;
}
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		sort(s+1,s+1+10);
		for(int j=1;j<=10;++j)ss[i]+=s[j];
	}
	sort(ss+1,ss+1+n);
	long long tmp=0;
	long long ans=0;
	for(int i=1;i<n;++i){
		if(issame(ss[i],ss[i+1])){
			tmp++;
			for(int j=i+1;j<n;++j){
				i=j;
				if(issame(ss[j],ss[j+1]))tmp++;
				else break;
			}
			ans+=tmp*(tmp+1)/2;
			//cout<<i<<" "<<tmp<<endl;
			tmp=0;
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 8064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>

typedef long long LL;

const int MAXN = 2e5 + 10;

int len;
int bin[233];
char s[MAXN];

int main() {
	scanf(" %s", s + 1), len = strlen(s + 1);
	for (int i = 1; i <= len; ++i) ++bin[s[i] - 'a'];
	LL ans = 1LL * len * (len - 1) / 2 + 1;
	for (int i = 0; i < 26; ++i) ans -= 1LL * bin[i] * (bin[i] - 1) / 2;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	a := S[0:1]
	b := S[1:2]
	c := S[2:3]
	res := "Yes"
	if a == b && b == c && c == a {
		res = "No"
	}
	fmt.Println(res)

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define S str[ima]
using namespace std;
int ima;
string str;

int suji(){
  int n = 0;
  while('0'<=S && S <= '9'){
    n*=10;
    n+=S-'0';
    ima++;
  }

  return n;
}
    
int siki(){
  vector <int> num;
  int n=0;
  while(S=='['||('0'<=S && S<='9')){
    if(ima == str.size()) break;
    //   cout << ima << endl;
    if(S == '['){  
    ima++;
    num.push_back(siki());
    ima++;
    }
    else if('0'<=S && S<='9'){
      n = suji();
      //cout << n <<" "<<S<<endl;
      return n; 
    }
  }
  
  int ans = 0;
  sort(num.begin(),num.end());
  for(int j=0;j<num.size()/2+1;j++){
    if(num.size() == 0) break;
    ans += num[j]/2+1;
  }
  // cout << ans << endl;
  return ans*2-1;
}  
	


    
int main() {
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> str;
    ima = 0;
    int ans = siki();
    cout << ans/2+1 <<endl;
    
  }

  return 0;
}
    
    
    

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 40) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T>
bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for(int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
}


Measured memory_bytes: 256
n = gets.to_i
A = gets.split.map(&:to_i)

B = []
C = []

n.times do |i|
  
  B.push(A[i]) if i % 2 == 0
  C.push(A[i]) if i % 2 != 0
end

ans = C.reverse + B if n % 2 == 0
ans = B.reverse + C if n % 2 != 0

puts ans.join(" ")

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vvi g(n);
  REP(i, n-1) {
    int u, v; cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }

  function<int(int, int)> dfs = [&](int now, int prev) {
    int res = 0;
    for(auto &nxt: g[now]) {
      if(nxt == prev) continue;
      res ^= dfs(nxt, now) + 1;
    }
    return res;
  };

  int win = dfs(0, -1);
  cout << (win ? "Alice" : "Bob") << endl;

  return 0;
}








Measured memory_bytes: 17876
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int k, x, ans = 0;
    cin >> k >> x;
    cout << x - k + 1;
    for(int i = x - k + 2; i < k + x; i++){
        cout << " " << i;
    }
    cout << endl;
    return 0;
}


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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int x, y;

int main()
{
    cin >> x >> y;

    cout << x + y / 2 << endl;
}

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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			final int N = s.nextInt();
			final int D = s.nextInt();
			final int X[][] = new int[N][D];
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < D; j++) {
					X[i][j] = s.nextInt();
				}
			}

			int ret = 0;
			for (int i = 0; i < N; i++) {
				for (int j = i + 1; j < N; j++) {
					if (calc(X[i], X[j])) {
						ret++;
					}
				}
			}
			System.out.println(ret);
		}
	}

	static boolean calc(int[] x1, int[] x2) {
		int sum = 0;
		for (int i = 0; i < x1.length; i++) {
			sum += (x2[i] - x1[i]) * (x2[i] - x1[i]);
		}

		return Math.sqrt(sum) == (int) Math.sqrt(sum);
	}
}


Measured memory_bytes: 21844
def examA():
    N, K = LI()
    if (N+1)//2>=K:
        print("YES")
    else:
        print("NO")
    return

def examB():
    d = [0]*4
    for _ in range(3):
        a, b = LI()
        a -=1; b -=1
        d[a] +=1
        d[b] +=1
    for i in d:
        if i>=3 or i==0:
            print("NO")
            return
    print("YES")
    return

def examC():
    K, A, B = LI()
    if A+1>=B:
        ans = K+1
        print(ans)
        return
    l = 0; r = K+1
    while(r-l>1):
        # 何回換金できるか
        now = (l+r)//2
        cur = K - now +1
        if cur<A:
            r = now
        else:
            l = now
    ans = K - l + (l//2)*(B-A) +1 + l%2
    print(ans)
    return
def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LFI(): return list(map(float,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Measured memory_bytes: 3552
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		Arrays.sort(arr);
		Boolean flag = true;
		for (int i = 0; i < n-1 && flag; i++) {
			if (arr[i] == arr[i+1])
				flag = false;
		}			
		if (flag)
			System.out.print("YES");
		else
			System.out.print("NO");
	}
}

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

int main(){
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  l == a+b;
  r == c+d;
  if (a + b > c + d){
    cout << "Left" << endl;
  }else if (a + b < c + d){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256