akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dp[2][202020][16];


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

	int N;
	cin >> N;
	vector<ll>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int t = 0; t < 2; t++) {
		for (int j = 0; j < 16; j++)dp[t][N - 1][j] = j;
		for (int i = N - 2; i >= 0; i--) {
			int c = 0;
			ll x = A[i], y = A[i + 1];
			for (int j = 0; j < 16; j++) {
				while (x > y) {
					y *= 4LL;
					c++;
				}
				dp[t][i][j] = ((c >= 16)?dp[t][i+1][15] + (N-i-1)*(c-15):dp[t][i+1][c]) + j;
				x *= 4;
			}
		}
		reverse(all(A));
	}

	ll ans = inf;
	for (int i = 0; i <= N; i++) {
		ll t = 0;
		if (i < N)t += dp[0][i][0];
		if (i > 0)t += dp[1][N - i][0];
		ans = min(ans, t * 2 + i);
	}
	puts(ans);
	return 0;
}

Measured memory_bytes: 52096
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int A,B,C,D;
    scanf("%lld%lld%lld",&A,&B,&C);
    D = (C/(A*7+B))*7;
    if(((C%(A*7+B)+A-1)/A)>7){
        D+=7;
    }else{
        D+=((C%(A*7+B)+A-1))/A;
    }
    
    printf("%lld\n",D);
}


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

bool prime[1000000];//false -> prime
int main(){
    int n = 1000000;

    prime[0] = prime[1] = true;
    for(int i = 2;i*i <= n;i++){

        if(prime[i] == false){
            for(int j = i*i;j <= n;j+=i){
                prime[j] = true;
            }
        }
    }
    while(cin>>n){
        int cnt = 0;
        for(int i = 0;i <= n;i++){
            if(prime[i] == false)cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 2136
import sys
from numpy import*
from scipy.sparse import*
f=csgraph.floyd_warshall
n,m,l,*t=map(int,sys.stdin.buffer.read().split())
t=int32(t)
d=f(f(csr_matrix((t[2:m*3:3],(t[:m*3:3],t[1:m*3:3])),(n+1,n+1)),0)<=l)-1
d[d==inf]=-1
print('\n'.join(map(str,map(int,d[t[m*3+1::2],t[m*3+2::2]]))))

Measured memory_bytes: 36216
N, M = map(int, input().split())
AB = [[0, 0] for i in range(N)]
for i in range(N):
    AB[i][0], AB[i][1] = map(int, input().split())

AB = sorted(AB)
ans = 0
for i in AB:
    if M - i[1] >= 0:
        ans += i[0] * i[1]
        M -= i[1]
    else:
        ans += M * i[0]
        break
print(ans)


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    int N; cin >> N;
    vi a(N); REP(i, N) cin >> a[i];
    vb c(8, false);
    int n = 0;
    REP(i, N)
    {
        if(a[i] >= 3200) n++;
        else c[a[i]/400] = true;
    }

    int k = accumulate(ALL(c), 0);
    int s = max(1, k);
    int t = k + n;
    cout << s << " " << t << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
	int n,a[101];
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0) 
			{
				cout<<"DENIED";
				return 0;
			}
		}
	}
	cout<<"APPROVED";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>

using namespace std;

int main(void){
    int n, m, x, y, tmp;
    int flag1 = 0;
    int flag2 = 0;
    cin>>n>>m>>x>>y;
    vector<int> vx, vy, vxy;

    for(int i=0; i<n; i++){
        cin>>tmp;
        vx.push_back(tmp);
    }
    for(int i=0; i<m; i++){
        cin>>tmp;
        vy.push_back(tmp);
    }
    for(int i=1; i<y-x+1; i++){
        vxy.push_back(x+i);
    }
    for(int i=0; i<vxy.size(); i++){
        for(int j=0; j<vx.size(); j++){
            if(vx[j]<vxy[i]){

            }else{
                flag1++;
            }
        }
        if(flag1==0){
            for(int j=0; j<vy.size(); j++){
                if(vxy[i]<=vy[j]){

                }else{
                    flag2++;
                }
            }
            if(flag1==0 && flag2==0){
                cout<<"No War"<<endl;
                return 0;
            }
        }
        flag1=0;
        flag2=0;
    }
    cout<<"War"<<endl;
    return 0;
}

Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


n, a, b = inl()

print(min(n * a, b))


Measured memory_bytes: 3572
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
const int INF = 1 << 30;
const int MaxN = 1e5;

int n;
LL a[105];

LL GCD(LL x, LL y)
{
	if(y == 0) return x;
	else return GCD(y, x % y);
}

LL LCM(LL x, LL y)
{
	return x / GCD(x, y) * y;
}

int main()
{
	//printf("%d\n", GCD(4 ,6));
	while(scanf("%d", &n) != EOF)
	{
		for(int i = 1; i <= n; i++)
			scanf("%lld", &a[i]);
		LL ans = 1;
		for(int i = 1; i <= n; i++) {
			ans = LCM(ans, a[i]);
		}
		printf("%lld\n", ans);
		memset(a, 0, sizeof(a));
	}
	return 0;
}

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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;

using namespace std;

using ll = long long;

const int MOD = 998244353;
const ll INF_LLONG = 1e18 + 9;
const int INF_INT = 1e9 + 9;

template<typename T>
unsigned int index_of_max(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] > arr[idx])
			idx = i;
	}
	return idx;
}

template<typename T>
unsigned int index_of_min(vector<T>& arr) {
	unsigned int idx = 0;
	for (int i = 0; i < arr.size(); ++i) {
		if (arr[i] < arr[idx])
			idx = i;
	}
	return idx;
}

bool isPalindrome(string s, int l, int r) {
	for (; l <= r; ++l, --r) {
		if (s[l] != s[r])
			return false;
	}
	return true;
}

int main()
{
	//	#ifndef ONLINE_JUDGE
	//		(void)freopen("input.txt", "r", stdin);
	//		(void)freopen("output.txt", "w", stdout);
	//	#endif	
	FAST_IO;
	int n, S;
	cin >> n >> S;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	vector<ll> dp(3001);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		dp[0] += 1;
		for (int j = S; j >= 0; --j) {
			if (j + a[i] <= S) {
				dp[j + a[i]] += dp[j];
				dp[j + a[i]] %= MOD;
			}
		}
		ans += dp[S];
		ans %= MOD;
	}
	cout << ans;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = (a); i < (b); i++)
#define rep2(r, aa, bb) for(ll r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int n, m;
vector<vector<int>> dp(3005,vector<int>((1<<12),-1));
vector<pair<int,int>>A;
ll get(ll curr, ll bits)
{
    if(bits==0)
    return 0;
    if(curr==m)
    return 1000000000;
    if(dp[curr][bits]!=-1)
    return dp[curr][bits];
    int x=bits;
    rep(i,0,n)
        if(((1<<i)&bits)&(1<<i)&A[curr].second)
            x-=(1<<i);
     int res=min(get(curr+1, bits), A[curr].first+get(curr+1, x));
     dp[curr][bits]=res;
     return res;
}
int main()
{
    cin>>n>>m;
    A.resize(m);
    rep(i,0,m)
    {
        int a,b;
        cin>>a>>b;
        A[i].first=a;
        int c=0;
        rep(i,0,b)
        {
            int x;
            cin>>x;
            c+=(1<<(x-1));
        }
        A[i].second=c;
    }
    int x=(1<<n)-1;
    int ans=get(0, x);
    if(ans>=1000000000)
    {
        cout<<-1<<endl;
    }
    else cout<<ans<<endl;
}

Measured memory_bytes: 48640
#include<iostream>
#include<string>
#include<string.h>

int n, m;
char s[10000000];

int main()
{
	while( 1 ){
		std::cin >> n;
		
		if( !n ) break;
		
		memset( s, '\0', sizeof( s ) );
		
		while( n-- ){
		 	char c1, c2;
			std::cin >> c1 >> c2;
			s[c1] = c2;
		}
		
		std::string res;
		
		std::cin >> m;
		while( m-- ){
		 	char c;
			std::cin >> c;
			
			if( s[c] != '\0' ){
			 	res += s[c];
			}
			else{
			 	res += c;
			}
		}
		
		std::cout << res << std::endl;
	}

 	return 0;
}

Measured memory_bytes: 11092
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
# https://uxmilk.jp/24023
a.sort!.reverse!   # sort はその要素の新しい配列を返す sort! はその要素の反対に配列を返す

## reverse は配列が一度反転する。 reverse! は反転させ、自身の配列も変更させる。

kumakichi = 0
kintaro = 0

n.times do |i|
  if i.even?
    kumakichi += a[i]
  else
    kintaro += a[i]
  end
end

puts kumakichi - kintaro



Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        // ##### 初期読み込み #######################################################################

        // 1行 数字 1文字 ---------------------------------------------------------------------------
        long a = Long.parseLong(scanner.nextLine());



        // ##### メイン処理 #######################################################################
        if (a % 2 == 0) {
            System.out.println(a /2);
        } else {
            System.out.println((a + 1) / 2);
        }
    }
}

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

int main() {
  int t;
  cin >> t;
  while (t--) {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    map<ll, ll> m;
    auto f = [&](auto&& f, ll x) -> ll {
      if (x == 0) return 0;
      if (x == 1) return d;
      if (x == 2) return min(2 * d, d + a);
      if (m.count(x)) return m[x];
      ll r = 1e18;
      if (x <= 1e18 / d) r = x * d;
      r = min(r, f(f, x / 2) + a + abs(x / 2 * 2 - x) * d);
      r = min(r, f(f, x / 2 + 1) + a + abs((x / 2 + 1) * 2 - x) * d);
      r = min(r, f(f, x / 3) + b + abs(x / 3 * 3 - x) * d);
      r = min(r, f(f, x / 3 + 1) + b + abs((x / 3 + 1) * 3 - x) * d);
      r = min(r, f(f, x / 5) + c + abs(x / 5 * 5 - x) * d);
      r = min(r, f(f, x / 5 + 1) + c + abs((x / 5 + 1) * 5 - x) * d);
      return m[x] = r;
    };
    cout << f(f, n) << endl;
  }
}


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

signed main() {
  int N;
  cin >> N;
  
  int A;
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A;
    ans += A-1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
job = []
for i in range(n):
    a, b = map(int, input().split())
    job.append([b, a])
job.sort()
time = 0
for i in range(n):
    time += job[i][1]
    if time > job[i][0]:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 35608
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main (){
    let nm: Vec<i32> = read_vec();
    let edge: Vec<Vec<i32>> = read_vec2(nm[1] as u32);
    //let ans = hoge(&node,&nm[0],&nm[1]);
    let mut graph = vec![vec![false;nm[0] as usize];nm[0] as usize];
    let mut visited = vec![false;nm[0] as usize];
    for i in 0..edge.len() {
        graph[(edge[i][0] - 1) as usize][(edge[i][1] -1 ) as usize] = true;
        graph[(edge[i][1] -1 ) as usize][(edge[i][0] - 1) as usize] = true;
    }
    let mut ans = 0;
    for i in 0..nm[1] {
        graph[(edge[i as usize][0] - 1) as usize][(edge[i as usize][1] -1 ) as usize] = false;
        graph[(edge[i as usize][1] - 1 ) as usize][(edge[i as usize][0] - 1) as usize] = false;

        for j in 0..nm[0] { visited[j as usize] = false }
        dfs(0,&mut visited,&graph);
        let mut bridge = false;
        for j in 0..nm[0] {
            if visited[j as usize] == false {
                bridge = true;
            }
        }
        if bridge {
            ans += 1
        }
        graph[(edge[i as usize][0] - 1) as usize][(edge[i as usize][1] -1 ) as usize] = true;
        graph[(edge[i as usize][1] -1 ) as usize][(edge[i as usize][0] - 1) as usize] = true;
    }
    print!("{}",ans);
}
fn dfs(v:i32 ,visited:&mut Vec<bool>,graph:&Vec<Vec<bool>>) {
    visited[v as usize] = true;
    for v2 in 0..visited.len() {
        if graph[v as usize][v2 as usize] == false {
            continue;
        }
        if visited[v2 as usize] == true{
            continue;
        }
        dfs(v2 as i32,visited,graph);
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, x, t;
  cin >> n >> x >> t;
  ll v = ceil((double)n / x) * t;
  cout << v << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
    char ch;
    while(ch!='\n'){
        scanf("%c",&ch);
        if( isalpha(ch)){
            if(islower(ch)) printf("%c", toupper(ch));
            else if(isupper(ch)) printf("%c",tolower(ch));
        }
        else printf("%c",ch);
        
    }
    return 0;
}




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

using ll = long long;

int main(int argc, char **argv)
{
	bool flag;

	int N;
	cin >> N;
	vector<ll> a(N+10);
	vector<ll> b(N+10);

	for (int i = 0; i < N; ++i)
		cin >> a[i];
	for (int i = 0; i < N; ++i)
		cin >> b[i];

	ll larger_a{0}, larger_b{0};
	for (int i = 0; i < N; ++i)
	{
		if (a[i] > b[i]) larger_a += a[i] - b[i];
		if (b[i] > a[i]) larger_b += (b[i] - a[i]) / 2;
	}

	if (larger_a <= larger_b) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define NM (int)2e5
using namespace std;

ll w[NM],p[NM],dp[105][NM];

int main()
{   int n,g;
    cin>>n>>g;
    for(int i=1; i<=n; i++)
        cin>>w[i]>>p[i];
    /// dp[i][j] = maximum value of weight j from the firsts i objects
    for(int i=1; i<=n; i++)
        for(int j=1; j<=g; j++)
        {   dp[i][j]=dp[i-1][j];
            if(j>=w[i])
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[i]]+p[i]);

        }
    cout<<*max_element(dp[n]+1,dp[n]+1+g);
    return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    
    int ans = 0;
    for(int i = 0; i<s.length(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3908
fn main() {
    let stdin = std::io::stdin();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let val_num: u64 = buffer.trim().parse().unwrap();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let mut vals: Vec<f32> = buffer.split_whitespace().map(|s| s.parse().unwrap()).collect();

    for (k, v) in vals.iter().enumerate() {
        if k == (val_num - 1) as usize {
            print!("{}\n", v);
        } else {
            print!("{} ", v);
        }
    }

    for i in 1..val_num {
        let key = vals[i as usize];
        for j in 0..i {
            if vals[j as usize] > key {
                vals.remove(i as usize);
                vals.insert(j as usize, key);
                break;
            }
        }

        // Print current state
        for (k, v) in vals.iter().enumerate() {
            if k == (val_num - 1) as usize {
                print!("{}\n", v);
            } else {
                print!("{} ", v);
            }
        }
    }

}



Measured memory_bytes: 5084
#include<bits/stdc++.h>
using namespace std;
int n,t1,t2,s1,s2,ans=2000000000;
inline int read()
{
	int num=0,flag=1;
	char c=getchar();
	for (;c<'0'||c>'9';c=getchar())
	if (c=='-') flag=-1;
	for (;c>='0'&&c<='9';c=getchar())
	num=(num<<3)+(num<<1)+c-48;
	return num*flag;
}
int main()
{
	n=read();
	for (int i=1;i<=n/2;++i)
	{
		t1=i;
		t2=n-i;
		s1=0;
		s2=0;
		while (t1>0)
		{
			s1+=t1%10;
			t1/=10;
		}
		while (t2>0)
		{
			s2+=t2%10;
			t2/=10;
		}
		ans=min(ans,s1+s2);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e15;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
template<typename T, typename F> ll sum(T begin, T end, F func) {return accumulate(begin, end, 0ll, func);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;

ld calcVolume(const ld a, const ld b, const ld rad) {
  const ld threshhold = atan(1.0*b/a);
  if(threshhold > rad) {
    return a * a * b - a * a * (a * tan(rad)) / 2;
  }
  else { 
    return a * b * (b / tan(rad)) / 2;
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  ld a, b, x;
  cin >> a >> b >> x;
  ld lft = 0;
  ld rgt = M_PI / 2;
  REP(i, 1e6) {
    ld mid = (rgt + lft) / 2;
    ld v = calcVolume(a, b, mid);
    if(v > x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  cout << lft * 180 / M_PI << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
//   typedef unsigned long long ull;
  // ll INF = INT_MAX;
  // ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const int N = 2e5 + 5;


 
  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("input.txt");

    int k,n;
    cin>>k>>n;
    vector<int> a(n);
    int start = 0;
    int dist_max = 0;
    for (int i = 0;i<n;i++) cin>>a[i];
    ll ans = 0;
    for (int i = 0;i<n;i++){
     if ((a[(i+1)%n]-a[i]+k)%k > dist_max){
      dist_max = (a[(i+1)%n]-a[i]+k)%k;
      start = (i+1)%n;
     }

    }
    // cout<<start<<endl;
    for (int i = start; i<start+n-1;i++){
      ans+= (a[(i+1)%n]-a[i%n]+k)%k;
    }
    cout<<ans<<"\n";

}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(var,start,stop,step) for(long long var=start;var<stop;var+=step)
#define vi vector<int>
#define vl vector<long long>
#define fio  cin.tie(nullptr); ios::sync_with_stdio(false); cout.tie(nullptr);
 
int main()
{
    fio;
    string s,t;
    cin>>s>>t;
    int ans=0;
    int len = s.size();
    loop(i,0,len,1) if(s[i]!=t[i]) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3796
S = input()

front_str = ''
back_str = ''
result = 0
for i in range(2, len(S)-1, 2):
    front_str = S[:int(i/2)]
    back_str = S[int(i/2):i]
    tmp_len = 0
    if front_str == back_str:
        tmp_len = i
        result = max(result, tmp_len)

print(result)

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ms(v, x) memset((v), (x), sizeof(v))
#define all(v) (v).begin(), (v).end()
#define ff first
#define ss second
#define iopt ios::sync_with_stdio(false); cin.tie(0)

int gcd(int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int power(int x, int p, int MOD) {
    if(p == 0) return 1%MOD;
    if(p == 1) return x%MOD;
    int res = power(x, p/2, MOD);
    res = (long long)res*res%MOD;
    if(p&1) res = (long long)res*x%MOD;
    return res;
}

typedef pair<int, int> ii;
typedef long double LD;
typedef vector<int> vi;

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

  map<int, int> cnt[2];
  for(int i = 0; i < n; i++) {
    int x; cin >> x;
    cnt[i&1][x]++;
  }

  set<ii> st[2];
  for(int i = 0; i < 2; i++) {
    for(auto p : cnt[i])
      st[i].insert({p.second, p.first});
  }

  vector<ii> vs[2];
  vs[0] = vector<ii>(all(st[0]));
  reverse(all(vs[0]));
  vs[1] = vector<ii>(all(st[1]));
  reverse(all(vs[1]));

  int cost = 1e9;
  for(int i = 0; i < min(2LL, (int)vs[0].size()); i++) {
    for(int j = 0; j < min(2LL, (int)vs[1].size()); j++) {
      if(vs[0][i].second == vs[1][j].second) continue;
      cost = min(cost, n - vs[0][i].first - vs[1][j].first);
    }
  }

  for(int k = 0; k < 2; k++) {
    for(int i = 0; i < min(1LL, (int)vs[k].size()); i++) {
      cost = min(cost, n - vs[k][i].first);
    }
  }

  cout << cost << endl;
}


Measured memory_bytes: 14336
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize
    };
    use std::cmp::Ordering::*;
    println!(
        "{}",
        match (a + b).cmp(&(c + d)) {
            Less => "Right",
            Equal => "Balanced",
            Greater => "Left",
        }
    );
}


Measured memory_bytes: 2088
N = input()
line = list(input())

tmp = ['' for _ in range(int(N))]
i = 0 
while len(line) != 0:
    c = line.pop(0)
    if c == ' ':
        i = 0
    else:
        tmp[i] = tmp[i] + c
        i = i + 1

print(''.join(tmp))



Measured memory_bytes: 3060
import sys
import numpy as np
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
A = np.array([0] + lr())
Acum = A.cumsum()
sum_range = Acum[:, None] - Acum[None, :]
sum_range = sum_range[sum_range>0]

def check(x):
    return np.sum(sum_range&x == x) >= K

answer = 0
for i in range(40, -1, -1):
    if check(answer + (1 << i)):
        answer += 1 << i

print(answer)
# 00


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

int main()
{
	unordered_set<string> s;
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;


	return 0;
}

Measured memory_bytes: 17728
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		   
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			int x = scanner.nextInt();
			int y = scanner.nextInt();
			
			if( a + b <= 2 * c ) 
			{
				System.out.println(a * x + b * y);
			}
			else  // 2c < a + b 
			{
				if( x == y ) 
				{
					System.out.println(c * x * 2);
				}
				else if( x < y ) 
				{
					if(b < 2 * c) 
					{
						System.out.println(c * 2 * x + b * (y-x));
					}
					else 
					{
						System.out.println(c * 2 * y);
					}
				}
				else
				{
					if(a < 2 * c) 
					{
						System.out.println(c * 2 * y + a * (x-y));
					}
					else 
					{
						System.out.println(c * 2 * x);
					}
				}
			}
		    scanner.close(); }
		  }

Measured memory_bytes: 21844
#include <stdio.h>
int main(void){
    // Your code here!
    char c[3];
    scanf("%c%c%c",&c[0],&c[1],&c[2]);
    
    if(c[0]==c[1]&&c[1]==c[2])
        puts("No");
    else
        puts("Yes");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include<math.h>
using namespace std;
vector<long long> code(26, 0);

vector<long long> l(51, 0);

int main() {
	int N;
	cin >> N;
	cout << "ABC" << N << endl;
	return 0;
}


Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = []
for i in range(D):
    a = list(map(int, input().split()))
    S.append(a)
last_d = [0] * 26  # それぞれのタイプでのd - last(d,i)
threshould = 100  # Ci*(last_d) / sqrt(Ci) がこれを超えたら対処する
for i in range(D):
    idx = 1
    tmp_max = 0
    for j in range(26):
        # もし閾値を超えるやつがあればそれをすぐに使う
        if C[j] * (i + 1 - last_d[j]) / ((C[j] + 0.1) ** 0.5) >= threshould:
            idx = j
            break
        if tmp_max <= S[i][j]:
            tmp_max = S[i][j]
            idx = j

            # print("a", idx)
    print(idx + 1)
    last_d[idx] = i + 1  # i+1日目に最後に使われた



Measured memory_bytes: 9500
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	vector<long long int> v[100];
	long long int x[100], y[100];
	for(int i=0; i<n; i++){
		scanf("%lld %lld", &x[i], &y[i]);
	}
	int e=0;
	for(int i=1; i<n; i++){
		for(int j=0; j<i; j++){
			int p=0, m=0, z=0;
			for(int k=0; k<n; k++){
				if((y[j]-y[i])*(x[k]-x[i])-(x[j]-x[i])*(y[k]-y[i])>0){
					p++;
				}else if((y[j]-y[i])*(x[k]-x[i])-(x[j]-x[i])*(y[k]-y[i])<0){
					m++;
				}else{
					z++;
				}
			}
			if(p==0 && m==0){
				e=1;
            }
			if(p==0 || m==0){
				int e1=0;
				for(int k=0; k<n; k++){
					if((y[j]-y[i])*(x[k]-x[i])-(x[j]-x[i])*(y[k]-y[i])==0 && ((y[j]-y[i])*(y[j]-y[i])+(x[j]-x[i])*(x[j]-x[i])<(y[k]-y[i])*(y[k]-y[i])+(x[k]-x[i])*(x[k]-x[i]) || (y[j]-y[i])*(y[j]-y[i])+(x[j]-x[i])*(x[j]-x[i])<(y[j]-y[k])*(y[j]-y[k])+(x[j]-x[k])*(x[j]-x[k]))) e1=1;
				}
				if(e1==0){
					v[i].push_back(j);
					v[j].push_back(i);
				}
			}
		}
	}
	if(e==0){
		int v1[100];
		set<int> st;
		for(int i=0; i<n; i++){
			if(!v[i].empty()){
				v1[0]=i;
				v1[1]=v[i][0];
				st.insert(v1[0]);
				st.insert(v1[1]);
				break;
			}
		}
		int vnum=2;
		while(1){
			if(st.find(v[v1[vnum-1]][0])==st.end()){
				v1[vnum]=v[v1[vnum-1]][0];
				st.insert(v1[vnum]);
			}else if(st.find(v[v1[vnum-1]][1])==st.end()){
				v1[vnum]=v[v1[vnum-1]][1];
				st.insert(v1[vnum]);
			}else{
				break;
			}
			vnum++;
		}
		double r[100];
		for(int i=0; i<vnum; i++){
			if(i!=vnum-1){
				r[i]=sqrt((double)((x[v1[i]]-x[v1[i+1]])*(x[v1[i]]-x[v1[i+1]])+(y[v1[i]]-y[v1[i+1]])*(y[v1[i]]-y[v1[i+1]])));
			}else{
				r[i]=sqrt((double)((x[v1[i]]-x[v1[0]])*(x[v1[i]]-x[v1[0]])+(y[v1[i]]-y[v1[0]])*(y[v1[i]]-y[v1[0]])));
			}
		}
		double prod[100];
		for(int i=0; i<vnum; i++){
			if(i!=0 && i!=vnum-1){
				prod[i]=(double)((x[v1[i]]-x[v1[i-1]])*(x[v1[i]]-x[v1[i+1]])+(y[v1[i]]-y[v1[i-1]])*(y[v1[i]]-y[v1[i+1]]));
			}else if(i==0){
				prod[i]=(double)((x[v1[i]]-x[v1[vnum-1]])*(x[v1[i]]-x[v1[i+1]])+(y[v1[i]]-y[v1[vnum-1]])*(y[v1[i]]-y[v1[i+1]]));
			}else{
				prod[i]=(double)((x[v1[i]]-x[v1[i-1]])*(x[v1[i]]-x[v1[0]])+(y[v1[i]]-y[v1[i-1]])*(y[v1[i]]-y[v1[0]]));
			}
		}
		double pi=acos(-1.0);
		double ans[100]={};
		for(int i=0; i<vnum; i++){
			if(i!=0){
				ans[v1[i]]=(pi-acos(prod[i]/(r[i]*r[i-1])))/(2*pi);
			}else{
				ans[v1[i]]=(pi-acos(prod[i]/(r[i]*r[vnum-1])))/(2*pi);
			}
		}
		for(int i=0; i<n; i++){
			printf("%f\n", ans[i]);
		}
	}else{
		double ans[100]={};
		for(int i=0; i<n; i++){
			if(!v[i].empty()) ans[i]=0.5;
		}
		for(int i=0; i<n; i++){
			printf("%f\n", ans[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define ll long long
constexpr int MOD = 1e9 + 7;
using namespace std;

constexpr static int MAXN = 2002;
#define co(ans) cout<<ans<<endl
#define MAX 5100000

int get_init_a_book_num(const vector<ll> &A, ll K, ll &time) {
  time = 0;
  REP(i, int(A.size())) {
    if(time + A[i] <= K)
      time += A[i];
    else
      return i;
  }
  return A.size();
}

int main() {
  int M, N;
  ll K;
  cin >> N;
  cin >> M;
  cin >> K;
  vector<ll> A(N), B(M);
  REP(i, N) { cin >> A[i]; }
  REP(i, M) { cin >> B[i]; }


  ll time_sum;
  int i_books_a = get_init_a_book_num(A, K, time_sum);
  int i_books_b = 0;
  while(time_sum + B[i_books_b] <= K && i_books_b < M) {
    time_sum += B[i_books_b++];
  }
  int i_books_max = i_books_a + i_books_b;

  while(i_books_a > 0 && i_books_b < M) {
    time_sum -= A[--i_books_a];
    while(time_sum + B[i_books_b] <= K && i_books_b < M) {
      time_sum += B[i_books_b++];
    }
    i_books_max = max(i_books_max, i_books_b + i_books_a);
  }
  co(i_books_max);
return 0;
}

Measured memory_bytes: 6352
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C = list(map(int, sys.stdin.buffer.readline().split()))

    print('Yes' if A <= C and C <= B or A >= C and C >= B else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
int main() {
	int r;
	scanf("%d",&r);
	char vetor[r];
	scanf("%s",vetor);
	if(r%2==0){
	    for(int x=0;x<r/2;++x){
	        if(vetor[x]!=vetor[x+(r/2)]){
	            printf("No\n");
	            return 0;
	        }
	    }
	}
	else{
	    printf("No\n");
	    return 0;
	}
	printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n;
  cin >> n;
  ll l[n],r[n],ans=0,max_a=0,tmp,ri,le,min_r=100000000000,max_l=0;
  map<ll,ll> mp;
  P val[n];
  for(int i=0;i<n;i++){
    cin >> l[i]>>r[i];
    r[i]++;
    val[i].first = l[i];
    val[i].second = r[i];
    min_r = min(min_r,r[i]);
    max_l = max(max_l,l[i]);
    max_a = max(max_a,r[i]-l[i]);
  }
  ans = max_a + max(min_r-max_l,(ll)0);
  sort(val,val+n);
  for(int i=0;i<n;i++){
    mp[val[i].second]++;
  }
  min_r = 10000000000000;
  for(int i=0;i<n-1;i++){
    min_r = min(min_r,val[i].second);
    mp[val[i].second]--;
    if(mp[val[i].second]==0){
      mp.erase(val[i].second);
    }
    ri = mp.begin()->first;
    le = val[n-1].first;
    tmp = max((ll)0,ri-le);

    ri = min_r;
    le = val[i].first;
    tmp += max((ll)0,ri-le);
    ans = max(ans,tmp);
  }
  cout << max(ans,max_a)<<endl;
}


Measured memory_bytes: 11264
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


struct priority_queue{
	size_t __nmemb;
	size_t __size;
	int (*__compar) (const void*, const void*);
	size_t length;
	void *heap;
	void *temp;
	int (*push)(struct priority_queue*, int);
	int (*pop)(struct priority_queue*);
	void (*clear)(struct priority_queue*);
	void (*dispose)(struct priority_queue*);
};

int priority_queue_push(struct priority_queue *p, int value){
	if(p->length == p->__nmemb){
		return -1;
	}
	void *heap = p->heap - p->__size;
	p->length++;
	memcpy(heap+(p->length*p->__size), (void*)&value, p->__size);

	size_t node = p->length;
	void *pnt = heap+node*p->__size;
	void *pnt2 = heap+(node/2)*p->__size;
	while(node!=1 && p->__compar(pnt, pnt2)<0){
		memcpy(p->temp, pnt, p->__size);
		memcpy(pnt, pnt2, p->__size);
		memcpy(pnt2, p->temp, p->__size);
		node/=2;
		pnt = heap+node*p->__size;
		pnt2 = heap+(node/2)*p->__size;
	}
	return 0;
}

int priority_queue_pop(struct priority_queue *p){
	if(p->length == 0){
		return 0;
	}
	int ret;
	size_t node, downto;
	size_t left, right;
	char f;
	void *heap = p->heap - p->__size;
	
	ret = *((int*)(heap+p->__size));
	
	memcpy(heap+p->__size, heap+(p->length*p->__size), p->__size);
	p->length--;
	node = 1;
	while(1) {
		downto = node;
		left = node<<1;
		right = left+1;
		if (left<=p->length && p->__compar(heap+downto*p->__size, heap+left*p->__size)>0){
			downto=left;
		}
		if (right<=p->length && p->__compar(heap+downto*p->__size, heap+right*p->__size)>0){
			downto = right;
		}
		if(downto==node){
			break;
		}
		memcpy(p->temp, heap+node*p->__size, p->__size);
		memcpy(heap+node*p->__size, heap+downto*p->__size, p->__size);
		memcpy(heap+downto*p->__size, p->temp, p->__size);
		node = downto;
	}
    return ret;
}

void priority_queue_clear(struct priority_queue *p){;
	p->length = 0;
}

void priority_queue_dispose(struct priority_queue *p){
	free(p->heap);
}

int create_priority_queue(struct priority_queue *p, size_t __nmemb, /*size_t __size, */int (*__compar) (const void*, const void*)){
	size_t __size = sizeof(int);
	if((p->heap = malloc(__nmemb * __size)) == NULL){
		return -1;
	}
	if((p->temp = malloc(__size)) == NULL){
		free(p->heap);
		return -1;
	}
	p->__nmemb = __nmemb;
	p->__size = __size;
	p->__compar = __compar;
	p->length = 0;
	p->push = priority_queue_push;
	p->pop = priority_queue_pop;
	p->clear = priority_queue_clear;
	p->dispose = priority_queue_dispose;
	return 0;
}

int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}

struct priority_queue A;
int N, M, a, i;
long sum;

int main(void){
	scanf("%d%d", &N, &M);
	create_priority_queue(&A, N, compare_int);
	for(i=0; i<N; i++){
		scanf("%d", &a);
		sum += a;
		A.push(&A, a);
	}
	for(i=0; i<M; i++){
		a = A.pop(&A);
		sum -= (a+1)>>1;
		A.push(&A, a>>1);
	}
	printf("%ld\n", sum);
}



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

using namespace std;
int n, kk;
long long mod = 1e9 + 7;
long long d[52][52][5000];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n >> kk;
	d[0][0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= kk + 1; k++) {
				d[i + 1][j][k + j * 2] += d[i][j][k];
				d[i + 1][j][k + j * 2] %= mod;

				if (j - 1 >= 0) {
					d[i + 1][j - 1][k + (j - 1) * 2] += (d[i][j][k] * j * j);
					d[i + 1][j - 1][k + (j - 1) * 2] %= mod;
				}

				d[i + 1][j][k + j * 2] += d[i][j][k] * (2 * j);
				d[i + 1][j][k + j * 2] %= mod;

				d[i + 1][j + 1][k + (j + 1) * 2] += d[i][j][k];
				d[i + 1][j + 1][k + (j + 1) * 2] %= mod;
			}
		}
	}

	cout << d[n][0][kk] % mod << '\n';



}

Measured memory_bytes: 102656
N = int(input())
x, y, h = [], [], []
for i in range(N):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)

for i in range(N):
    if h[i] != 0:
        target = i
        break

for i in range(101):
    for j in range(101):
        CX = i
        CY = j
        H = h[target] + abs(x[target]-CX) + abs(y[target]-CY)
        find = True
        for k in range(N):
            if max((H-abs(x[k]-CX)-abs(y[k]-CY)), 0) != h[k]:
                find = False
                break
        if find:
            break
    if find:
        break

print(CX, CY, H)    

Measured memory_bytes: 3188
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

int main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, ac = 0, wa = 0, tle = 0, re = 0;
    string s;
    cin >> n;
    while(n--)
    {
        cin >> s;
        if(s == "AC")
            ac++;
        else if(s == "WA")
            wa++;
        else if(s == "TLE")
            tle++;
        else if(s == "RE")
            re++;
    }

    cout << "AC x " << ac << endl
             << "WA x " << wa << endl
             << "TLE x " << tle << endl
             << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3656
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int res = 0;
        for (int a=0; a<=A; a++){
            for (int b=0; b<=B; b++){
                int c = (X - a*500 - b*100) / 50;
                if (c >= 0 && c <= C)
                    res++;
            }
        }

        System.out.println(res);

    }
}

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


int main() {
  int M,N, i,j;
  cin >> M ;
  int d=0;
  int temp;
  N=M;
  for(i=8;i>0;i--){
    temp=1;
    for(j=0;j<i;j++){
      temp*=10;
    }
    d+=(N/temp);
    N-=(N/temp)*temp;
  }
  d+=N;
  if(M%d==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
def search_xx(s)
  (s.size - 1).times do |i|
    if s[i] == s[i+1] then
      return [i, i+1]
    end
  end
  return nil
end

def search_xyx(s)
  (s.size - 2).times do |i|
    if s[i] == s[i+2] then
      return [i, i+2]
    end
  end
  return nil
end

s = gets.chomp

r1 = search_xx(s)
r2 = search_xyx(s)

r = [-2, -2]
if r1 != nil then
  r = r1
elsif r2 != nil then
  r = r2
end
puts r.map{|v| v+1}.map(&:to_s).join(' ')

Measured memory_bytes: 2044
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		FastScanner fs =  new FastScanner();


		int K = fs.nextInt();
		int A = fs.nextInt();
		int B = fs.nextInt();

		for(int i = A; i <= B; i++) {
			if(i % K == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");

	}

}


Measured memory_bytes: 25356
#include <bits/stdc++.h>
#define ll long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define rep(i, init, n) for (int i = init; i < n; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define gcd __gcd
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 10;
const ll MOD = 998244353;
vector<int> edge[N];
vector<vector<int>> adj(N);
vector<int> used(N,0);
vector<int> component;
 
ll POW(ll base, ll exponent){
    ll result = 1;
    while (exponent > 0)
    {
        if (exponent % 2 == 1)
            result = (result * base) % mod;
        exponent = exponent >> 1;
        base = (base * base) % mod;
    }
    return result;
}


void dfs(int u){
    used[u] = 1;
    component.push_back(u);
    for(int v : adj[u]){
        if(!used[v])
            dfs(v);    
    }
}


int main() {
    
   int N , W;
   cin >> N >> W;
   vector<pair< int, int>> item(N);
   for(int i = 0 ; i < N ; i++){
       cin >> item[i].first >> item[i].second;
   }
    vector<vector<ll>> dp(N+1 , vector<ll>(W+1 , 0));
    //dp[0][0] = 1;
   for(int i = 1 ; i <= N ; i++){
       for(int w = 1 ; w <= W ; w++){
           if(item[i-1].first <= w){
               dp[i][w] = max(dp[i-1][w], dp[i-1][w-item[i-1].first] + item[i-1].second);
           }
           else dp[i][w] = dp[i-1][w];
       }
       
   }
   cout << dp[N][W];

    return 0;
}


Measured memory_bytes: 88188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int x[10][10];
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < d; k++) {
            cin >> x[i][k];
        }
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int s = 0;
            for (int k = 0; k < d; k++) {
                int t = x[i][k] - x[j][k];
                s += t * t;
            }
            double t = sqrt(s);
            if (t == (int)t) r++;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let S = rl().chars().collect::<Vec<_>>();

    // 境界
    let mut k = 0;
    // 境界より左側にある黒の個数
    let mut left_black = 0;
    // 境界より右側にある白の個数
    let mut right_white = S.iter().filter(|&&c| c == '.').count();

    let mut min_cost = N;

    while k <= N {
        min_cost = min(min_cost, left_black + right_white);

        // 境界を右に動かす。
        if k < N && S[k] == '#' {
            left_black += 1;
        }
        if k < N && S[k] == '.' {
            right_white -= 1;
        }
        k += 1;
    }

    println!("{}", min_cost)
}


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

typedef long long ll;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, M, K, MOD = 1e9 + 7;
    cin >> N >> M >> K;
    ll ans = (N * N * (N - 1) / 2 - (N - 1) * N * (2 * N - 1) / 6) * M * M;
    ans += (M * M * (M - 1) / 2 - (M - 1) * M * (2 * M - 1) / 6) * N * N;
    ans %= MOD;
    vector<ll> f(200001, 1);
    rep(i, 200000) f[i + 1] = (f[i] * (i + 1)) % MOD;
    ans = (ans * f[N * M - 2]) % MOD;
    ans = (ans * mod_pow(f[K - 2], MOD - 2, MOD)) % MOD;
    ans = (ans * mod_pow(f[N * M  - K], MOD - 2, MOD)) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 4800