akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
};

int n, m;
int root;
vector< vector<edge> > g, rev;
P memo[100010];

P solve(int v){
    if(v == root){
        return {0, v};
    }
    if(memo[v].first >= 0){
        return memo[v];
    }
    P res = {0, 0};
    for(auto x : rev[v]){
        P tmp = solve(x.to);
        if(res.first < 1 + tmp.first){
            res.first = 1 + tmp.first;
            res.second = x.to;
        }
    }
    return memo[v] = res;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n >> m;

    g.resize(n);
    rev.resize(n);
    vector<int> iri(n, 0);
    rep(i, n - 1 + m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].push_back({a, b});
        rev[b].push_back({b, a});
        ++iri[b];
    }

    rep(i, n){
        if(iri[i] == 0){
            root = i;
            break;
        }
    }

    fill(memo, memo + n, make_pair(-1, -1));

    vector<int> ans(n);
    ans[root] = 0;

    rep(i, n){
        if(iri[i] >= 1){
            ans[i] = solve(i).second + 1;
        }
    }

    rep(i, n){
        cout << ans[i] << endl;
    }

    return 0;

}

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

using namespace std;

int main(){
    int a,b,c;  cin >> a >> b >> c;
    if(a == b)
        cout << c << endl;
    
    else if(a == c)
        cout << b << endl;
    
    else
        cout << a << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int N,M;
	cin >> N;
	vector<string> s,t;
	for(int i=0; i<N; i++)
	{
		string x;
		cin >> x;
		s.push_back(x);
	}
	cin >> M;
	for(int i=0; i<M; i++)
	{
		string y;
		cin >> y;
		t.push_back(y); 
	}

	vector<int> B;
	for(int i=0; i<N; i++)
	{
		B.push_back(0);
		for(int j=0; j<max(N,M); j++)
		{
            if(j<N && s[i]==s[j])
            {
                B[i]++;   
            } 
            if(j<M && s[i]==t[j])
            {
                B[i]--;
            }
		}
	}

	int m = *max_element(B.begin(), B.end());
    cout << max(0,m) << endl;
    
	return 0;
}

Measured memory_bytes: 256
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

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


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair
#define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move





int main()
{
    fast_in_out;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,m;
    cin>>n;
    int cnt[n+5];
    memset(cnt,0,sizeof cnt);
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<cnt[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 4440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T;
  int M=1001;
  cin>>N>>T;
  vector<vector<int>> vec(N, vector<int>(2));
  for(int X=0;X<N;X++){
    for(int Y=0;Y<2;Y++){
      cin>>vec.at(X).at(Y);
      if (Y==1 && vec.at(X).at(1)<=T){
        if(vec.at(X).at(0)<M){
          M=vec.at(X).at(0);
        }
      }
    }
  }
  if(M==1001){
    cout<<"TLE"<<endl;
  }
  else{
    cout<<M<<endl;
  }
}

Measured memory_bytes: 3636
n,a,b=map(int,input().split())
m=10**9+7

def cmb(x,y):

    r=1

    for i in range(1,y+1):

        r=(r*(x-i+1)*pow(i,m-2,m))%m
        
    return r
print((pow(2,n,m)-1-cmb(n,a)-cmb(n,b))%m)


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

typedef long long ll;
#define rep(i,n) for(int i=0,i<n;i++)
#define rept(i,n) for(int i=n,i>0;i--)
#define for(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()

using namespace std;

int main(){
    int h,a,n;
    cin>>h>>a;
    n=h/a;
    if(h%a!=0){
        n+=1;
    }
    cout<<n;
    return 0;
}



Measured memory_bytes: 3592
using System;

namespace B___Tap_Dance
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            for (var i = 1; i <= s.Length; i++)
            {
                if (i % 2 == 1)
                {
                    if (s[i - 1] == 'L')
                    {
                        Console.WriteLine ("No");
                        return;
                    }
                }
                else
                {
                    if (s[i - 1] == 'R')
                    {
                        Console.WriteLine ("No");
                        return;
                    }
                }
            }
            Console.WriteLine ("Yes");
        }
    }
}

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

int main (){
    int a,b,c;
    cin >> a >> b ;
    if(a==2){
        cout <<"No"<< endl;
        return 0;
    }else if(b==2){
        cout <<"No"<< endl;
        return 0;
    }else{
        cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(void){
    string s;
    cin >> s;
    bool ans=true;
    rep(i,s.length()){
        if(i%2==1){
            if(s[i]==82){
                ans=false;
            }
        }else{
            if(s[i]==76){
                ans=false;
            }
        }
        
    }
    if(ans){
        cout  << "Yes"<<endl;
    }else{
        cout  <<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32,
        m: i32,
    }

    let ans =
        if n == m {
            "Yes"
        } else {
            "No"
        };
    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque



def main():
    a, b = map(int, input().split())
    print(max(a - b * 2, 0))






if __name__ == '__main__':
    main()


Measured memory_bytes: 38508
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    int ans = 0;
    if (x <= 3) ans += (4-x)*100000;
    if (y <= 3) ans += (4-y)*100000;
    if (x == 1 && y == 1) ans += 400000;
    printf("%d",ans);

}


Measured memory_bytes: 256
using System;

class program
{
    static int p(int x)
    {
        if (x == 2) return 1;
        else if (x == 4 || x == 6 || x == 9 || x == 11) return 2;
        else return 3;
    }

    static void Main(string[] args)
    {
        string[] inputs = Console.ReadLine().Split();
        int x = int.Parse(inputs[0]);
        int y = int.Parse(inputs[1]);
        if (p(x) == p(y)) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
struct erato {
  vector<bool> hyou;
  int mx;
  void init() {
    hyou[1] = true;
    for (int i = 2; i <= mx; i++) {
      if (hyou[i] == false) continue;
      hyou[i] = true;
      for (int j = 2; j <= mx / i; j++) {
        hyou[i * j] = false;
      }
    }
  }
  erato(int x) {
    hyou.resize(x + 3, true);
    mx = x;
    init();
  }
};
const int mx = 1e5;
int main() {
  int Q;
  cin >> Q;
  erato era(mx);
  vector<ll> A(mx + 1);
  A[0] = 0;
  for (int i = 1; i <= mx; i++) {
    A[i] = A[i - 1];
    if (era.hyou[i] == true && era.hyou[(i + 1) / 2] && i % 2 == 1 && i != 1)
      A[i]++;
  }
  REP(i, Q) {
    int l, r;
    cin >> l >> r;
    cout << A[r] - A[l - 1] << endl;
  }
}

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

int main(){
	int n, t;
	cin >> n >> t;
	vector<pair<int, int>> time(n);
	for(int i = 0; i < n; ++i){
		int a, b;
		cin >> a >> b;
		time[i].first = a;
		time[i].second = b;
	}
	sort(time.begin(), time.end());
	for(int i = 0; i < n; ++i){
		if(time[i].second <= t){
			cout << time[i].first << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  int n, m;
  int b, d;
  cin >> n >> m;

  int a[m] = {}, c[m] = {};


  for (int i = 0; i < m; i++){
    cin >> a[i] >> b;
    for (int j = 0; j < b; j++){
      cin >> d;
      c[i] = c[i] | (1 << (d - 1));
    }
  }


  // dp[i][j + 1] : jまでの鍵でiを開けるときの最小(無理なときはINF)
  vector<vector<ll>> dp((1 << n), vector<ll>(m + 1, INF));
  for (int i = 0; i < 1 << n; i++){
    dp[i][0] = INF;
  }
  for (int i = 0; i < m + 1; i++){
    dp[0][i] = 0;
  }


  for (int i = 1; i < (1 << n); i++){
    for (int j = 1; j < m + 1; j++){
      dp[i][j] = min(dp[i][j-1], dp[i & (~c[j - 1])][j - 1] + a[j - 1]);
//      cout << i << " " << c[j - 1] << " " << (i | c[j - 1]) << endl;
//      dp[i | c[j - 1]][j] = min(dp[i | c[j - 1]][j-1], dp[i][j - 1] + a[j - 1]);
    }
  }

  if (dp[(1 << n) - 1][m] == INF)
    cout << -1 << endl;
  else
    cout << dp[(1 << n) - 1][m] << endl;


  return 0;
}


Measured memory_bytes: 32384
n,m=gets.split.map(&:to_i)
l=[nil]
n.times do
  l << []
end
n.times do
end
m.times do
  x,y,z=gets.split.map(&:to_i)
  l[x] << y
  l[y] << x
end
c=0
v=[0]*(n+1)
1.upto(n) do |i|
  next if v[i]==1
  c+=1
  s=[i]
  while s!=[]
    z=[]
    s.each do |ss|
      l[ss].each do |t|
        if v[t]==0
          z << t 
          v[t]=1
        end
      end
    end
    s=z.dup
  end
end
puts c


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

int main(){
    int n; cin>>n;
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        if(a%4==0)x++;
        else if(a%2==0)y++;
        else z++;
    }
    bool ok;
    if(y==0)ok=(z<=x+1);
    else ok=(z<=x);
    cout<<(ok?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
while True:
    L = map(int,raw_input().split())
    H = (L[0])
    W = (L[1])
    
    if H == 0 and W == 0:break
    for x in range(0,H):
        if x == 0 or x == H-1: print "#" * W
        else: print "#{}#".format("."*(W-2))
        
    print ""

Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int ways3[7][7]={{1,0,0},{1,0,0},{0,2,2}};
int ways4[7][7]={{2,3,1,1},{2,3,4,4},{5,5,7,8},{6,6,7,8}};
int ways5[7][7]={{0,0,1,2,3},{0,0,1,2,3},{4,4,7,5,5},{6,6,7,0,10},{8,8,9,9,10}};
int ways6[7][7]={{0,0,0,1,2,3},{0,0,0,1,2,3},{4,5,6,0,0,0},{4,5,6,0,0,0},{7,7,8,8,9,9},{10,10,11,11,12,12}};
int ways7[7][7]={{0,0,0,0,1,2,3},{0,0,0,0,1,2,3},{0,0,0,0,4,5,6},{0,0,0,0,4,5,6},{7,7,8,8,0,0,11},{9,9,10,10,0,0,11},{12,12,13,13,14,14,0}};
int ans[N][N];

int n;

void work(int x,int y,int len,int a[7][7]) {
	for(int i=x;i<x+len;i++)
		for(int j=y;j<y+len;j++) ans[i][j]=a[i-x][j-y];
}

void print() {
	for(int i=0;i<n;i++,cout<<'\n')
		for(int j=0;j<n;j++) {
			if(!ans[i][j]) putchar('.');
			else putchar(ans[i][j]-1+'a');
		}
}

int main() {
	cin>>n;
	if(n==2) { cout<<-1;return 0; }
	if(n==3) { work(0,0,3,ways3);print();return 0; }
	for(int i=0;i+7<n;i+=4) work(i,i,4,ways4);
	if(n%4==0) work(n-4,n-4,4,ways4);
	else if(n%4==1) work(n-5,n-5,5,ways5);
	else if(n%4==2) work(n-6,n-6,6,ways6);
	else if(n%4==3) work(n-7,n-7,7,ways7);
	print();
	return 0;
}


Measured memory_bytes: 5120
N = int(input())
array = list(map(int, input().split()))
if array[0] != 0:
    print(0)
    exit()
array.sort()
if 1 in array and len(set(array[1:])) == 1:
    print(1)
    exit()
if not (2 in array):
    print(0)
    exit()
if 0 in array[1:]:
    print(0)
    exit()
index = array.index(2)
count = 1
count_old = array.count(1)
ans = 1
first = array[index]
for i in range(index,N-1):
    if first != array[i+1]:
        if first != array[i+1] - 1:
            print(0)
            exit()
        ans *= count_old ** count
        count_old = count
        count = 1
    else:
        count += 1
    first = array[i+1]
    ans %= 998244353
ans *= count_old ** count
ans %= 998244353
print(ans)

Measured memory_bytes: 16252
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
 
int main()
{
    Khela
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    //string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>m)
    {
        string str[n];
        for(i=0;i<n;i++)  cin>>str[i];
        int sum[5][n][m];
        memset(sum,0,sizeof sum);
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
               if(j==0) {
                   if(str[i][j]=='.') sum[1][i][j]=1;
                   if(i>0 && str[i][j]=='.') sum[2][i][j]=sum[2][i-1][j]+1;
                   else if(i==0 && str[i][j]=='.') sum[2][i][j]=1;
                }
                else if(i==0) {
                    if(str[i][j]=='.') sum[2][i][j]=1;
                    if(str[i][j]=='.') sum[1][i][j]=sum[1][i][j-1]+1;
                }
                else{
                    if(str[i][j]=='.') sum[1][i][j]=sum[1][i][j-1]+1,sum[2][i][j]=sum[2][i-1][j]+1;
                }
            }
        }

        for(i=n-1;i>=0;i--){
            for(j=m-1;j>=0;j--){
                    if(j==m-1) {
                        if(str[i][j]=='.') sum[3][i][j]=1;
                        if(i<n-1 && str[i][j]=='.') sum[4][i][j]=sum[4][i+1][j]+1;
                        else if(i==n-1 && str[i][j]=='.') sum[4][i][j]=1;
                    }
                    else if(i==n-1) {
                        if(str[i][j]=='.')  sum[4][i][j]=1;
                        if(str[i][j]=='.') sum[3][i][j]=sum[3][i][j+1]+1;
                    }
                else{
                    if(str[i][j]=='.') sum[3][i][j]=sum[3][i][j+1]+1,sum[4][i][j]=sum[4][i+1][j]+1;
                }
            }
        }


        mx=0;
        for(i=0;i<n;i++){
            for(j=0;j<m;j++){
                if(str[i][j]=='.') p=sum[1][i][j]+sum[2][i][j]+sum[3][i][j]+sum[4][i][j];
                mx=max(mx,p-3);
            }
        }

        cout<<mx<<endl;
    }





}

Measured memory_bytes: 82688
s=int(input())
target=[s]
i=0

while True:
    if target[i]%2==0:
        tmp=target[i]/2
    else:
        tmp=3*target[i]+1
    if tmp in target:
        i+=1
        break
    else:
        target.append(tmp)
        i+=1
print(i+1)

Measured memory_bytes: 9232
N,A,B,C,D=map(int,input().split())
i=1
j=1
while True:
    if A*i>=N:
        E=i*B
        break
    i=i+1
while True:
    if C*j>=N:
        F=j*D
        break
    j=j+1
print(min(E,F))


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        int n = s.length();
        int[] digit = new int[n];
        for(int i = 0; i < n; i++){
            digit[i] = s.charAt(i) - '0';
        }
        int[] count = new int[2019];
        count[0] = 1;
        long ans = 0;
        int cur = 0;
        int pow = 1;
        for(int i = n-1; i >= 0; i--){
            cur += pow * digit[i];
            cur %= 2019;
            ans += count[cur];
            count[cur]++;
            pow *= 10;
            pow %= 2019;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 40948
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

const ll p = 1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

const ll INF = 100000000000000000;

int n, m;
struct st
{
    int s;
    int f;
    ll cost;
};


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, a, b;
    cin>>n>>a>>b;
    cout<<min(a, b)<<' '<<max(a+b-n, 0);

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

int main() {
  int N,K; cin>>N>>K;
  string S; cin>>S;
  int ans=0;
  for(int i=0; i<N-1; i++){
    if(S.at(i)!=S.at(i+1)){
      ans++;
    }
  }
  ans=min(N-1, N-1-ans+2*K);
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N;
vector<ll> X,Y;

int main(){
  cin>>N;
  X.resize(N);
  Y.resize(N);
  for(int i=0;i<N;i++) cin>>X[i]>>Y[i];

  vector<pair<double,int>> v;
  for(int i=0;i<N;i++){
      v.push_back(mkp(atan2(Y[i],X[i]),i));
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++) v.push_back(v[i]);

  double ans=0.0;
  for(int l=0;l<N;l++){
      for(int r=l;r<l+N;r++){
          ll x=0,y=0;
          for(int k=l;k<=r;k++){
              int now=v[k].second;
              x+=X[now];
              y+=Y[now];
          }
          double res=x*x+y*y;
          ans=max(ans,res);
      }
  }

  ans=sqrt(ans);
  cout<<fixed<<setprecision(15)<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
<?php
$input = trim(fgets(STDIN));
list($H, $W) = explode(' ', $input);

$lines = [];
$Ws = [];
for($i=1;$i<=$H; $i++) {
    $input = trim(fgets(STDIN));
    if (strpos($input, '#') === false) continue;
    for ($j = 1; $j <= $W; $j++) {
        if(!isset($lines[$j][$i])) $lines[$j][$i] = null;
        $lines[$j][$i] = $input[$j-1];
    }
}

for ($j = 1; $j <= $W; $j++) {
    $allWhile = true;
    for($i=1;$i<=$H; $i++) {
        if(($lines[$j][$i]) == '#'){
            $allWhile = false;
        }
    }
    if($allWhile){
        unset($lines[$j]);
    }
}

for($i=1;$i<=$H; $i++) {
    $isOutput = false;
    for ($j = 1; $j <= $W; $j++) {
        if(isset($lines[$j][$i])){
            echo $lines[$j][$i];
            $isOutput = true;
        }
    }
    if($isOutput) echo "\n";
}


Measured memory_bytes: 6648
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

const int MAX_N = 1000;
const int MAX_ABC = 301;
const int BLACK = 0;
const int WHITE = 1;
const int GRAY = 2;

int main() {
    int a, b, c, n;
    while (cin >> a >> b >> c) {
        cin >> n;
        int data[MAX_N][4], check[MAX_ABC];
        for (int i = 0; i < MAX_ABC; i++) check[i] = GRAY;
        for (int i = 0; i < n; i++) {
            cin >> data[i][0] >> data[i][1] >> data[i][2] >> data[i][3];
            if (data[i][3]) {
                check[data[i][0]] = check[data[i][1]] = check[data[i][2]] = WHITE;
            }
        }
        for (int i = 0; i < n; i++) {
            if (!data[i][3]) {
                int sum = 0;
                if (check[data[i][0]] == WHITE) sum++;
                if (check[data[i][1]] == WHITE) sum++;
                if (check[data[i][2]] == WHITE) sum++;
                if (sum == 2) {
                    for (int j = 0; j < 3; j++) {
                        if (check[data[i][j]] != WHITE) check[data[i][j]] = 0;
                    }
                }
            }
        }
        for (int i = 0; i < a+b+c; i++) {
            cout << check[i+1] << endl;
        }
    }
}


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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

int main(){
  ll N, K;
  ll a;

  scanf("%lld%lld", &N, &K);

  a = N % K;
  a = MIN(a, K-a);

  printf("%lld", a);
  
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}
int lcm(int x,int y){
	return x/gcd(x,y)*y;
}
signed main(){
	int a,b;
	while(cin>>a>>b){
		cout<<gcd(a,b)<<' '<<lcm(a,b)<<endl;
	}
}


Measured memory_bytes: 2996
#pragma region
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#pragma endregion
//-------------------
constexpr int MX = 2e5+3;
ld a[MX];

int main(){
    cin.tie(0); ios::sync_with_stdio(false); //cout << fixed << setprecision(15);
    int n; ll k; cin >> n >> k;
    // priority_queue<tuple<ld, ld, int>> pq;
    rep(i,n) {
        cin >> a[i];
    }

    ld left = 0.0;
    ld right = 1e10;
    auto f = [&](ld cur, ll total) {
        rep(i,n) {
            total -= ceil(a[i]/cur) - 1;
            // cout << total << endl;
        }
        if(total < 0) return false;
        else return true;
    };
    rep(_, 100) {
        ld mid = (left+right)/2.0;
        if(f(mid, k)) right = mid;
        else left = mid; 
        // cout << left << endl;
    }
    cout << fixed << (ll) ceil(left) << endl;
   
    return 0;
}


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

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

    int win = 0;

    rep(i,200) {
        C -= B;
        if(C<=0) {
            win = 1;
            break;
        }
        A -= D;
        if(A<=0) {
            win = 2;
            break;
        }
    }

    if(win==1) {
        cout << "Yes" << endl;
    } else if(win==2) {
        cout << "No" << endl;
    } else {
        cout << -1 << endl;
    }
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, K, ans[305][305];
char S[305][305];

int main(){
  cin >> H >> W >> K;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
    }
  }

  int now = 0;
  for (int i = 0; i < H; i++){
    bool flag = false;
    for (int j = 0; j < W; j++){
      if (S[i][j] == '#'){
        flag = true; now++;
      }
      if (flag) ans[i][j] = now;
    }

    for (int j = W - 1; j >= 0; j--){
      if (ans[i][j] == 0) ans[i][j] = ans[i][j+1];
    }
  }

  for (int j = 0; j < W; j++){
    for (int i = 1; i < H; i++){
      if (ans[i][j] == 0) ans[i][j] = ans[i-1][j];
    }
    for (int i = H - 1; i >= 0; i--){
      if (ans[i][j] == 0) ans[i][j] = ans[i+1][j];
    }
  }


  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cout << ans[i][j];
      if (j < W - 1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 4100
#include <iostream>
using namespace std;
 
int main() {
int a, b, c;
cin >> a >> b  >> c;
if (a > b) {
swap(a, b);
}
if (b > c) {
swap(b, c);
}
if (a > b) {
swap(a, b);
}
cout << a << " " << b << " " <<  c << endl;
return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
#define MOD 1e9+7
typedef long long llong;
using namespace std;

int main(){
	vector<pair<int ,int> > a(5);
	REP(i,5){
		int n;
		cin>>n;
		a[i]=make_pair(n%10,n);
	}
	
	sort(ALL(a),greater<pair<int ,int> >());
	
	int time=0;
	int j=4;
	while(a[j].first==0){
		time+=a[j].second;
		j--;
	}
	for(int i=0;i<=j;++i){
		int tmp=time/10;
		time=10*(tmp+(time%10?1:0))+a[i].second;
	}
	
	cout<<time<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())
A = list(inpl()) + [0]

i = 1
ans = 0
while i < N:
    if A[i-1] == A[i]:
        ans += 1
        i += 1
    i += 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
using namespace std;
int n, k, a, g, mx;
int gcd(int p, int q) {return q ? gcd(q,p%q) : p;}
int main() {
	scanf("%d%d", &n, &k);
	for(int i=0; i<n; i++) {
		scanf("%d", &a);
		g = gcd(i?g:a, a);
		mx = max(mx, a);
	}
	printf("%sPOSSIBLE", k%g || k>mx ? "IM":"");
	return 0;
}

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

int main(){
  string c;
  cin>>c;
  
  if ( c == "a" ||
       c == "e" ||
       c == "i" ||
       c == "o" ||
       c == "u" ){
    cout << "vowel" << endl;
  }
  
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#define QUEUE_LENGTH 60000
#define QUEUE_NAME 100
#define QUEUE_MAX 50001
using namespace std;

class queue{
	int front=0;
	int back=0;
	int q[QUEUE_LENGTH];
public:
	bool isEmpty(void);
	bool isFull(void);
	int enQueue(int x);
	int deQueue(int *x);
	void initialize(void);

};

void queue::initialize(void){
	front=0;
	back=0;
	}

bool queue::isEmpty(void){
	return front==back;
}

bool queue::isFull(void){
	return back==(front+1 % QUEUE_LENGTH);
}

int queue::enQueue(int x){
	if(isFull())
		return -1;	//error
	else{
		q[front]=x;
		if(front+1>QUEUE_LENGTH)
			front=0;
		else
			front+=1;
		return 0;
	}
}

int queue::deQueue(int *x){
	if(isEmpty())
		return -1;
	else{
		*x=q[back];
		if(back+1>QUEUE_LENGTH)
			back=0;
		else
			back+=1;
		return 0;
	}
}

class qu{
public:
	char name[QUEUE_NAME];
	int time;
};

int inputnumberandtime(int *n,int *t){
	cin >> *n >> *t;
	return 0;
}

int inputqueues(int n,qu *q){
	for(int i=0;i<n;i++)
		cin >> (q+i)->name >> (q+i)->time;
	return 0;
}

int printqueues(int n,int time,qu *q){
	cout << n << ' ' << time << endl;
	for(int i=0;i<n;i++)
		cout << (q+i)->name << " " << (q+i)->time << endl;;
	cout << endl;
	return 0;
}

int initqueue(int n,queue *q){
	q->initialize();
	for(int i=0;i<n;i++)
		q->enQueue(i);
	return 0;
}

int processing(int n,int time,qu *que,queue *q){
	int t=0,num;
	initqueue(n,q);

	while(q->deQueue(&num)!=-1){
		if((que+num)->time > time){
			t+=time;
			(que+num)->time-=time;
			q->enQueue(num);
		}else{
			t+=(que+num)->time;
			(que+num)->time=0;
			cout << (que+num)->name << " " << t << endl;
		}
	}

	return 0;
}


int main() {
	int n,time;
	qu *que=new qu[QUEUE_MAX];
	queue *q=new queue;

	inputnumberandtime(&n,&time);
	inputqueues(n,que);
	//printqueues(n,time,que);
	processing(n,time,que,q);


	return 0;
}



Measured memory_bytes: 8348
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String o = scanner.next();
		String e = scanner.next();

		for (int i = 0; i < o.length(); i++) {
			System.out.print(o.charAt(i));
			try {
				System.out.print(e.charAt(i));
			} catch (Exception ex) {
				return;
			}
		}
	}
}

Measured memory_bytes: 21460
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n,m,q,v[12],a[55],b[55],c[55];
ll d[55];

ll solve(int i, int x){
	int j;
	ll ret = 0ll;
	if(i<n){
		for(j=x; j<=m; ++j){
			v[i] = j;
			ret = std::max(ret,solve(i+1,j));
		}
	}else{
		for(j=0; j<q; ++j){
			if(v[b[j]]-v[a[j]]==c[j]){
				ret += d[j];
			}
		}
	}
	return ret;
}

int main(void){
	int i;
	std::cin >> n >> m >> q;
	for(i=0; i<q; ++i){
		std::cin >> a[i] >> b[i] >> c[i] >> d[i];
		--a[i]; --b[i];
	}
	std::cout << solve(0,1) << std::endl;
	return 0;
}


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

ans = [0 for _ in range(9)]
for i in list(map(int,input().split())):
    if i < 400:
        ans[0] = 1
    elif i < 800:
        ans[1] = 1
    elif i < 1200:
        ans[2] = 1
    elif i < 1600:
        ans[3] = 1
    elif i < 2000:
        ans[4] = 1
    elif i < 2400:
        ans[5] = 1
    elif i < 2800:
        ans[6] = 1
    elif i < 3200:
        ans[7] = 1
    else:
        ans[8] += 1

if sum(ans[:8]) != 0:
    print(sum(ans[:8]), sum(ans))
else:
    print(1,sum(ans))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long k; cin >> k;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  long long ans = 0;
  int start_bit = 0;
  while (true) {
    if ((1LL << start_bit) > k) break;
    ++start_bit;
  }
  for (int i = start_bit-1; i >= 0; --i) {
    long long bit = 1LL << i;
    int zero = 0, one = 0;
    REP(j, n) {
      if (a[j] & bit) ++one;
      else ++zero;
    }
    if (zero > one && ans + bit <= k) ans += bit;
  }
  long long res = 0;
  REP(i, n) res += (a[i] ^ ans);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Set<String> sets = new HashSet<>();
        for(int i=0;i<N;i++){
            sets.add(sc.next());
        }
        System.out.println(sets.size());
    }

}


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

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

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

int main()
{
	long long a, b;
	while (cin >> a >> b)
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<int>;

int main(){
  int n;
  cin >> n;
  auto a = vector<int>(n,0);
  for (int i = 0; i < n; i++)
  {
     cin >> a[i];
  }
  
  auto b = list<int>();

  for (int i = 0; i < n; i++)
  {
     if(i%2==0){
        b.push_back(a[i]);
     }else{
        b.push_front(a[i]);
     }
  }
  
  if(n%2==1){
     reverse(b.begin(),b.end());
  }
  copy(b.begin(),b.end(),ostream_iterator<int>(cout," "));
  
}
  
  

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



int main()
{
        int n,w;
        cin>>n>>w;
        LL a[n+2][2],DP[n+2][w+2];
        for(int i=0;i<=n;i++)
        {
                for(int j=0;j<=w;j++)
                {
                        DP[i][j] = 0;
                }
        }
        for(int i=1;i<=n;i++)
        {
                cin>>a[i][0]>>a[i][1];
        }
        for(int i=1;i<=n;i++)
        {
                for(int j=1;j<=w;j++)
                {
                        DP[i][j] = max(DP[i-1][j] , DP[i][j-1]);
                        if(j-a[i][0]>=0)
                        {
                                DP[i][j] = max(DP[i][j],a[i][1]+DP[i-1][j-a[i][0]]);
                        }
                }
        }
        cout<<DP[n][w];
        
}

Measured memory_bytes: 79616
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [a, b] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ a * b

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 3744
n=int(input())
def gauss_2(n):
    g=0
    while g<=n**(1/2):
        g+=1
    return g-1

def gauss_3(n):
    g=0
    while g<=n**(1/3):
        g+=1
    return g-1
def gauss_4(n):
    g=0
    while g<=n**(1/4):
        g+=1
    return g-1
def gauss_5(n):
    g=0
    while g<=n**(1/5):
        g+=1
    return g-1
def gauss_6(n):
    g=0
    while g<=n**(1/6):
        g+=1
    return g-1
def gauss_7(n):
    g=0
    while g<=n**(1/7):
        g+=1
    return g-1

if n<=3:
    print(1)
elif n not in (125,216,343,512,729,1000):
    print(max(gauss_2(n)**2,gauss_3(n)**3,gauss_4(n)**4,gauss_5(n)**5,gauss_6(n)**6,gauss_7(n)**7))
else:
    print(n)

Measured memory_bytes: 3064
// https://atcoder.jp/contests/abc063/tasks/arc075_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int n, a, b;
vector<int> v;
bool check(ll x) {
    ll c = 0;
    auto it = lower_bound(ALL(v), b * x);
    while (it != v.end()) {
        // 全体にbダメージ * x回
        ll h = *it - x * b;
        if (h > 0) {
            // a - b の追加ダメージ
            c += ceil((double)h / (a - b));
        }
        it++;
    }
    return c <= x;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> a >> b;
    v.resize(n);
    REP(i, n) cin >> v[i];
    sort(ALL(v));
    int ng = 0, ok = v[n - 1];
    // NGとOKの境界を二分探索する
    while (ng + 1 != ok) {
        int x = (ng + ok) / 2;
        if (check(x))
            ok = x;
        else
            ng = x;
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int pw[100];

signed main()
{
	ios::sync_with_stdio(false);
	int n;cin>>n;
	int tot=0,cnt=0;
	pw[0]=1;
	while(tot<n){
		cnt++;pw[cnt]=pw[cnt-1]*26;tot+=pw[cnt];
	}
	n-=(tot-pw[cnt]);
	string ans="";
	for(int i=1;i<=cnt;i++){
		int num=0,sum=1;
		while(num<n){
			num+=pw[cnt-i];sum++;
		}
		num-=pw[cnt-i];n-=num;
		sum--;
		ans+=char('a'+sum-1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3652
h, w = map(int, input().split())
ch, cw = 1, 1
while h != 0 and w != 0:
    while h >= ch:
        if ch % 2 == 1:
            while w >= cw:
                if cw % 2 == 1:
                    print("#", end = "")
                else:
                    print(".", end = "")
                cw += 1
        else:
            while w >= cw:
                if cw % 2 == 1:
                    print(".", end = "")
                else:
                    print("#", end = "")
                cw += 1
        print("")
        cw = 1
        ch += 1
    print("")
    h, w = map(int, input().split())
    ch, cw = 1, 1



Measured memory_bytes: 7012
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
using namespace std;
typedef long long LL;
typedef pair<int,int> pt;
const int N=1e6+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int bb=18;
const double eps=1e-10;
const double pi=acos(-1);
int n,m;
char str[N];
int f[N];
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    r(n);
    bool flag=1;
    FOR(i,1,n) r(f[i]);
    FOR(i,1,n){
        if(f[i]&1) ;
        else{
            if(f[i]%3!=0&&f[i]%5!=0){
                flag=0;
                break;
            }
        }
    }
    if(flag) cout<<"APPROVED\n";
    else cout<<"DENIED\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INTXT std::ifstream in ("input.txt"); std::cin.rdbuf(in.rdbuf());
#define INF 1e9

using namespace std;
typedef long long ll;
static const int MOD = 1000000007LL;

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

  vector<int> nums;
  int max_val = -1 * INF;

  REP(i, n){
    int a;
    cin >> a;
    a = -a;
    if (a >= max_val){
      nums.push_back(a);
      max_val = a;
    }
    else{
      int idx = distance(nums.begin(), upper_bound(nums.begin(), nums.end(), a));
      nums.at(idx) = a;
      max_val = min(nums.at(nums.size() - 1), max_val);
    }
    
    // cout << i << " ";
    // REP(j, nums.size()){
    //   cout << " " << nums.at(j);
    // }
    // cout << endl;
  }
  cout << nums.size() << endl;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int in[100000];
vector<int> G[100000];
int par[100000];
void dfs(int v, int p) {
	vector<int> child;
	for (int to : G[v]) {
		if (to == p) continue;
		if (in[to] == 1) {
			child.push_back(to);
			par[to] = v + 1;
		}
		in[to]--;
	}
	for (int to : child) {
		dfs(to, v);
	}
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N - 1 + M; i++) {
		int A, B;
		cin >> A >> B;
		A--; B--;
		in[B]++;
		G[A].push_back(B);
	}
	int root = -1;
	for (int i = 0; i < N; i++) {
		if (in[i] == 0) {
			root = i;
			break;
		}
	}
	par[root] = 0;
	dfs(root, -1);
	for (int i = 0; i < N; i++) {
		cout << par[i] << endl;
	}
}

Measured memory_bytes: 21120
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define ld long double
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p = MOD) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 1e5 + 1;
lli n, sm = 0, k, b, c, q;

void solve(){
    cin >> n >> k;
	vi a(n);
	NA(i,0,n) cin >> a[i];
	sort(all(a));
	sm = 0;
	NA(i,0,k) sm += a[i];
	cout << sm << '\n';
    return;
}
        
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int array[N];
    for(int i=0;i<N;i++){
        cin >> array[i];
    }
    double d=0.0;
    sort(array,array+N);
    d=array[0];
    for(int i=1;i<N;i++){
        d = (d+array[i])/2;
    }
    cout << d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	if( s == "Sunny" ) cout << "Cloudy" << endl;
	if( s == "Cloudy" ) cout << "Rainy" << endl;
	if( s == "Rainy" ) cout << "Sunny" << endl;
	
	return 0;
}


Measured memory_bytes: 256
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
PX = []
for i in range(M):
    PX.append(list(map(int,input().split())))

d_sum = sum(T)
for p,x in PX:
    res = d_sum
    res -= T[p-1]
    res += x
    print(res)

Measured memory_bytes: 3064
import java.util.Scanner;

public 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();
		System.out.println(A + B >= C ? "Yes" : "No");
	}
}

Measured memory_bytes: 22608
import numpy as np

n,m,x=map(int,input().split())
c=[]
a=[]
ans=10**8

for k in range(n):
  line=list(map(int,input().split()))
  c.append(line[0])
  a.append(line[1:])

a=np.array(a)


for i in range(2**n):
  level=np.zeros(m)
  price=0
  for j in range(n):
    if ((i>>j)&1):
      level+=a[j]
      price+=c[j]
  bottom=int(np.amin(level))
  if bottom>=x and price<ans:
    ans=price
if ans==10**8:
  print(-1)
else:
  print(ans)


Measured memory_bytes: 27188