akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  int n,ans;
  cin >> n;
  if(n%2==0) ans=n/2;
  else  ans=n/2+1;
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

struct sum{
	int v, h;
};

int main(){
	int H, W;
	cin >> H >> W;

	string S[H];
	for (int i = 0; i < H; i++){
		cin >> S[i];
	}

	struct sum t[H][W];
	memset(t, -1, sizeof(t));

	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			if(S[i][j] == '#'){
				t[i][j].h = 0;
				t[i][j].v = 0;
				continue;
			}
			if(t[i][j].h == -1){
				t[i][j].h = 1;
				for (int k = 1; j + k < W && S[i][j + k] != '#'; k++){
					t[i][j].h++;
				}
				for (int k = 1; j - k >= 0 && S[i][j - k] != '#'; k++){
					t[i][j].h++;
				}
				for (int k = 1; j + k < W && S[i][j + k] != '#'; k++){
					t[i][j + k].h = t[i][j].h;
				}
				for (int k = 1; j - k >= 0 && S[i][j - k] != '#'; k++){
					t[i][j - k].h = t[i][j].h;
				}
			}

			if(t[i][j].v == -1){
				t[i][j].v = 1;
				for (int k = 1; i + k < H && S[i + k][j] != '#'; k++){
					t[i][j].v++;
				}
				for (int k = 1; i - k >= 0 && S[i - k][j] != '#'; k++){
					t[i][j].v++;
				}
				for (int k = 1; i + k < H && S[i + k][j] != '#'; k++){
					t[i + k][j].v = t[i][j].v;
				}
				for (int k = 1; i - k >= 0 && S[i - k][j] != '#'; k++){
					t[i + k][j].v = t[i][j].v;
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++){
		for (int j = 0; j < W; j++){
			ans = max(ans, t[i][j].h + t[i][j].v - 1);
		}
	}

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


Measured memory_bytes: 35584
#include <iostream>
using namespace std;
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; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
const int MAX_N = 110;
const int MAX_V = 100100;
long long dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    // 初期化
    for (int i = 0; i < MAX_N; ++i) {
        for (int j = 0; j < MAX_V; ++j) {
            dp[i][j] = INF;
        }
    }
    
    // 初期条件
    dp[0][0] = 0;
    
    
    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
            
            // i 番目の品物を選ぶ場合
            if (sum_v + value[i] < MAX_V) chmin(dp[i+1][sum_v + value[i]], dp[i][sum_v] + weight[i]);
            
            // i 番目の品物を選ばない場合
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    
    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Measured memory_bytes: 86272
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  ll n,k;cin>>n>>k;
    vector<ll>a(n);
    ll sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    vector<ll>y(0);
    for(int i=1;i<sqrt(sum);i++){
        if(sum%i==0){
            if(sum/i!=i)y.pb(sum/i);
            y.pb(i);
        }
    }
    ll ans=1;
    for(int i=0;i<y.size();i++){
        ll s=y[i];
        priority_queue<ll>pq;
        ll ss=0;
        for(int j=0;j<n;j++){
            ss+=a[j]%s;
            pq.push(a[j]%s);
        }
        ll cnt=ss;
        for(int j=0;j<ss/s;j++){
            cnt+=(s-2*pq.top());
            pq.pop();
        }
        if(cnt<=2*k){
            ans=max(ans,y[i]);
        }
      //cout<<y[i]<<' '<<cnt<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
public class Program
{
  public static void Main()
  {
    var s = Console.ReadLine();
    var t = Console.ReadLine();
 
    var posList = Enumerable.Range(0, 'z' - 'a' + 1)
      						.Select(x => new List<int>())
      						.ToList();
    
    var text = s + s;
    for (var index = 0; index < text.Length; index++)
    {
      posList[text[index] - 'a'].Add(index);
    }
 
    long result = 0;
 
    foreach (var c in t)
    {
      var list = posList[c - 'a'];
 
      if (!list.Any())
      {
        result = -1;
        break;
      }
 
      var current = (int)(result % s.Length);
      var listIndex = list.BinarySearch(current);
      
      if (listIndex < 0)
      {
        listIndex = ~listIndex;
      }
 
      var next = list[listIndex];
      result += next - current  + 1;
    }
 
    Console.WriteLine(result);
  }
}

Measured memory_bytes: 20956
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef stack<int> S;
const int N=200200;
int n;
int a[N];
int b[N];
S s;
void gg(){
	puts("-1");
	exit(0);
}
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d",&b[i]);
		if(b[i]<a[i]){
			gg();
		}
	}
	for(int i=0;i<n;i++){
		s.push(i);
	}
	LL ans=0;
	while(!s.empty()){
		int x=s.top();
		s.pop();
		int l=(x-1+n)%n;
		int r=(x+1)%n;
		LL db=b[l]+b[r];
		LL da=b[x]-a[x];
		if(b[x]<=db){
			continue;
		}
		int o=da/db;
		if(o==0){
			continue;
		}
		ans+=o;
		b[x]-=o*db;
		assert(b[x]>=a[x]);
		s.push(l);
		s.push(r);
	}
	for(int i=0;i<n;i++){
		if(a[i]!=b[i]){
			gg();
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, k;
bool v[105];
ll cnt;

int main()
{
//    freopen("input.txt", "r", stdin);
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < k; i++)
    {
        ll t;
        scanf("%lld", &t);
        while(t--)
        {
            ll tt;
            scanf("%lld", &tt);
            v[tt] = true;
        }
    }
    for(ll i = 1; i <= n; i++)
    {
        if(!v[i]) cnt++;
    }
    printf("%lld\n", cnt);
    return 0;
}


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


void solve(long long a, long long b, long long c, long long d){
    cout << max({a * c, a * d, b * c, b * d}) << endl;
}

// Generated by 1.1.7.1 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 a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    long long d;
    scanf("%lld",&d);
    solve(a, b, c, d);
    return 0;
}


Measured memory_bytes: 3684
import math
d, g = map(int, input().split())
p = []
c = []
for _ in range(d):
    a, b  = map(int, input().split())
    p.append(a)
    c.append(b)

min_cnt = 1000
for i in range(2**d):
    cnt = 0
    point = 0
    idx = 0
    for j in range(d):
        if i>>j & 1:
            cnt += p[j]
            point += (j+1)*100*p[j] + c[j]
        else:
            idx = j
    if point>=g and min_cnt>=cnt:
        min_cnt = cnt
    else:
        q = point+(idx+1)*100*(p[idx]-1)
        if q>=g:
            count = max(math.ceil((g-point)/((idx+1)*100)),0)
            cnt += count
            if min_cnt>=cnt:
                min_cnt=cnt
         
print(min_cnt) 


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 2];
        int sum = 0;
        int cur = 0;
        arr[n] = 0;
        arr[n + 1] = 0;

        for (int i = 1; i < n + 1; i++) {
            arr[i] = sc.nextInt();
            sum += Math.abs(cur - arr[i]);
            cur = arr[i];
        }
        sc.close();

        sum += Math.abs(cur);

        for (int i = 1; i <= n; i++) {
            System.out.println(sum - Math.abs(arr[i - 1] - arr[i]) - Math.abs(arr[i] - arr[i + 1])
                    + Math.abs(arr[i - 1] - arr[i + 1]));
        }
    }
}

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

using namespace std;

int n, a, b;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
/*input
7
zenkoku
touitsu
program
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

int n;
string a,b,c;

void solve(){
     cin >> n >> a >> b >> c;
     int ans = 0;
     REP(i,n){
       set<char> haha;
       haha.insert(a[i]);
       haha.insert(b[i]);
       haha.insert(c[i]);
       ans += haha.size()-1;
     }
     cout << ans;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  //freopen(".in","r",stdin);freopen(".out","w",stdout);
  int t = 1;//cin >> t;
  WL(t)solve();
  return 0;
}

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

int h, w;
char c[310][310];
int dp1[310][310];
int dp2[310][310];
char *a, *b;

int cost(int x, int y) {
    int &res = dp1[x][y];
    if (res != -1) return res;
    if (x == 0 || y == 0) {
        res = 0;
    } else {
        res = cost(x - 1, y - 1) + (a[x - 1] == b[y - 1]);
    }
    return res;
}

int opt(int x, int y) {
    int &res = dp2[x][y];
    if (res != -1) return res;
    if (x == 0 || y == 0) {
        res = 0;
    } else {
        res = min(opt(x - 1, y), opt(x, y - 1)) + cost(x, y);
    }
    return res;
}

int solve(int x) {
    memset(dp1, -1, sizeof dp1);
    memset(dp2, -1, sizeof dp2);
    a = c[x], b = c[x + 1];
    return opt(w, w);
}

int main() {
    while (cin >> h >> w) {
        char d[333][333];
        for (int i = 0; i < h; i++) {
            cin >> d[i];
        }
        memset(c, 0, sizeof c);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                c[j][i] = d[i][j];
            }
        }
        swap(h, w);
        int ans = 0;
        for (int i = 0; i < h - 1; i++) {
            ans += solve(i);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>1&&b<=1)
    {
        cout<< (a*(a-1))/2;
    }
    else if(a>1&&b>1)
    {
        cout<< (a*(a-1))/2 + (b*(b-1))/2;
    }
    else if(b>1&&a<1)
    {
        cout<<(b*(b-1))/2;
    }
    else
    {
        cout<<0;
    }

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long> a(N);
	long long ans = 0;
	for (int i = 0; i < N; i++)cin >> a[i];
	for (int i = 0; i < N; i++) {
		while (1) {
			if (a[i] % 2 == 0)ans++;
			else break;
			a[i] /= 2;
		}
	}
	cout << ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
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;
}




int main() {
    int N;
    cin >> N;
    vector<int>a(N-1);
    for(int i = 0; i < N-1;i++) {
        cin >> a[i];
    }
    vector<int>count(N+1);
    for(int i = 0;i < N-1;i++) {
        count[a[i]] +=1;
    }
    for(int i = 1;i < N+1;i++) {
        cout << count[i] <<endl;
    }
}


Measured memory_bytes: 4844
//状态:
//题号:
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
inline string ToBin(int x) {
	char c=(x%2+'0');
	if (x==0)return "0";
	else if (x==1)return "1";
	else return ToBin(((x/2)))+c;
}
long long C(int n){
	return (long long)(n-1)*n/2;
}
int n;
int a[200005],sum;
long long ans;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int l=0,r=0;
	for(;l<n;++l){ 
		while(r<n&&(sum+a[r]==(sum^a[r])))sum+=a[r],ans+=r-l+1,++r;
		sum-=a[l];
	}
	cout<<ans<<endl;
	return 0;
}


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


int main()
{
	int W, H, x, y, r;
	cin >> W;
	cin >> H;
	cin >> x;
	cin >> y;
	cin >> r;

	if (r <= x && r <= y && x <= W - r && y <= H - r){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi p(n);
	int down=1000000;
	rep(i,n){
		cin>>p[i];
		if(chmin(down,p[i])){
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4048
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;
import std.math;

alias real F;
F dot(F[] a, F[] b){ return a[0]*b[0]+a[1]*b[1]; }
F cross(F[] a, F[] b){ return a[0]*b[1]-b[0]*a[1]; }
F[] add(F[] a, F[] b){ return [a[0]+b[0],a[1]+b[1]]; }
F[] sub(F[] a, F[] b){ return [a[0]-b[0],a[1]-b[1]]; }

void main()
{
    foreach(s;stdin.byLine())
    {
        auto m = s.split(",").map!(to!F).array();
        auto P1=m[0..2], P2=m[2..4], Q=m[4..6];
        auto vp=sub(P2,P1), vq=sub(Q,P1);
        auto x = atan2(cross(vp,vq),dot(vp,vq));
        F[] t = [sin(-2*x),cos(-2*x)];
        auto vr = [cross(vq,t),dot(vq,t)];
        auto R = add(vr,P1);
        R.map!(v=>format("%.6f",v)).join(" ").writeln();
    }
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//#define CHKR
#define ll int
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008
ll n,m;
ll a[ARRS];

ll da[500];
ll f[500];
#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll k=0,p,q,l,r;
    string s;
    cin>>s;
    da['N']=1;
    da['S']=1;
    da['E']=2;
    da['W']=2;
    for(int i=0; i<s.size(); i++){
		if(!f[s[i]])k=k^da[s[i]];
		f[s[i]]=1;
    }
    if(!k)cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int A, B, C;

int c(int a, int b){
	if(a > b)
		return a - b;
	return (b - a + 1) / 2 + (b - a) % 2;
}
void solve(){
	int d[3] = {
		c(A, C) + c(B, C),
		c(C, A) + c(B, A),
		c(C, B) + c(A, B),
	};
	cout << min(d[0], min(d[1], d[2])) << endl;

}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B >> C;

		solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){
  ll N;
  cin >> N;
  N %= 1000;
  if(N==0)N=1000;
  cout << 1000 - N << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
using ll=long long;
int a[maxn];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    if(a[0]>x){
        ans+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]<=x)
            continue;
        else{
            ans+=(ll)(a[i-1]+a[i]-x);
            a[i]-=(a[i-1]+a[i]-x);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


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

int main() {
   int n,count;
   cin >> n;
   count = 0;
   string x,a;
   cin >> x;
   a = "ABC";

   for(int i=0;i<n-2;i++){
     //cout << x.compare(i,i+2,a) << endl;
      if(x.compare(i,3,a)==0){
         count += 1;
      }
      string y;
      y = x.at(i) + x.at(i+1) + x.at(i+2);
      
   }
   cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi;
typedef vector<double> vd;
 
double mypow(double b ,int e){
      if(e == 0) return 1;
      if(e%2==0)
            return mypow( b*b, e/2 );
      else
            return mypow( b*b, e/2 ) * b;
}
 
int main(){
 
 
      int N,M,L; cin >> N >> M >> L ;
      if(N==1){
            cout << 1.0 << endl;
            return 0;
      }
      vector<vd> prob(N,vd(M+1,0.0));
      vector<vd> dist(N,vd(M+1,0.0));
 
      vd p(N),t(N),v(N);
      for(int i=0; i<N; i++) cin >> p[i] >> t[i] >> v[i];
 
      // PRE PROCESS
      for(int i=0; i<N; i++){
            dist[i][0] = (double)L / v[i];
            for(int j=1; j<=M; j++){
                  dist[i][j] = dist[i][j-1] + t[i];
            }
      }
      for(int i=0; i<N; i++)
            prob[i][0] = mypow((100-p[i])/100,M);
      for(int i=0; i<N; i++){
            for(int j=1; j<=M; j++){
                  if(p[i] != 100)
                        prob[i][j] = (prob[i][j-1] * (p[i]/100)) / ((100-p[i])/100);
                  else
                        prob[i][j] = 1.0;
            }
      }
      double comb = 1;
      for(int j=1; j<=M; j++){
            comb = comb * (M - j + 1) / j; 
            for(int i=0; i<N; i++){
                  prob[i][j] *= comb;
            }
      }
       
      vector<vd> sum = prob;
      for(int i=0; i<N; i++){
            for(int j=M-1; j>=0; j--){
                  sum[i][j] += sum[i][j+1];
                  if(sum[i][j] > 1) sum[i][j] = 1;
            }
      }
 
      vector<vd> ans = prob;
      for(int i=0; i<N; i++){
            for(int j=0; j<=M; j++){
                  for(int k=0; k<N; k++){
                        if(i==k) continue;
                        int id = upper_bound(dist[k].begin(),dist[k].end(), dist[i][j]) - dist[k].begin();
                        if(id > M) ans[i][j] = 0.0;
                        else       ans[i][j] *= sum[k][id];
 
                  }
            }
      }
 
      for(int i=0; i<N; i++){
            double tmp = 0.0;
            if(p[i] == 100) tmp = ans[i][M];
            else
                  for(int j=0; j<=M; j++)
                        tmp += ans[i][j];
            if(tmp > 1) tmp = 0;
            printf("%.10f\n",tmp);
      }
                         
}

Measured memory_bytes: 3364
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
    ll n, count=0;
    cin >> n;
    string str;
    map<string, ll> check;

  for(ll i=0;i<n;++i){
    cin >> str;
    vector< string > copy;
    for(ll j=0;j<10; ++j){
      copy.push_back(str.substr(j,1));
    }
    sort(copy.begin(), copy.end());
    string ans ="";
    for(ll j=0;j<10; ++j){
      ans += copy[j];
    }
    if(check.find(ans) != check.end()){
      check[ans] += 1LL;
    } else {
      check[ans] = 1LL;
    }
  }

  for(auto itr = check.begin();itr != check.end();++itr){
    if(itr->second == 1) continue;
    count += (itr->second)*(itr->second - 1LL) / 2LL;
  }
  cout << count << endl;
}
int main()
{
		    ios_base::sync_with_stdio(false);
			cin.tie(NULL);
	ll t = 1; 
	//cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>

int main() {
	int a, b, c, flag = 0;
	scanf("%d %d %d", &a, &b, &c);
	if (a < b) {
		if (b < c) {
			printf("Yes\n");
			flag = 1;
		}
	}
	if (flag == 0) {
		printf("No\n");
	}
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int n;
    cin >> n;
    int a[200010] = {0};
    int h[200010] = {0};
    rep(i,n)cin >> a[i+1];

    for(int i = n;i >= 1;i--){
        if(2*i > n)h[i] = a[i];
        else{
            int s = 0;
            for(int j = 2*i;j <= n;j += i){
                s += h[j];
            }
            // cerr << i << " : ";
            // for(int k = 1;k <=n;k++)cerr << h[i] << " ";
            // cerr << endl;
            // cerr << i << ":" << s << endl;
            if(a[i] == s%2)h[i] = 0;
            else h[i] = 1;
        }
    }
    vector<int> ans;
    for(int i = 1;i <= n;i++){
        if(h[i]){
            ans.pb(i);
        }
        // cerr << h[i] << endl;
    }
    if(ans.size() == 0)cout << 0 << endl;
    else{
        cout << ans.size() <<endl;
        for(auto x:ans)cout << x << " ";
        cout << endl;
    }


    
    

    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc134.contest.atcoder.jp/tasks/abc134_b

Measured memory_bytes: 5364
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, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

r, g, b = MAP()

if int(str(g) + str(b))%4 == 0:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 5396
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 18;

int n, m, k;
int was[N][3];
vector<int> g[N];

void solve(int test)
{
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g[x].push_back(y);
  }
  int s, t;
  cin >> s >> t;
  --s; --t;
  queue<pair<int, int>> q;
  q.emplace(s, 0);
  was[s][0] = 1;
  while (!q.empty()) {
    int v, x;
    tie(v, x) = q.front();
    q.pop();
    for (auto to : g[v]) {
      if (!was[to][(x + 1) % 3]) {
        was[to][(x + 1) % 3] = was[v][x] + 1;
        q.emplace(to, (x + 1) % 3);
      }
    }
  }
  if (was[t][0]) {
    cout << (was[t][0] - 1) / 3 << '\n';
  }
  else {
    cout << "-1\n";
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#define rep(a,b,c) for(int a=b;a<c;a++)
#define rep_(a,b,c) for(int a=c-1;a>=b;a--)
using namespace std;

int main()
{
	cin.sync_with_stdio(false);
	cout.sync_with_stdio(false);
	string s;
	int ans=0;
	getline(cin,s);
	rep(i,1,s.length())
		if (s[i-1]!=s[i]) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 512
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef double dd;
typedef pair <int, int> pii;
#define pb push_back
#define pf push_front
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
//const int mx = 1000 * 100 + 5;
int32_t main(){		
	ios_base::sync_with_stdio(false);
    cin.tie(0);
	cout.tie(0);
	int k, x;
	cin >> k >> x;
	cout << (500 * k >= x ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
int A[3];
 
cin >> A[0] >> A[1] >> A[2];
 
sort(A,A+3);
 
cout << A[0]  << " "<< A[1] << " " <<A[2] << endl;
 
}
 

 

Measured memory_bytes: 3136
def main(n: int, a: list):
    if 0 in a:
        print(0)
        return

    ans = a[0]

    for i in a[1:]:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            return

    print(ans)


if __name__ == "__main__":
    n = map(int, input().split())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 21696
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>
 
#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
 
using namespace std;
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VII;
typedef pair<int,int> PII;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
 
int dp[100] = {1,1};
int a[100] = {1,1};
            
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
     
    for(int i = 2;i < n + 1;i++){

        dp[i] = dp[i - 1] + dp[i - 2];
    }
    cout << dp[n] << endl;
 
    return 0;
}

Measured memory_bytes: 1192
import Foundation

let (n, x, t) = readInts().tuple()

print(Int(ceil(Double(n) / Double(x)) * Double(t)))









// MARK: ----------------------------------------------------------------------


func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func tuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}


extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}


Measured memory_bytes: 13564
def asum(l,r):
	global cumsum
	l+=1
	r+=1
	return cumsum[r-1]-cumsum[l-1]
def check(l,r):
	global dp
	if l==r:
		return 0
	if l == r-1:
		return arr[l]+arr[r]
	if dp[l][r] != None:
		return dp[l][r]
	else:
		ans = 10**18
		for i in range(l, r):
			st1 = asum(l,i)
			st2 = asum(i,r+1)
			ans = min(st1 + st2 + check(l,i)+ check(i+1, r), ans)
		
		dp[l][r] = ans
		return ans





ll = int(input())
arr = [int(i) for i in input().split()]
cumsum = [0]

for i in arr:
	cumsum.append(cumsum[-1]+i)
dp = [[None for i in range(ll+1)] for j in range(ll+1)]
print(check(0, ll-1))


Measured memory_bytes: 48860
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

    int n;
    cin>>n;
    string s;
    cin>>s;
    vi d(n+1);
    rep(i,n)if(s[i]=='#')d[i+1]=1;
    rep(i,n)d[i+1]+=d[i];
    int out=min(d[n],n-d[n]);
    rep(i,n-1)cmin(out,d[i+1]+n-i-1-d[n]+d[i+1]);
    cout<<out<<endl;
}
//...##


Measured memory_bytes: 1428
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    ll sum=0;
    cin>>n;
    map<int,int>m;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];

    }
    int q;
    cin>>q;
    while(q--)
    {
        int b,c;
        cin>>b>>c;
        sum+=m[b]*(c-b);
        m[c]+=m[b];
        m[b]=0;
        cout<<sum<<endl;
    }

}
































Measured memory_bytes: 8360
/*
*
*	AUTHOR :- @soham01
*		// "WORK HARD AND NEVER GIVE UP" //
*
*/
#include "bits/stdc++.h"

using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> //find_by_order(), order_of_key()
#define pb push_back
#define mp make_pair 
#define vi vector<long long int >
#define vb vector<bool>
#define vs vector<string>
#define vd vector<double>
#define vvi vector<vector<long long int> >
#define vp vector<pair<long long int , long long int > >
#define seti set<long long int >
#define setc set<char>
#define setd set<double>
#define mod 1000000009
#define endl '\n'
typedef long long int lli;

// ITS MY REQUEST TO PLEASE PLEASE DO LOOK AT THE CONSTRAINS GIVEN CAREFULLY
// DO CHECK FOR CORNER CASES

/*-------LET THE GAME BEGIN-----------*/

void solve()
{
	lli n,i,j,c=0,s=0;
	cin >> n;
    lli arr[n-1],brr[n+1]={0};
    for(i=0;i<n-1;i++)cin >> arr[i];
    unordered_map<lli, lli> m;
    for(i=0;i<n-1;i++)
    {
    	m[arr[i]]++;
    }
    for(auto it :m)
    {
    	brr[it.first]=it.second;
    }
    for(i=1;i<=n;i++)
    {
    	cout << brr[i] << endl;
    }
    
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
		solve();
	return 0;
}





Measured memory_bytes: 14552
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();

        if (a == b) {
            System.out.println(2 * a);
        } else {
            System.out.println(2 * Math.max(a, b) - 1);
        }
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
 int a,b;
  cin>>a>>b;
  if(a<=9&&b<=9){cout<<a*b<<endl;}
  else cout<<-1<<endl;
}

Measured memory_bytes: 256
b = input().split()
a = []
for i in b:
    a.append(int(i))

a.sort()
#print(a)
x1 = int(a[2]) -  int(a[0])
x2 = int(a[2]) -  int(a[1])

#print(x1)
#print(x2)

d1 = divmod(x1,2)
d2 = divmod(x2,2)

total = 0
amari = 0

if d1[1] == 0:
    total += d1[0]
else:
    total += d1[0]
    amari += d1[1]

if d2[1] == 0:
    total += d2[0]
else:
    total += d2[0]
    amari += d2[1]

#print(total)

if amari != 0:
    if amari % 2 == 0:
        total += 1
    else:
        total += 2

print(total)


Measured memory_bytes: 3064
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	int n,a;cin>>n>>a;
	int s=n*n;
	cout<<s-a<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def calc_div(N):
    sq = int(N**.5 + 10)
    x = np.arange(1, sq)
    x = x[N % x == 0]
    x = np.concatenate((x, N // x))
    return np.unique(x)

def inv_mod(a, mod):
    b, u, v = mod, 1, 0
    while b:
        t = a // b
        a, b = b, a - t * b
        u, v = v, u - t * v
    return u % mod

def main(N):
    N *= 2
    div = calc_div(N)
    for a in div:
        a = int(a)
        b = N // a
        if np.gcd(a, b) != 1:
            continue
        # b | an + 1
        n = (-inv_mod(a, b)) % b
        k = a * n
        if k == 0:
            k += N
        assert k * (k + 1) % N == 0
        yield k

N = int(read())
print(min(main(N)))

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

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        ll x;
        cin >> x;

        ll f = 100, i = 0;
        while (true) {
                f *= 1.01;
                f = static_cast<ll>(f);
                i++;

                if (f >= x) {
                        cout << i << endl;
                        return 0;
                }
        }

        return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
struct edge
{
	int to,cost;
	edge(int to,int cost):to(to),cost(cost){}
};
int c,n,m,s,d;
int id(int index,int rem)
{
	return ((c+1)*index+rem);
}
vector<edge> g[2000];
int dist[2000];
void dijkstra()
{
	for(int i=0;i<2000;i++)dist[i]=INF;
	dist[id(s,c)]=0;
	priority_queue<P,vector<P>,greater<P> > q;
	q.push(P(0,id(s,c)));
	while(!q.empty())
	{
		P a=q.top();
		q.pop();
		int v=a.sec;
		if(dist[v]<a.fi)continue;
		for(int i=0;i<g[v].size();i++)
		{
			edge e=g[v][i];
			if(dist[e.to]>dist[v]+e.cost)
			{
				dist[e.to]=dist[v]+e.cost;
				q.push(P(dist[e.to],e.to));
			}
		}
	}
	return;
}
int main()
{
	while(1)
	{
		scanf("%d %d %d %d %d",&c,&n,&m,&s,&d);
		if(c==0&&n==0&&m==0&&s==0&&d==0)break;
		s--;d--;
		for(int i=0;i<2000;i++)g[i].clear();
		for(int i=0;i<m;i++)
		{
			int A,B,C;
			scanf("%d %d %d",&A,&B,&C);
			A--;B--;
			for(int j=0;j<=c;j++)
			{
				g[id(A,j)].pb(edge(id(B,j),C));
				g[id(B,j)].pb(edge(id(A,j),C));
			}
			for(int j=1;j<=c;j++)
			{
				g[id(A,j)].pb(edge(id(B,j-1),C/2));
				g[id(B,j)].pb(edge(id(A,j-1),C/2));
			}
		}
		dijkstra();
		int ans=INF;
		for(int i=0;i<=c;i++)ans=min(ans,dist[id(d,i)]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1484
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ten = sc.nextInt();
        int c[] = new int[n];
		int a[][] = new int[n][m];

        int count;
        int ans = 999999999;
        int check = 0;
        for(int i = 0; i < n;i++ ){
          c[i] = sc.nextInt();
            for(int j = 0; j < m;j++){
               a[i][j] = sc.nextInt();
            }
        }
      
        for(int i = 0;i < Math.pow(2,n);i++){
          check = 0;
          count = 0;
          int cost[] = new int[m];
          for(int j = 0; j < n;j++){
            if((i >> j & 1) == 1){
              count += c[j];
              for (int k = 0; k < m; k++) {
						cost[k] += a[j][k];
					}
            }
          }
          for(int j = 0;j < m ;j ++){
            if(cost[j] < ten){check = 1;}
          }
          if(check != 1){
            if(count < ans){
              ans = count;
            }
          }
        }
        if(ans == 999999999){
          System.out.println(-1);
        }else{
          System.out.println(ans);
        }
          
    }
}

Measured memory_bytes: 37452
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{
		return x != p.x? x < p.x: y < p.y;
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -1;
static const int ON_SEGMENT = 0;

int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

Point calc_Cross_Point(double x1,double x2,double x3,double x4,double y1,double y2,double y3,double y4){
	Point ret;
	ret.x = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
	if(x1 != x2){
		ret.y = ((y2-y1)*ret.x+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
	}else{
		ret.y = ((y4-y3)*ret.x+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
	}
	return ret;
}

Point calc_Cross_Point(Point a,Point b,Point c,Point d){
	return calc_Cross_Point(a.x,b.x,c.x,d.x,a.y,b.y,c.y,d.y);
}

Polygon ConvexCut(Polygon g,Point a,Point b){

	Polygon ret;
	int N = g.size();

	for(int i = 0; i < g.size(); i++){
		Point A = g[i], B = g[(i+1)%N];
		if(ccw(a,b,A) != -1)ret.push_back(A);
		if(ccw(a,b,A)*ccw(a,b,B) == -1)ret.push_back(calc_Cross_Point(a,b,A,B));
	}

	return ret;
}

double calc_S(Polygon g){

	int N = g.size();
	double ret = 0;

	for(int i = 0; i < g.size(); i++){
		ret += cross(g[i],g[(i+1)%N]);
	}
	return ret/2.0;
}

int main(){

	int N;
	scanf("%d",&N);

	Polygon g;
	double x,y;

	for(int loop = 0; loop < N; loop++){
		scanf("%lf %lf",&x,&y);
		g.push_back(Point(x,y));
	}

	int Q;
	scanf("%d",&Q);

	Point a,b;
	Polygon ret;

	for(int loop = 0; loop < Q; loop++){
		scanf("%lf %lf %lf %lf",&a.x,&a.y,&b.x,&b.y);
		ret = ConvexCut(g,a,b);
		printf("%.10lf\n",calc_S(ret));
	}

	return 0;
}




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

int main(){
    int table[101][101]={{}};
    int i,j,r,c;
    cin >> r >> c;
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin >> table[i][j];
        }
    }
    
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            table[i][c]+=table[i][j];
            table[r][j]+=table[i][j];
            table[r][c]+=table[i][j];
        }
    }
    
    for(i=0;i<=r;i++){
        for(j=0;j<=c;j++){
            if(j) cout << " " << table[i][j];
            else cout << table[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        c: i32,
        b: [i32; m],
    };

    let mut count = 0;
    for _ in 0..n {
        input! {
            a: [i32; m],
        };

        let a: Vec<i32> = a;

        let mut sum: i32 = 0;
        for (ai, bi) in a.iter().zip(b.iter()) {
            sum += ai * bi;
        }
        sum += c;

        if sum > 0 {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 2148