akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#define N 100005
#define LL long long
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n, m, c[2], vis[N][2];
vector<int> v[N];
LL ans;
bool u[N], has;

void dfs(int x, int y, int d){
	u[x] = 1;
	ans += c[d ^ 1];
	c[d]++;
	
	fi(i, 0, v[x].size()) if(v[x][i] != y){
		int z = v[x][i];
		if(!u[z]) dfs(z, x, d ^ 1);
	}
}

void bip(int x, int y){
	vis[x][y] = 1;
	fi(i, 0, v[x].size()) {
		int z = v[x][i];
		if(!vis[z][y ^ 1]) bip(z, y ^ 1);
	}
}

int main(){
	scanf("%d %d", &n, &m);
	fi(i, 0, m){
		int x, y;
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	
	dfs(1, 0, 0);
	bip(1, 0);
	
	FI(i, 1, n) if(vis[i][0] && vis[i][1]) has = 1;
	
	if(has) ans = (LL) n * (n - 1) / 2;
	ans -= m;
	cout << ans << '\n';
}

Measured memory_bytes: 8448
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    int cnt = 0, cur = 0;
    for (int ai: a) {
        if (ai == cur + 1) {
            cur = ai;
            cnt++;
        }
    }
    if (cnt == 0) return !(cout << -1 << endl);
    cout << n - cnt << endl;
    return 0;
}


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

class SegmentTree
{
public:
    SegmentTree(int n)
    {
        ll cnt = 1;
        while (cnt < n)
            cnt <<= 1;
        node.resize(2 * cnt - 1);
        REP(i, 2 * cnt - 1)
        {
            node[i] = inf;
        }
        mN = cnt - 1;
    }
    ~SegmentTree()
    {
        node.resize(0);
    }

    //! 0-index get
    ll get(int left, int right, int l = 0, int r = -1, int index = 0)
    {
        if (r == -1)
            r = mN;

        if (r < left || right < l)
            return inf;
        if (left <= l && r <= right)
            return node[index];
        return std::min(get(left, right, l, (l + r) / 2, 2 * index + 1),
                        get(left, right, (l + r) / 2 + 1, r, 2 * index + 2));
    }

    //! 0-index set
    void set(int index, ll value)
    {
        node[mN + index] = value;
        //! update
        int par = (mN + index);
        while (par > 0)
        {
            par = (par - 1) / 2;
            node[par] = std::min(node[2 * par + 1], node[2 * par + 2]);
        }
    }

private:
    ll mN;
    vector<ll> node;
    const ll inf = INF;
};

struct Data
{
    ll l;
    ll r;
    ll c;
};

Data D[100005];
int main()
{
    ll N, M;
    cin >> N >> M;
    REP(i, M)
    {
        cin >> D[i].l >> D[i].r >> D[i].c;
    }
    SegmentTree seg(N + 1);
    sort(D, D + M, [](Data a, Data b) { return a.l < b.l; });
    seg.set(0, 0);
    REP(i, M)
    {
        ll min = seg.get(D[i].l - 1, D[i].r - 2);
        ll cost = min + D[i].c;
        ll t = seg.get(D[i].r - 1, D[i].r - 1);
        seg.set(D[i].r - 1, std::min(t, cost));
    }

    ll c = seg.get(N - 1, N - 1);
    if (c == INF)
        cout << -1 << endl;
    else
        cout << c << endl;
    return 0;
}

Measured memory_bytes: 4608
n, k = map(int, input().split())
p = 0
for i in range(1, min(k-1, n)+1):
  pi = 1 / n
  s = i
  while s < k:
    s *= 2
    pi /= 2
  p += pi
  
print(p + max((n-k+1)/n, 0))

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                int x = Integer.parseInt(sc.next());
                int t = Integer.parseInt(sc.next()); 
                int q = (int)Math.ceil(n * 1.0 / x);  
                ou.print(q * t + "\n");     
                ou.flush();
        }
}

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

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

    double s, l, h;
    s = a * b * sin(c / 180.0 * M_PI) / 2;
    l = sqrt((a * a) + (b * b) - 2 * a * b * cos(c / 180.0 * M_PI)) + a + b;
    h = 2 * s / a;

    cout << fixed << setprecision(7) << s << endl;
    cout << fixed << setprecision(7) << l << endl;
    cout << fixed << setprecision(7) << h << endl;
}



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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll A, B, C, D;
  cin >> A >> B >> C;
  if (A%B!=0){
    cout << (A/B)*C+C;
  }
  else cout << (A/B)*C;
}

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

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int d=a*x+b*y; //baragai
  int e=c*max(x,y)*2; //ABnomi
  int f;
  if(x>y) f=c*y*2+(x-y)*a;
  else f=c*x*2+(y-x)*b;
  cout<<min({d,e,f});

}


Measured memory_bytes: 3604
package main

import (
  "fmt"
)

var (
  a,b,x,y int
)

func main() {
  fmt.Scanf("%d%d",&a,&b)
  if a > b {
    x = a
    a--
  } else {
    x = b
    b--
  }
  if a > b {
    y = a
    a--
  } else {
    y = b
    b--
  }
  fmt.Println(x + y)
}

Measured memory_bytes: 512
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << "\n";
}



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

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

    static class CFiveTransportations {
        static double EPS = 1e-6;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long n = in.nextLong(), a[] = new long[5];
            for (int i = 0; i < 5; ++i) a[i] = in.nextLong();
            long m = a[0];
            for (int i = 1; i < 5; ++i) m = Math.min(m, a[i]);
            if (m >= n) out.println(5);
            else out.println((long) (Math.ceil(n * 1.0 / m + EPS) + 4));
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 23124
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())

if (n%2==0):
    print(n)
else:
    print(n*2)




Measured memory_bytes: 9128
package main
import (
  "fmt"
)

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

func main() {
  var n int
  fmt.Scan(&n)
  bs := make([]int, n-1)
  for i := 0; i < n-1; i++ {
    fmt.Scan(&bs[i])
  }
  result := bs[0]
  for i, b := range bs {
    if i == n-2 {
      result += b
      break
    }
    result += min(b, bs[i+1])
  }
  fmt.Println(result)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(in) in.begin(), in.end()
#define FIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int, int> PII;

int main(){
    FIO;
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i = 0 ; i < n ; i++){
        cin >> arr[i];
    }
    ll m1=arr[0], cnt=0, m2=-1;
    for(ll i = 0 ; i < n ; i++){
        m1 = max(arr[i], m1);
    }
    for(ll i = 0 ; i < n ; i++){
        if(arr[i] == m1 && cnt){
            cnt = 2;
            m2 = arr[i];
        }else if(arr[i] == m1 && !cnt){
            cnt++;
        }else{
            m2 = max(arr[i], m2);
        }
    }
    for(ll i = 0 ; i < n ; i++){
        if(cnt == 2){
            cout << m1 << endl;
        }else{
            if(arr[i] == m1){
                cout << m2 << endl;
            }else{
                cout << m1 << endl;
            }
        }
    }
    return 0;
}


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

const int mod = 9;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    rep(i,s.size()) {
        sum+=s[i]-'0';
        sum%=mod;
    }
    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

LL n,a,b,ans;

int main(){
	scanf("%lld%lld%lld",&n,&a,&b);
	ans=n; 
	if (a%2==b%2) ans=abs(a-b)/2;
	ans=min(ans,max(a,b)-1);
	ans=min(ans,n-min(a,b));
	if (a>b) swap(a,b);
	ans=min(ans,(a-1)+(b-a)/2+1);
	ans=min(ans,(n-b)+(b-a)/2+1);
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int cnt[10][10];

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

  for(int i = 1; i <= n; ++i){
  	int e = i % 10;
  	int a;
  	int j = i;
  	while(j){
  		a = j;
  		j /= 10;
  	}
  	++cnt[a][e];
  }

  ll ans = 0;
  for(int i = 0; i <= 9; ++i){
  	for(int j = 0; j <= 9; ++j){
  		ans += cnt[i][j] * cnt[j][i];
  	}
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int main()
{
  int n = in() ;
  unordered_map<string , int> mp
  ;string s ;
  mp["AC"] = mp["WA"] = mp["TLE"] = mp["RE"] = 0 ;
  for(int i = 1 ; i <= n ;i ++ )
   cin >> s , mp[s] ++ ;
  cout << "AC x " << mp["AC"] << endl ;
  cout << "WA x " << mp["WA"] << endl ;
  cout << "TLE x " << mp["TLE"] << endl ;
  cout << "RE x " << mp["RE"] << endl ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3268
#include <stdio.h>

int main(void)
{
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if ( 0 <= (x-r) && (x+r) <= w 
            && 0 <= (y-r) && (y+r) <= h) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 584
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans -= cin.nextInt();
            ans += cin.nextInt();
            ans++;
        }
        Console.WriteLine(ans);
    }
    


}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'




int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
     // int t;
     // cin >> t;

     // while(t--){
 		

     // }

     int n;
     cin >> n;
     string arr;
    	cin >> arr;
     int i = 0;
     int j = n-1;
     int count = 0;
     while(i < j){
     	while(i < j && arr[i] == 'R')i++;
     	while(i < j && arr[j] == 'W')j--;
    	if(i < j){
    		swap(arr[i],arr[j]);
    		j--;
    		i++;
    		count++;
    	}

     }
     cout << count << endl;



return 0;
}




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

ll n, m, i, j, w[109], v[109], dp[109][100009];
int main()
{
    cin >> n >> m;

    for(i = 1; i <= n; i++)
        cin >> w[i] >> v[i];

    for(i = 0; i <= m; i++)
        dp[0][i] = 0;

    for(i = 1; i <= n; i++)
    {
        for(j = 0; j <= m; j++)
        {
            if(j < w[i])
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);
        }
    }

    cout << dp[n][m];
}


Measured memory_bytes: 80128
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n int
  fmt.Scan(&n)
  d := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d[i])
  }
  sort.Ints(d)
  firstI := n/2 - 1
  secondI := n/2
  result := 0
  if d[firstI] != d[secondI] {
    result = d[secondI] - d[firstI]
  }
  fmt.Println(result)
}

Measured memory_bytes: 5504
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

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

	cin >> a >> b >> c;

	if (a + b == c || a + c == b || c + b == a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


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

  int gcnt = 0;
  for(int i = 1; i <= N; i++){
    int dcnt = 0;
    int num = i;
    while(num != 0){
        num /= 10;
        dcnt++;
    }
    if((dcnt % 2) != 0){
      gcnt++;
    }
  }

  cout << gcnt << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        while (true) {
            int h, w;
            h = sc.nextInt();
            w = sc.nextInt();
            if (h == 0 && w == 0)
                break;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                        System.out.print("#");
                    else
                        System.out.print(".");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
  
}


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

int main(){
  long A,B;
  cin>>A>>B;
  long sum=A;
  long  ans=1;

  while(sum<B){
   sum+=A-1;
    ans++;
  }
  if(B==1)ans=0;
  cout<<ans<<endl;
}
  
  

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

using namespace std;

int main (void) {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;

    for ( int i = 0; i < dy; i++ )
        cout << 'U';
    for ( int i = 0; i < dx; i++ )
        cout << 'R';
    for ( int i = 0; i < dy; i++ )
        cout << 'D';
    for ( int i = 0; i < dx; i++ )
        cout << 'L';
    cout << 'L';
    for ( int i = 0; i < dy+1; i++ )
        cout << 'U';
    for ( int i = 0; i < dx+1; i++ )
        cout << 'R';
    cout << 'D';
    cout << 'R';
    for ( int i = 0; i < dy+1; i++ )
        cout << 'D';
    for ( int i = 0; i < dx+1; i++ )
        cout << 'L';
    cout << 'U' << endl;

    return 0;
}


Measured memory_bytes: 3636
def main():

    s = list(input())
    ans = 0
    h = 0
    i = 0
    while i < len(s):
        if s[i] == "A":
            h += 1
            # print(i, h, s)
            if s[i:i+3] == ["A", "B", "C"]:
                ans += h
                h -= 1
                i += 2
                s[i] = "A"
            else:
                i += 1
        else:
            h = 0
            i += 1
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 4840
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn main(){
    let line = read_as_vec::<u32>();
    let (n, a, b) = (line[0], line[1], line[2]);

    println!("{}", cmp::min(n*a, b));
}


Measured memory_bytes: 4352
/**
 *      ABC 90 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-01 00:22:28
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string c1, c2, c3; cin >> c1 >> c2 >> c3;
    cout << c1[0] << c2[1] << c3[2] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;

template <typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

vector<ll> fact(222222, 1), inv(222222, 1);

ll comb(int n, int r)
{
    if (r < 0 || n < r)
        return 0;
    ll ret = fact[n] * inv[r] % MOD;
    ret = ret * inv[n - r] % MOD;
    return ret;
}

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

    ll n, m, k;
    cin >> n >> m >> k;
    for (ll i = 2; i <= 220000; i++)
    {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = mypow(fact[i], MOD - 2);
    }
    ll ret = 0;
    for (ll i = 0; i <= k; i++)
    {
        // n + 2i 回左右移動
        ll a = comb(n + 2 * i, i) * (n + 1) % MOD;
        a = a * mypow(n + i + 1, MOD - 2) % MOD;
        ll j = k - i;
        ll b = comb(m + 2 * j, j) * (m + 1) % MOD;
        b = b * mypow(m + j + 1, MOD - 2) % MOD;
        ll sum = a * b % MOD;
        sum = sum * comb(n + m + 2 * k, n + 2 * i) % MOD;
        ret = (ret + sum) % MOD;
    }
    cout << ret << endl;
}



Measured memory_bytes: 6068
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count = 0;
		for(int i = 1;i<=N;i++) {
			if(String.valueOf(i).length()%2==1) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 28240
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B, C;
  cin >> A >> B >> C;

  long ans = (A%2) * B * C;
  ans = min(ans, (B%2) * A * C);
  ans = min(ans, (C%2) * B * A);

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	string str;

	cin >> str;

	if (str[0] == str[2])
	{
		cout << "Yes" << endl;
	}else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

#define topper top //XDDDDDDD

#define mp make_pair
#define pb push_back
#define db(x) cerr << #x << " == " <<  x << endl;
#define _ << " " <<

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

const long double EPS = 1e-9;
const int N=1e5+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;

int n;
char s[30], cur;

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

  int l = 0, r = n-1;

  printf("%d\n", l);
  fflush(stdout);

  scanf("%s", s);
  if(s[0] == 'V') return 0;

  cur = s[0];

  for(int i=0; i<20; i++) {
    int mid = (l+r+1)/2;
    printf("%d\n", mid);
    fflush(stdout);

    int swt = (mid - l) & 1;
    
    scanf("%s", s);
    if(s[0] == 'V') return 0;
    if((swt and s[0] != cur) or (!swt and s[0] == cur)) l = mid, cur = s[0];
    else r = mid-1;
  }

	return 0;
}



Measured memory_bytes: 852
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll n;
ll t[1010],a[1010];

int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>t[i]>>a[i];
	ll ans1=1,ans2=1;
	for(int i=0;i<n;i++){
		ll n=max(((t[i]-1+ans1)/t[i]),(a[i]-1+ans2)/a[i]);
		ans1=n*t[i];
		ans2=n*a[i];
	}
	cout<<ans1+ans2<<endl;
	return 0;
}

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

constexpr auto mod = 998244353ll;

template <class T>
T pow(T x, T n, T mod) {
    T ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

template <class T>
T inverse(T x, T p) { return pow(x, p - 2, p); }

int main() {
    long long n, k;
    std::cin >> k >> n;
    std::vector<long long> fact(10001), inv(10001), a(2 * k - 1);
    fact[0] = 1;
    for (auto i = 1; i <= 10000; i++) fact[i] = fact[i - 1] * i % mod;
    inv[10000] = inverse(fact[10000], mod);
    for (auto i = 10000; i > 0; i--) inv[i - 1] = inv[i] * i % mod;

    for (int i = 2; i <= k + 1; i++) {
        auto ret = 0ll;
        for (int j = 0; j <= std::min((i - 1) / 2, (int)n); j++) {
            if (!j && i > k) continue;
            auto cnt = fact[(i - 1) / 2] * inv[j] % mod * inv[(i - 1) / 2 - j] % mod
                * pow(2ll, (long long)j, mod) % mod
                * fact[j + (k - (i - 1)) - 1 + n - j] % mod * inv[n - j] % mod * inv[j + (k - (i - 1)) - 1] % mod;
            ret = (ret + cnt) % mod;
        }
        if (i % 2 == 0) {
            for (int j = 0; j <= std::min(i / 2 - 1, (int)n - 1); j++) {
                if (!j && i > k) continue;
                auto cnt = fact[(i - 1) / 2] * inv[j] % mod * inv[(i - 1) / 2 - j] % mod
                    * pow(2ll, (long long)j, mod) % mod
                    * fact[j + (k - (i - 1)) - 1 + n - 1 - j] % mod * inv[n - 1 - j] % mod * inv[j + (k - (i - 1) - 1)] % mod;
                ret = (ret + cnt) % mod;
            }
        }
        a[i - 2] = ret;
    }

    for (int i = 0; i < 2 * k - 1; i++) std::cout << a[std::min(i, 2 * (int)k - 2 - i)] << std::endl;

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,char> pl;

vector<int> G[200001];
vector<ll> dp(200001,0);
vector<bool> memo(200001,0);

void dfs(int node,int cost){
  dp[node]+=cost;
  memo[node]=1;
  for(int i=0;i<G[node].size();i++){
    int to=G[node][i];
    if(memo[to])continue;
    int tocost=dp[node];
    dfs(to,tocost);
  }
}

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

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

  dfs(0,0);
  for(i=0;i<n;i++){
    cout<<dp[i]<<(i==n-1?"\n":" ");
  }
}


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

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

int main() {
    int x, n;
    cin >> x >> n;
    int ans = 0, mval = 1000;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    for(int i = -200; i <= 200; i++){
        bool check = true;
        rep(j, v.size()){
            if(i == v[j]){
                check = false;
                break;
            }
        }
        if(check){ 
            int m = abs(x - i);
            if(m < mval){
                mval = m;
                ans = i;
            }
        }
    }
    cout << ans << endl;
    return 0;    
}


Measured memory_bytes: 3628
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    a, b = map(int, input().split())

    ans = 2000
    for i in range(1, 1001):
        if a == math.floor((i * 1.08)) - i and b == math.floor((i * 1.10)) - i:
            ans = min(ans, i)
    if ans == 2000:
        print('-1')
    else:
        print(ans)


main()


Measured memory_bytes: 38256
#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;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 R,G,B,N;
    cin >> R >> G >> B >> N;

    i64 ans=0;
    rep(r,0,N+1){
        rep(g,0,N+1){
            i64 rem=N-(r*R+g*G);
            if(rem<0 or rem%B!=0) continue;
            ++ans;
        }
    }

    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: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,W;cin >> n >> W;
  vector<ll> w(n),v(n);
  int vsum=0;
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
    vsum+=v[i];
  }
  vector<vector<ll>> d(n+1,vector<ll>(vsum+1,1e18));
  d[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=vsum;j++){
      if(j-v[i]>=0){
        d[i+1][j]=min(d[i][j-v[i]]+w[i],d[i][j]);
      }
      else{
        d[i+1][j]=d[i][j];
      }
    }
  }
  for(int i=vsum;i>=0;i--){
    if(d[n][i]<=W){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	int cnta = 0, cntb = 0, cntab = 0;
	while(n--){
		string x;
		cin >> x;
		int n = x.length();
		if(n == 1){
			if(x[0] == 'A') cnta++;
			else if(x[0] == 'B') cntb++;
			continue;
		}
		for(int i = 0; i < n - 1; i++)
			if(x[i] == 'A' && x[i + 1] == 'B')
				ans++;
		if(x[0] == 'B' && x[n - 1] == 'A') cntab++;
		else if(x[0] == 'B') cntb++;
		else if(x[n - 1] == 'A') cnta++;
	}
	if(cnta > 0 || cntb > 0){
		ans += min(cnta, cntb) + cntab;
	}
	else{
if(cntab >0)
		ans += cntab - 1;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;

int main(){
	//データの読み込み
	int A;	//500円玉の枚数
	int B;	//100円玉の枚数
	int C;	//50円玉の枚数
	int X;	//合計金額
	cin >> A >> B >> C >> X;

	//main
	// int cnt = 0;
	// int maxA = X / A;
	// for (int cntA = 0; cntA <= maxA; ++cntA){
	// 	int maxB = (X - cntA * 500) / B;
	// 	for (int cntB = 0; cntB <= maxB; ++cntB){
	// 		int rem = X - cntA * 500 - cntB * 100;
	// 		for (int cntC = 0; cntC < count; ++cntC) {
	// 			/* code */
	// 		}
	// 	}
	// }

	int cnt = 0;
	for (int cntA = 0; cntA <= A; ++cntA){
		for (int cntB = 0; cntB <= B; ++cntB){
			for (int cntC = 0; cntC <= C; ++cntC){
				int value = 500 * cntA + 100 * cntB + 50 * cntC;
				if (value == X){
					cnt++;
				}
			}
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  string A;
  cin >> K;
  cin >> S;
  
  if (S.size() <= K) {
    cout << S << endl;
  }
 
  else {for (int i = 0; i < K; i++) {
    A += S.at(i);
}
    cout << A << "..." << endl;
  }
 
  
}

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

using namespace std;
 
typedef long long ll;


int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b;
    vector<int> a[21]; 
    for(int i = 0; i < m; i++)
    {
        int tmp;
        cin >> tmp;
        b.push_back(tmp);       
    }
    
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            int tmp;
            cin >> tmp;
            a[i].push_back(tmp);       
        }
    }
    
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        int score = 0;
        for(int j = 0; j < m; j++)
        {
            score += a[i][j]*b[j];
        }

        score += c;
        //printf("%d\n",score);
        if (score > 0) ans++;
    }
    
    cout << ans;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def combi2(k):
    return k * (k - 1) // 2

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    sum_a = [0]
    for i in range(n):
        sum_a.append(sum_a[-1] + ai[i])

    di = {}
    for s in sum_a:
        if s not in di:
            di[s] = 1
        else:
            di[s] += 1

    res = 0
    for s in di:
        if di[s] >= 2:
            res += combi2(di[s])

    print(res)

main()


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

int n,m,q,a,b,c,d;
vector<int>V;
int sol=0;
int arrA[55];
int arrB[55];
int arrC[55];
int arrD[55];

void check() {
    int cnt=0;
    for (int i=0;i<q;i++) {
        if (V[arrB[i]-1]-V[arrA[i]-1]==arrC[i]) cnt+=arrD[i];
    }
    sol=max(sol,cnt);
}

void rek(int i,int last) {
    if (i==n) {
        check();
        return;
    }
    for (int j=last;j<=m;j++) {
        V.push_back(j);
        rek(i+1,j);
        V.pop_back();
    }
}

int main() {
    cin >> n >> m >> q;
    for (int i=0;i<q;i++) {
        cin >> arrA[i] >> arrB[i] >> arrC[i] >> arrD[i];
    }
    rek(0,1);
    cout << sol;
}


Measured memory_bytes: 3608
#DPトレーニング
#ABC099 C
#dp[i]と言うと本来「i番目までの整数の中から整数を選んで総和をとったときの総和の最大値」
#だが、これを読み替え「整数を選んで総和iにしたときの回数の最小値」とする

N = int(input())

F = [1]
F += [pow(6,i) for i in range(1,7)]
F += [pow(9,i) for i in range(1,6)]

dp = [0]

for i in range(1,N+1):
    dp.append(dp[i-1]+1) #1を選択すると、回数は1回増える
    for f in F:
        if i-f>=0: #一番回数の少ないトコからその値に辿り着けるfを選択
            dp[i] = min(dp[i],dp[i-f]+1) 
            
print(dp[N])

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  int k, n;
  scanf("%d %d", &k, &n);
  
  int p1;
  scanf("%d", &p1);
  
  int p = p1, q, d = 0;
  for(int i = 1; i < n; i++){
    scanf("%d", &q);
    d = max(d, q - p);
    p = q;
  }
  
  printf("%d", min(k - d, p - p1));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const ll INF = 1e18 + 5;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

const int mxs = 402;
int main()
{
    int n;
    ll dp[mxs][mxs] = {}, in[mxs];
    cin >> n;

    for(int i = 0; i< n; i++)
    {
		cin >> in[i];
	}
	auto sum = [&](int l, int r)
	{
			ll s = 0;
			for(int i = l; i <= r; i++)
				s += in[i];
			return s;
	};
	for(int i = n - 1; i >= 0; i--)
	{
		for(int j = i; j < n; j++)
		{
			if(i == j) dp[i][j] = 0;
			else
			{
				dp[i][j] = INF;
				ll s = sum(i, j);
				for(int k = i; k <= j - 1; k++)
				{
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]  + s);
				}
			}
		}
	}
	/* 
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
			cout << dp[i][j] << ' ';
		cout << '\n';
	}
	*/
	cout << dp[0][n - 1] << '\n';
}


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

//typedef pair <int, int> ii;
//typedef vector <ii> vii;
//typedef vector <int> vi;
typedef  long long ll;
typedef unsigned long long ull;

#define MAX 100000
#define inf (1061109567)
#define pb(x) push_back(x)
#define pp(x) pop_back(x)
#define stream istringstream
#define mem(x,y) memset(x,y,sizeof(x));
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define repv(i,n) for(int i=n-1; i>=0; i--)
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define mp make_pair
#define ff first
#define ss second



using namespace std;

int main()
{
    string s;
	cin >> s;
	if((s[0] != s[1] && s[0] != s[2]) && s[1] != s[2])
        cout << "Yes\n";
    else
        cout << "No\n";
   // main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  int b,a[100];
  cin>>b;
  for(int i=0;i<b;i++){
    cin>>a[i];
  }
  for(int i=b-1;i>=0;i--){
    cout<<a[i];
    if(i!=0)cout<<" ";
  }
  cout<<endl;
  
    return 0;
}



Measured memory_bytes: 3136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, x, put;
    cin >> n >> x;
    vi v;
    for(int i = 0; i < n; i++){
        cin >> put;
        v.pb(put);
    }
    
    vi sumv;
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum+=v[i];
        sumv.pb(sum);
    }
    sumv.pb(0);
    sort(all(v));
    int ans = 0;
    for(int i = 0; i < (n+1); i++){
        if(sumv[i]<=x){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
#define pi 3.1415926535897
int gcd(int a, int b) {
	if (b != 0) return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int a, b; cin >> a >> b;
	bool f = false;
	rep(i, a + 1){
		if(i * 2 + (a - i) * 4 == b) f = true;
	}
	Yes(f);
}

Measured memory_bytes: 3636
// Problem: A - Not
// Contest: AtCoder - AtCoder Beginner Contest 178
// URL: https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long int
#define vi vector<int>
#define vii vector<int, int>
#define vc vector<char>
#define vl vector<ll>
#define mod 1000000007 
#define INF 1000000009
using namespace std;


int main()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
     cout.tie(0);
     
     
    	int n;
    	cin >> n;
    	
    	if(n == 0) {
    		cout << "1\n";
    	}
    	else {
    		cout << "0\n";
    	}
     
     
     
     
     
return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    long long x, k, d;
    cin>>x>>k>>d;
    x = abs(x);
    d = abs(d);
    if(k <= ((x-x%d)/d)) {
        cout<< x - k*d;
    } else{
        long long movesleft = k - (x-x%d)/d;
        long long t = abs(x%d - d);
        if(movesleft % 2)
        cout<<abs(t);
        else
        {
            cout<<abs(x%d);
        }
        
    }
    return 0;
}

Measured memory_bytes: 3648
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

int n,x ;
int a[100];


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

	cin >> n >> x;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int ans = 0;
	rep(i,n) {
		if (a[i] <= x) {
			x -= a[i];
			ans++;
		}
	}
	if (x && ans == n)ans--;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
/*#include <vector>
#include <string>
#include <iostream>*/
using namespace std;

vector<string> split(string s, char dev){
	int first = 0;
	int last = s.find_first_of(dev);

	vector<string> result;

	while (first < s.size()){
		string subStr(s, first, last - first);

		result.push_back(subStr);

		first = last + 1;
		last = s.find_first_of(dev, first);

		if (last == string::npos){
			last = s.size();
		}
	}

	return result;
}

int main(void){
	int B;
	long long sum = 0, sumsub = 0;
	string S, Stmp("");
	//int N = 6;
	vector<string> S_devided(30);
	/*for(int i = 0; i< N; i++){
	cin >> E[i];
	}*/
	cin >> S;
	//cin >> B;
	//cin >> L;
	for (int i = 0; i < 1 << (S.size() - 1); i++){
		sumsub = 0;
		Stmp = "";
		for (int j = 0; j < S.size(); j++){
			Stmp += S[j];
			if (S.size() - 2 - j >= 0 && (i & (1 << (S.size() - 2 - j))) > 0){
				Stmp += '+';
			}
		}
		
		S_devided = split(Stmp, '+');
		/*for (int k = 0; k < S_devided.size(); k++){
			cout << S_devided[k] << " ";
		}
		cout << "\n";*/
		for (int l = 0; l < S_devided.size(); l++){
			sumsub += stoll(S_devided[l]);
		}
		sum += sumsub;
	}


	cout << sum - stoll(S) << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
f = int(s[:2])
b = int(s[2:])

if 0 < f and f < 13:
    if 0 < b and b < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 0 < b and b < 13:
        print('YYMM')
    else:
        print('NA')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vvll G(N, vll(0));
  vll incount(N, 0);
  for(int i = 0; i < N-1+M; i++){
    ll A, B;
    cin >> A >> B;
    A--; B--;
    G.at(A).push_back(B);
    incount.at(B)++;
  }
  int root;
  for(int i = 0; i < N; i++){
    if(incount.at(i) == 0){
      root = i;
      break;
    }
  }
  queue<int> que;
  que.push(root);
  vll num(N, -1);
  num.at(root) = 0;
  vll par(N, -1);
  par.at(root) = 0;
  while(!que.empty()){
    int v = que.front(); que.pop();
    for(int i = 0; i < sz(G.at(v)); i++){
      int next = G.at(v).at(i);
      incount.at(next)--;
      if(incount.at(next) == 0){
        num.at(next) = num.at(v) + 1;
        par.at(next) = v+1;
        que.push(next);
      }
    }
  }
  for(auto x: par) cout << x << endl;
}

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

using namespace std;

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

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

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

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

#define fst first
#define snd second

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

int tan( int money, int year, double rishi, int tesu )
{
	int t_rishi = 0;
	int res = money;
	REP( i, 0, year )
	{
		t_rishi += res * rishi;
		res -= tesu;
	}
	return res + t_rishi;
}

int fuku( int money, int year, double rishi, int tesu )
{
	REP( i, 0, year )
	{
		money += money * rishi;
		money -= tesu;
	}
	return money;
}

int ( * const funcs[] )( int m, int y, double r, int t ) = { tan, fuku };

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

	int m;
	cin >> m;
	REP( times, 0, m )
	{
		int money, year, n;
		cin >> money >> year >> n;

		VI type( n ), tesu( n );
		vector<double> rishi( n );

		REP( i, 0, n )
		{
			cin >> type[i] >> rishi[i] >> tesu[i];
		}

		int res = 0;
		REP( i, 0, n )
		{
			res = max( res, (*funcs[ type[i] ])( money, year, rishi[i], tesu[i] ) );
		}

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1248