akhauriyash/Code-Regression huggingface dataset:
import Data.List
import Data.Tuple

main = do
    s <- getLine
    t <- getLine
    let p1 = sort $ zip s t
        p2 = sort $ zip t s
    putStrLn $ if check p1 && check p2 then "Yes" else "No"
        
check [] = True
check [a] = True
check ((a,b):(c,d):es) | a == c && b /= d = False
                       | otherwise = check ((c,d):es)

Measured memory_bytes: 64892
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    int x,y,n,m=0,k,w,sum=0,ans=0,Max=-1e9,count=0,Min=1e9+1;
    string t,u;
    bool ok=true;
    cin >> n;
    VI c(n);
    VI s(n);
    VI f(n);
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i,n){
        ans = 0;
        for(int j=i; j<n-1; j++){
            if(ans < s[j]) 
                ans = s[j];
            else if (ans%f[j]==0);
            else ans = ans+f[j] - ans%f[j];
            ans += c[j];
        }    
        cout << ans << endl;
    }
    return 0;
}

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

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


Measured memory_bytes: 256
console.log((args=>{
  const [[N],a] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const b = [], c = Array(N).fill(0);
  for ( let i = N-1; i >= 0; i-- ) {
    let s = 0;
    for ( let j = i; j < N; j+=i+1 ) s ^= c[j];
    c[i] = s ^ a[i];
    if ( c[i] ) b.push(i+1);
  }
  return b.length + '\n' + b.join` `;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 46780
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>
     
using namespace std;
     
typedef long long ll;
     
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
     
#define MOD 1000000007


int main(){
  ll x,k,d;
  cin>>x>>k>>d;
  if(x<0)x=-x;
  if(x/d>=k){
    cout << x-k*d << endl;
  }
  else{
    ll a = x/d;
    k -= a;
    x -= x/d*d;
    if(k%2==0){
      cout << x << endl;
    }
    else{
      cout << abs(x-d) << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;

const double PI  = 3.141592653589793238463;

int main() {
    int l = 0, r, b = 0, t, n, a, x, y;
    cin >> r >> t >> n;
    for(int i = 0; i < n; i++){
        cin >> x >> y >> a;
        if(a == 1){
            l = max(l,x);
        }
        else if(a == 2){
            r = min(r,x);
        }
        else if(a == 3){
            b = max(b,y);
        }
        else{
            t = min(t,y);
        }
    }
    int area = max((r-l),0) * max((t-b),0);
    cout << max(area,0);
    cout << endl;
}


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


int main(){
  int N;
  cin >> N;
  long ene =1;
  int mod = 1000000007;
  for (int i = 1; i<= N; i++){
    ene*=i;
    ene %=mod;
  }
 cout <<ene << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007LL                                              
# define MAX 100005                                                                                //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair                                                     
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	int x,a;
	cin>>x>>a;
	if(x<a)
	cout<<0;
	else
	cout<<10;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter


def main():
    """
    1 ≤ N  ≤ 2 * 10^5
    1 ≤ Di ≤ 10^9
    1 ≤ M  ≤ 2 * 10^5
    1 ≤ Ti ≤ 10^9

    N*M: TLE
    """
    N = int(input())
    D = map(int, input().split())
    M = int(input())
    T = map(int, input().split())

    f(N, D, M, T)


def f(N, D, M, T):
    c = Counter(D)
    for t in T:
        if c[t] == 0:
            print("NO")
            return

        c[t] -= 1

    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 59612
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;

int main(){

    long long n, k; cin >> n >> k;
    long long ans = 1;
    for(long long i = 0; i < n; i++){
        ans *= k;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(s.size()<=n) {
		cout<<s<<endl;
	} else {
		cout<<s.substr(0,n)<<"..."<<endl;
	}
	return 0;
}

Measured memory_bytes: 3600
n,m=map(int,input().split())

l_max=1
r_min=n

for i in range(m):
    l,r=map(int,input().split())
    l_max=max(l_max,l)
    r_min=min(r_min,r)

if r_min-l_max+1>=0:
    print(r_min-l_max+1)
else:
    print(0)


Measured memory_bytes: 45544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string s;
int q;
vector<int>edge[100005];
bool ok[100005],okA[100005],okB[100005];
struct UF{
	int par[100005],ran[100005];
	void init(){ for(int i=0;i<100005;i++) par[i] = i; }
	int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
	void unite(int x,int y){
		x = find(x); y = find(y); if(x==y) return;
		if(ran[x] < ran[y]) par[x] = y;
		else{
			par[y] = x;
			if(ran[x] == ran[y]) ran[x]++;
		}
	}
	bool same(int x,int y){ return find(x)==find(y); }
}A,B;
int cmp[100005];
int num[100005];
int ax[100005],bx[100005];
int main(){
	A.init(); B.init();
	cin>>s;
	cin>>q;
	rep(i,q){
		int a,b; scanf("%d%d",&a,&b);
		ax[i]=a; bx[i]=b;
		if(a == 1){
			ok[b] = 1;
		}
		else if(b == s.size()){
			ok[a-1] = 1;
		}
		else{
			A.unite(a-1,b);
		}
	}
	int n = s.size();
	for(int i=1;i<n;i++){
		cmp[i] = A.find(i);
	}
	for(int i=1;i<n;i++){
		if(i >= n-i) continue;
		int x = cmp[i];
		int y = cmp[n-i];
		if(x != y){
			B.unite(x,y);
		}
	}
	for(int i=1;i<n;i++){
		int k = B.find(A.find(i));
		num[k] += (s[i]-s[i-1]);
		if(ok[i]) okB[k] = 1;
	}
	for(int i=1;i<n;i++){
		if(A.find(i) != i || B.find(i) != i || okB[i]) continue;
		if(num[i]%26 != 0){
			puts("NO"); return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 6016
// Problem : D - Alter Altar
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt=0;
	for(int i=0;i<n;++i)
	{
		if(s[i]=='R')
		cnt++;
	}
	int ans=min(cnt,n-cnt);
	int cnt2=0;
	for(int i=0;i<cnt;++i)
	{
		if(s[i]=='W')
		cnt2++;
	}
	ans=min(ans,cnt2);
	cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3764
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    long L = scan.nextLong();
    long R = scan.nextLong();
    long min = 2019;
    
    if(R-L >= 2018-(L%2019)){
      System.out.println(0);
      return;
    } else {
      for(Long i = L; i < R; i++){
        for(int j = 1; j <= R-i; j++){
          if((i*(i+j))%2019 < min){
            min = (i*(i+j))%2019;
          }
        }
      }
      System.out.println(min);
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N = 2e5 + 5, mod = 2019;
const ll inf=2e9;
void solve(){
    string s;
    cin>>s;
    int n=s.length();
    int p=1;
    int a=0;
    unordered_map<int, int> mp;
    mp[0]++;
    ll ans = 0;
    for(int i=n-1; i>=0; i--){
        int j = s[i] - '0';
        a += j * p;
        a = a % mod;
        p *= 10;
        p = p % mod;
        ans += mp[a];
        mp[a]++;
    }
    cout<<ans<<endl;
}

int main(){
    //#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	//#endif
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3764
N,L=map(int, input().split())
if N+L-1<=0:
  print(int(L*(N-1)+N*(N-1)/2-N+1))
elif L>=0:
  print(int(L*(N-1)+N*(N+1)/2-1-N+1))
else :
  print(int(L*N+N*(N+1)/2-N))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
static const long long INFTY = (1LL << 32);
long long num[105][105];
int n, m;
void floyd() {
	for(int k = 0; k < n; k++) {
		for(int i = 0; i < n; i++) {
			if(num[i][k] == INFTY) continue;
			for(int j = 0; j < n; j++) {
				if(num[k][j] == INFTY) continue;
				num[i][j] = min(num[i][j], num[i][k] + num[k][j]);
			}
		}
	}
	return;
}
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			num[i][j] = (i == j) ? 0 : INFTY;
		}
	}
	int a, b, c;
	for(int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		num[a][b] = c;
	}
	floyd();
	for(int i = 0; i < n; i++) {
		if(num[i][i] < 0) { cout << "NEGATIVE CYCLE" << endl; return 0; }
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(j) cout << " ";
			if(num[i][j] == INFTY) cout << "INF";
			else cout << num[i][j];
		}
		cout << endl;
	}
	return 0;
}
/*
4 6
0 1 1
0 2 5
1 2 2
1 3 4
2 3 1
3 2 7
*/


Measured memory_bytes: 3176
N,W = map(int,input().split())
wv = [tuple(map(int,input().split())) for i in range(N)]

dp = [{} for i in range(N+1)]
dp[0][0] = 0
for i,(w,v) in enumerate(wv):
    for v0,w0 in dp[i].items():
        if v0 in dp[i+1]:
            dp[i+1][v0] = min(dp[i+1][v0], w0)
        else:
            dp[i+1][v0] = w0
        if w0+w > W: continue
        if v0+v in dp[i+1]:
            dp[i+1][v0+v] = min(dp[i+1][v0+v], w0+w)
        else:
            dp[i+1][v0+v] = w0+w
print(max(dp[-1].keys()))

Measured memory_bytes: 286728
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 20);
vector<int> G[1 << 17];

int n, k;
int root;
ll ans = 1;
void dfs(int id, int fr) {
	rep(j, G[id].size()) {
		int to = G[id][j];
		if (fr == to)continue;
		dfs(to, id);
	}
	if (id == root) {
		ans = ans * p.combP(k, 2) % mod;
	}
	else {
		ans = ans * p.combP(k - 2, G[id].size() - 1)%mod;
	}
}

void solve() {
	cin >> n >> k;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if (k == 1) {
		if (n == 1) {
			cout << 1 << endl;
		}
		else {
			cout << 0 << endl;
		}
		return;
	}
	if (n == 1) {
		cout << k << endl; return;
	}
	rep(i, n) {
		if (G[i].size() == 1) {
			root = i; break;
		}
	}
	dfs(root, -1);
	cout << ans << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  if(A%N==0||B%N==0){
    cout << "OK" <<endl;
  }
  else if(B/N-A/N>=1) {
    cout << "OK" <<endl;
  }  
  else{
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3632
a = input()
d = {}
for i in a:
    if i not in d.keys():
        d[i] = 0
    d[i]+=1

import itertools
ans = 0
for l in itertools.combinations(d.values(),2):
    x,y = l[0],l[1] 
    ans+=(x*y)
print(ans+1)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    INT(h,w,m);
    set<pair<int,int>> yxpoint;
    vector<pair<int,int>> ynum(h+1),xnum(w+1);
    rep(i,h+1){ynum[i].first=0;ynum[i].second=i;}
    rep(i,w+1){xnum[i].first=0;xnum[i].second=i;}
    int x,y;
    rep(i,m){
        in(y,x);
        yxpoint.insert(make_pair(y,x));
        ynum[y].first++;
        xnum[x].first++;
    }
    sort(rall(ynum));
    sort(rall(xnum));
    ll d=0,ans=0;
    for(int i=0;i<h;i++){
        if(ynum[i].first<ynum[0].first)break;
        for(int j=0;j<w;j++){
            if(xnum[j].first<xnum[0].first)break;
            d=xnum[j].first+ynum[i].first-yxpoint.count(make_pair(ynum[i].second,xnum[j].second));
            ans=max(ans,d);
            if(ans==xnum[0].first+ynum[0].first)goto skip;
        }
    }
    skip:
    out(ans);
}

Measured memory_bytes: 21980
# include <iostream>
# include <cstring>
using namespace std;
char s[205];
bool check(int x)
{
	if(x % 2 == 1) return 0;
	for(int i=0;i<x/2;i++)
		if(s[i]!=s[x/2+i])
			return 0;
	return 1;
}
int main()
{
	cin >> s;
	int n = strlen(s) -1;
	while(!check(n)) n--;
	cout << n;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define TRI (3)

int isRightAngle(int a[]);

int main()
{
	int i, j, n, a[TRI];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; ++i) {
		for (j = 0; j < TRI; ++j) {
			scanf("%d", (a + j));
		}
		
		if (!isRightAngle(a)) {
			puts("YES");
		} else {
			puts("NO");
		}
	}
	
	return 0;
}

int isRightAngle(int a[])
{
	int i, idx = 0, ret;
	
	for (i = 1; i < TRI; ++i) {
		if (a[i] > a[idx]) idx = i;
	}
	
	ret = a[idx]*a[idx];
	for (i = 1; i < TRI; ++i) {
		ret -= a[(idx + i) % TRI] * a[(idx + i) % TRI];
	}
	
	return ret;
}

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

int main()
{
    double a,b;
    cin>>a>>b;
    int c=a+1;
    int t=c/0.08;
    int s=b/0.1;
    int i;
    int flag=1;
    for(i=s;i<=t;i++)
    {
        int m,n;
        m=floor(i*0.08);
        n=floor(i*0.1);
        if(m==a&&n==b)
        {
            cout<<i;
            flag=0;
            break;
        }
    }
    if(flag)
        cout<<-1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<functional>
using namespace std;
long long n, P, a[100], dp[100][2];
int main() {
	cin >> n >> P;
	for (int i = 0; i < n; i++)cin >> a[i];
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 2; j++) {
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][(j + a[i]) % 2] += dp[i][j];
		}
	}
	cout << dp[n][P] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main(){

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

  rep(i, 1000000000){
    if(abs(a - i) == abs(b - i)){
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()));
a = list(map(int,input().split()));
 
a.sort(reverse = True);
 
i = 0;
while i<n and a[i] >= sum(a)/(4*m):
    i += 1;
 
if i >= m :
    print('Yes');
else :
    print('No');

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

i64 X;

int main(){
  cin >> X;

  i64 ans = 1;
  while(ans * (ans + 1) / 2 < X) ans++;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>         //█████████████████████████████
#include <stdlib.h>        //█                           █
#include <math.h>          //█        ▄▀▄     ▄▀▄        █
#include <string.h>        //█       ▄█░░▀▀▀▀▀░░█▄       █
#include <ctype.h>         //█   ▄▄  █░░░░░░░░░░░█  ▄▄   █
#include <iostream>        //█  █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█  █
#include <algorithm>       //█████████████████████████████
#include <string>
#include <vector>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

#define swap(a, b) {int temp = a;a = b;b = temp;}
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){
	int x, y, z;

	scanf("%d %d %d", &x, &y, &z);

	swap(x, y);
	swap(x, z);

	printf("%d %d %d", x, y, z);
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
-- end of templete



main = getInt >>= flip replicateM ((\[s,x] -> (s, readInt x)) . words <$> getLine) >>= mapM_ putStrLn . map (uncurry (++) . fmap ((' ':) . show) . fnTuple (fst . head, sum . map snd)) . groupBy (on (==) fst) . sortBy (dictCompare [comparing (length . fst), comparing fst])


Measured memory_bytes: 11320
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

struct Point {
  int x, y;

  Point() {}
  Point(int x_, int y_) : x(x_), y(y_) {}
};

int main() {
  int x1, y1, x2, y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  if (x1 > x2) {
    swap(x1, x2);
    swap(y1, y2);
  }
  int x_min, x_max, y_min, y_max;
  x_min = min(x1, x2);
  x_max = max(x1, x2);
  y_min = min(y1, y2);
  y_max = max(y1, y2);

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

  vector<Point> xy;
  map<int, int> ytox;

  rep (i, n) {
    int x_, y_;
    scanf("%d %d", &x_, &y_);
    if (x_min <= x_ && x_ <= x_max && y_min <= y_ && y_ <= y_max) {
      xy.push_back(Point(x_, y_));
      ytox[y_] = x_;
    }
  }
  n = xy.size();

  if (n == 0) {
    printf("%.11f\n", 100.0 * (x_max - x_min + y_max - y_min));
    return 0;
  }
  double penalty = M_PI * 10 - 20;
  if (x_max == x_min || y_max == y_min) {
    printf("%.11f\n", (double)100.0 * (x_max - x_min + y_max - y_min) + n * penalty);
    return 0;
  }


  sort(all(xy), [](Point a, Point b) {
      return a.x < b.x;
      });

  if (y1 > y2) {
    reverse(all(xy));
  }

  vi l;
  l.push_back(xy[0].y);
  for (int i = 1; i < n; ++i) {
    if (l[(int)l.size() - 1] < xy[i].y) {
      l.push_back(xy[i].y);
    } else {
      *lower_bound(all(l), xy[i].y) = xy[i].y;
    }
  }
  int n_s = l.size();
  int n_p = 0;
  if (n_s == 1 + min(x_max - x_min, y_max - y_min)) {
    n_s -= 1;
    n_p = 1;
  }

  double shortcut = 20 - M_PI * 5;
  printf("%.11f\n", 100.0 * (x_max - x_min + y_max - y_min) - n_s * shortcut + n_p * penalty);

  return 0;
}


Measured memory_bytes: 13040
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 s;
  cin >> s;
  i64 ng = -1, ok = 1e9 + 1;
  while (1 < ok - ng)
  {
    i64 mid = (ok + ng) / 2;
    if (mid * mid < s)
      ng = mid;
    else
      ok = mid;
  }
  i64 n = ok * ok - s;
  for (i64 i = 1;; i++)
    if (n % i == 0)
    {
      cout << 0 << " " << 0 << " " << ok << " " << i << " " << n / i << " " << ok << endl;
      return 0;
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}
//cout << fixed << setprecision(10);

int main(){
  ll a,b; cin>>a>>b;
  cout<<6-a-b<<endl;
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1000000000005L
ll dp[105][100005], w[105], p[105];

int main()
{
    int i, j, N, W, maxp = 0;

    scanf("%d %d",&N,&W);
    for(i=1; i<=N; i++)
    {
        scanf("%lld %lld",&w[i], &p[i]);
        maxp+=p[i];
    }

    for(i=0; i<=N; i++)
        for(j=1; j<=maxp; j++)
            dp[i][j] = inf;

    for(i=1; i<=N; i++)
    {
       // printf("For %d --> ", i);
        for(j=1; j<=maxp; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(j>=p[i])
                dp[i][j] = min(dp[i][j], dp[i-1][j-p[i]]+w[i]);
         //   printf("%d ",dp[i][j]);
        }
        //printf("\n");
    }

    for(j=maxp; j>=0; j--)
        if(dp[N][j]<=W)
        {
            printf("%d\n", j);
            break;
        }

    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
namespace my_header {
#define pb push_back
#define mp make_pair
#define pir pair<int, int>
#define vec vector<int>
#define pc putchar
#define clr(t) memset(t, 0, sizeof t)
#define pse(t, v) memset(t, v, sizeof t)
#define bl puts("")
#define wn(x) wr(x), bl
#define ws(x) wr(x), pc(' ')
    const int INF = 0x3f3f3f3f;
    typedef long long LL;
    typedef double DB;
    inline char gchar() {
        char ret = getchar();
        for(; (ret == '\n' || ret == '\r' || ret == ' ') && ret != EOF; ret = getchar());
        return ret; }
    template<class T> inline void fr(T &ret, char c = ' ', int flg = 1) {
        for(c = getchar(); (c < '0' || '9' < c) && c != '-'; c = getchar());
        if (c == '-') { flg = -1; c = getchar(); }
        for(ret = 0; '0' <= c && c <= '9'; c = getchar())
            ret = ret * 10 + c - '0';
        ret = ret * flg; }
    inline int fr() { int t; fr(t); return t; }
    template<class T> inline void fr(T&a, T&b) { fr(a), fr(b); }
    template<class T> inline void fr(T&a, T&b, T&c) { fr(a), fr(b), fr(c); }
    template<class T> inline char wr(T a, int b = 10, bool p = 1) {
        return a < 0 ? pc('-'), wr(-a, b, 0) : (a == 0 ? (p ? pc('0') : p) : 
            (wr(a/b, b, 0), pc('0' + a % b)));
    }
    template<class T> inline void wt(T a) { wn(a); }
    template<class T> inline void wt(T a, T b) { ws(a), wn(b); }
    template<class T> inline void wt(T a, T b, T c) { ws(a), ws(b), wn(c); }
    template<class T> inline void wt(T a, T b, T c, T d) { ws(a), ws(b), ws(c), wn(d); }
    template<class T> inline T gcd(T a, T b) {
        return b == 0 ? a : gcd(b, a % b); }
    template<class T> inline T fpw(T b, T i, T _m, T r = 1) {
        for(; i; i >>= 1, b = b * b % _m)
            if(i & 1) r = r * b % _m;
        return r; }
};
using namespace my_header;
const int N = 1e5 + 100;
int n, k, a[N];

int main() {
#ifdef lol
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
#endif
	fr(n, k);
	for (int i = 1; i <= n; ++i)
		fr(a[i]);
	int d = a[1];
	for (int i = 2; i <= n; ++i)
		d = gcd(d, a[i]);
	bool ok = false;
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= k && (a[i] - k) % d == 0)
			ok = true;
	}
	if (ok) {
		puts("POSSIBLE");
	} else {
		puts("IMPOSSIBLE");
	}

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int H,W;cin>>H>>W;swap(H,W);
  typedef pair<int,int> P;
  std::vector<P> v(H+W);
  for(int i=0;i<W;i++){
    int a;cin>>a;
    v[i]=P(a,1);
  }
  for(int i=0;i<H;i++){
    int a;cin>>a;
    v[W+i]=P(a,0);
  }
  sort(v.begin(),v.end());
  int ans=0;int h=H+1,w=W+1;
  for(int i=0;i<H+W;i++){
    if(v[i].second){
      ans+=h*v[i].first;
      w--;
    }
    else{
      ans+=w*v[i].first;
      h--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

struct team_t {
	int id, univ, accept, penalty;
	team_t(int id, int univ, int accept, int penalty)
		: id(id), univ(univ), accept(accept), penalty(penalty) {}
	bool operator<(const team_t &o) const {
		return 
			accept != o.accept ? 
			    accept > o.accept : 
			    penalty != o.penalty ? 
				    penalty < o.penalty : id < o.id;
	}
};

int main() {
	int n;
	while (cin >> n, n != 0) {
		vector<team_t> teams;
		for (int x = 0; x < n; x++) {
			int i, u, a, p;
			cin >> i >> u >> a >> p;
			teams.push_back(team_t(i, u, a, p));
		}
		sort(teams.begin(), teams.end());
		vector<team_t> selected;
		map<int, int> univ;
		for (int i = 0; i < teams.size(); i++) {
			if (selected.size() < 10 && univ[teams[i].univ] < 3) {
				selected.push_back(teams[i]);
				univ[teams[i].univ]++;
			} else if (selected.size() < 20 && univ[teams[i].univ] < 2) {
				selected.push_back(teams[i]);
				univ[teams[i].univ]++;
			} else if (selected.size() < 26 && univ[teams[i].univ] < 1) {
				selected.push_back(teams[i]);
				univ[teams[i].univ]++;
			}
		}
		for (int i = 0; i < selected.size(); i++) {
			cout << selected[i].id << endl;
		}
	}
	return 0;
}
	

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

typedef bitset<5200> bs;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<double> fact(100001);

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

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


  int c = min(a,b);
  int d = max(a+b-n, 0);

  cout << c << ' ' << d << endl;
}

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

# X * 0.08 = A
# X * 0.1 = B
# となる最小のXを求める
# _max = int(A / 0.08)
# _min = int(B / 0.1)
# この間の整数に答えがある

for ans in range(1, 1010):
    if (int(ans * 0.08) == A and int(ans * 0.1) == B):
        print(ans)
        exit()
print(-1)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long

using namespace std;
ll a[200100];
map < ll , ll > mp;

int main()
{
    ll Ans = 0,n;
    cin >> n;
    for(int i = 1;i<=n;i++)  cin >> a[i];
    for(int i = 1;i<=n;i++){
        Ans+=mp[i - a[i]];
        mp[a[i] + i]++;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 27872
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

bool dp[10005];
int n;

int main() {
  dp[0] = true;
  scanf("%d", &n);
  int s = 0;
  while(n--) {
    int t;
    scanf("%d", &t);
    s += t;
    for(int i = s; i >= t; i--) {
      dp[i] |= dp[i-t];
    }
  }
  int ret = s;
  while(ret != 0 && (ret%10 == 0 || !dp[ret])) ret--;
  printf("%d\n", ret);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int K, X;
    cin >> K >> X;

    if (K * 500 >= X) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
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 fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    print((1000 - int(input()) % 1000) % 1000)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78092
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

const int p=1000000007;
int n,a[110],f[55][110][110],ans;

int main()
{
    scanf("%d",&n);
    repu(i,1,n*2-1)
        scanf("%d",&a[i]);
    sort(a+1,a+n*2);
    f[n][1][1]=1;
    repd(i,n,2)
        repu(j,1,(n-i)*2+1)
            repu(k,1,j)
                if (f[i][j][k])
                {
                    int x=a[i-1]==a[i],y=j+(a[n*2-i]!=a[n*2-i+1]);
                    repu(l,x,y)
                        (f[i-1][y-x+1-max(0,abs(k-l)-1)][l<=k?l-x+1:k-x+2]+=f[i][j][k])%=p;
                }
    repu(i,1,n*2-1)
        repu(j,1,i)
            (ans+=f[1][i][j])%=p;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc127_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var m = CIn.ReadInt();

      var a = new SortedDictionary<int,int>();

      for (var i = 0; i < n; i++)
      {
        var v = CIn.ReadInt();

        if (a.ContainsKey(v)) a[v]++;
        else a.Add(v, 1);
      }
      
      for (var i = 0; i < m; i++)
      {
        var b = CIn.ReadInt();
        var c = CIn.ReadInt();

        while (b > 0)
        {
          var k = a.First().Key;
          if (k >= c) break;

          if (a[k] > b)
          {
            if (a.ContainsKey(c)) a[c] += b;
            else a.Add(c, b);

            a[k] -= b;
            b = 0;
          }
          else
          {
            if (a.ContainsKey(c)) a[c] += a[k];
            else a.Add(c, a[k]);

            b -= a[k];
            a.Remove(k);
          }
        }
      }

      var ans = 0L;

      foreach (var e in a)
      {
        ans += (long)e.Key * e.Value;
      }

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 35416
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}


struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) { //ｘの入ってる集合と yの入ってる集合を併合
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { //xとyが同じ集合に入っているかどうかを判定
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool isroot(int x) {
		return data[x] < 0;
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	int n;

	scanf("%d", &n);
	vector<pii> pos(n);
	vector<pii> x(n), y(n);
	REP(i, n) {
		scnaf("%d %d", &pos[i].first, &pos[i].second);
		x[i] = { pos[i].first,i };
		y[i] = { pos[i].second,i };
	}
	sort(ALL(x));
	sort(ALL(y));
	UnionFind uf(n);
	priority_queue<pair<int, pii>, vector<pair<int, pii>>,greater<pair<int,pii>>> pq;
	rep(i, 1, n) {
		pq.push(MP(abs(x[i].first - x[i - 1].first), MP( x[i - 1].second, x[i].second )));
		pq.push(MP(abs(y[i].first - y[i - 1].first), MP(y[i - 1].second, y[i].second)));
	}
	ll ans = 0;

	int edc = 0;
	while (edc < (n - 1)) {
		pair<int, pii> cur = pq.top();
		pq.pop();
		if (!uf.findSet(cur.second.first, cur.second.second)) {
			uf.unionSet(cur.second.first, cur.second.second);
			ans += (ll)cur.first;
			edc++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    long long h;
    long long a=1,ans,r=2,n;
    cin >> h;
    ans = (a * (pow(r, long(log2(h))+1 ) - 1)) / (r - 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	double n,k;
	cin>>n>>k;
	double probability = 0;
	for(int i =1;i <=n; i++){
		if(i>=k)
			probability+=1;
		else{
		int p = ceil(((double)log(k/i)/log(2.0)));
		probability+=pow(.5,p);
	}
	}
	cout<<setprecision(16)<<fixed;
	cout<<probability/n;
	return 0;
}

Measured memory_bytes: 4168
#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int hp_taka;
    int at_taka;
    int hp_ao;
    int at_ao;

    cin >> hp_taka >> at_taka >> hp_ao >> at_ao;

    while(1)
    {
        hp_ao = hp_ao - at_taka;

        if(hp_ao <= 0)
        {
            cout << "Yes" << endl;
            break;
        }

        hp_taka = hp_taka - at_ao;

        if(hp_taka <= 0)
        {
            cout << "No" << endl;
            break;
        }
    }

}

Measured memory_bytes: 3624
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int N;
    int a;
    int b;
    int c;
    cin >> N;
    a = N / 100;
    b = (N / 10) %10;
    c = N % 10;
    if(a == 7||b == 7|| c == 7) 
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
    return 0;
}


    


Measured memory_bytes: 3632
VAR
  n, le : longint ;
  x, y : real ;
BEGIN
  readln(n) ;
  if n = 1 then 
    begin
      writeln('1.0000000000') ;
      halt ;
    end else
  if ( n mod 2 = 0 ) then le := n div 2 else le := n div 2 + 1 ;
  y := n ;
  x := le ;
  writeln(x/y:0:10) ;
END.

Measured memory_bytes: 256