akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int a[200005],b[200005];
int main()
{
	int n;
	cin>>n;
	map<int,int>cnt;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i] = a[i];
		cnt[a[i]]++;
	}
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++)
	{
		if(a[i] == b[0] && cnt[b[0]] == 1)cout<<b[1]<<endl;
		else cout<<b[0]<<endl;
	}
	
}

Measured memory_bytes: 8704
/*
 0…未確定
 1…素数
 2…素数でない
*/
#include <iostream>

using namespace std;

int main(){
    int num[1000000]={0}, b, a, n, c;
    for(int i=2;i<=1000;i++){
        if(num[i]==0){
            num[i]=1;
            b=1;
            while((a=(++b*i))<1000000) num[a]=2;
        }
    }

    while(cin >> n){
        c=0;
        for(int i=2;i<=n;i++) {
            if(num[i]==1||num[i]==0) c++;
        }
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 5072
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val v :Array[Double] = StdIn.readLine().split(" ").map(_.toDouble)

  print(v.sorted.tail.foldLeft(v.sorted.head) { (acc, elem) =>
    (acc + elem) / 2
  })

}


Measured memory_bytes: 25424
#include<stdio.h>

int main(){
  int n;
  int i,j;
  int p;
  int point;
  int s[100] = {0};

  for(j = 0;;j++){
    point = 0;
  do{
    scanf("%d",&n);
  }while(n % 4 != 0);

  if(n == 0){break;}

  for(i = 0; i < n/4; i++){
    scanf("%d",&p);
    point += p;
  }

  s[j] = point;
  }

  for(i = 0; i < j; i++){
    printf("%d\n",s[i]);
  }
  return 0;
}
    

Measured memory_bytes: 596
#include<iostream>

using namespace std;

struct Point{
  double x, y;
  Point(){ x = 0; y = 0; }
  Point(double x_, double y_){ x = x_; y = y_; }
};

bool rotation_direction(const Point& p1, const Point& p2, const Point& p3){
  double x = p1.x*(p2.y-p3.y) + p2.x*(p3.y-p1.y) + p3.x*(p1.y-p2.y);
  return (x > 0);
}

bool solve(const Point& a, const Point& b, const Point& c, const Point& p){
  bool flag = rotation_direction(a, b, c);
  return (flag == rotation_direction(p, a, b) &&
	  flag == rotation_direction(p, b, c) &&
	  flag == rotation_direction(p, c, a));
}

int main(){
  Point a, b, c, p;
  while(cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> p.x >> p.y){
    if(solve(a, b, c, p)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
use proconio::input;
use std::collections::BTreeMap;

fn factors(n: i64) -> BTreeMap<i64,i64> {
    let mut result = BTreeMap::new();
    let mut ntmp = n;
    for i in 2..n + 1 {
        if i * i > n {
            break;
        }
        while ntmp % i == 0 {
            *result.entry(i).or_insert(0) += 1;
            ntmp /= i;
        }
    }
    if ntmp != 1 {
        *result.entry(ntmp).or_insert(0) += 1;
    }
    result
}

fn calc_num(count: i64) -> i64 {
    let mut ans = 0;
    let mut sum = 0;
    for i in 1..count+1 {
        if sum + i > count {
            break;
        }
        ans += 1;
        sum += i;
    }
    ans
}

fn main() {
    input! {
        n: i64,
    }
    let fs = factors(n);
    let mut ans = 0;
    for v in fs.values() {
        ans += calc_num(*v);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  ll n, k;
  cin >> n >> k;
  int cnt = 0;
  while (n > 0)
  {
    n /= k;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int main(){
    long long n,a,b;
    long long kurikaesi;
    long long aonum=0;

    cin >> n;
    cin >> a;
    cin >> b;

    kurikaesi = n / (a+b);
    aonum = a * kurikaesi;
    if((n % (a+b))>a){
        aonum += a;
    }else{
        aonum += n % (a+b);
    }

    
    cout << aonum << endl;
}

Measured memory_bytes: 256
require 'prime'

n = gets.strip.to_i

primes = (2..n).to_a.map(&:prime_division).inject([], :+)

dims = primes.group_by(&:first).map {|k, arr| arr.map(&:last).inject(:+) }

#p primes
#p dims
result = 0

# 5,5,3
dims.select {|e| e>=2 }.combination(3).each do |d1, d2, d3|
  result += 1 if (d1>=4 && d2>=4 && d3 >= 2)
  result += 1 if (d1>=4 && d2>=2 && d3 >= 4)
  result += 1 if (d1>=2 && d2>=4 && d3 >= 4)
end

#75
result += dims.select {|e| e>=74 }.length

#15,5
dims.select {|e| e>=4 }.combination(2).each do |d1, d2|
  result += 1 if d1>=14 && d2 >= 4
  result += 1 if d1>=4 && d2 >= 14
end

#25,3
dims.select {|e| e>=2 }.combination(2).each do |d1, d2|
  result += 1 if d1>=24 && d2 >= 2
  result += 1 if d1>=2 && d2 >= 24
end

p result


Measured memory_bytes: 2044
#!/usr/bin/env python3
import sys


def solve(R: int, G: int, B: int, N: int):
    ret = 0
    for r in range(N // R + 1):
        rest = N - r * R
        for g in range(rest // G + 1):
            if (rest - g * G) % B == 0:
                ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007;

int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        // #ifndef ONLINE_JUDGE
        //     freopen("input.txt","r",stdin);
        //     freopen("output.txt","w",stdout);
        // #endif
        string s;cin>>s;
        if(s[0]=='7'||s[1]=='7'||s[2]=='7'){
            cout<<"Yes"<<endl;
        }
        else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3612
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,ans; string s;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);cin>>s;char last=s[0];
	for(int i=1;i<n;i++){
		if(s[i]==last)continue;
		else{
			ans++;last=s[i];
		}
	}
	ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const long long LINF = (1LL << 60);

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

  vector<int> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }

  long long ans = T;
  for (int i = 1; i < N; i++) {
    if (t[i] - t[i - 1] >= T) {
      ans += T;
    } else {
      ans += t[i] - t[i - 1];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int n,x;
	cin >> n >> x;
	while(n != 0){
		int way = 0;
		for (int i = 1; i <= n; i++){
			for (int j = i + 1; j <= n; j++){
				for (int k = j + 1; k <= n; k++){
					if (i + j + k == x && i != j && i != k && j != k){
						way += 1;
					}
				}
			}
		}
		cout << way << endl;
		cin >> n >> x;
	}
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void) {
	int i, j;
	int scnt = 0;
	int tcnt = 0;
	int ans_diff;
	int diffcnt;
	char s[1001],t[1001];
	scanf("%s",s);
	scanf("%s",t);
	for (i = 0; s[i] != '\0'; i++)scnt++;
	for (i = 0; t[i] != '\0'; i++)tcnt++;
	ans_diff = tcnt;
	for (i = 0;i + tcnt<=scnt; i++) {
		for (j = 0, diffcnt = 0; j < tcnt; j++) {
			if (s[i + j] != t[j])diffcnt++;
		}
		if (diffcnt < ans_diff)ans_diff = diffcnt;
	}
		printf("%d", ans_diff);
	return 0;
}

Measured memory_bytes: 1712
#include <iostream>

int main() {
  int N, K, X, Y;
  std::cin >> N >> K >> X >> Y;

  int fee = 0;
  for (int i = 1; i <= N; ++i) {
    if ( i <= K ) fee += X;
    else fee += Y;
  }
  std::cout << fee << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++)
    scanf("%d",&a[i]);
    int count=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[k]+a[j]>a[i] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]){
                    //printf("%d %d %d\n",i+1,j+1,k+1);
                    count++;
                }
                //count++;
            }
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 1732
fun main(args: Array<String>) {
    val (N, K) = listOfInt()
    val S = next().map { it - '0' }
    val A = mutableListOf<Int>()  //1・0の連続数
    var c = 0
    var h = 1   //1始まり
    S.forEach {
        if (it != h) {
            A.add(c)
            h = it
            c = 1
        } else c += 1
    }
    if (c > 0) A.add(c)
    if (A.size % 2 == 0) A.add(0)   //1終わり

    val W = Array(A.size + 1) { 0 }
    for (n in 0 until A.size) W[n + 1] = W[n] + A[n]
    var ans = 0
    for (n in 0 .. A.size - 1 step 2) {
        val left = n
        val right = Math.min(n + (2 * K + 1), A.size)
        val tmp = W[right] - W[left]
        if (ans < tmp) ans = tmp
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 39560
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var nmc = lines[0].split(' ');
 var nmc = nmc.map(function(str) { return Number(str)});
 var n = nmc[0];
 var m = nmc[1];
 var c = nmc[2];
 var count = 0;

 var b = lines[1].split(' ');
 var b = b.map(function(str) { return Number(str)});

 for(i=2; i<n+2; i++){
   var sum = c;
   var info = lines[i].split(' ');
   var info = info.map(function(str) { return Number(str)});
   for(j=0; j<m; j++){
     sum += info[j] * b[j]; 
   }
   if(sum>0){
     count++;
   }
   
   }
 
 console.log(count);
});

Measured memory_bytes: 7756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int ans = 0;
    for (int i = n-1; i >= 0; i -= 2) {
        if (i != 0) ans += a[i]-a[i-1];
        else ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 998244353;
/*************************************************************************/

ll x;
void solve() {
    cin>>x;
    ll num = x/500;
    x -= x/500 * 500;
    ll res = x/5*5 + num*1000;
    cout<<res<<endl;
}

int main()
{
#ifndef ONLINE_JUDGE
  //freopen("/Users/chong_wang/Desktop/ev/Code/i.txt", "r", stdin);
  //freopen("o.txt", "w", stdout);
#endif
     solve();
  return 0;
}





Measured memory_bytes: 256
from bisect import bisect_left

N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()

def isOverEq(n):
    cnt = 0
    for a in A:
        cnt += N - bisect_left(A, n - a)
    return cnt >= M

overEq = -1
less = A[-1] * 2 + 100
while less - overEq > 1:
    mid = (less + overEq) // 2
    if isOverEq(mid):
        overEq = mid
    else:
        less = mid

accA = [0] * (N + 1)
for i, a in enumerate(A, start=1):
    accA[i] = accA[i - 1] + a

ans = 0
cnt = 0
for a in A:
    i = bisect_left(A, overEq - a)
    ans += accA[N] - accA[i]
    ans += (N - i) * a
    cnt += N - i

ans -= max(0, cnt - M) * overEq
print(ans)


Measured memory_bytes: 14324
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       ArrayList<Integer> arraylist = new ArrayList<Integer>();
       int N = sc.nextInt();//枚数
       int Y = sc.nextInt();//金額
       int []array = new int[N];
       if(Y > (N *10000) || Y < (N * 1000) ){
           System.out.println("-1 -1 -1");
           System.exit(0);
       }else if(N == 2000 && Y == 20000000){
           System.out.println("2000 0 0");
           System.exit(0);
       }
       for(int i = N; i >=0; i--){
           for(int j = 0; j < N+1; j++){
               if(10000*i + 5000*j + 1000*(N-(i+j)) == Y && (N-(i+j))>=0){
                    System.out.println(i+" "+j+" "+(N-(i+j)));
                    System.exit(0);
               }
           }
       }
       System.out.println("-1 -1 -1");
        

    }
}




Measured memory_bytes: 24148
import math


A, B, H, M = map(int, input().split())

_h = (H * 60 + M) * 0.5
_m = M * 6

theta = abs(_h - _m)
theta = 360 - theta if theta > 180 else theta
theta = math.radians(theta)

c = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))

print(c)


Measured memory_bytes: 9440
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = bf.readLine().split("");
        for(int i=0; i<arr.length; i++) {
            if((i+1)%2 == 1) {
                if(!arr[i].equals("R") && !arr[i].equals("U") & !arr[i].equals("D")) {
                    System.out.println("No");
                    return;
                }
            } else {
                if(!arr[i].equals("L") && !arr[i].equals("U") & !arr[i].equals("D")) {
                    System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }

}

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

#define Fast           ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO             freopen("in.txt", "r", stdin)
#define FC             freopen("out.txt", "w", stdout)
#define aise           cout<<"aise"<<endl
#define pb             push_back
#define pf             push_front
#define ppb            pop_back
#define ppf            pop_front
#define mp             make_pair
#define ll             long long
#define all(x)         x.begin(), x.end()
#define mset(v, a)     memset(v, a, sizeof(v))
#define pll            pair< ll, ll >
#define pd             pair< double, double >
#define ff             first
#define ss             second
#define pi             acos(-1.0)
#define mxN            2010
#define inf            1e14
#define mod            1000000007
#define tc             ll tc;scanf("%lld",&tc);while(tc--)

//NCR iterative
/*voidcomb_table(intN)
{
    for(inti=0; i<=N; ++i)
    {
        for(intj=0; j<=i; ++j)
        {
            if(j==0or j==i)
            {
                C[i][j]=1LL;
            }
            else
            {
                C[i][j]=(C[i-1][j-1]+C[i-1][j]);
            }
        }
    }
}*/


//NCR recursive
/*ll dp[55][55];

ll NCR(ll n,ll r)
{

    if(n==r)
        return dp[n][r]=1;
    if(r==0)
        return dp[n][r]= 1;
    if(r==1)
        return dp[n][r]=n ;
    if(dp[n][r] != -1)
        return dp[n][r];
    return dp[n][r] = NCR(n-1,r)+NCR(n-1,r-1);
}*/

//Sieve:
/*bool Flag[1000010];
vector<ll> Prime;

void sieve()
{

    ll val=sqrt(1000010);
    for(ll i=4;i<=1000005; i+=2) Flag[i]=1;
    for(ll i=3;i <= val;i+=2)
    {

        if(Flag[i]==0)
        {

            for(ll j=i*i;j<=1000005;j+=i) Flag[j]=1;
        }
    }
    Flag[1]=1;
    for(ll i=1;i<=1000000;i++)
        if(Flag[i]==0) Prime.pb(i);
}*/


//Conversion
/*string bin(ll x)
{

    string ret;
    while(x)
    {

        ll t=x%2;
        char c;
        if(t==1)
            c='1';
        else
            c='0';
        ret.pb(c);
        x/=2;
    }
    reverse(all(ret));
    return ret;
}*/

/*ll lcm(ll x, ll y)
{

    ll ret=__gcd(x,y);
    return (x*y)/ret;
}*/

/*ll dx[]= {0,0,1,-1};
ll dy[]= {1,-1,0,0};*/

int main()
{

    ll n, ans=0;
    vector<ll> v, h;
    cin >> n;
    for(ll i=0;i<=n;i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    for(ll i=0;i<n;i++)
    {

        ll x;
        cin >> x;
        h.pb(x);
    }
    for(ll i=0;i<h.size();i++)
    {

        ll a=v[i];
        ll x=h[i];
        if(a<=x)
        {

            ans+=a;
            x-=a;
            v[i]=0;
        }
        else
        {

            ans+=x;
            v[i]-=x;
            x=0;
        }
        a=v[i+1];
        if(a<=x)
        {

            ans+=a;
            x-=a;
            v[i+1]=0;
        }
        else
        {

            ans+=x;
            v[i+1]-=x;
            x=0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 5608
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)




const int MAX_V = 128;
const int INF_F = 1<<29;

struct Edge {int to, cap, rev;};

struct Dinic {
    vector <Edge> G[MAX_V];
    int level[MAX_V], iter[MAX_V];

    void add_edge(int from, int to, int cap) {
        Edge e1 = {to, cap, (int)G[to].size()}, e2 = {from, 0, (int)G[from].size()-1};
        G[from].pb(e1), G[to].pb(e2);
    }

    void bfs(int s) {
        memset(level, -1, sizeof(level));
        queue <int> q;
        level[s] = 0;
        q.push(s);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for (auto &e : G[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    q.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < (int)G[v].size(); i++) {
            Edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            memset(iter, 0, sizeof(iter));
            int f;
            while ((f = dfs(s, t, INF_F)) > 0) {
                flow += f;
            }
        }
    }

};


void solve(void){
    int V, E;
    cin >> V >> E;

    Dinic dinic;

    rep(E, meaningless_) {
        int a, b, c;
        cin >> a >> b >> c;
        dinic.add_edge(a, b, c);
    }

    cout << dinic.max_flow(0, V-1) << endl;

}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  if(n==1||m==1){
    cout <<"1\n";
    return 0;
  }
  ans = (n/2+n%2)*(m/2+m%2)+(n/2)*(m/2);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
a,b,c=map(int,input().split())
ad=list(map(int,input().split()))
bd=list(map(int,input().split()))

ae=-1
be=-1
ans=0
gen=0
nokori=c
for i in range(a):
  if nokori>=ad[i]:
    nokori-=ad[i]
    gen+=1
    ae+=1
  else:
    break

for i in range(b):
  if nokori>=bd[i]:
    nokori-=bd[i]
    gen+=1
    be+=1
  else:
    break

ans=gen
while ae!=-1:
  nokori+=ad[ae]
  gen-=1
  ae-=1
  while be<b-1:
    if nokori>=bd[be+1]:
      nokori-=bd[be+1]
      gen+=1
      be+=1
    else:
      break
    
  if ans<gen:
    ans=gen
    
print(ans)
    
    

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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            String S = Console.ReadLine();
            String[] line = S.Split(' ');
            int[] X = new int[N];
            long ans = (int)Math.Pow(100,2)*100;

            for(int i=0; i<N; i++)
            {
                X[i] = int.Parse(line[i]);
            }

            for(int i=X.Min(); i<=X.Max(); i++)
            {
                long res = 0;
                for(int j=0; j<N; j++)
                {
                    res += (int)(Math.Pow(X[j] - i, 2));
                }
                if(res < ans)
                {
                    ans = res;
                }
            }

            Console.WriteLine(ans);


        }
    }
}

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

#define int long long
const int MOD = 998244353;

int dp[4001][4001];
int N;
string s;
int R[2001], B[2001];

int dfs(int r, int b) {
  if ( r+b == 2*N ) return 1;
  if ( dp[r][b] >= 0 ) return dp[r][b];

  int ret = 0;
  if ( r+b >= N ) {
    if ( R[N-1] > r ) ret += dfs(r+1, b);
    if ( B[N-1] > b ) ret += dfs(r, b+1);    
  } else {
    if ( R[r+b] > r ) ret += dfs(r+1, b);
    if ( B[r+b] > b ) ret += dfs(r, b+1);    
  }

  return dp[r][b] = ret%MOD;  
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  fill_n(*dp, 4001*4001, -1);
  cin >> s;
  N = s.size();

  for ( int i = 0; i < N; i++ ) {
    if ( i ) {
      R[i] += R[i-1];
      B[i] += B[i-1];      
    }
    if ( s[i] == '0' ) {
      R[i] += 2;
    }
    if ( s[i] == '1' ) {
      R[i]++;
      B[i]++;
    }
    if ( s[i] == '2' ) {
      B[i] += 2;      
    }
  }

  cout << dfs(0, 0) << endl;  
  
  return 0;
}


Measured memory_bytes: 125568
#include<bits/stdc++.h>
using namespace std;
int main() {
 int n;
 string s;
 cin >> n >> s;
 int ans = 0;
 for(int i = 0; i <= n - 3; i++) {
 if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') ans++;
 }
 cout << ans << endl;
 return 0;
 }


Measured memory_bytes: 3612
#include <stdio.h>

int main(){

  int a[26]={};
  int num,i;  
  char ch;
     while(scanf("%c",&ch) != EOF){
       if(isupper(ch)){
	 ch=tolower(ch);
	 num=ch-'a';
	 a[num]++;
       }
       else if(islower(ch)){
	 num=ch-'a';
	 a[num]++;
       }
     }
     printf("a : %d\n",a[0]);
     printf("b : %d\n",a[1]);
     printf("c : %d\n",a[2]);
     printf("d : %d\n",a[3]);
     printf("e : %d\n",a[4]);
     printf("f : %d\n",a[5]);
     printf("g : %d\n",a[6]);
     printf("h : %d\n",a[7]);
     printf("i : %d\n",a[8]);
     printf("j : %d\n",a[9]);
     printf("k : %d\n",a[10]);
     printf("l : %d\n",a[11]);
     printf("m : %d\n",a[12]);
     printf("n : %d\n",a[13]);
     printf("o : %d\n",a[14]);
     printf("p : %d\n",a[15]);
     printf("q : %d\n",a[16]);
     printf("r : %d\n",a[17]);
     printf("s : %d\n",a[18]);
     printf("t : %d\n",a[19]);
     printf("u : %d\n",a[20]);
     printf("v : %d\n",a[21]);
     printf("w : %d\n",a[22]);
     printf("x : %d\n",a[23]);
     printf("y : %d\n",a[24]);
     printf("z : %d\n",a[25]);

  return 0;
}

Measured memory_bytes: 548
#include <iostream>
using namespace std;
int main(){
  int a,b,c,d,e,na,nb,nc,o;
  int i,j,k;
  cin >> a >> b >> c >> d  >> e;
  while(a!=0&&b!=0&&c!=0&&d!=0&&e!=0){
    o=0;
    cin >> na >> nb >> nc;
    if(nc>=d) {
      o+=nc*e;
    }else if(nc+nb<=d){
      if(nc+nb+na<=d){
	if(c*nc+b*nb+a*na>d*e) {
	  o+=d*e;
	  nb=0;
	  na=0;
	}else{
	  o+=c*nc;
	}
      }else if(c*nc+b*nb+a*(d-nb-nc)>d*e){
	o+=d*e;
	na-=(d-nb-nc);
	nb=0;
      }else if(c*nc+b*nb>d*e){
	o+=d*e;
	nb=0;
      }else{
	o+=c*nc;
      }
    }else if(c*nc+b*(d-nc)>d*e){
      o+=d*e;
      nb-=(d-nc);
    }else if(c*nc>d*e){
      o+=d*e;
    }else{
      o+=c*nc;
    }
     
  
    o+=a*na;
    o+=b*nb;
    cout << o << endl;
    cin >> a >> b >> c >> d  >> e;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <typeinfo>
#include <cmath>
using namespace std;

int main()
{
    int N;
    std::cin >> N;
    std::vector<int> value(N);
    std::vector<int> cost(N);
    std::vector<int> total(N);
    for(int i = 0; i < N; ++i) std::cin >> value[i];
    for(int i = 0; i < N; ++i) std::cin >> cost[i];
    for(int i = 0; i < N; ++i) total[i] = value[i] - cost[i];
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        if(total[i] > 0) cnt = cnt + total[i];
    }
    std::cout << cnt << "\n";
    return 0;
}

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

// Nをmで割った商と余りが等しい
// N mod m
// 8 3 2 2
// 8 7 1 1

// N = m * p + p
// N = (m+1) * p
// 8 = 1 * 8
// 8 = 2 * 4
// 素因数分解して大きい数からやっていく

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

long long solve(long long N) {
    long long res = 0;
    vector<long long> nums = divisor(N);
    for (long long i=0; i<nums.size(); ++i) {
        long long m = N / nums[i];
        if (m > 2 && N / (m-1) == N % (m-1)) {
        	res += m - 1;
        }
    }
    
    return res;
}

int main() {
    long long N; cin>>N;
    cout << solve(N) << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int f(int n) {
  int count = 0;
  while(n % 100 == 0) {
    count++;
    n /= 100;
  }
  return count;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, n;
    int count = 0;
    cin >> d >> n;
    for (int i = 1; ; i++) {
      if (f(i) == d) {
        count++;
      }
      if (count == n) {
        cout << i << '\n';
        exit(0);
      }
    }

    return 0;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
string s;
int n;
int main(){
  cin>>n>>s;
  int min=INF;
  vector<int> w;
  vector<int> e;
  w.push_back(0);
  e.push_back(0);
  REP(i,n){
    if(s[i]=='W'){
      w.push_back(w[i]+1);
      e.push_back(e[i]);
    }else{
      w.push_back(w[i]);
      e.push_back(e[i]+1);
    }
  }
  REP(i,n){
    if(w[i]-w[0]+e[n]-e[i+1]<min){
      min=w[i]-w[0]+e[n]-e[i+1];
    }
  }
  cout<<min<<endl;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define ll   long long int
using namespace std;
#define fr(i,n) for(ll i=0;i<n;i++)
#define pii pair <ll ,ll>
#define ppi pair < pii , int > 
#define x first
#define y second
vector <ll> adj[100001];
vector <ll> w(100001);
vector <ll> b(100001);
ll mod = 1e9 + 7;
void dfs(int s,int visited[],int p)
{
  // cout<<s<<" ";
  int leaf = 1;
   fr(i,adj[s].size())
   {
     if(!visited[adj[s][i]])
     {
       leaf = 0; 
       visited[adj[s][i]]=1;
       dfs(adj[s][i],visited,s);
     }
   }
     b[s]=1;w[s]=1;
  if(!leaf){
   fr(i,adj[s].size())
   {
     if(adj[s][i]==p)continue;
     b[s]= (b[s]%mod * w[adj[s][i]]%mod)%mod;
     w[s]= (w[s]%mod * (w[adj[s][i]] + b[adj[s][i]]) %mod )%mod;
   }}

}
int main()
{
  ll n;cin>>n;
  fr(i,n-1)
  {
    ll u,v;
    cin>>u>>v;
    adj[u-1].push_back(v-1);
    adj[v-1].push_back(u-1);
  }
  fr(i,n)w[i]=1;
  fr(i,n)b[i]=1;
  int visited[n];fr(i,n)visited[i]=0;
  visited[0]=1;
  dfs(0,visited,-1);
  cout<<(w[0]%mod+b[0]%mod)%mod<<endl;
  return 0;
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
using ll =  long long;
const ll INTF = 1e9 + 7;

int main() {

    string k;
    cin >> k ;

    int d;
    cin >> d;

    vector<vector<int>> dp(d, vector<int>(2));
    dp[0][0] = 1;
    for(int i=0; i<k.length(); i++)
    {
        vector<vector<int>> ndp(d, vector<int>(2));
        for(int j=0; j<d; j++)
        {
            for(int p=0; p<=1; p++)
            {
                for(int q=0; q<10; q++)
                {
                   if(q > k[i]-'0' && !p)
                    break;
                    ndp[(q+j)%d][p || q < k[i]-'0'] = (ndp[(q+j)%d][p || q < k[i]-'0'] + dp[j][p])%INTF;
                }
            }
        }
        dp = ndp; 
    }

    int ans = 0;
    ans = (dp[0][0] + dp[0][1])%INTF;

    --ans;
    if(ans<0)
        ans += INTF;

    cout<<ans;
    
    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int m = n-1;
	int mx = (n-1) * (n-2) / 2;
	if(k > mx) {
		cout << -1 << endl;
		return 0;
	}
	int now = mx;
	vector<pair<int, int>> ans;
	rep(i, n-1) {
		ans.push_back(make_pair(1, i+2));
	}
	rep(i, n-1) {
		if (now == k) break;
		if(i == n-2)ans.push_back(make_pair(i+2, 2));
		else ans.push_back(make_pair(i+2, i+3));
		now--;
	}
	for(int i = 2; i <= n-2; i++) {
		for(int j = i+2; j <= n; j++) {
			if (now == k) break;
			if(i==2 && j==n) continue;
			ans.push_back(make_pair(i, j));
			now--;
		}
	}
	cout << ans.size() << endl;;
	for(auto t: ans) printf("%d %d\n", t.first, t.second);
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int, char>;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(3);
  rep(i, 3) cin >> a[i];
  string s;
  cin >> s;
  vector<int> c(256);
  c['r'] = 2;
  c['s'] = 0;
  c['p'] = 1;
  int ans = 0;
  rep(i, k) {
    vector<int> x;
    for (int j = i; j < n; j += k) {
      x.push_back(c[s[j]]);
    }
    vector<int> dp(2);
    int pre = -1;
    for (int nx : x) {
      vector<int> p(2);
      swap(dp, p);
      dp[0] = max(p[0], p[1]);
      if (pre == nx) {
        dp[1] = p[0] + a[nx];
      } else {
        dp[1] = max(p[0], p[1]) + a[nx];
      }
      pre = nx;
    }
    ans += max(dp[0], dp[1]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4004
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    answer = 1
    cur_min = P[0]
    for i in range(1,N):
        if P[i] <= cur_min:
            answer += 1
        
        cur_min = min(cur_min,P[i])
    print(answer)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, P)

if __name__ == '__main__':
    main()


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

int main(void) {
    char S[4] = {0};
    char T[4] = {0};
    char *p;
    uint32_t a;
    cin >> S >> T;
    a = (*((uint32_t*)S)) ^ (*((uint32_t*)T));
    p = (char*)&a;
    cout << 3- (p[0]!=0) - (p[1]!=0) - (p[2]!=0) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	int i,h,n,a[100000],all=0;
	cin>>h>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		all+=a[i];
	}
	if(h<=all) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int w = stdIn.nextInt();
        int n = stdIn.nextInt();
        int[] values = new int[w];
        for(int i = 0; i < values.length; i++) {
            values[i] = i + 1;
        }
        for(int i = 0; i < n; i++) {
            String str = stdIn.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;

            int work = values[a];
            values[a] = values[b];
            values[b] = work;
        }
        for(int i = 0; i < values.length; i++) {
            System.out.println(values[i]);
        }
        stdIn.close();
    }
}


Measured memory_bytes: 26284
#include <stdio.h>
main(){
  int a,b,c,ans=0,i;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0){
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 596
n = int(input())
A = list(map(int,input().split()))
num = 1
flag = True
if A.count(0)>=1:
    print(0)
else:
    for i in A:
        num *= i
        if num > pow(10,18):
            print(-1)
            flag =False
            break

    if flag:
        print(num)

Measured memory_bytes: 21600
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vvii vector<vii>
#define F first
#define S second
#define pb push_back
#define FOR(i,l,r) for(int i=l; i<r; ++i)
#define ROF(i,r,l) for(int i=r; i>l; --i)
#define all(x) x.begin(), x.end()
#define amin(a,b) a = min(a,b)
#define amax(a,b) a = max(a,b)
#define test int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long ll;

const int MAXN = 2e5+73;
const int MAXINT = 2147483098;
const int MAXLL = 9223372036854775258LL;
const int MOD = 998244353;




void solve(){
    int n,x, t;
    cin >> n >> x >> t;
    cout << t*((n+x-1)/x);

}





int32_t main()
{
    fast;
    //test;
    solve();
    //freopen("kotlin.in", "r", stdin);
    //freopen("kotlin.out","w", stdout);



    return 0;
}


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

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define dbg(x) { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[N][4],sum[N][4];

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        rep(j,1,4)
        cin >> a[i][j];
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= 3; j++) {
            sum[i][j] = 0;
            for (int k = 1; k <= 3; k++) {
                if(k!=j)
                    sum[i][j] = max(sum[i][j],sum[i-1][k]);
            }
            sum[i][j]+=a[i][j];
        }
    }
    int ans = max({sum[n][1],sum[n][2],sum[n][3]});
    cout << ans;
    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void){
    int a, b, c ,i, x;
    scanf("%d %d %d",&a ,&b ,&c);
    x = 0;

    for(i = a; i <= b; i++){
      if(c % i == 0){
       x++;
     }
   }

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

  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<math.h>
#include<iomanip>
#include <string>
#include <cstdio>
#include<stdio.h>
#include <cstring>
#include <algorithm>
using namespace std;int stop;
#define N 200010
#define ll long long
ll a,b;
ll k;

int main(){
    ll i,j;
    scanf("%lld %lld %lld",&k,&a,&b);
    ll get1 = 1,k1 = k;
    if(k1>=a-1+2 && b>a){
      k1-=(a-1);get1 = a;
      ll remain = k1>>1;
      get1 += remain * (b-a);
      get1+=k1&1;
      printf("%lld",max(get1,1+k));
    }else{
      printf("%lld\n",1+k);
      return 0;
    }
    return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef __int128 ll;
typedef pair<int, int> pii;
typedef vector<int> vi;


//const ll mod = 3006703054056749LL;
//const ll mod = 1000000009;
const ll mod = 31443539979727LL;

ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

vector<ll> BerlekampMassey(vector<ll> s) {
  int n = sz(s), L = 0, m = 0;
  vector<ll> C(n), B(n), T;
  C[0] = B[0] = 1;

  ll b = 1;
  rep(i,0,n) { ++m;
    ll d = s[i] % mod;
    rep(j,1,L+1) d = (d + C[j] * s[i - j]) % mod;
    if (!d) continue;
    T = C; ll coef = d * modpow(b, mod-2) % mod;
    rep(j,m,n) C[j] = (C[j] - coef * B[j - m]) % mod;
    if (2 * L > i) continue;
    L = i + 1 - L; B = T; b = d; m = 0;
  }

  C.resize(L + 1); C.erase(C.begin());
  trav(x, C) x = (mod - x) % mod;
  return C;
}


typedef vector<ll> Poly;
ll linearRec(Poly S, Poly tr, ll k) {
  int n = sz(tr);

  auto combine = [&](Poly a, Poly b) {
    Poly res(n * 2 + 1);
    rep(i,0,n+1) rep(j,0,n+1)
      res[i + j] = (res[i + j] + a[i] * b[j]) % mod;
    for (int i = 2 * n; i > n; --i) rep(j,0,n)
      res[i - 1 - j] = (res[i - 1 - j] + res[i] * tr[j]) % mod;
    res.resize(n + 1);
    return res;
  };

  Poly pol(n + 1), e(pol);
  pol[0] = e[1] = 1;

  for (++k; k; k /= 2) {
    if (k % 2) pol = combine(pol, e);
    e = combine(e, e);
  }

  ll res = 0;
  rep(i,0,n) res = (res + pol[i + 1] * S[i]) % mod;
  return res;
}


int slv(string s) {
  char lst = '#';
  int cnt = 0;
  trav(c,s) {
    if(c == lst) {
      ++cnt;
      lst = '#';
    }
    else lst = c;
  }
  return cnt;
}


#ifdef LOCAL
#include "pretty_debug.h"
#else
#define debug(...) //ignore
#endif

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
  string s;
  int k;
  cin>>s>>k;
  vector<ll> S(50);
  string t = s;
  rep(i,0,50) {
    S[i] = slv(t);
    t += s;
  }
  vector<ll> tr = BerlekampMassey(S);
  debug(vector<long long>(all(tr)));
  ll ans = tr.empty() ? 0 : linearRec(S, tr, k-1);
  cout << (long long)(ans) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	string t, s;
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}



Measured memory_bytes: 256