akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
//int count =0;
//int count2 =0;
Node treeMinimum(Node x){
   while (x->left != NIL){
    x = x->left;
}
return x;
}



Node IterativetreeSearch(Node u, int k){

  if(u == NIL || k == u -> key) return u;
  if(k < u -> key) return IterativetreeSearch(u -> left, k);
  else return IterativetreeSearch(u -> right, k);

}



/*Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key) return u;

  if(k < u->key) 
  return treeSearch(u->left,k);
  
  else return treeSearch(u->right,k);
  
  }*/

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
      }
  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else x = x->right; 
  }
  z->parent = y;

  if(y == NIL){
    root = z;
  }
  else if (z->key < y->key){
    y->left = z;
  }
  
  else y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" ");
    printf("%d",u->key);
    inorder(u->right);
  }
 
}




void preorder(Node u){
  
  
    if (u != NIL) {
      printf(" ");
      printf("%d",u->key); 
      preorder(u->left);
      preorder(u->right);
    
 
    
    }
}

int main(){
  int n, i, x;
    //int num[500000];
  char com[20];
  scanf("%d", &n);
  //for ( i = 0; i < n; i++ ){num[i] = 0;}//???
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = IterativetreeSearch(root, x);
      if ( t != NIL ){ 
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    
    
    else if ( com[0] == 'p' ){
      
      /*for(j=0;j<n;j++){
	  if(num[j]==1)printf("yes\n");
	  else if(num[j]==2)printf("no\n");
	  else printf("");
	  }  */
	  
	  inorder(root);
	  printf("\n");
	  preorder(root);
	  printf("\n");
	  //count = 0;
	
       
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(IterativetreeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- readLn :: IO Int
  putStrLn $ canPay' n a

canPay :: Int -> Int -> Bool
canPay n a = let r = n `rem` 500 in
  if r > a
    then False
    else True

canPay' :: Int -> Int -> String
canPay' n a
  | canPay n a = "Yes"
  | otherwise  = "No"


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    int n,m;
    cin>>n>>m;
    COMinit();
    ll ans=1;
    for(int i=2;i*i<=m;i++){
        int t=0;
        while(m%i==0){
            m/=i;
            t++;
        }
        ans=(ans*COM(t+n-1,t))%MOD;
    }
    if(m!=1){
        ans=(ans*n)%MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 12160
N,M = map(int, input().split())
ks = [[int(i) for i in input().split()] for j in range(M)]
p = [int(i) for i in input().split()] 

ans = 0

for i in range(1 << N):
    cnt_on = [0]*M
    for j in range(N):
        if ((i >> j) & 1) == 1:
            for m in range(M):
                cnt_on[m] += ks[m][1:].count(j+1)

    c = 0
    for m in range(M):
        if cnt_on[m]%2 == p[m]:
            c += 1
    
    if c == M:
        ans += 1


print(ans)

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

int n;
int k;
int x, y;

int main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> x >> y;
		x--; y--;
		
		int dist = min(min(x, n - 1 - x), min(y, n - 1 - y));
		cout << (dist % 3) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[310][90010] = {},mod = 998244353,sum = 0,a[310];
ll pw(ll a, ll x){
	ll ret = 1;
	while(x){
		while(!(x&1)){
			x /= 2;
			(a *= a) %= mod;
		}
		x--;
		(ret *= a) %= mod;
	}
	return ret;
}
int main(){
	int i,j,k,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	dp[0][0] = 1;
	for(i=0;i<n;i++){
		sum += a[i];
		for(j=0;j<sum;j++){
			(dp[i+1][j + a[i]] += dp[i][j]) %= mod;
			(dp[i+1][j] += 2*dp[i][j]) %= mod;
		}
	}
	ll x = 0,y = 0;
	for(i=0;i<=sum;i++){
		if(sum - i<=i){
			(x += dp[n][i]) %= mod;
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=sum;j++){
			dp[i][j] = 0;
		}
	}
	dp[0][0] = 1;
	for(i=0;i<n;i++){
		for(j=0;j<sum;j++){
			(dp[i+1][j + a[i]] += dp[i][j]) %= mod;
			(dp[i+1][j] += dp[i][j]) %= mod;
		}
	}
	if(!(sum&1)){
		y = dp[n][sum/2];
	}
	cout << (pw(3,n) - 3*x%mod + 3*y%mod + mod)%mod << endl;
}

Measured memory_bytes: 213248
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	int a, b;
	try(Scanner scanner = new Scanner(System.in)) {
	    a = scanner.nextInt();
	    b = scanner.nextInt();
	}
	int perimeterLength = 2 * (a + b);
	int area = a * b;
	System.out.println(area + " " + perimeterLength);
    }
}

Measured memory_bytes: 25900
#include<iostream>
using namespace std;
string s="a";
int n;
void dfs(int step,char $){
    if(step==n){
        cout<<s<<endl;
        return;
    }
    string t=s;
//    s=s+s[step-1];
    char i;
    for(i='a';i<=$+1;i++){
    	s=t+i;
    	dfs(step+1,max($,i));
	}
	s=t;
//    dfs(step+1);
//    s=t+(char)(s[step-1]+1);
//    dfs(step+1);
//    s=t;
    
}
int main(){
    int i,j;
    cin>>n;
    dfs(1,'a');
//    for(i=0;i<n;++i){
//        for(j=0;j<n-i;j++){
//            cout<<"a";
//        }
//        for(j=0;j<i;j++){
//            cout<<"b";
//        }
//        cout<<endl;
//    }
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main (){
    int n,i,x[200000],max,min;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    max=x[1]-x[0];
    min=x[0];
    for(i=1;i<n;i++){
        if(max<x[i]-min){
            max=x[i]-min;
        }
        if(min>x[i]){
            min=x[i];
        }  
    }
    printf("%d\n",max);
    return 0;
}
    


Measured memory_bytes: 2512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    rep(i, n){
        if(i == n - 1)ans++;
        else if(s[i] == s[i+1]){
            if(i == n - 2){
                ans++;
                break;
            }else{
                ans += 2;
                i += 2;
            }
        }else ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3664
a,b,h,m=map(int,input().split())
x=abs(30*h-5.5*m)
y=min(x,360-x)
import math
rady=math.radians(y)
cosy=math.cos(rady)
c=(a**2+b**2-2*a*b*cosy)**0.5
print("{:.20}".format(c))

Measured memory_bytes: 9564
#include <stdio.h>

int main(void) {
	int i;
	double v, y;
	
	while(scanf("%lf", &v)!=EOF){
		y=49*v*v/98/9.8;
		
		for(i=0;;i++)
		if(5*i-5>=y){
		printf("%d\n", i);
		break;
		}
	}
	return 0;
}

Measured memory_bytes: 628
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int n, a;
    cin >> n >> a;

    print(a >= n % 500 ? "Yes" : "No");

}

Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let (n, y) = (read::<i64>(), read::<i64>());

    for i in 0..2001 {
        for j in 0..2001 {
            if y == (i as i64 * 10000 + j as i64 * 5000 + (n - i as i64 - j as i64) * 1000) && n >= i + j {
                println!("{} {} {}", i, j , n - i as i64 - j as i64);
                return;
            }
        }
    }
    println!("-1 -1 -1")
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		int x,y;

		while ( 0 != ( x = sc.nextInt() ) | 0 != ( y = sc.nextInt() ) ) {
			if ( x < y )
				sb.append( x + " " + y + "\n" );
			else
				sb.append( y + " " + x + "\n" );
		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 35464
#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 sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      string s,t;
      cin>>s>>t;
      // int n=s.length();
      string ans="";
      for(int i=0;i<n;i++){
        ans+=s[i];
        ans+=t[i];
      }
      cout<<ans;
} 
// I never lose. I either win or I learn

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

for i in range(len(S) - 1):
	if S[i] == S[i + 1]:
		print("Bad")
		exit()

print("Good")

Measured memory_bytes: 61420
N = int(input())

def digit_sum(A):
    S = 0
    while A > 0:
        S += A % 10
        A //= 10
    return S

ans = 10e+5
for A in range(1, N):
    cand = digit_sum(A) + digit_sum(N - A)
    ans = min(ans, cand)

print(ans)

Measured memory_bytes: 9032
import heapq
N=int(input())
a=list(map(int,input().split()))
earl=[]
late=[]
for i in range(N):
  heapq.heappush(earl,a[i])
  heapq.heappush(late,-a[2*N+i])
E=0
L=0
for i in range(N):
  E+=a[i]
  L-=a[2*N+i]
e=[E]*(N+1)
l=[L]*(N+1)
for i in range(N):
  e[i+1]=e[i]+a[N+i]-heapq.heappushpop(earl,a[N+i])
  l[N-1-i]=l[N-i]-a[2*N-1-i]-heapq.heappushpop(late,-a[2*N-1-i])

ans=e[N]+l[N]
for i in range(N):
  ans=max(ans,e[i]+l[i])
print(ans)

Measured memory_bytes: 37212
from collections import defaultdict

N, Q = map(int, input().split())

parent = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    parent[b] = a

values = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    values[p] += x


for i in range(2, N + 1):
    values[i] += values[parent[i]]
values = map(str, values[1:])
print(" ".join(values))

Measured memory_bytes: 121036
#include <iostream>
using namespace std;
int main() {
  int t, n;
  cin >> t >> n;
  
  int a = 1;
  while (--n) {
    ++a;
    if(a % 100 == 0) ++a;
  }
  
  while (t--) {
    a *= 100;
  }
  
  cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int dx[4] = {0,-1,0,1};
int dy[4] = {-1,0,1,0};


ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}


int main(){
    string s;
    cin >> s;
    if(s=="RSS"){
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    int mx=0;
    rep(i,3){
        if(s[i]=='R') {
            ans++;
            mx = ans;
        }

        else {
            mx = ans;
            ans=0;
        }
    }
    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int a,b,cal,i;
 
  while(scanf("%d",&a)!=EOF)
    {
      cal=0;
 
      for(i=0; i*a<=(600-a); i++)
    {
      cal=cal+(i*a)*(i*a)*a;
    }
 
      printf("%d\n", cal);
    }
 
  return 0;
}


Measured memory_bytes: 1980
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    while((st=sc.readLine())!=null){
		String[] sp = st.split(",");
		double tai = Double.valueOf(sp[1]);
		double shin = Double.valueOf(sp[2]);
		if(tai/(shin*shin)>=25.0)
		    System.out.println(sp[0]);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9760
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

class Stack
{
    int *data_;
    int totalCapacity_;
    int insertPos_;
public:
    Stack(int);
    int push(int);
    int pop(void);
    int getTotalCapacity(void) const;
    int isEmpty(void) const;
    int isFull(void) const;
};

Stack::Stack(int dataSize)
{
    data_ = new int[dataSize];
    totalCapacity_ = dataSize;
    insertPos_ = 0;
}

int Stack::push(int pushData)
{
    if (isFull()) return 1;
    data_[insertPos_] = pushData;
    insertPos_++;
    return 0;
}

int Stack::pop(void)
{
    if (isEmpty()) return 0;
    insertPos_--;
    return data_[insertPos_];
}

int Stack::getTotalCapacity(void) const
{
    return totalCapacity_;
}

int Stack::isEmpty(void) const
{
    if (insertPos_ == 0) return 1;
    return 0;
}

int Stack::isFull(void) const
{
    if (insertPos_ == totalCapacity_) return 1;
    return 0;
}

int main(void)
{
    int num1, num2;
    Stack stack(100);
    char inputTmp[7];
    char newLineCheck;

    while ("Main loop") {
        scanf("%s%c", inputTmp, &newLineCheck);
        switch (inputTmp[0]) {
        case '+':
            num1 = stack.pop();
            num2 = stack.pop();
            stack.push(num2 + num1);
            break;
        case '-':
            num1 = stack.pop();
            num2 = stack.pop();
            stack.push(num2 - num1);
            break;
        case '*':
            num1 = stack.pop();
            num2 = stack.pop();
            stack.push(num2 * num1);
            break;
        case '/':
            num1 = stack.pop();
            num2 = stack.pop();
            stack.push(num2 / num1);
            break;
        default:
            stack.push(atoi(inputTmp));
            break;
        }
        if (newLineCheck == '\n') break;
    }
    cout << stack.pop() << endl;

    return 0;
}

Measured memory_bytes: 1196
import heapq
N, M = map(int, input().split())

mem = [[0] for _ in range(10**5+1)]
for _ in range(N):
    a, b = map(int, input().split())
    mem[a].append(-b)

x = mem[1].copy()

ans = 0
for i in range(1, M+1):
    if i == 1:
        heapq.heapify(x)
    else:
        for d in mem[i]:
            heapq.heappush(x, d)

    if len(x) <= 0:
        continue
    ans -= heapq.heappop(x)


print(ans)


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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


int main(){
	int n; cin >> n;
	vector<pair<int,int>> x(n);
	rep(i,n){
		int a; cin >> a;
		x[i] = make_pair(a,i);
	}
	sort(all(x));
	int l = x[n/2-1].first;
	int r = x[n/2].first;
	vector<bool> isleft(n,false);
	rep(i,n){
		if(i < n/2){
			isleft[x[i].second] = true;
		}
	}
	rep(i,n){
		cout << (isleft[i] ? r : l) << endl;
	}
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=0;i<a.size();i++)ans+=(a[i]==b[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void) {
  int n, y;
  cin>>n>>y;
  for(int i=0; i<=n; i++) {
    for(int j=0; j<=n-i; j++) {
      if(y==i*1000+j*5000+10000*(n-i-j)) {
	printf("%d %d %d\n", n-i-j, j, i);
	return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(all(t), greater<int>());
	if (s < t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int m,n,i,k,j,ans;
	cin>>n>>m;
	long long a[n][2],b[m+1][2];
	for(i=0;i<n;i++)cin>>a[i][0]>>a[i][1];
	for(i=1;i<=m;i++)cin>>b[i][0]>>b[i][1];
	for(i=0;i<n;i++)
	{
		ans=1;k=abs(a[i][0]-b[1][0])+abs(a[i][1]-b[1][1]);
		for(j=2;j<=m;j++)
		{
			if(k>abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]))
			{
				ans=j;
				k=abs(a[i][0]-b[j][0])+abs(a[i][1]-b[j][1]);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
} 

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

int main() {
  char b;
  cin >> b;
  if (b == 'A') cout << 'T' << endl;
  if (b == 'T') cout << 'A' << endl;
  if (b == 'G') cout << 'C' << endl;
  if (b == 'C') cout << 'G' << endl;
  return 0;
}

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

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

    bool flag = true;
    for(int i = 0; i < a.size(); i++) {
        if(a[i] != b[i]) flag = false;
    }

    flag ? cout << "Yes" << endl : cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
#define y1 y1___
using namespace std;
char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
ll read(){
	char ch=gc();ll x=0;int op=1;
	for (;!isdigit(ch);ch=gc()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=gc()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
int len,ans;char op[5];
int init(){
    int k=10;
    for(int i=1;i<=9;i++){
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='N') return i;
        k=k*10;
    }
    k=9;
    for(int i=1;i<=9;i++){
        printf("? %lld\n",k);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y') return i;
        k=k*10+9;
    }
    return 10;
}
int main(){
	len=init();
    if(len==10)
    {
        printf("! %d\n",(int)1e9);
        return 0;
    }
	for(int i=1;i<len;i++)
    {
        int l=0,r=9,t=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            printf("? %d\n",ans*10+mid);
            fflush(stdout);
            scanf("%s",op);
            if(op[0]=='Y')
            {
                t=max(t,mid);
                l=mid+1;
            }
            else
                r=mid-1;
        }
        ans=ans*10+t;
    }
	for(int i=(len==1?1:0);i<=9;i++)
    {
        printf("? %lld\n",((ll)ans*10+i)*10);
        fflush(stdout);
        scanf("%s",op);
        if(op[0]=='Y')
        {
            ans=ans*10+i;
            break;
        }
    }
    printf("! %d\n",ans);
	return 0;
}


Measured memory_bytes: 596
package main
 
import "fmt"
 
func main() {
	var mod int64 = 1000000007
	var n int64
	fmt.Scan(&n)
 
	a := make([]int64, n)
 
	for i := range a {
		fmt.Scan(&a[i])
	}
 
	var data int64
	var ans int64
 
	for i := n -2; i >= 0; i--{
		data = (data + a[i+1]) % mod
		ans = (ans + (data*a[i])%mod) % mod
 
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6488
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
int n,a[105],k,ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int d,c;
		cin>>d;
		for(int j=1;j<=d;j++)
		    cin>>c,a[c]++;
	}
	for(int i=1;i<=n;i++)
	    if(a[i]==0) ans++;
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<set>
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++) //REP(i, 5) cout<<i;
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define MOD 10000007 //10^9+7

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}


int main(void){
  
  double r;
  cin>> r;

  std::cout << std::setprecision(25) << 2.0*r*M_PI<<endl;
  //cout<< 2.0*r*M_PI<<endl;
  return 0;

}

Measured memory_bytes: 3784
n = int(input())
lis=[0]*n
for a in range(1,101):
    for b in range(1,101):
        for c in range(1,101):
            x=a**2+b**2+c**2+a*b+b*c+c*a
            if x<=n:
                lis[x-1]+=1
for li in lis:
    print(li)

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

int main() {
  int n;
  cin >> n;
  vector<double> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  double sum = accumulate(as.begin(), as.end(), 0.0), ave = sum / n;
  int ans = -1;
  double diff = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    if (abs(as[i] - ave) < diff) {
      diff = abs(as[i] - ave);
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

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

    if(n/100==7) {
        cout<<"Yes";
        return 0; 
    }
    else if(n%10==7){
        cout<<"Yes";
        return 0; 
    }
    else if((n/10)%10==7){
        cout<<"Yes";
        return 0;
    }
    else{
        cout<<"No";
    }
} 


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

int main() {
  int n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  ll l[n], r[n+1];
  l[0] = a[0]; r[n-1] = a[n-1]; r[n] = 1e10;
  for (int i = 1; i < n; ++i) l[i] = l[i-1] + a[i];
  for (int i = n-2; i >= 0; --i) r[i] = r[i+1] + a[i];
  int j = -1;
  for (int i = 0; i < n-1; ++i) {
    if (abs(l[i]-r[i+1]) < abs(l[i+1]-r[i+2])) {
      cout << abs(l[i]-r[i+1]) << endl;
      break;
    }
  }
  return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  if (n == 0) {
    cout << 0 << '\n';
    return;
  }
  string ans;
  while (n) {
    int t = n % -2;
    if (t == -1) {
      t = 1;
      n -= 2;
    }
    ans += to_string(t);
    n /= -2;
  }
  reverse(all(ans));
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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


int partition(int A[], int p, int r)
{
    int x = A[r];
    int i = p - 1;
    for (int j = p; j < r; j++){
        if (A[j] <= x) {
            i += 1;
            int t = A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    int t = A[i+1];
    A[i+1] = A[r];
    A[r] = t;
    for (int k = 0; k < r+1; k++){
        if(k) cout << " ";
        if (k == i + 1){
            cout << "[" << A[i+1] << "]" ;
        } else {        
            cout << A[k];
        }
    }
    return i + 1;
    
}

int main()
{
    int n, A[100000];
    
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> A[i];
    }
    partition(A, 0, n-1);
    cout << endl;
    
    return 0;
}

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


int main(){
	char S[3];

	scanf("%s",S);

	if(strcmp(S,"AAA") == 0 || strcmp(S,"BBB") == 0){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;
Graph G;
bool seen[10]={false};
int N;
int res=0;

void dfs(int v) {
    bool end = true;
    rep(i,N){
        if (!seen[i] && i != v) end = false;
    }
    if (end) {
        ++res;
        return;
    }

    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv);
    }
    seen[v] = false;
}

int main() {
    int M;
    cin >> N >> M;
    G.assign(N, vector<int>());

    rep(i,M){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0);
    cout << res << endl;

 //   system("pause");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;


int main() {
    int n;
    cin >> n;
    vi p(n);
    rep(i, n) cin >> p[i];
    sort(all(p), greater<int>());
    int ans = 0;
    rep(i, n) {
        if (i == 0) ans += p[i] / 2;
        else ans += p[i];
    }
    cout << ans << endl;
}


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

int main(int, char**)
{
	long long N;
	cin >> N;
	vector<long long> xs(N), ys(N);
	for (long long i = 0; i < N; ++i)
	{
		cin >> xs[i] >> ys[i];
	}
	vector<vector<double>> lengths(N, vector<double>(N, DBL_MAX));
	for (long long i = 0; i < N; ++i)
	{
		for (long long j = i; j < N; ++j)
		{
			lengths[i][j] = sqrt((xs[i] - xs[j]) * (xs[i] - xs[j]) + (ys[i] - ys[j]) * (ys[i] - ys[j]));
			lengths[j][i] = lengths[i][j];
		}
	}
	vector<long long> perm(N);
	iota(perm.begin(), perm.end(), 0);
	double total = 0;
	do
	{
		long long prev = perm[0];
		for (long long i = 1; i < N; ++i)
		{
			total += lengths[perm[i]][prev];
			prev = perm[i];
		}
	} while (next_permutation(perm.begin(), perm.end()));
	long long total_pattern = 1;
	for (long long i = 1; i <= N; ++i)
	{
		total_pattern *= i;
	}
	printf("%.7f\n", total / total_pattern);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100005][3];
ll a[100005][3];
int n;
ll go(int i,int j)
{
	if(i>=n) return 0;
	ll &ans=dp[i][j];;
	if(ans!=-1)
		return ans;
	ans=INT_MIN;
	if(j==0)
		ans=max(ans,a[i][j]+go(i+1,j+1)) , ans=max(ans,a[i][j]+go(i+1,j+2));
	if(j==1)
		ans=max(ans,a[i][j]+go(i+1,j+1)) , ans=max(ans,a[i][j]+go(i+1,j-1));
	if(j==2)
		ans=max(ans,a[i][j]+go(i+1,j-1)) , ans=max(ans,a[i][j]+go(i+1,j-2));
	return ans;
}
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	ll ans = max(go(0,0),max(go(0,1),go(0,2)));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 9600
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# ---------標準入力時--------------
h,w=map(int,readline().split())
ch, cw=map(int,readline().split())
dh, dw=map(int,readline().split())
m=list(map(lambda x: list(x.decode()), readlines()))
# ---------標準入力時--------------

ud=[(-1,0), (1,0)] # 上下
lr=[(0,-1), (0,1)] # 左右
warp = [(-2, -2),(-2, -1),(-2, 0),(-2, 1),(-2, 2),
 (-1, -2),(-1, -1),(-1, 1),(-1, 2),
 (0, -2),(0, 2),
 (1, -2),(1, -1),(1, 1),(1, 2),
 (2, -2),(2, -1),(2, 0),(2, 1),(2, 2)]

def bfs5():
    '''
    bfs4から少し変更
    あるマス(i,j)から上(i-1,j)下(i+1,j) もしくは 左(i,j-1)右(i,j+1)に歩いて行ける時、
    (i,j)からwarpで行ける範囲は、その上下もしくは左右でカバーされるので、(i,jは考えなくていい)
    '''
    que1=[]
    que2=[] # queueというよりはメモリ
    m[ch][cw]=str(0)
    que1.append((ch,cw))

    while que1!=[]:
        l1=len(que1)
        r1=0 # que1における使用済みindex

        # que1の要素(座標)から歩いていけるマス
        while r1<l1:
            i, j=que1[r1]
            cnt_ud=0
            # 隣接した上下のマスへの移動
            for si, sj in ud:
                if m[i+si][j+sj]=='.': 
                    m[i+si][j+sj]=m[i][j]
                    que1.append((i+si, j+sj))
                    cnt_ud+=1
            cnt_lr=0
            # 隣接した上下のマスへの移動
            for si, sj in lr:
                if m[i+si][j+sj]=='.': 
                    m[i+si][j+sj]=m[i][j]
                    que1.append((i+si, j+sj))
                    cnt_lr+=1

            if cnt_ud==2 or cnt_lr==2: # que1[r1]は不要
                que1.pop(r1); l1+=cnt_ud+cnt_lr-1
            else: # que1[r1]は必要
                r1+=1; l1+=cnt_ud+cnt_lr

        # 歩いていけないマス
        for i,j in que1:
            for si, sj in warp:
                if m[i+si][j+sj]=='.':
                    m[i+si][j+sj]=str(int(m[i][j])+1)
                    que2.append((i+si, j+sj))

        que1=que2
        que2=[]
        
for i in range(h):
    m[i] = ['#']*2 + m[i] + ['#']*2
    
m = [['#']*(w+4)]*2 + m + [['#']*(w+4)]*2
ch+=1; cw+=1; dh+=1; dw+=1

bfs5() 
if m[dh][dw] == '.':
    print(-1)
else:
    print(m[dh][dw])

Measured memory_bytes: 29048
#include <stdio.h>

int	main(void)
{
	int join_times = 0;
	int disp_rare = 0;
	int inter_rate = 0;
	
	scanf("%d %d", &join_times, &disp_rare);

	if(join_times >= 10)
	{
		printf("%d\n", disp_rare);
	}
	else
	{
		inter_rate = disp_rare + (100 * (10 - join_times));
		printf("%d\n", inter_rate);
	}
	return (0);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

int main() {
    string S;
    cin >> S;
    ll cnt0 = 0, cnt1 = 0;
    for(ll i = 0; i < S.size(); i++) {
        cnt0 += (S[i] == '0');
        cnt1 += (S[i] == '1');
    }
    cout << 2 * min(cnt0, cnt1) << endl;
    return 0;
}


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

int main() {
    int N, M;
    std::cin >> N >> M;

    std::vector<int> as, bs, cs,ds;
    as.reserve(N);
    bs.reserve(N);
    cs.reserve(M);
    ds.reserve(M);

    for (int n = 0; n < N; ++n) {
        std::cin >> as[n] >> bs[n];
    }

    for (int m = 0; m < M; ++m) {
        std::cin >> cs[m] >> ds[m];
    }

    std::vector<int> points(N, -1);
    std::vector<int> distances(N, (int)1e10);
    for (int n = 0; n < N; ++n) {
        for (int m = 0; m < M; ++m) {
            auto distance = std::abs(as[n] - cs[m]) + std::abs(bs[n] - ds[m]);
            if (distance < distances[n]) {
                points[n] = m;
                distances[n] = distance;
            }
        }
    }

    for (int n = 0; n < N; ++n) {
        std::cout << (points[n] + 1) << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println(solve(sc.nextLong(),sc.nextLong()));
	}
	
	public static long solve(long n,long s) {
		long sqrtN = sqrtFloor(n);
		for(long b=2;b<=sqrtN;b++) {
			if (f(b,n) == s) {
				return b;
			}
		}

		if (n < s) {
			return -1;
		}
		
		if (n == s) {
			return n + 1;
		}
		
		ArrayList<Long> divisors = divisors(n-s);
		long min = Long.MAX_VALUE;
		for(long d: divisors) {
			long b = d + 1;
			if (f(b,n) == s) {
				min = Math.min(min, b);
			}
		}
		
		return min == Long.MAX_VALUE ? -1 : min;
	}
	
	public static long f(long b,long n) {
		long sum = 0;
		while(n > 0) {
			sum += n % b;
			n /= b;
		}
		return sum;
	}
	
	public static long sqrtFloor(long x) {
		long y = (long) Math.sqrt(x);
		return x >= y * y ? y : y - 1;
	}
	
	public static ArrayList<Long> divisors(long x) {
		ArrayList<Long> divisors = new ArrayList<>();
		for(long i=1;i*i<=x;i++) {
			if (x % i == 0) {
				divisors.add(i);
				if (i * i != x) {
					divisors.add(x/i);
				}
			}
		}
		return divisors;
	}
	
}


Measured memory_bytes: 10068
N = int(input())

cnt = 0

N4 = int(N /1000)

N = N - N4 * 1000

N3 = int(N /100)


N = N - N3 * 100

N2 = int(N /10)

N = N - N2 * 10
     

if N == 2:
    cnt =cnt + 1

if N4 == 2:
    cnt =cnt + 1

if N3 == 2:
    cnt =cnt + 1

if N2 == 2:
    cnt =cnt + 1

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  int d = b - a;
  int h = 0;
  for (int i = 1; i < d; i++)
    h += i;
  int ans = h - a;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	int a,b,c;
	int cnt=0,k;
	cin>>a>>b>>c>>k;
	while(b<=a){
		b*=2;
		cnt++;
	} 
	while(c<=b){
		c*=2;
		cnt++;
	}
	if(cnt<=k){
		cout<<"Yes\n";
	}else {
		cout<<"No\n";
	}
    return 0;
}



Measured memory_bytes: 3632
#include<iostream>

int main () {
    int a, b;
    std::cin >> a >> b;

    int ans;
    if (a <= 5)
    {
        ans = 0;
    }
    else if (a <= 12)
    {
        ans = b / 2;
    } else {
        ans = b;
    }

        std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	char fi[n][m]; int ans[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> fi[i][j];
		}
	}
	for(int i=0;i<n;i++){
		int cnt=-1;
		for(int j=0;j<m;j++){
			if(fi[i][j]=='.'){
				ans[i][j]=cnt;
				if(cnt>0)cnt++;
			}else{
				ans[i][j]=0;
				cnt=1;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout << ans[i][0];
		for(int j=1;j<m;j++){
			cout << " " << ans[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3184
// 1Dimensional World's Tale
#include <iostream>
#include <algorithm>
using namespace std;

int main () {
    int N, M, X, Y;
    int x[101];
    int y[101];
    bool ans = false;
    cin >> N >> M >> X >> Y;
    int xmax = -120;
    int ymin = 120;

    for (int i = 0; i < N; ++i) {
        cin >> x[i];
        xmax = max(xmax, x[i]);
    } 
    for (int i = 0; i < M; ++i) {
        cin >> y[i];
        ymin = min(ymin, y[i]);
    }

    for (int i = -100; i <= 100; ++i) {
        if (X < i && i <= Y && xmax < i && ymin >= i) {
            ans = true;
            break;
        }
    }

    if (ans) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
H, N = map(int, input().split())
ls = []
m = 0
for i in range(N):
  a, b = map(int,input().split())
  ls += [(a,b)]
  if m<a:
    m = a
dp = [float('inf')]*(H+m+1)
dp[0] = 0
L = H+m+1
ans = float('inf')
for i in range(1,L):
  for j in range(N):
    a, b = ls[j]
    if i-a>=0:
      dp[i] = min(dp[i-a]+b, dp[i])
    if i>=H:
      if ans>dp[i]:
        ans = dp[i]
print(ans)

Measured memory_bytes: 43868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    string s, ans = "Yes";
    cin >> s;
    rep(i,s.size()){
        if(i%2 == 0){
            if(s[i] == 'L') ans = "No";
        }
        else {
            if(s[i] == 'R') ans = "No";
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int x;
  	cin >> x;
  
  	int ans = 9;
  	while(x >= 400){
    	x -= 200;
      	ans--;
    }
  
  	cout << ans << endl;
}

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

void solve(long long N, std::vector<std::string> S) {
    set<string> set;
    for (long long i = 0; i < N; i++) {
        set.insert(S[i]);
    }
    cout << set.size() << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> S(N);
    for (int i = 0; i < N; i++) {
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 25244
# from statistics import median

n = int(input())
a = map(int, input().split())
a = tuple(sorted(x - i for i, x in enumerate(a, 1)))

# b = median(a)
b = a[n // 2]  # 要素が偶数個のとき、中央値の計算に使用する2値のいずれでもよい

ans = sum(abs(x - b) for x in a)
print(ans)


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

int main() {
	int N;
	cin >> N;
	// 105 = 3 * 35 = 3 * 5 * 7
	// このように素因数分解したときに3つの素数となれば、8つの約数をもつ。
	// 5 * 7 * 11 > 200 
	// 2 * 7 * 11 = 154
	// 2 * 3 * 13 = 78 
	// 200 / (2*3) = 33.** < 34
	// 3 * 7 * 11 = 231 > 200
	// N < 105 なら 0... ?  
	// 2 * 3 * 5 = 30
	// 素数3つでなくても、約数が8つになる奇数はありうる。
	// 1つの素数の2乗に対して、取りうる値は3通りになる。1乗なら2通りだった。
	// 2 * 2 * 2 = 8か、
	// 4 * 2 = 8のどちらか。 4となるは、素数の3乗を含む場合。
	// 2^3 = 8 か、3^3 = 27のどちらかのみ。
	int ans = 0;
	vector<int> cand = {3, 5, 7, 11, 13, 17, 19, 23, 29};
	for (int i=0; i<cand.size(); ++i) {
		for (int j=i+1; j<cand.size(); ++j) {
			for (int k=j+1; k<cand.size(); ++k) {
				int t = cand[i]*cand[j]*cand[k]; 
				if ((t % 2 == 1) && t <= N) {
					//cout << t << endl;
					ans++;
				}
			}
		}
	}
	/*
	/// 1*2*2*2 -> evenなので不要。
	for (int i=0;i<cand.size();++i) {
		if (i==0) continue;
		int t = 8*cand[i];
		if (t % 2 == 1 && t <= N) {
			cout << t << endl;
			ans++;
		}
	}
	*/
	/// 3*3*3 
	for (int i=1;i<cand.size();++i) {
		int t = 27*cand[i];
		if (t % 2 == 1 && t <= N) {
			//cout << t << endl;
		 	ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
def main():
    point_count = int(input())
    inf = 10 ** 10
    max_sum, min_sum, max_diff, min_diff = - inf, inf,  - inf, inf
    for _ in range(point_count):
        x, y = [int(x) for x in input().split()]
        max_sum = max(x + y, max_sum)
        min_sum = min(x + y, min_sum)
        max_diff = max(x - y, max_diff)
        min_diff = min(x - y, min_diff)
    return max(max_sum - min_sum, max_diff - min_diff)


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


Measured memory_bytes: 9152
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int[] a=new int[10000];
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        for(int i=n-1;0<=i;i--){
            if(i==0) System.out.println(a[i]);
            else System.out.printf("%d ",a[i]);
        }
    }
}


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

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

    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> a[i][j];

    rep(_, w+2) cout << '#';
    cout << endl;
    rep(i, h) {
        cout << '#';
        rep(j, w){
            cout << a[i][j];
        }
        cout << '#' << endl;
    }
    rep(_, w+2) cout << '#';
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*; 

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

  		
    
 	if(n>=10){
    		System.out.println(r);
    	}else{
     		System.out.println(100*(10-n)+r);
   	 }

    	
    }
}


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

int main(){
  int W,A,B; cin >> W >> A >> B;
  int AW=A+W;
  int BW=B+W;
  if(BW>=A && B<=AW){
    cout << 0 << endl;
  }
  else cout << min(abs(BW-A),abs(AW-B)) << endl;
}

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

int main() {
  int a;
  cin >> a;
  int H,J,I;
  H = a / 100; //百の位
  a = a % 100; //左の一桁を切り捨てる
  J = a / 10; //十の位
  a = a % 10; //真ん中の一桁を切り捨てる
  I = a; //一の位
  cout << H + J + I << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char last = 'a';
        HashSet<String> hs = new HashSet<>();
        for(int i = 0; i < n; i++){
            String s = sc.next();
            hs.add(s);
            if(last == s.charAt(0) || i == 0){
                last = s.charAt(s.length()-1);
            } else {
                System.out.println("No");
                return;
            }
        }
        if(n == hs.size()){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23764
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import numpy as np
def func(ans, b_list, a_list, c_list, k, x):
    if k == 0:
        b_list = np.asarray(b_list)
        x_list = np.dot(b_list, a_list)
        if np.all(x_list >= x):
            return np.inner(c_list, b_list)
        else:
            return ans
    ans = min(ans, func(ans, b_list + [1], a_list, c_list, k - 1, x))
    ans = min(ans, func(ans, b_list + [0], a_list, c_list, k - 1, x))
    return ans

n, m, x = map(int, input().split())
c_list = [] 
a_list = []
for i in range(0, n):
    c, *a = map(int, input().split())
    c_list.append(c)
    a_list.append(a)
ans = float("inf")
c_list = np.asarray(c_list)
a_list = np.asarray(a_list)
ans = min(ans, func(ans, [1], a_list, c_list, n - 1, x))
ans = min(ans, func(ans, [0], a_list, c_list, n - 1, x))

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 27304