akhauriyash/Code-Regression huggingface dataset:
h,w = map(int,input().split())
s_list = [list(input()) for nesya in range(h)]
k = 0
for s in s_list:
  m = 0
  for a in s:
    if a == '#':
      pass
    else:
      c = []
      if m != 0:
        c.append(s_list[k][m-1])
        if k != 0:
          c.append(s_list[k-1][m-1])
        if k != h-1:
          c.append(s_list[k+1][m-1])
      if m != w-1:
        c.append(s_list[k][m+1])
        if k != 0:
          c.append(s_list[k-1][m+1])
        if k != h-1:
          c.append(s_list[k+1][m+1])
      if k != 0:
        c.append(s_list[k-1][m])
      if k != h-1:
        c.append(s_list[k+1][m])
      hoge = c.count('#')
      s_list[k][m] = str(hoge)
    m += 1
  k += 1
for ans in s_list:
  print(''.join(ans))

Measured memory_bytes: 3188
n = int(input())
a = list(map(int, input().split()))

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)



Measured memory_bytes: 32376
def calc(num,capacity):
    dp = [0]*(capacity+1)
    for _ in range(num):
        weight, value = map(int, input().split())
        for w in range(capacity,weight - 1,-1):
            tmp = dp[w - weight] + value
            if dp[w] < tmp:
              dp[w] = tmp
    return dp[capacity]

num, capacity = map(int, input().split())
print(calc(num,capacity))

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

int mygcd(int x,int y){
	while((x%=y)&&(y%=x));
	return x^y;
}

int a[100000];

int play(int n){
	int odd=0,even=0;
	for(int i=0;i<n;i++)
		if(a[i]&1)	odd++;
		else	even++;
	if(even&1)	return 0;
	else if(odd>=2)	return 1;
	else	return 2;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,cnt=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	if(n==1)	return cout<<"Second"<<endl, 0;
	while(true) {
		int res = play(n);
		if(res==2){
			bool invalid = false; 
			for(int i=0;i<n;i++)
				if(a[i]&1) {
					a[i]--;
					if(a[i]==0)	invalid=true;
					break;
				}
			if(invalid)	{
				cnt++;
				break;
			}
			int g = a[0];
			for(int i=1;i<n;i++)
				g = mygcd(g,a[i]);
			for(int i=0;i<n;i++)
				a[i]/=g;
			cnt++;
		}
		else{
			cnt+=res;
			break;
		}
	}
	if(cnt&1)
		cout<<"Second"<<endl;
	else
		cout<<"First"<<endl;
}


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

int main() {
    int n;
    cin >> n;
    
    int debt = 100000;
    for(int i=0; i<n; i++) {
        debt *= 1.05;
        if(debt%1000 != 0) {
            debt /= 1000;
            debt *= 1000;
            debt += 1000;
        }
    }
    cout << debt << endl;
    return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<queue>
#include<string>
using namespace std;

struct process{
  string name;
  int time;
};

int main(){

    int sum,quantam,sumtime=0;
    cin >> sum >> quantam;
    queue<process> q;
    while(!q.empty()){
      q.pop();
    }
    for(int i=0;i<sum;i++){
      process tmp;
      cin >> tmp.name >> tmp.time;
      q.push(tmp);
    }
    while(!q.empty()){
      process processing = q.front();
      q.pop();
      if(processing.time <= quantam){
        sumtime += processing.time;
        cout << processing.name << ' ' << sumtime << endl;
      }
      else{
        sumtime += quantam;
        processing.time -= quantam;
        q.push(processing);
      }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
ll n;
vll h;
vll dp;


//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;

    vll z(n,0);
    dp = h = z;

    REP(i,n){
        cin >> h[i];
    }

    REP(i,n){
        if(i==0) dp[i] = 0;
        else if(i==1) dp[i] = abs(h[1]-h[0]);
        else dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout << dp[n-1] <<endl;
    
    return 0;
}



Measured memory_bytes: 5472
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll T[1001],A[1001];
	ll minhyoT,minhyoA;
	ll lastT,lastA;
	scan(N);
	rep(i,N){
		scan(T[i]);scan(A[i]);
		if(i==0) minhyoT=T[i],minhyoA=A[i];
		else{
			ll baisu=max(minhyoT/T[i]+(minhyoT%T[i]!=0),minhyoA/A[i]+(minhyoA%A[i]!=0));
			minhyoT=baisu*T[i];
			minhyoA=baisu*A[i];
		}
		if(i==N-1){
			lastT=minhyoT,lastA=minhyoA;
		}
		//printf("T:%lld A:%lld\n",minhyoT,minhyoA);
	}
	prin(lastT+lastA);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<queue>
using namespace std;

typedef pair<int,int> P;
int n,q,a,v,f[1000001]={0};

int main(){
  scanf("%d%d",&n,&q);
  priority_queue<P> p;
  for(int i=0;i<q;i++){
    scanf("%d%d",&a,&v);
    f[a]+=v; p.push(P(f[a],-a));
    for(;;){
      P t=p.top();
      if(t.first==f[-t.second]){ printf("%d %d\n",-t.second,t.first); break; }
      p.pop();
    }
  }
}

Measured memory_bytes: 5840
import java.util.Scanner;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();

		long x = sc.nextLong();
		long y = sc.nextLong();

		long sum = 0;
		if (n > k) {
			sum += x * k;
			sum += y * (n - k);
		} else {
			sum += x * n;
		}

		System.out.println(sum);

	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 9548
#include<iostream>
#include<algorithm>
#include<queue>

#define YJSP 114514

using namespace std;

int N;	//????????°
int K;	//??????????????°
int M;	//???????????°
int S;	//???????????¬??\???
int P;	//?????????
int Q;	//????´????

int zd[100000];	//??????????????????????????¢
long long cost[100000];	//0??????????????????????????????

int AB[200000][2];	//???????????\?¶??????¨???

int main(){
	int i,j;
	int a,b;
	bool change;

	cin>>N>>M>>K>>S;
	cin>>P>>Q;

	//????????¢???????????????
	for(int i=0;i<N;i++){
		zd[i]=YJSP;
		cost[i]=-1;
	}
	cost[0]=0;

	//???????????\???
	for(i=0;i<K;i++){
		cin>>a;a--;
		zd[a]=0;
	}
	//????????\???
	for(i=0;i<M;i++){
		cin>>a>>b;a--;b--;
		AB[i][0]=a;AB[i][1]=b;
	}
	//zd??????
	do{
		change=false;
		for(i=0;i<M;i++){
			for(j=0;j<2;j++){
				//a??????b
				a=AB[i][j];b=AB[i][1-j];
				if(zd[a]+1<zd[b]){
					zd[b]=zd[a]+1;
					change=true;
					break;
				}
			}
		}
	}while(change);

	//???????????¢??????
	do{
		change=false;
		for(i=0;i<M;i++){
			for(j=0;j<2;j++){
				//a??????b
				a=AB[i][j];b=AB[i][1-j];
				if(cost[a]==-1) continue;
				if(zd[b]==0) break;	//??????????????¨?????\?¶??????????
				int yado;	//?????£???
				if(b==N-1){
					yado=0;
				}else{
					yado=(zd[b]<=S)?Q:P;
				}
				if(cost[b]==-1 || cost[a]+yado<cost[b]){
					cost[b]=cost[a]+yado;
					change=true;
					break;
				}
			}
		}
	}while(change);

	cout<<cost[N-1]<<endl;

	return 0;
}

Measured memory_bytes: 5796
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;

class Program
{
   static void Main(string[] args)
   {
        /* log(n^2) */
        //int n = int.Parse(Console.ReadLine());
        //int[] array = new int[n];
        //long maxv = -10000000000;

        //for(int i=0; i<n; i++)
        //{
        //    array[i] = int.Parse(Console.ReadLine());
        //}

        //for(int i=0; i < n; i++)
        //{
        //    for(int j=i+1; j < n; j++)
        //    {
        //        maxv = Math.Max(maxv, (array[j] - array[i]));
        //    }
        //}
        //Console.WriteLine(maxv);

        /* log(n) */
        int n = int.Parse(Console.ReadLine());
        long[] array = new long[n];
        long maxv = -1000000000000000000;

        for(int i=0; i<n; i++)
        {
            array[i] = long.Parse(Console.ReadLine());
        }

        long minv = array[0];

        for(int i=1; i<n; i++)
        {
            maxv = Math.Max(maxv, (array[i] - minv));
            minv = Math.Min(minv, array[i]);
        }

        Console.WriteLine(maxv);
   }
}


Measured memory_bytes: 12364
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Point
{
	double x, y;

	Point() : x( 0 ), y( 0 )
	{
		return;
	}

	Point( double x, double y ) : x( x ), y( y )
	{
		return;
	}

	Point operator + ( const Point &a ) const
	{
		return Point( x + a.x, y + a.y );
	}

	Point operator - ( const Point &a ) const
	{
		return Point( x - a.x, y - a.y );
	}

	Point operator * ( const double &a ) const
	{
		return Point( x * a, y * a );
	}

	Point operator / ( const double &a ) const
	{
		return Point( x / a, y / a );
	}

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

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

vector< Point > getConvex( vector< Point > ps )
{
	const int N = ps.size();

	sort( ALL( ps ) );

	int k = 0;
	vector< Point > convex( N * 2 );

	for ( int i = 0; i < N; i++ )
	{
		while ( 2 <= k && cross( convex[ k - 1 ] - convex[ k - 2 ], ps[i] - convex[ k - 1 ] ) <= 0 )
		{
			k--;
		}

		convex[ k++ ] = ps[i];
	}

	for ( int i = N - 2, t = k; 0 <= i; i-- )
	{
		while ( t < k && cross( convex[ k - 1 ] - convex[ k - 2 ], ps[i] - convex[ k - 1 ] ) <= 0 )
		{
			k--;
		}

		convex[ k++ ] = ps[i];
	}

	convex.resize( k - 1 );

	return convex;
}

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		vector< Point > ps( n );

		EACH( p, ps )
		{
			char d;

			cin >> p.x >> d >> p.y;
		}

		vector< Point > convex = getConvex( ps );

		cout << n - convex.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

using namespace std;

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}
template <class Con>
string concat(const Con &c, const string &spr){
	stringstream ss;
	typename Con::const_iterator it = c.begin(), en = c.end();
	bool fst = true;
	for(; it != en; ++it){
		if(!fst){ ss << spr; }
		fst = false;
		ss << *it;
	}
	return ss.str();
}

template <class Con, class Fun>
vector<typename Con::value_type> cfilter(const Con &c, Fun f) {
	vector<typename Con::value_type> ret;
	typename Con::const_iterator it = c.begin(), en = c.end();
	for(; it != en; ++it){
		if(f(*it)){
			ret.emplace_back(*it);
		}
	}
	return ret;
}
#if __cplusplus >= 201103L
template <class Con, class Fun>
auto cmap(const Con &c, Fun f) -> vector<decltype(f(*c.begin()))> {
	vector<decltype(f(*c.begin()))> ret;
	ret.reserve(c.size());
	for(const auto &x: c){
		ret.emplace_back(f(x));
	}
	return ret;
}
#endif


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()
#define tget(t,i) get<i>(t)

#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int d, t, s;
	cin >> d >> t >> s;
	puts(t * s >= d ? "Yes" : "No");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(const exception &e){
	cerr << "exception: " << e.what() << endl;
	abort();
}
catch(...){
	cerr << "exception" << endl;
	abort();
}


Measured memory_bytes: 3600
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0,n;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    vector<char>ans;
    for(int i=0;i<s.size();i++){

        if(s[i]=='0')ans.push_back('0');
        else if(s[i]=='1')ans.push_back('1');
        else if(!ans.empty())ans.pop_back();
    }
    for(int i=0;i<ans.size();i++){

        cout<<ans[i];
    }

    ALL_UP_WITH;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<=0&&b>=0)printf("Zero\n");
	else if(a>0&&b>0)printf("Positive\n");
	else
	{
		if((b-a)%2==0)printf("Negative\n");
		else printf("Positive\n");
	}//
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(){
    char s[200000];
    scanf("%s",s);
    int len=strlen(s);

    int max=0;
    int i=0;
    while(max==0){
        if(s[i]=='A'){
            for(int j=len-1;j>i;j--){
                if(s[j]=='Z'){
                    max=j-i+1;
                    break;
                }
            }
        }
        i++;
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 1896
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<list>
#include<array>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>v(N+1);
	vector<int>u(N+1);
	for (int i=0;i < N;i++){
		cin >> v.at(i+1);
	}
	for (int i=0; i < N; i++) {
		int a = N - i;
		int j = 2;
		int k = 0;
		while (j * a <= N) {
			k += u.at(j * a);
			j++;
		}
		u.at(a) = (v.at(a) - k) % 2;
	}
	int c = 0;
	for (int i=0; i < N; i++) {
		if (u.at(i + 1) != 0)
			c++;
	}
	cout << c << endl;
	for (int i = 0; i < N; i++) {
		if (u.at(i + 1) != 0)
			cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 2432
function main(input){
  const lines = input.split('\n');
  const N = lines[0].split(' ').map(x => parseInt(x))[0];
  const K = lines[0].split(' ').map(x => parseInt(x))[1];
  const As = lines[1].split(' ').map(x => parseInt(x));


  var result = Math.ceil((N-K)/(K-1))+1;
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 16716
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define N 200005

using namespace std;
typedef pair<int,int> Pair;

inline int input() {
	int x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

int n, fa[N], f[N];
vector<int> T[N];

inline bool cmp(int x, int y) { return f[x] < f[y]; }

void dfs(int u) {
	for (int v : T[u]) dfs(v);
	sort(T[u].begin(), T[u].end(), cmp);
	for (int v : T[u]) f[u] = max(f[u], f[v]) + 1;
}

int main() {

	n = input();
	for (int i = 2; i <= n; ++i)
		fa[i] = input(), T[fa[i]].push_back(i);

	dfs(1);
	printf("%d\n", f[1]);
	return 0;
}


Measured memory_bytes: 15744
#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <unordered_set>
#include <deque>
#include <queue>
#include <iomanip>
#include <fstream>
#include <string>
#include <climits>
#include <sstream>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define vi vector<ll>
#define pii pair<int, int>
#define fi(n) for(ll i = 0; i < (n); i++)
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define RFOR(i, k, n) for(int i = (k); i >= (n); i--)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define umin(a, b) a = min(a, b)
#define umax(a, b) a = max((ll)a, (ll)b)

//const long long LINF = LLONG_MAX;
//const long long LINF = 1e14;
const int INF = 1e9 + 1;
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> v(n);
	fi(n)
		cin >> v[i];
	vector<ll> d(n + 1);
	FOR(i, 0, n)
		d[v[i]] = d[v[i] - 1] + 1;
	sort(all(d));
	cout << n - d.back() << endl;
  	return 0; 
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
//mp.reserve(1024);
//mp.max_load_factor(0.25);
bool sortinrev(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return (a.first > b.first);
}

int main()
{
	ios_base::sync_with_stdio(false);
   	cin.tie(NULL);
   	cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output1.txt", "w", stdout);
	ll n;
	cin>>n;
	if(n%1000!=0)
	cout<<1000 - n%1000 <<endl;
	else
		cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000001


int main(){

	int N,X,T;
	cin>>N>>X>>T;
	
	cout<<((N+X-1)/X)*T<<endl;
	
	return 0;
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	. "fmt"
	"io"
	"math"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
type vec struct{ x, y int }
type vs []vec

func (a *vec) add(b vec)          { a.x += b.x; a.y += b.y }
func (a vec) len2() int           { return a.x*a.x + a.y*a.y }
func (a vec) polarAngle() float64 { return math.Atan2(float64(a.y), float64(a.x)) }
func (v vs) Len() int             { return len(v) }
func (v vs) Less(i, j int) bool   { return v[i].polarAngle() < v[j].polarAngle() }
func (v vs) Swap(i, j int)        { v[i], v[j] = v[j], v[i] }

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	var n, ans int
	Fscan(in, &n)
	ps := make(vs, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
	}
	sort.Sort(ps)
	ps = append(ps, ps...)
	for i := 0; i < n; i++ {
		p := vec{}
		for j := i; j < n+i; j++ {
			p.add(ps[j])
			if l := p.len2(); l > ans {
				ans = l
			}
		}
	}
	Fprintf(_w, "%.12f", math.Sqrt(float64(ans)))
}

func main() { run(os.Stdin, os.Stdout) }


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}


bool P[100005];
vector<ll> prime;
vector<pair<ll,ll> > PN;
ll N , M;


ll fact[200001];
ll rev[200001];
ll fact_rev[200001];
void gene(){
    P[0] = true;
    P[1] = true;
    rep(i, sqrt(M+1) + 1) rep(j, sqrt(M+1) + 1){
        if(i <= 1) continue;
        if(j <= 1) continue;
        if(i * j > (sqrt(M+1)+1)) break;
        
        P[i*j] = true;
    }
    
    rep(i, sqrt(M+1)+1){
        if(P[i] == false) prime.pb(i);
    }
    
    ll a = M ;
    rep(i, prime.size()){
        if(a == 1) break;
        
        ll cnt = 0;
        while(true){
            if(a % prime[i] != 0) break;
            else{
                cnt ++;
                a /= prime[i];
            }
        }
        if(cnt != 0)PN.pb(mp(prime[i], cnt));
    }
    if(a != 1) PN.pb(mp(a, 1));
    
    
    ll now = 1;
    rep(i, N + 100000){
        if(i == 0) {
            fact[i] = 1;
            continue;
        }
        now *= i;
        now %= MOD;
        fact[i] = now;
        
        rev[i] = power(i, MOD-2);
    }
    now = 1;
    rep(i, N + 100000){
        if(i == 0 ) {
            fact_rev[i] = 1;
            continue;
        }
        now *= rev[i];
        now %= MOD;
        fact_rev[i] = now;
    }
    
    return ;
}


ll comb(ll a,  ll b){
    ll ans = fact[a];
    ans *= fact_rev[b];
    ans %= MOD;
    ans *= fact_rev[a-b];
    ans %= MOD;
    return ans ;
}



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

    cin >> N >> M ;
    gene();
    
    ll ans = 1;
    rep(i, PN.size()){
        ans *= comb(PN[i].second + N - 1, PN[i].second);
        ans %= MOD;
    }
    cout <<  ans  << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  ll ans = 10000000000000;
  ll x = 0;
  ll y = 0;
  for(ll i=1; i*i<=N; i++) {
    if(N%i==0 and ans > i+(N/i)) {
      ans = i+(N/i);
      x = i;
      y = (N/i);
    }
  }
  std::cout << x-1+y-1 << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#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;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define ar array 

void test_case() {
	int n;
	cin >> n;
	vector<pair<int,int>> a(n);
	for(int i = 0 ; i < n ; i++)
		cin >> a[i].first >> a[i].second;
	for(int i = 0 ; i < n-2 ; i++){
		if(a[i].first == a[i].second && a[i+1].first == a[i+1].second && a[i+2].first == a[i+2].second){
			cout<<"Yes\n";
			return;
		}
	}
	cout<<"No\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T = 1;
	//cin >> T;
	while(T--){
		test_case();
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for(i=a;i<b;i++)

set<ll>::iterator it;
ll mod = 1000000007;
ll power(ll a,ll b)
{
	ll p = 1;
	a = a%mod;
	while(b>0)
	{
		if(b%2==1)
			p=((p%mod)*(a%mod))%mod;
		b=b>>1;
		a=((a%mod)*(a%mod))%mod;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n,t;
	cin>>n;
	cout<<1000*(ceil(n/1000.0)) - n<<endl;
	return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll a , b ; 
    cin >> a >> b ;
    if (0 >= a && 0 <= b) return cout << "Zero" , 0 ;
    if (a > 0) return cout << "Positive" , 0 ;
    ll cnt = b - a +1 ;
    if (cnt & 1) cout << "Negative" ;
    else return cout << "Positive" , 0 ;
    
    return (0) ;
}

Measured memory_bytes: 256
import math
 
a,b,C = map(float, input().split())
C_rad = C / 180 * math.pi
 
H = b * math.sin(C_rad)
S = H * a / 2 
L = math.sqrt( (a-b*math.cos(C_rad)) **2 + H**2 ) + a + b

print(S)
print(L)
print(H)

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

int main(){
    ll n;
    cin >> n;
    vector<ll> hst(1e5+10);
    rep(i,n) {
        int a;
        cin >> a;
        hst.at(a)++;
    }

    ll ans = 0;
    rep(i,hst.size()){
        ans += hst.at(i) * i;
    }

    ll q;
    cin >> q;
    rep(i,q){
        ll b,c;
        cin >> b >> c;
        ans += hst.at(b) * c;
        ans -= hst.at(b) * b;
        hst.at(c) += hst.at(b);
        hst.at(b) = 0;
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3992
import heapq
from decimal import *
import math

def binary_search(left: int, right: int, check_func, search_max:bool=False):
    # ok と ng のどちらが大きいかわからないことを考慮
    while abs(right - left) > 1:
        mid = (left + right) // 2
    
        if check_func(mid) ^ search_max:
            right = mid
        else:
            left = mid

    return left if search_max else right

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def isOK(x):
        b = sum([(a - 1) // x for a in A])

        return b <= K

    ans = binary_search(0, 10 ** 9, isOK)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32408
using System;

namespace aoj7a
{
    class Program
    {
        static void Main(string[] args)
        {
            
            for(;;)
            {
                string[] line = (Console.ReadLine()).Split(' ');
                int n = int.Parse(line[0]);
                int x = int.Parse(line[1]);
                int counter = 0;
               
                if(n == 0 && x == 0)
                {
                    break;
                }

                for(int i = 1; i <= n; i++)
                {
                    for(int j = i+1; j <= n; j++)
                    {
                        for(int k = j+1; k <= n; k++)
                        {
                            if(i + j + k == x)
                            {
                                counter++;
                            }
                        }
                    }
                }
                Console.WriteLine(counter);
                
            }
        }
    }
}

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


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int a[26] = {0};
    int cnt = 0;

    for(int i = 0; i < n; i++){
        a[s[i] - 'a']++;
    }

    for(int i = 0; i < 26; i++){
        if(a[i] == 0){
            break;
        }else{
            ++cnt;
        }
    }
    if(cnt != 26){
        char c = 'a' + cnt;
        cout << c << endl;
    }else{
        cout << "None" << endl;
    }
}

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

int main()
{
	long long s;
	cin >> s;
	long long x1 = 1e9, y1 = 0, x2 = 0, y2 = (s+1e9)/1e9;
	if (s == 1e18)
	{
		y2 = 1e9;
	}
	else
	{
		y1 = 1;
		x2 = x1 * y2 - s;
	}
	cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

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

int main()
{
	int n, result, sum =0;
	int *input = new int;
	int tmp;

	cin >> n;

	// tim mau chung nho nhat 
	for (int i = 0; i < n; i++)
	{
		cin >> input[i];
		if (i == 0)
			tmp = input[i];
		else{
			tmp = bcnn(tmp, input[i]);
		}
			
		result = (i == (n - 1)) ? tmp : 0;
	}

	for (int i = 0; i < n; i++)
	{
		sum += result / input[i];
	}

	cout << (float)result / sum;

	return 0;
}

Measured memory_bytes: 256
n,t = map(int, input().split())
lst_c = []
lst_t = []
a = 0
b = 0
for i in range(n):
    a,b = map(int, input().split())
    if b <= t:
        lst_c.append(a)
if lst_c == []:
    print("TLE")
else:
    print(min(lst_c))


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

int main(){
    int N, K, X[100];
    int sum = 0;
    cin >> N >> K;

    for(int i=0;i<N;i++){
        cin >> X[i];
        if(X[i] <= K-X[i]){
            sum += 2*X[i];
        }

        else{
            sum += 2*(K-X[i]);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

vi calc_perm(ll a, ll b, ll n) {
  // cerr << a << " " << b << endl;
  vi a_zero, a_one, b_one, b_zero;
  rep(i, n) {
    if ((a >> i) & 1LL) {
      a_one.push_back(i);
    } else {
      a_zero.push_back(i);
    }
  }
  rep(i, n) {
    if ((b >> i) & 1LL) {
      b_one.push_back(i);
    } else {
      b_zero.push_back(i);
    }
  }
  assert(a_zero.size() == b_zero.size());
  assert(a_one.size() == b_one.size());
  
  vi bit_perm(n);
  rep (i, a_zero.size()) {
    bit_perm[a_zero[i]] = b_zero[i];
  }
  rep (i, a_one.size()) {
    bit_perm[a_one[i]] = b_one[i];
  }
  return bit_perm;
}

ll apply_perm(ll x, const vi& bit_perm) {
  ll ans = 0;
  rep(i, bit_perm.size()) {
    ll b = (x >> i) & 1LL;
    ans |= b << bit_perm[i];
  }
  return ans;
}

vl solve_bit(ll n, ll last);

vl solve_count(ll n, ll k) {
  assert(k <= n and k % 2 == 1);
  if (n == 1) {
    return {0, 1};
  }

  vl ans(1LL << n);
  if (k == 1) {
    ll hn = 1LL << (n-1);
    vl half = solve_count(n - 1, 1);
    rep(i, hn) {
      ans[i] = half[i];
    }
    rep(i, 1LL << (n-1)) {
      ans[i + hn] = half[hn - 1 - i] | hn;
    }
  } else {
    ll hn = 1LL << (n-1);
    vl half1 = solve_count(n - 1, 1);
    rep(i, hn) {
      ans[i] = half1[i];
    }

    ll bit = ((1LL << (k-1)) - 1LL) ^ half1.back();
    vl half2 = solve_bit(n - 1, bit);
    rep(i, hn) {
      ans[i + hn] = (half2[i] ^ half1.back()) | hn;
    }
  }
  return ans;
}

vl solve_bit(ll n, ll last) {
  ll N = 1LL << n;
  ll k = __builtin_popcountll(last);
  vl perm = solve_count(n, k);
  /*
  for (ll a : perm) {
    cerr << a << " ";
  }
  cerr << endl;
  */

  vi bit_perm = calc_perm(perm.back(), last, n);

  vl ans(N);
  rep(i, N) {
    ans[i] = apply_perm(perm[i], bit_perm);
  }

  return ans;
}

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  const ll N = 1LL << n;

  ll nb = b ^ a;
  if (__builtin_popcountll(nb) %2 == 0) {
    cout << "NO" << endl;
    return 0;
  }

  vl ans = solve_bit(n, nb);

  cout << "YES" << endl;
  rep(i, N) {
    cout << (ans[i] ^ a) << " \n"[i == N-1];
  }
}


Measured memory_bytes: 3324
using System;
class atcoder
{
	public static void Main()
	{
		string[] a = Console.ReadLine().Split(' ');
		int sa = Math.Abs(int.Parse(a[1]) - int.Parse(a[2]));
		if (int.Parse(a[0]) >= sa)
		{
			Console.WriteLine(0);
		}
		else
		{
			Console.WriteLine(sa - int.Parse(a[0]));
		}
	}
}


Measured memory_bytes: 11220
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL C[8];

void MAIN() {
    LL K;
    scanf("%lld", &K);
    vector<LL> X;

    REP (t, 35) {
	REP (c, 7) REP (k, t) {
	    if (c == 0) C[0]++;
	    else C[c] += C[c-1];
	    X.push_back(C[6]);
	}
    }
    VI Y(X.size());
    for (int i=X.size(); --i;) {
	while (X[i] && X[i] <= K) {
	    K -= X[i];
	    Y[i]++;
	}
    }
    int idx = 0;
    REP (t, 35) {
	REP (c, 7) REP (k, t) {
	    putchar("FESTIVA"[c]);
	    if (c == 0) C[0]++;
	    else C[c] += C[c-1];

	    REP (z, Y[idx]) putchar('L');
	    idx++;
	}
    }
    putchar('\n');
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a[5];
	int i,s=0,m=0;
	for(i=0;i<3;i++)
	scanf("%d" ,&a[i]);
	for(i=0;i<3;i++)
	{
		if(a[i]==5) s++;
		if(a[i]==7) m++;
	}
	 if(s==2&&m==1)
	 printf("YES");
	 else printf("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    unsigned int N,K;
    cin >> N >> K;
    ll ans = INFLL;
    for(unsigned int bit = 0; bit < (1u << K); bit++) {
        ll state = 1;
        REP(i,N) {
            if(bit & (1u << i)) state *= 2;
            else state += K;
        }
        chmin(ans,state);
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
arr=["A","C","G","T"]
ans=0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        cnt=0
        for k in s[i:j]:
            if k in arr:
                cnt+=1
        if cnt==len(s[i:j]):
            ans=max(ans,cnt)
print(ans)

Measured memory_bytes: 64748
program main
    implicit none
    integer k
    character s*100
    character(:), allocatable :: s1
    integer i
    read(*,*) k
    read(*,*) s
    i = len_trim(s)

    if (i <= k ) then
        write(*,*) s
    else
        allocate(character(k+3) :: s1)
        s1(1:k) = s(1:k)
        s1(k+1:k+1) = "."
        s1(k+2:k+2) = "."
        s1(k+3:k+3) = "."
        write(*,*) s1
        deallocate(s1)
    end if

end program

Measured memory_bytes: 2856
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

void eval(int n, int x, vector<vector<int>> &adj, map<ii,ll> &paths, map<ii,int> &ord) {
	map<int,int> par;
	queue<int> q; q.push(x);
	set<int> vis; vis.insert(x);
	while(!q.empty()) {
		int cur=q.front(); q.pop();
		for (auto nxt : adj[cur]) {
			if(vis.count(nxt))
				continue;
			vis.insert(nxt);
			par[nxt]=cur;
			q.push(nxt);
		}
	}
	for (int z=0; z<n; z++) {
		int y=z;
		if(y==x)
			continue;
		vector<int> path;
		path.push_back(y);
		while(y!=x)
			y=par[y], path.push_back(y);
		for (int i=0; i<path.size()-1; i++)
			paths[minmax({x,z})]|=1LL<<ord[minmax({path[i],path[i+1]})];
	}
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n),b(n);
	vector<vector<int>> adj(n);
	map<ii,int> ord;
	for (int i=0; i<n-1; i++) {
		cin>>a[i]>>b[i]; a[i]--; b[i]--;
		adj[a[i]].push_back(b[i]);
		adj[b[i]].push_back(a[i]);
		ord[minmax({a[i],b[i]})]=i;
	}

	map<ii,ll> paths;
	for (int i=0; i<n; i++) {
		eval(n,i,adj,paths,ord);
	}
	int m; cin>>m;

	vector<int> u(m), v(m);
	for (int i=0; i<m; i++) {
		cin>>u[i]>>v[i]; u[i]--; v[i]--;
	}

	ll ret=0;
	for (int i=0; i<(1<<m); i++) {
		ll used=0;
		int sgn=1;
		for (int j=0; j<m; j++) {
			if(i&(1<<j)) {
				auto path=paths[minmax({u[j], v[j]})];
				used|=path;
				sgn=-sgn;
			}
		}
		ll val=1LL<<(n-1-__builtin_popcountll(used));
		ret+=sgn*val;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
int main()
{
	int i,n,a;
	int b[101]={0};
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin>>a;
		b[a]=1;
	}
	n=0;
	for(i=0;i<101;i++)
	{
		if(b[i])
		{
			n++;
		}
	}
	cout<<n;
} 

Measured memory_bytes: 256
x,n=list(map(int,input().split()))
if n==0:
  p=set([])
else:
  p=set(map(int,input().split()))
a=0
while True:
  if not((x-a) in p):
    print(x-a)
    break
  if not((x+a) in p):
    print(x+a)
    break
  a+=1

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    vector<vector<int>> edge(n, vector<int>());
    vector<vector<int>> weight(n, vector<int>());
    for(int i=0; i<n-1; i++){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--; b[i]--; c[i];
        edge[a[i]].push_back(b[i]);
        edge[b[i]].push_back(a[i]);
        weight[a[i]].push_back(c[i]);
        weight[b[i]].push_back(c[i]);
    }

    int q, k;
    cin >> q >> k;
    k--;

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
    pq.push(make_pair(0, k));
    vector<int> dis(n, -1);
    while(!pq.empty()){
        int d = pq.top().first;
        int p = pq.top().second;
        pq.pop();
        if(dis[p] != -1) continue;
        dis[p] = d;
        for(int i=0; i<edge[p].size(); i++){
            int next = edge[p][i];
            if(dis[next] == -1){
                pq.push(make_pair(d + weight[p][i], next));
            }
        }
    }


    for(int i=0; i<q; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        cout << dis[x] + dis[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 20984
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <climits>
#include <iomanip>
#include <string.h>
#include <algorithm>
#include <functional>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back

typedef unsigned long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N = (int)2e5+77;
const int mod = (int)1e9+7;

ll n,m,k,x,y;
vector<pll> g[N];
ll d[N];

void dfs(ll u, ll p){
    for(auto v : g[u]){
        if(v.first==p) continue;
        d[v.first] = v.second + d[u];
        dfs(v.first,u);
    }
}

int main() {
    fast;
    cin>>n;
    forn(i,n-1){
        cin>>x>>y>>k;
        g[x].pb({y,k});
        g[y].pb({x,k});
    }

    cin>>m>>k;

    dfs(k,0);

    while(m--){
        cin>>x>>y;
        cout<<d[x] + d[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 16640
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	static int N, M;
	static int[] link, size;
	
	static class H implements Comparable<H>{
		int land, time;
		H(int land, int time){
			this.land=land;
			this.time=time;
		}
		public int compareTo(H s) {
			return s.time-this.time;//消える時間降順
		}
	}
	
	static class Edge implements Comparable<Edge>{
		int u, v, cost;
		Edge(int u, int v, int cost){
			this.u=u;
			this.v=v;
			this.cost=cost;
		}
		public int compareTo(Edge e){
			return this.cost-e.cost;
		}//辺の重さ昇順
	}
	
	static void init() {
		for(int i=0; i<N; i++) {
			link[i]=i;
			size[i]=1;
		}
	}
	static int find(int x) {
		while(x!=link[x]) x=link[x];
		return x;
	}
	static boolean same(int a, int b) {
		return find(a)==find(b);
	}
	static void unite(int a, int b) {
		a=find(a);
		b=find(b);
		if(size[a]<size[b]) {
			int k=a;
			a=b;
			b=k;
		}
		size[a]+=size[b];
		link[b]=a;
	}
	
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				N=sc.nextInt();
				M=sc.nextInt();
				if(N+M==0) break;
				link=new int[N+1];
				size=new int[N+1];
				int[] ht=new int[N];
				H[] h=new H[N];
				Edge[] pq=new Edge[M];
				int[][] dis=new int[N+1][N+1];
				PriorityQueue<H> pq1=new PriorityQueue<>();
				for(int i=0; i<N; i++) {
					int time=sc.nextInt();
					ht[i]=time;
					h[i]=(new H(i, time));
				}
				for(int i=0; i<M; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					int c=sc.nextInt();
					pq[i]=(new Edge(a-1, b-1, c));
				}
				Arrays.sort(h);
				Arrays.sort(pq);
				init();
				int ans=0, count=0;
				for(int i=0; i<N; i++) {//時刻ごとに毎回minimum spanning tree
					int at=h[i].land;
					int now=h[i].time;
					if(i==N-1 || now!=h[i+1].time) {//次が同時に沈まないときそれまでのを処理しちゃう
						for(int j=0; j<M; j++) {
							int l=pq[j].u;
							int r=pq[j].v;
							if(ht[l]>=now && ht[r]>=now && !same(l, r)) {
								ans+=pq[j].cost;
								unite(l, r);
								//System.out.println(Arrays.toString(link));
								count++;
							}
						}
						if(count!=i) {//辺と(頂点-1)の数合わない＝やり直し
							count=0;
							ans=0;
							init();
						}
					}
				}
				System.out.println(ans);
			}

		}

	}
}


Measured memory_bytes: 175484
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        (&mut $iter).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn gcd(a: usize, b: usize) -> usize {
    match b {
        0 => a,
        _ => gcd(b, a % b),
    }
}

fn lcm(a: usize, b: usize) -> usize {
    a * b / gcd(a, b)
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(iter, 2);
    let a: Vec<usize> = parse!(iter, n);
    let a: Vec<usize> = a.iter().map(|x| x / 2).collect();
    let d = a[0] & (!a[0] + 1);
    if !a.iter().all(|x| x & (!x + 1) == d) {
        println!("{}", 0);
        return;
    }
    let l = a.iter().fold(a[0], |a, &b| lcm(a, b));
    println!("{}", (m / l + 1) / 2);
}


Measured memory_bytes: 8444