akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int answer = digits(1, 1.ToString().Length) + digits(N - 1, (N - 1).ToString().Length);
            int digit = 0;
            for(int i = 1; i < N; i++)
            {
                digit = digits(i, i.ToString().Length) + digits(N - i, (N - i).ToString().Length);
                if (answer >= digit) answer = digit;
            }
            Console.WriteLine(answer);
        }

        static int digits(int C, int len)
        {
            int digit_sum = 0;
            for (int i = 0; i < len; i++)
            {
                digit_sum += C % 10;
                C = C / 10;
            }
            return digit_sum;
        }
    }
}


Measured memory_bytes: 15188
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    like_food = [0] * M
    for _ in range(N):
        _, *A = map(int, input().split())
        for a in A:
            like_food[a - 1] += 1

    ans = like_food.count(N)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
T = int(input())

for i in range(T):
    N,A,B,C,D = map(int, input().split())
    memo = {}

    def f(n):
         if n == 0:
             return 0
         if n == 1:
             return D
         if n in memo:
             return memo[n]

         ret = min(
             D * n,
             D * abs(n - n//5*5) + C + f(n//5),
             D * abs(n - (n+4)//5*5) + C + f((n+4)//5),
             D * abs(n - n//3*3) + B + f(n//3),
             D * abs(n - (n+2)//3*3) + B + f((n+2)//3),
             D * abs(n - n//2*2) + A + f(n//2),
             D * abs(n - (n+1)//2*2) + A + f((n+1)//2)
         )

         memo[n] = ret
         return ret

    print(f(N))

Measured memory_bytes: 11004
#include<iostream>
#include<cstdio>
#include<climits>
using namespace std;

#define N 120
int n;

int g[N][N];
int mini;
int weight[N];
bool us[N];

int prim(){
  int v;
  int ans=0;
  weight[1]=0;
  
  while(true){
    v=-1;
   
    for(int i=1;i<=n;i++){
      if(us[i]!=true && (v==-1 ||weight[i]<weight[v]))v=i;
    }

    if(v==-1)break;
    us[v]=true;
    ans+=weight[v];

    for(int i=1;i<=n;i++){
      if(weight[i]>g[v][i])weight[i]=g[v][i];
      else weight[i]=weight[i];
    }
  }
  return ans;
}


int main(){

  //load n
  cin >>n;

  //load data
  for(int i=1;i<=n;i++){
    weight[i]=INT_MAX;
    us[i]=false;
    for(int j=1;j<=n;j++){
      scanf("%d",&g[i][j]);
      if(g[i][j]== -1)g[i][j]=INT_MAX;
      //    cout <<g[i][j]<<" ";
    }
    //    cout <<endl;
  }




  //print
  cout <<prim()<<endl;

  return 0;

}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    static int maxn = (int)1e5 + 5;
    static int g[] = new int[maxn << 2];
    static int a[] = new int[maxn];

    static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static void pushup(int o){
        g[o] = gcd(g[o << 1], g[o << 1 | 1]);
    }

    static void build(int o, int l, int r){
        if(l == r){
            g[o] = a[l];
            return;
        }
        int mid = l + r >> 1;
        build(o << 1, l, mid);
        build(o << 1 | 1, mid + 1, r);
        pushup(o);
    }

    static int query(int o, int tl, int tr, int l, int r){
        if(tl > r || tr < l) return 0;
        if(l <= tl && tr <= r) return g[o];
        int mid = tl + tr >> 1;
        return gcd(query(o << 1, tl, mid, l, r), query(o << 1 | 1, mid + 1, tr, l, r));
    }

    public static void main(String args[]){
        Scanner cin = new Scanner(System.in);
        int n = cin.nextInt();
        for(int i = 1; i <= n; i++) a[i] = cin.nextInt();
        build(1, 1 , n);
        int res = Math.max(query(1, 1, n, 2, n), query(1, 1, n, 1, n - 1));
        for(int i = 2; i < n; i++){
            res = Math.max(res, gcd(query(1, 1, n, 1, i - 1), query(1, 1, n, i + 1, n)));
        }
        System.out.println(res);

    }

}

Measured memory_bytes: 61640
#include <algorithm>
#include <iostream>

using namespace std;

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

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

  const auto d = abs(a - b);
  const auto ans = d < W ? 0 : d - W;
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SZ(x) (int)(x).size()
#define mset(a,x) memset(a,x,sizeof(a))
#define dbg(x) cout<<#x<<": "<<(x)<<"\n"
#define OUT(x) cout<<(x)<<"\n"
#define pb push_back
#define mp make_pair

int main() {
    int n, m, tot = 0;
    cin >> n;
    vi t(n+5);
    rep(i,n){
        cin >> t[i];
        tot += t[i];
    }

    cin >> m;
    rep(i,m){
        int p,x;
        cin >> p >> x;
        --p;
        OUT(tot - t[p] + x);
    }

    return 0;
}


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

class Prog
{
    public static void Main(string[] args)
    {
        string input = Console.ReadLine();

        bool[] judges = new bool[26];
        for(int i = 0;i < 26;i++)
        {
            judges[i] = true;
        }

        for(int i = 0;i < input.Length;i++)
        {
            int index = CtoN(input[i]) - 1;
            judges[index] = !judges[index];
        }

        int count = 0;
        for(int i = 0;i < judges.Length;i++)
        {
            if (!judges[i]) count++;
        }

        if (count == 0) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }

    private static int CtoN(char c)
    {
        switch (c)
        {
            case 'a':
                return 1;
            case 'b':
                return 2;
            case 'c':
                return 3;
            case 'd':
                return 4;
            case 'e':
                return 5;
            case 'f':
                return 6;
            case 'g':
                return 7;
            case 'h':
                return 8;
            case 'i':
                return 9;
            case 'j':
                return 10;
            case 'k':
                return 11;
            case 'l':
                return 12;
            case 'm':
                return 13;
            case 'n':
                return 14;
            case 'o':
                return 15;
            case 'p':
                return 16;
            case 'q':
                return 17;
            case 'r':
                return 18;
            case 's':
                return 19;
            case 't':
                return 20;
            case 'u':
                return 21;
            case 'v':
                return 22;
            case 'w':
                return 23;
            case 'x':
                return 24;
            case 'y':
                return 25;
            case 'z':
                return 26;
            default:
                return 0;
        }
    }
}

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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 MOD = 1000000007;
const int INF = 1000000001;
const char EOL = '\n';

void solve();

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

void solve() {
    int n;
    cin >> n;
    REP1(i, 9) REP1(j, 9) {
        if (i * j == n) {
            cout << "Yes" << EOL;
            return;
        }
    }
    cout << "No" << EOL;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, 0,-1,0 };
int dy[] = { 0, 1,0,-1 };

void solve() {
	int n, m;
	cin >> n >> m;
	vi cake;
	rep(i, m) {
		int a;
		cin >> a;
		cake.push_back(a);
	}
	int pos = -1;
	while (n > 0) {
		int maxi = 0;
		int npos = -1;
		rep(i, m) {
			if (cake[i] >= maxi) {
				if (pos != i) {	
					maxi = cake[i];
					npos = i;
				}
			}
		}
		if (maxi == 0) {
			break;
		}
		else {
			cake[npos]--;
			n--;
		}
		pos = npos;
		//P(pos);
	}
	int count = 0;
	rep(i, m) {
		//P(cake[i]);
		if (cake[i] != 0) {
			count += cake[i];
		}
	}
	P(count);
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> dp(n + 4, 0);

  dp[0] = 1;

  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    dp[a] = -1;
  }



  for (int i = 0; i < n ; i++) {
    if (dp[i] == -1) continue;
    if (dp[i + 1] != -1) (dp[i + 1] += dp[i]) %= mod;
    if (dp[i + 2] != -1) (dp[i + 2] += dp[i]) %= mod;
  }

  cout << dp[n] << endl;

  return 0;
} 

Measured memory_bytes: 640
import copy

N,W=map(int,input().split())
G=[0]   #G[0]はダミー
for index1 in range(N):
    w,v=map(int,input().split())
    G.append((w,v))

#DP[i][j]=i番目までの品物を使って重さj以下の最大価値
DP=[[0]*(W+1)]
inf=float('inf')
component=[0]+[-inf]*W
for index2 in range(N):
    DP.append(copy.copy(component))

for i in range(1,N+1):
    for j in range(1,W+1):
        if j>=G[i][0]:
            DP[i][j]=max(DP[i-1][j],DP[i-1][j-G[i][0]]+G[i][1])
        else:
            DP[i][j]=DP[i-1][j]


#for index3 in range(N+1):
    #print(DP[index3])

print(DP[N][W])

Measured memory_bytes: 259312
#include <stdio.h>

int main(void)
{
    int a,b,c;
    int i;
    scanf("%d %d %d",&a,&b,&c);
    
    i= 2*b-a-c;
    if(i==0){
        printf("YES");
    }else{printf("NO");
        
    }
    
}

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

int main() {
    int N, H;
    cin >> N >> H;
    vector<P> ba(N);
    int mx = 0;
    REP(i, N) {
        cin >> ba[i].second >> ba[i].first;
        mx = max(mx, ba[i].second);
    }
    sort(ba.begin(), ba.end(), greater<P>());
    int res = 0;
    int i = 0;
    while (i < N && ba[i].first > mx && H > 0) {
        ++res;
        H -= ba[i].first;
        ++i;
    }
    if (H > 0) {
        res += (H + mx - 1) / mx;
    }
    cout << res << endl;
    return 0;
}

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

Measured memory_bytes: 7296
#include "bits/stdc++.h"
using namespace std;

const int N = 1e6 + 6;
const int md = 1e9 + 7;

int dp[N][2][2];

int add(int a, int b) {
	a += b;
	if(a >= md)
		a -= md;
	return a;
}

int solve(int pos, int z, int ni, int& n) {
	if(pos >= n)
		return z && ni;

	if(dp[pos][z][ni] != -1)
		return dp[pos][z][ni];

	int res = 0;

	for(int cur = 0; cur <= 9; ++cur) 
		res = add(res, solve(pos + 1, z | (cur == 0), ni | (cur == 9), n));

	return dp[pos][z][ni] = res;
}

int main() {
	memset(dp, -1, sizeof dp);
	int n; cin >> n;
	cout << solve(0, 0, 0, n) << '\n';
	return 0;
}

Measured memory_bytes: 97308
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto s = readln.chomp;

    // dp(i, j) = (i番目までを{0, 1, .., i}で作り、末尾がjであって条件を満たす順列の数)
    auto dp = new long[][](n + 1, n + 1);
    dp[0][0] = 1;

    foreach (i ; 1 .. n) {
        if (s[i - 1] == '<') {
            // dp(i, j) = dp(i - 1, 0) + dp(i - 1, 1) + .. + dp(i - 1, j - 1)
            //          = dp(i, j - 1) + dp(i - 1, j - 1)
            foreach (j ; 1 .. i + 1) {
                dp[i][j] = dp[i-1][j-1] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
        else {
            // dp(i, j) = dp(i - 1, j) + dp(i - 1  j + 1) + .. + dp(i - 1, i - 1)
            //          = dp(i - 1, j) + dp(i, j + 1)
            foreach_reverse (j ; 0 .. i) {
                dp[i][j] = dp[i-1][j] + dp[i][j + 1];
                dp[i][j] %= mod;
            }
        }
    }

    long ans;
    foreach (i ; 0 .. n) {
        ans += dp[n - 1][i];
        ans %= mod;
    }
    writeln(ans);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

int main() {
  int a[12], b[13];
  int c, n;
  bool f;
  map<int, int> m;

  while (cin >> n && n) {
    m.clear();
    for (int i=0; i<n; i++) {
      cin >> a[i];
      m.insert(map<int, int>::value_type(a[i], i+1));
      a[i] = m[a[i]];
    }

    c = -1;
    do {
      f = true;
      for (int i=1; i<=n; i++) b[i]=0;
      for (int i=0; i<n; i++) b[a[i]]++;
      for (int i=0; i<n; i++) {
        if (a[i] != b[a[i]]) f=false;
        a[i] = b[a[i]];
      }
      c++;
    } while (!f);
    cout << c << endl;
    cout << a[0];
    for (int i=1; i<n; i++) cout << " " << a[i];
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
using namespace std;
int main() {
  int n, a = 100000;
  cin >> n;
  while(n--) {
	a *= 1.05;
	if(a % 1000 > 0) {
	  a += 1000;
	  a -= (a % 1000);
	}
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;

int n,m,q;
int a[N],b[N],c[N],d[N];
int ans;
int v[N];
ll t;
void go(int i, int f){
	if(i==n){
		++t;
		int cur = 0;
		for(int i=0;i<q;++i) if(v[b[i]-1] - v[a[i]-1] == c[i]) cur+=d[i];
		ans = max(ans, cur);
		return ;
	}
	
	for(v[i]=f;v[i]<=m;++v[i]){
		go(i+1,v[i]);
	}
}

int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
 
	cin>>n>>m>>q;
	for(int i=0;i<q;++i) cin>>a[i]>>b[i]>>c[i]>>d[i];
	go(0,1);
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;

    if ( N % 1000 == 0) {
        cout << 0 << endl;
    } else {
            cout << 1000 - N % 1000 << endl;
    }




    return 0;
}

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

long long f(long long n) {
  long long res = (n * (n + 1)) / 2;
  return res;
}

int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += i * f(n/i);
  }
  
  cout << ans;
}

Measured memory_bytes: 3636
import java.io.*;

public class Main{
public static void main(String[] args) throws IOException{
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String[] str = br.readLine().split(" ");
	int n = Integer.parseInt(str[0]);
	int m = Integer.parseInt(str[1]);
	int[][] MatA = new int[n][m];
	int[] MatB = new int[m];
	int ans;

	for(int i = 0; i < n; i++){
		String[] strx = br.readLine().split(" ");
		for(int j = 0; j < m; j++){
			MatA[i][j] = Integer.parseInt(strx[j]);
		}
	}

	for(int k = 0; k < m; k++){
		MatB[k] = Integer.parseInt(br.readLine());
	}

	for(int x = 0; x < n; x ++){
		ans = 0;
		for(int y = 0; y < m; y++){
			ans += MatA[x][y] * MatB[y];
		}
		System.out.println(ans);
	}
}
}

Measured memory_bytes: 22576
#include "bits/stdc++.h"
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
void ran() {
	srand(chrono::steady_clock::now().time_since_epoch().count());
}
long long get_rand() {
	long long a = rand();
	long long b = rand();
	return a * (RAND_MAX + 1ll) + b; 
}
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

signed main() {
	
	ran(); fast();
	
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2] << endl;
	
}


Measured memory_bytes: 3616
import java.util.Scanner

object Main extends App {
  val ABC = Array("A", "B", "C")
  def printABC(n: Int): Unit = {
    println(ABC(n))
  }

  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val (a, b, c) = (sc.nextInt(), sc.nextInt(), sc.nextInt())
  val ss = (1 to n).map { _ =>
    val s = sc.next()
    S.find(s)
  }

  var state = State(Array(a, b, c), Nil)
  ss.zipWithIndex.foreach { case (s, idx) =>
    val Array(i, j) = s.target
    if(state(i) + state(j) <= 0) {
      println("No")
      sys.exit(0)
    }
    state = if(state(i) == 0) state.add(i, j)
    else if(state(j) == 0) state.add(j, i)
    else {
      ss.lift(idx + 1).fold { state.add(i, j) } { nextS =>
        if(nextS.target.contains(i)) state.add(i, j) else state.add(j, i)
      }
    }
  }
  println("Yes")
  state.result.reverse.foreach(printABC)

}

case class State(ary: Array[Int], result: List[Int]) {
  def add(incr: Int, decr: Int): State = {
    val nextAry = ary.clone()
    nextAry(incr) += 1
    nextAry(decr) -= 1
    State(nextAry, incr :: result)
  }

  def apply(n: Int): Int = ary(n)
}

sealed abstract class S {
  lazy val name: String = getClass.getSimpleName.init

  def target: Array[Int]

  def dup(s: S): Int = (target.toSet & s.target.toSet).head
}

object S {
  case object AB extends S {
    override val target: Array[Int] = Array(0, 1)
  }

  case object AC extends S {
    override val target: Array[Int] = Array(0, 2)
  }

  case object BC extends S {
    override val target: Array[Int] = Array(1, 2)
  }

  val values: Seq[S] = AB :: AC :: BC :: Nil
  def find(name: String): S = values.find(_.name == name).get
}


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

int N, Q;
string S;
int l[100000];
int r[100000];
int t[100000];

int main(){
	cin >> N >> Q;
	cin >> S;
	for (int i = 0; i < Q; ++i) cin >> l[i] >> r[i];
	if((S[0] == 'A') && (S[1] == 'C')){
		t[0] = 1;
	}else{
		t[0] = 0;
	}
	for(int i = 1; i < N; ++i){
		if((S[i] == 'A') && (S[i+1] == 'C')){
			t[i] = t[i-1] + 1;
		}else{
			t[i] = t[i-1];
		}
	}
	for(int i = 0; i < Q; ++i){
		cout << t[r[i] - 2] - t[l[i] - 2] << endl;
	}
}

Measured memory_bytes: 2176
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
using namespace std;
int main(){
    while(true){
        int max;
        cin >> max;
        if(max == 0){
            return 0;
        }
        for(int i=0; i<9; i++){
            int tmp;
            cin >> tmp;
            max -= tmp;
        }
        cout << max << endl;
    }
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(){
    int n;
    ll ans=0;
    cin >> n;
    string s;
    map<string,int> cnt;
    rep(i,n){
        cin >> s;
        sort(s.begin(),s.end());
        if(cnt[s]!=0)ans+=cnt.at(s);
        cnt[s]++;
    }
    cout << ans;
    return 0;
}

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

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

    while(true){
        int Aoki_rest = C-B;
        if(Aoki_rest <= 0){
            cout << "Yes" << endl;
            break;
        }
        int Takahashi_rest = A - D;
        if(Takahashi_rest <= 0){
            cout << "No" << endl;
            break;
        }
        C = Aoki_rest;
        A = Takahashi_rest;
    }

    return 0;
}

Measured memory_bytes: 3632
n,a,b = map(int,input().split())
ans = 0

if n % (a+b) == 0:
  ans += n//(a+b) *a
  
else:
  if n%(a+b)<a:
    ans += n//(a+b)*a + n%(a+b)
  else:
    ans += n//(a+b)*a + a
  
print(ans)

Measured memory_bytes: 3060
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
B = set(int(input()) for _ in range(N))
hit = [[False] * 3 for _ in range(3)]

for i in range(3):
    for j in range(3):
        if A[i][j] in B:
            hit[i][j] = True

cond = [all(hit[r]) for r in range(3)]
if any(cond):
    print("Yes")
    exit()

cond = [all(hit[r][c] for r in range(3)) for c in range(3)]
if any(cond):
    print("Yes")
    exit()

cond = [
    all(hit[i][i] for i in range(3)),
    hit[0][2] and hit[1][1] and hit[2][0]
]
if any(cond):
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,T;
  cin >> K >> T;
  vector<int> a(T);
  int M;
  for (int i = 0; i < T; i++){
    cin >> a[i];
    M = max(M,a[i]);
  }
  if (K % 2 == 0){
    if (M <= K / 2){
      cout << 0;
    } else if (M == K / 2 + 1){
      cout << 1;
    } else {
      cout << 2 * (M - K / 2) - 1;
    }
  } else {
    if (M <= K / 2 + 1){
      cout << 0;
    } else {
      cout << (M - K / 2 - 1) * 2;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
  if(a < b){
    return a;
  }
  return b;
}

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int N,T;
  int ans = 0;
  scanf("%d%d",&N,&T);

  int A[N];
  int maxi = 0,mini = 1000000000;
  for(int i = 0;i < N;i++){
    scanf("%d",&A[i]);
    mini = min(mini,A[i]);
    maxi = max(maxi,A[i]-mini);
  }
  mini = 1000000000;
  for(int i = 0;i < N;i++){
    mini = min(mini,A[i]);
    if(maxi == A[i]-mini) ans++;
  }

  printf("%d\n",ans);

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7

template<typename T>
string printVector(const vector <T> &data) {
    stringstream ss;
    ostream_iterator <T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

#define MAX_V 200005

struct edge {
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
using P = pair<ll, int>;

int V;
vector <edge> graph[MAX_V];
ll d[MAX_V];

void dijkstra(int s) {
    priority_queue <P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i = 0; i < graph[v].size(); ++i) {
            edge e = graph[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool flag = true;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        flag &= (a[i] % 2 == 0);
    }
    if (flag) cout << "second" << endl;
    else cout << "first" << endl;
}


Measured memory_bytes: 5376
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long w = sc.nextLong();		
        long h = sc.nextLong();
		long x = sc.nextLong();
        long y = sc.nextLong();
        double ans1 = w*h/2.0;
        int ans2 = 0;
        if(x*2==w && y*2==h){ans2++;}
		System.out.println(ans1 + " " + ans2);
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define LL long long 
#define LLU long long unsigned
#define rarr(arr, n) for(int aab = 0; aab < n; aab++){cin >> arr[aab];}
#define parr(arr, n) for(int aab = 0; aab < n; aab++){cout << arr[aab] << " ";}
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n";

#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);ios_base::sync_with_stdio(0);cin.tie(0);

int main(){
	long long int n, m, x, sum = 1000000000;
	cin >> n >> m >> x;
	long long int arr[n][m];
	long long int prices[n];
	for(int i = 0; i < n; i++){
		cin >> prices[i];
		for(int j = 0; j < m; j++){
			cin >> arr[i][j];
		}
	}

	for(int i = 0; i < (1 << n); i++){
		long long int tempsum = 0;
		long long int sumarr[m] = {0};  
        for(int j = 0; j < n ; j++){      
            if((i & ( 1 << j )) != 0){
            	for(int i = 0; i < m; i++){
            		sumarr[i] += arr[j][i];
            	}
            	tempsum += prices[j];
            }       
        }
        
        bool flag = true;
        for(int i = 0; i < m; i++){
        	if(sumarr[i] < x){
        		flag = false;
        	}
        }
        if(flag && tempsum < sum){
        	sum = tempsum;
        }
    }
    if(sum != 1000000000){
    	cout << sum;
    }
    else{
    	cout << -1;
    }
} 

Measured memory_bytes: 3620
#include <iostream>

#include <vector>

#include <cassert>

#include <algorithm>

#include <functional>

#include <cmath>

#include <iomanip>

#include <limits>
#include <bits/stdc++.h>
#include<queue>
#include<type_traits>
#include<cstdint>
using namespace std;
using ll=long long;
int main(){
    int n;
    cin >> n;
    ll count=0;
    for(int i=0;i<n;i++){
        ll x;
        cin >>x;
        count += x;
    }
    cout << count-n << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string r, g, b;
    cin >> r >> g >> b;
    int a = stoi(r + g + b);

    if (a % 4 == 0)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char cup[3] = {1, 0, 0};
	char a, b;
	int i;
	
	while (scanf("%c,%c", &a, &b) != EOF){
		
		a -= 'A';
		b -= 'A';
		
		cup[a] += cup[b];
		cup[b] = cup[a] - cup[b];
		cup[a] -= cup[b];
	}
	
	for (i = 0; i < 3; i++){
		if (cup[i] == 1) printf("%c\n", 'A' + i);
	}
	
	return (0);
}

Measured memory_bytes: 544
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	a = abs(a);
	b = abs(b);
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
signed main(){
	int n; cin >> n; n *= 2;
	vel a(n);
	string s; cin >> s;
	rep(i, n) {
		int x = 0;
		if (s[i] == 'B') { x = 1; }
		if (x == (i % 2)) { a[i] = -1; }
		else { a[i] = 1; }
	}
	int ans = 1;
	int sum = 0;
	rep(i, n) {
		if (a[i] == -1) {
			ans *= sum; ans %= p;
		}
		sum += a[i];
	}
	for (int i = 1; i <= n / 2; i++) {
		ans *= i; ans %= p;
	}
	if (sum == 0) { cout << ans << endl; return 0; }
	cout << 0 << endl;
}

Measured memory_bytes: 2180
#include<bits/stdc++.h>
#define debug1 cout<<"?"<<endl;
#define debug2 cout<<"?"<<i<<endl
#define PII pair<int,int>
typedef long long ll;
const int maxn=2e5+9;
const double pi=acos(-1);
const int mod=1e9+7;
const int INF=1e9;
const double ep=1e-7;
using namespace std;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	if(n<=k)
	{
		printf("%lld\n",min(n,k-n));return 0;
	}
	n=n%k;
	printf("%lld\n",min(n,abs(n-k)));
}

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

const int N = 1e5+10;

vector<int> G[N];
bool visited[N];
vector<int> out; //トポロジカル順序

void dfs(int u){
  visited[u] = true;
  for(int v : G[u]){
    if(!visited[v]) dfs(v);
  }
  out.push_back(u);
}

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

  int n,m; cin >> n >> m;
  for(int i = 0; i < n-1+m; i++){
    int a,b; cin >> a >> b;
    G[a].push_back(b);
  }

  for(int i = 1; i <= n; i++){
    if(!visited[i]) dfs(i);
  }
  reverse(out.begin(),out.end());

  vector<int> dp(n+1,0); //根からの距離
  vector<int> ans(n+1,0);
  for(int i = 0; i < n; i++){
    for(int v : G[out[i]]){
      if(dp[v] < dp[out[i]]+1){
        dp[v] = dp[out[i]]+1;
        ans[v] = out[i];
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 12020
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0){
         c=c-b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a=a-d;

        if(a<=0){
            cout<<"No"<<endl;
            break;
        }

    }

    return 0;
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-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;}

int X;

signed main(){
    cin>>X;
    for(int i=2;i<=10;++i){
        if(X<i*200){
            cout<<10-i+1<<endl;
            break;
        }
    }
}

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

int num(int a, int b) {
	if (a >= b)return 0;
	return 1 + num(a * 4, b);
}
int num2(int a, int b) {
	int cnt = 0;
	while (a * 4 <= b) {
		cnt++; a *= 4;
	}
	return cnt;
}

struct BIT {
	int node[200006]; int N = 200002;
	void init() {
		fill(node, node + N + 1, 0);
	}
	void add(int i, int x) {
		while (i <= N) {
			node[i] += x; i += i & -i;
		}
	}
	int sum(int x) {
		int s = 0;
		while (x > 0) {
			s += node[x]; x -= x & -x;
		}
		return s;
	}
};

int a[200006];
BIT b1;
int n;

vector<int> solve() {
	b1.init();
	vector<int>ans(n);
	for (int i = n - 1; i > 0; i--) {
		b1.add(i, num2(a[i - 1], a[i]));//何回耐えるか
		ans[i - 1] += ans[i];
		int k = num(a[i], a[i - 1]);//何回4を掛けるか
		while (k) {
			k--;
			int lb = i - 1, ub = n;
			if (b1.sum(200001)) {
				while (ub - lb > 1) {
					int mi = (ub + lb) / 2;
					if (b1.sum(mi))ub = mi;
					else lb = mi;
				}
				b1.add(ub, -1);
				ans[i - 1] += ub - i;
			}
			else {
				ans[i - 1] += n - i;
			}
		}
	}
	return ans;
}
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	vector<int>cost1, cost2;
	cost1 = solve();

	reverse(a, a + n);
	cost2 = solve();
	reverse(cost2.begin(), cost2.end());
	int ans = 1e18;
	for (int i = 0; i <= n; i++) {//-の個数
		int d = i;
		if (i)d += cost2[i - 1] * 2;
		if (i != n)d += cost1[i] * 2;
		ans = min(ans, d);
	}
	cout << ans << endl;

}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string a,b;
    int i;
    int j=0;
    cin>>a>>b;
    for(i=0; i<3; i++){
        if(a[i]==b[i]){
            j++;
        }
    }
    cout<<j;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long
ll digitpower(ll a,ll b){//aのb乗を計算
  if(b==1){
    return a;
  }else if(b==0){
    return 1;
  }
  if(b%2==1){
    ll tmp = digitpower(a,(b-1)/2);
    tmp*=tmp;
    tmp*=a;
    return (tmp);
  }else{
    ll tmp = digitpower(a,(b)/2);
    tmp*=tmp;
    return (tmp);
  }
}
int main(void){
  string s;
  cin>>s;
  int ans=0;
  rep(i,s.size()/2){
  	if(s[i]!=s[s.size()-1-i])ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
ll h[211111];
ll L[211111],R[211111];

stack<int> st;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	rep(i,n)cin>>h[i];
	rep(i,n){
		while(st.size()&&h[st.top()]>h[i])st.pop();
		L[i]=st.size()==0?-1:st.top();
		st.push(i);
	}
	st=stack<int>();
	for(int i=n-1;i>=0;i--){
		while(st.size()&&h[st.top()]>h[i])st.pop();
		R[i]=st.size()==0?n:st.top();
		st.push(i);
	}
	ll res=0;
	rep(i,n){
		res+=(ll)(h[i])*(R[i]-i)*(i-L[i]);
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 6268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define s (1<<18)
int n,m,a[200005],b[200005];
vector<int>vec[200050];
class segtree
{
public:
	int seg[(1<<19)];
	int lazy[(1<<19)];
	void init(){
		memset(seg,0,sizeof(seg));
		memset(lazy,0,sizeof(lazy));
	}
	void lazy_evaluate(int k)
	{
		if(k*2+2>=s*2) return ;
		lazy[k*2+2]+=lazy[k];
		lazy[k*2+1]+=lazy[k];
		seg[k*2+2]+=lazy[k];
		seg[k*2+1]+=lazy[k];
		lazy[k]=0;
	}
	int update(int beg,int end,int idx,int lb,int ub,int num)
	{
		if(ub<beg||end<lb)
		{
			return seg[idx];
		}
		if(beg<=lb&&ub<=end)
		{
			lazy[idx]+=num;
			seg[idx]+=num;
			return seg[idx];
		}
		if(lazy[idx])
		{
			lazy_evaluate(idx);
		}
		return seg[idx]=max(update(beg,end,idx*2+1,lb,(lb+ub)/2,num),update(beg,end,idx*2+2,(lb+ub)/2+1,ub,num));
	}
	int query(int beg,int end,int idx,int lb,int ub)
	{
		if(ub<beg||end<lb)
		{
			return -1;
		}
		if(beg<=lb&&ub<=end)
		{
			return seg[idx];
		}
		if(lazy[idx])
		{
			lazy_evaluate(idx);
		}
		return max(query(beg,end,idx*2+1,lb,(lb+ub)/2),query(beg,end,idx*2+2,(lb+ub)/2+1,ub));
	}
}S;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		vec[a[i]].pb(b[i]);
	}
	int ret = max(n-m,0);
	{
		int mid = 0; //mid = 0;a
		S.init();
		for(int i=1;i<=m+1;i++) S.update(i,i,0,0,s-1,i);
		int x = m+1;
		for(int i=0;i<=m;i++){
			for(int j=0;j<vec[i].size();j++){
				S.update(0,vec[i][j],0,0,s-1,1);
			}
			//if(vec[i].size()) x = S.query(i+1,m+1,0,0,s-1);
			//cout << mid << " " << i+m+1+mid << " " << S.query(i+1,m+1,0,0,s-1) << endl;
			ret = max(ret,S.query(i+1,m+1,0,0,s-1) - i-m-1-mid);
		/*	if(i+m+1+mid < S.query(i+1,m+1,0,0,s-1)){
				lb = mid; goto bad;
			}*/
		}
		//ub = mid; bad:;
	}
	cout << ret << endl;
}

Measured memory_bytes: 14208
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)


def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True


X=int(input())

a=X//500
b=(X%500)//5

print(int(a*1000+b*5))

Measured memory_bytes: 21548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc145/abc145_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  string S;
  cin >> S;

  if (N % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  string l = S.substr(0, N / 2);
  string r = S.substr(N / 2, S.size());

  cout << (l == r ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    for (double i = 1; i <= n; i++) {
        if (floor(i * 1.08) == n) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

struct FordFulkerson {
    typedef long long flow_type;
    struct edge {
        int src, dst;
        flow_type capacity, flow;
        size_t rev;
    };
    int n;
    vector<vector<edge>> adj;
    FordFulkerson(int n) : n(n), adj(n) { }
    void add_edge(int src, int dst, flow_type capacity) {
        adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
        adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
    }
    flow_type max_flow(int s, int t) {
        vector<bool> visited(n);
        function<flow_type(int,flow_type)> augment = [&](int u, flow_type cur) {
            if (u == t) return cur;
            visited[u] = true;
            for (auto &e: adj[u]) {
                if (!visited[e.dst] && e.capacity > e.flow) {
                    flow_type f = augment(e.dst, min(e.capacity - e.flow, cur));
                    if (f > 0) {
                        e.flow += f;
                        adj[e.dst][e.rev].flow -= f;
                        return f;
                    }
                }
            }
            return flow_type(0);
        };
        for (int u = 0; u < n; ++u)
            for (auto &e: adj[u]) e.flow = 0;

        flow_type flow = 0;
        while (1) {
            fill(visited.begin(),visited.end(), false);
            flow_type f = augment(s, INF);
            if (f == 0) break;
            flow += f;
        }
        return flow;
    }
};


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W;cin>>H>>W;
  vector<string> a(H);
  int srcc,srcr,dstc,dstr;
  for(ll i=0;i<H;i++){
    cin>>a[i];
    for(ll j=0;j<W;j++){
      if(a[i][j]=='S'){
        srcc=i;
        srcr=H+j;
      }
      if(a[i][j]=='T'){
        dstc=i;
        dstr=H+j;
      }
    }
  }
  if(srcc==dstc||srcr==dstr){
    cout<<-1<<endl;
    return 0;
  }
  FordFulkerson g(H+W+2);
  ll src=H+W,dst=H+W+1;
  g.add_edge(src,srcc,INF);
  g.add_edge(src,srcr,INF);
  g.add_edge(dstc,dst,INF);
  g.add_edge(dstr,dst,INF);
  for(ll i=0;i<H;i++){
    for(ll j=0;j<W;j++){
      if(a[i][j]!='.'){
        g.add_edge(i,H+j,1);
        g.add_edge(H+j,i,1);
      }
    }
  }
  cout<<g.max_flow(src,dst)<<endl;
  return 0;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    while(h!=0||w!=0){
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cout<<'#';
            }
            cout<<endl;
        }
        cout<<endl;
        cin>>h>>w;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;
ll waru(ll x) {
	ll count = 0;
	while (x % 2 == 0) {
		x /= 2;
		count++;
	}
	return count;
}

int main() {
	ll n,sum=0;
	cin >> n;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
		sum += waru(a[i]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,w[200001],v[200001],BIT[200001];

ll lowbit(ll a)
{
	return a&-a;
}

void fix(ll x,ll k)
{
	while(x<=n)
		BIT[x]=max(BIT[x],k),x+=lowbit(x);
}

ll search(ll x)
{
	ll re=0;
	while(x)
		re=max(re,BIT[x]),x-=lowbit(x);
	return re;
}

int main()
{Tie
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>w[i];
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=0;i<n;i++)
		fix(w[i],search(w[i])+v[i]);
	cout << search(n)<<'\n';
}

Measured memory_bytes: 4992
tmp = [int(i) for i in input().split(" ")]
n = tmp[0]
k = tmp[1]
a = [int(i) for i in input().split(" ")]
import numpy as np
a = np.array(a)
uni = np.unique(a)
co = [np.sum(a==i) for i in uni]
ind = np.array([np.sum(co[:uni.tolist().index(i)]) for i in a]).astype(np.int32)
c = 0

for i in range(len(a)):
    c += np.sum(a[i:]<a[i])
m = 10**9+7
tm = int(c)*int(k) % m
if k % 2 == 0:
    t = k * (k//2-1) + k//2
    t %= m
else:
    t = k * (k//2)
    t %= m
print((int(np.sum(ind))*t+tm) % m)


Measured memory_bytes: 14532
#include<iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int n;
char cs[300];
vector<int> parens;
int inserts[300];// 場所
int insert;
int depth;
int main() {
	scanf("%d",&n);
	scanf("%s",cs);
	for(int i=0;i<n;i++){
		if(cs[i]=='(')depth++;
		else depth--;
		if(depth<0){
			insert++;
			depth++;
		}
	}
	while(insert--)printf("(");
	for(int i=0;i<n;i++){
		printf("%c",cs[i]);
	}
	while(depth--)printf(")");
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    long a=sc.nextLong();
    int t=0;
    long p=100;
    while(a>p)
    {
      p=p+p/100;
      t++;
    }
      System.out.println(t);
     
  }
}

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

int main(){
  int64_t N;
  cin >> N;
  if(N==0){
    cout << 0 << endl;
  }
  vector<int64_t> A(51, 0);
  for(int64_t i=1; i<=50; i++){
    if(N%(int64_t)pow(2, i)!=0){
      A.at(i)=1;
      N-=(int64_t)pow(2, i-1)*(int64_t)pow(-1, i-1);
    }
  }
  int64_t P=0;
  for(int64_t i=50; i>0; i--){
    if(A.at(i)==1){
      P=1;
      cout << 1;
    }
    else if(P==1){
      cout << 0;
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N; cin >> N;
    vector<long long > a(N);
    for (int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    
    long long sum = 0;
    int ans = 0;
    for (int i=0; i<N; i++){
        if (2 * sum < a[i]){
            ans = i;
        }
        sum += a[i];
    }

    cout << N - ans  << endl;
    
}
    


Measured memory_bytes: 4008
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i) {
    cin >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256