akhauriyash/Code-Regression huggingface dataset:
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let (k, q): (usize, usize) = (io.read(), io.read());

    let d = io.readn::<i64>(k);

    for qq in 0..q {
        let (n, x, m): (i64, i64, i64) = (io.read(), io.read(), io.read());

        let mut last = x;
        let mut eq = 0;
        for i in 0..k {
            let num = (n - i as i64 - 1 + k as i64 - 1) / k as i64;
            last += (d[i] % m) * num;
            if d[i] % m == 0 {
                eq += num;
            }
        }
        let ans = n - 1 - (last / m - x / m) - eq;
        io.writeln(ans);
    }
}

static MOD: i64 = 1000000007;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4476
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
  ll t;
  if (a < b){ t = a; a = b; b = t; }
  while (( t = a % b ) != 0){ a = b; b = t; }
  return b;
}
ll lcm(ll a, ll b) {
  return (a / gcd(a,b)) * b;
}
int main() {
  ios::sync_with_stdio(false);
  ll A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

void solve(int n,int m){
    int fr[501][501],a,b,ans=0;
    
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            fr[i][j]=100;
    
    
            
    for(int i=0;i<m;i++){
        scanf("%d%d",&a,&b);
        fr[a][b]=1;
        fr[b][a]=1;
    }
    
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                fr[i][j]=min(fr[i][j],fr[i][k]+fr[k][j]);
    
    for(int i=2;i<=n;i++)
        ans+=(fr[1][i]==2 || fr[1][i]==1);
    
    printf("%d\n",ans);
    
    return;
}


int main(){
    int n,m;
    
    while(1){
        scanf("%d%d",&n,&m);
        if(n+m==0) break;
        solve(n,m);
    }
    
    return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};
int main(){
    int n,m;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        --x;--y;
        uf.unite(x,y);
    }
    int ans=0;
    rep(i,n)if(uf.find(i)==i)++ans;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const double INF = 1001001001;

int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	rep(i, n) {
		int s;
		cin >> s;
		sum += s;
		t[i] = s;
	}
	int m;
	cin >> m;
	rep(i, m) {
		int p, x;
		cin >> p >> x;
		p--;
		int ans = sum + x - t[p];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

# 全て - 存在しない（1 ~ 8)まででできる
N = getN()
print((pow(10, N, mod) - pow(9, N, mod) - pow(9, N, mod) + pow(8, N, mod)) % mod)

Measured memory_bytes: 83580
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int N;cin>>N;
    int K=0;
    while(K<N){
        K+=1000;
    }
    cout<<K-N<<endl;
}

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

using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int cnt=0;
		for(int i=1;i<N;i++){
			int goukei=0;
			for(int j=i;j<N;j++){
				goukei+=j;
				if(goukei==N){
					cnt++;
					break;
				}
				else if(goukei>N)
					break;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
	int n;scanf("%d",&n);
	int nn=n;
	int x;
	int n4=0,n2=0,n1=0;
	while(nn--)
	{
		scanf("%d",&x);
		if(x%4==0)
			n4++;
		else if(x%2==0)
			n2++;
		else
			n1++;
	} 
	if(n2)
	{
		if(n4>=n1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
	{
		if(n4+1>=n1)
			printf("Yes\n");
		else
			printf("No\n");
	}
	return 0;
}

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

using namespace std;
#define X first
#define Y second
#define pb push_back
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e4+10,MAXM=1e6+10,INF=1<<28;
char s[105][105];
int n,m,sx,sy,tx,ty,S,T;

namespace MaxFlow
{
    int head[MAXN],level[MAXN],iter[MAXN],tot=-1;
    struct edge{int nxt,to,cap;}e[MAXM<<2];
    void init(){memset(head,-1,sizeof(head));}
    void add(int from,int to,int cap)
    {
        e[++tot].nxt=head[from];e[tot].to=to;e[tot].cap=cap;head[from]=tot;
        e[++tot].nxt=head[to];e[tot].to=from;e[tot].cap=0;head[to]=tot;
    }
    bool bfs()
    {
        for(int i=0;i<=T;i++) level[i]=-1;
        queue<int> q;q.push(S);level[S]=0;
        while(!q.empty())
        {
            int u=q.front();q.pop();
            for(int i=head[u];i!=-1;i=e[i].nxt)
                if(e[i].cap && level[e[i].to]==-1)
                    level[e[i].to]=level[u]+1,q.push(e[i].to);
        }
        return (level[T]!=-1);
    }
    int dfs(int v,int f)
    {
        if(v==T) return f;
        int ret=0;
        for(int &i=iter[v];i!=-1;i=e[i].nxt)
            if(level[e[i].to]==level[v]+1 && e[i].cap)
            {
                int d=dfs(e[i].to,min(f,e[i].cap));
                e[i].cap-=d;e[i^1].cap+=d;
                f-=d;ret+=d;if(!f) break;
            }
        return ret;
    }
    int Dinic()
    {
        int ret=0;
        while(bfs())
        {
            for(int i=S;i<=T;i++) iter[i]=head[i];
            ret+=dfs(S,INF);
        }
        return ret;
    }
}
using namespace MaxFlow;

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    init();S=0;T=n+m+1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(s[i][j]=='S') sx=i,sy=j;
            else if(s[i][j]=='T') tx=i,ty=j;
            else if(s[i][j]=='o') add(i,j+n,1),add(j+n,i,1);
    add(S,sx,INF);add(S,sy+n,INF);
    add(tx,T,INF);add(ty+n,T,INF);
    if(sx==tx||sy==ty) return puts("-1"),0;
    printf("%d",Dinic());
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue

#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
ll r, d, x;

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

    cin >> r >> d >> x;
    F0R(_, 10){
        x = r*x-d;
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
/* SHAHADATH HOSSAIN TAMIM
   BANGLADESH UNIVERSITY OF BUSINESS AND TECHNOLOGY
*/

#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define pob pop_back
#define sti(a) st.insert(a)
#define gcd __gcd
#define lcm(a,b) (a*b)/__gcd(a,b)
#define l s.length()
#define sts st.size()
#define mpss mps.size()
#define mpis mpi.size()
#define vs v.size()
#define sort(a) sort(a.begin(), a.end())
#define f(a,b) for(int i=a; i<b; i++)
#define fl(a,b) for(long long i=a; i<b; i++)

map<int, int>mpi;
map<string, int>mps;
set<int>st;
vector<int>v;
map<int, int>::iterator iti;
map<string, int>::iterator its;
set<int>:: iterator it;
vector<int>::iterator itv;

int main()
{
    //freopen("tamim.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mpi.clear();
    mps.clear();
    st.clear();
    v.clear();

    string s;
    cin>>s;
    if(s[3]==s[2]&&s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



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

int main()
{
	std::string buf;
	getline(std::cin, buf);
	
	int offset = 0;
	bool lastword = false;
	bool first_output = true;
	while (!lastword) {
		int pos = buf.find(' ', offset);
		std::string tmp;
		if (pos==std::string::npos) {
			tmp = buf.substr(offset);
			lastword = true;
		} else {
			tmp = buf.substr(offset, pos-offset);
		}
		char last_char = tmp[tmp.size()-1];
		if (last_char == ',' || last_char == '.') {
			tmp.erase(tmp.size()-1);
		}
		if ( 3 <= tmp.size() && tmp.size() <= 6 ) {
			if (first_output) { std::cout << tmp; first_output = false; }
			else std::cout << " " << tmp;
		}
		offset = pos + 1;
	}
	std::cout << std::endl;
	
	return 0;
}


Measured memory_bytes: 3156
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARainySeason solver = new ARainySeason();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARainySeason {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.nextString().toCharArray();
            final int n = s.length;
            int res = 0;
            int count = 0;
//        boolean prevWasR = true;

            for (int i = 0; i < n; ++i) {
                if (s[i] == 'R') {
                    ++count;
                } else {
                    count = 0;
//                prevWasR = false;
                }
                res = Math.max(count, res);
            }
            out.println(res);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32496
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	ll x, d, k;
	cin >> x >> k >> d;
	x = abs(x);
	
	ll moves = x / d;
	if(moves >= k) cout << x - (k * d);
	else {
		ll prev = x - (moves * d);
		ll nxt = prev - d;
		
		ll rem = k - moves;
		if(rem & 1) cout << abs(nxt);
		else cout << abs(prev);
	}
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

//5
int gcd(int a,int b){return b?gcd(b,a%b):a;}



int main(){

ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;

string s;
set<string> res;
for(int i=0;i<n;i++){
cin>>s;
res.insert(s);
}

cout<<(int)res.size()<<endl;

}



//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 19136
#include <stdio.h>

int main(){
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	while (op != '?'){
		if ( op == '+'){
			printf("%d\n", a + b);
		} else if ( op == '-'){
			printf("%d\n", a - b);
		} else if ( op == '*'){
			printf("%d\n", a * b);
		} else if ( op == '/'){
			printf("%d\n", a / b);
		} else {
		}
		scanf("%d %c %d", &a, &op, &b);
	}
	return 0;
}

Measured memory_bytes: 600
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 1000005
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897L
#define db long double  /* print with %Lf */
#define EPS 1e-9
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define yup {cout<<"Yes\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// Dont paste code two times in the text file.
// ============================================================

int main() {

    get(n);
    bool f = 1;
    rep(i,n) {
        get(a);
        if(a%2) continue;
        if(a%3 && a%5) f = 0;
    }

    if(f) printf("APPROVED\n");
    else printf("DENIED\n");
    return 0;  
}   


Measured memory_bytes: 256
N = int(input())
xl = []
for i in range(N):
    x,l = map(int,input().split())
    xl.append([x-l,x+l])
xl.sort()
l,r = xl[0]
ans = N
for i in range(1,N):
    l1,r1 = xl[i]
    if l<l1 and r1<r:
        ans -= 1
        l = l1
        r = r1
    elif l1<r:
        ans -= 1
    else:
        l = l1
        r = r1
print(ans)

Measured memory_bytes: 60040
S = input()

N = 0
cnt = 0
maxCnt = 0

while len(S) > N:
    if S[N] == "A" or S[N] == "C" or S[N] == "G" or S[N] == "T":
        N += 1
        cnt += 1
        if maxCnt < cnt:
            maxCnt =cnt
        
    else:
        cnt = 0
        N += 1

print(maxCnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin() (a).end()

vector <int> g[2001];
int dis[2001];
int n, x, y;
void bfs(int s){
	bool visited[n+1];
	memset(visited,0,sizeof(visited));
	int distance[n+1];
	memset(distance,0,sizeof(distance));
	queue<int> q;
	q.push(s);
	visited[s] = true;
	while(q.size()!=0){
		int u = q.front();
		q.pop();
		for(int i = 0; i<g[u].size(); i++){
			int v = g[u][i];
			if(visited[v] == false){
				q.push(v);
				visited[v]= true;
				distance[v] = distance[u]+1;
				if(v>s){
					dis[distance[v]]++;
				}
			}
		}
	}
}
int main(){
	memset(dis,0,sizeof(dis));
	cin >> n >> x >> y;
    for(int i = 1 ;i < n ;i++){
		g[i].pb(i+1);
		g[i+1].pb(i);
	}
	g[x].pb(y);
	g[y].pb(x);
	for(int i =1 ; i < n ; i++)
	    bfs(i);
    for(int i = 1; i< n ;i++)
	    cout<<dis[i]<<"\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> dish(n,0),val(n+1,0),sat(n,0);
 
  for(int i=0;i<n;i++) cin>>dish[i];
  for(int j=1;j<=n;j++) cin>>val[j];
  for(int k=0;k<n-1;k++) cin>>sat[k+1];
    
  int sum=0; 
    
  for(int i=0;i<n;i++)
      sum+=val[dish[i]];
    
  for(int i=1;i<n;i++)
      if(dish[i]==dish[i-1]+1) 
          sum+=sat[dish[i-1]];
    
  cout<<sum<<endl;
  return 0;
}

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

using namespace std;

using lli = long long int;

const lli mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    lli ans, a, n, i, j, k;
    
    ans = 0;
    cin >> n;
    
    vector<lli> cnt(60);
    
    
    
    for(i = 0; i < n; ++i)
    {
        cin >> a;
        j = 0;
        while(a)
        {
            if (a % 2 == 1)
            {
                cnt[j] += 1;
            }
            a /= 2;
            ++j;
        }
    }
    
    for(i = 0; i < 60; ++i)
    {
        a = 1;
        a = a << i;
        a %= mod;
        k = (cnt[i] * (n - cnt[i])) % mod;
        ans = (ans  +  ((a * k) % mod)) % mod;
    }
    
    
    cout << ans;
    
    return 0;
    
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      q: usize,
      c: [Usize1; n],
      mut lr: [(Usize1, Usize1); q]
   }
   let mut query = vec![];
   for (i, (l, r)) in lr.iter().enumerate() {
      query.push((*l, *r, i));
   }

   let mut ans = vec![0; q];

   query.sort_by_key(|(_, r, _)| *r);
   let mut append = vec![n; n];
   let mut bit = vec![0; n + 1];

   let mut rn = !0;
   for &(l, r, i) in query.iter() {
      for j in rn + 1..=r {
         if append[c[j]] != n {
            bit.add(append[c[j]], !0);
         }
         append[c[j]] = j;
         bit.add(append[c[j]], 1);
      }
      rn = r;
      ans[i] = bit.range(l, r + 1);
   }
   for a in ans {
      println!("{}", a);
   }
}

use std::ops::{AddAssign, Sub};
trait BIT<T: Copy + Clone + Sub + AddAssign> {
   fn add(&mut self, idx: usize, w: T);
   fn sum(&self, idx: usize) -> T;
   fn range(&self, l: usize, r: usize) -> T;
}

impl<T: Copy + Clone + Sub<Output = T> + AddAssign> BIT<T> for [T] {
   /// Example:
   /// ```
   /// let mut bit = vec![0; n+1];
   /// let q = vec![(0,2), (1,3), (3,1)];
   /// for &(i, w) in q.iter() {
   ///    bit.add(i, w);
   /// }
   /// assert_eq!(bit.sum(1), 5);
   /// assert_eq!(bit.range(1, 3), 3);
   /// assert_eq!(bit.range(1, 4), 4);
   /// ```
   fn add(&mut self, idx: usize, w: T) {
      let mut j = (idx + 1) as i64;
      while j < self.len() as i64 {
         self[j as usize] += w;
         j += j & -j;
      }
   }
   /// [0, r]
   fn sum(&self, idx: usize) -> T {
      let mut i = (idx + 1) as i64;
      let mut sum = self[0];
      while i != 0 {
         sum += self[i as usize];
         i -= i & -i;
      }
      sum
   }
   /// [l, r)
   fn range(&self, l: usize, r: usize) -> T {
      match (l, r) {
         (0, _) => self.sum(r - 1),
         _ => self.sum(r - 1) - self.sum(l - 1),
      }
   }
}


Measured memory_bytes: 44940
#include <cstdio>
#include <string>
 
class List
{
    int* data_;
    int begin_;
    int end_;
public:
    List()
    {
        data_ = new int[2000000];
        begin_ = 2000000-1;
        end_  = 2000000-1;
    }
    void Insert(int X)
    {
        --begin_;
        data_[begin_] = X;
    }
    void Delete(int X)
    {
        int Index = end_;
        for(int i = begin_; i < end_; ++i){
            if(X == data_[i]){
                Index = i;
                break;
            }
        }
        if(Index == end_) return;
        for(int i = Index; i < end_; ++i){
            data_[i] = data_[i+1];
        }
        end_--;
    }
    void DeleteFirst()
    {
        begin_++;
    }
    void DeleteLast()
    {
        end_--;
    }
    void Show()const
    {
        printf("%d", data_[begin_]);
        for(int i = begin_ + 1; i < end_; ++i){
            printf(" %d", data_[i]);
        }
        printf("\n");
    }
};
 
int main()
{
    List list;
    int n, X;
    std::scanf("%d\n", &n);
    char com[1024];
    for(int i = 0; i < n; ++i){
        std::fgets(com, 1024, stdin);
        if(com[6] == 'F'){
            list.DeleteFirst();
        }else
        if(com[6] == 'L'){
            list.DeleteLast();
        }else{
            int v = 0;
            for(int j = 7; com[j] >= '0' && com[j] <= '9'; ++j){
                v = v*10 + (com[j] - '0');
            }
            if(com[0] == 'i'){
                list.Insert(v);
            }else
            if(com[0] == 'd'){
                list.Delete(v);
            }
        }
    }
    list.Show();
    return 0;
}

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,x,y;
    vector<long long int>v,u;
    cin>>n;
    for(long long int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
        u.push_back(x);
    }
    sort(u.begin(),u.end());
    for(long long int i=0;i<n;i++)
    {
        if(v[i]<u[n/2]) cout<<u[n/2]<<endl;
        else cout<<u[n/2-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 5476
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        long[] aryNum = new long[n];
        for (int i = 0; i < n; i ++) {
            aryNum[i] = sc.nextInt();
        }

        int cnt = -1;
        boolean flg = true;
        
        while (flg) {
            cnt++;
            for (int i = 0; i < n; i++) {
                if (aryNum[i] % 2 == 0) {
                    aryNum[i] = aryNum[i] / 2;
                } else {
                    flg = false;
                    break;
                }
            }
         }
        
        System.out.println(cnt);
    }
}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	int N;
	cin >> N;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	int ma = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (ma <= v[i]) {
			ma = v[i];
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
w = [list(map(int, input().split())) for _ in range(n)]
w = sorted(w, key=lambda x: x[1])
t = 0

for i in range(n):
  t += w[i][0]
  if t > w[i][1]:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 55264
#include<cstdio>
int a;
int b[5];
int main(void)
{
    int n;
    scanf("%d" ,&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d" ,&a);
        b[a%4]++;
    }
    b[1] += b[3];
    if(b[0]>=b[1] || (b[2]==0 && b[0]+1==b[1]))
        printf("Yes");
    else
        printf("No");
    return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n, a, b;
    cin >> n >> a >> b;

    MSG(min(n*a, b))
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    map<string,int>m;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        m[s]++;
    }
    int ans=0;
    for(auto iter = m.begin(); iter != m.end(); iter++){
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 19220
import math
n,h = map(int,input().split())
al = []
bl = []
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    al += [a]
    bl += [b]
am = max(al)
bl.sort(reverse=1)
for i in bl:
    if i>am:
        ans += 1
        h -= i
        if h <= 0:
            break
    else:
        break
if h > 0:
    ans += math.ceil(h/am)
print(ans)

Measured memory_bytes: 17044
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;

int main(void){
	cin >> s;
	for(int i=0;i+1<s.size();i++){
		if(s[i]==s[i+1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
 using namespace std;
  int main() {
       string s;
       while(cin>>s){
       int l=s.length();
       for(int i=0;i<l;i++){
       if(i==0) cout<<'2';
       else if(i==1) cout<<'0';
       else if(i==2) cout<<'1';
       else if(i==3) cout<<'8';
       else cout<<s[i];
                }
           cout<<endl;
		        }
    
	 return 0;
	  }

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
signed main(){
    ll n;cin>>n;
    vector<pll>d(2*n);
    rep(i,n){
        ll a;cin>>a;
        d[i]=mp(a,0);
    }
    rep(i,n){
        ll b;cin>>b;
        d[i+n]=mp(b,1);
    }
    ll ans=1;
    ll cnta=0,cntb=0;
    sort(all(d));
    rep(i,2*n){
        if(d[i].second){
            if(cnta){
                ans=ans*cnta%inf;
                cnta--;
            }else{
                cntb++;
            }
        }else{
            if(cntb){
                ans=ans*cntb%inf;
                cntb--;
            }else{
                cnta++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6412
n = int(input())
buf = [0 for i in range(30)]
how = 0
if n%2 == 1:
    how = 0
else:
    how = 0
    n = n//2
    base = 1
    for i in range(30):
        base = base*5
        ar =n//base
        buf[i] = ar
    for i in range(30):
        how += buf[i]
# print(buf)
print(how)


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N), acc(N + 1);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }


    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1, 1LL << 60));
    for (int i = 0; i < N; i++) {
        dp[i][i] = 0;
        dp[i][i + 1] = 0;
    }
    dp[N][N] = 0;
    for (int i = 0; i + 2 <= N; i++) {
        dp[i][i + 2] = A[i] + A[i + 1];
    }

    for(int w = 3; w <= N; w++) {
        for(int i = 0; i + w <= N; i++) {
            int j = i + w;

            ll mi = min(dp[i + 1][j], dp[i][j - 1]);
            for (int k = i + 2; k <= j - 2; k++) {
                mi = min(mi, dp[i][k] + dp[k][j]);
            }
            dp[i][j] = mi + acc[j] - acc[i];
        }
    }

    cout << dp[0][N] << endl;


}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>

using namespace std;

int A, B, C, X, Y;
int price;

int main()
{
  cin >> A >> B >> C >> X >> Y;
  if(A + B > 2 * C) {
    // Adjust to the smaller
    int min_price = min(X, Y) * 2 * C;
    if(min(X, Y) == Y)
      min_price += (X - Y) * A;
    else
      min_price += (Y - X) * B;
    // Adjust to the bigger 
    int max_price = max(X, Y) * 2 * C;
    price = min(min_price, max_price);
  }
  else {
    price = X * A + B * Y;
  }
  cout << price << endl;
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

int best=1;

void hoge(int v) {
	if(M/v>=N) best=max(best,v);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	for(i=1;i*i<=M;i++) if(M%i==0) {
		if(M/i>=N) best=max(best,i);
		if(M/(M/i)>=N) best=max(best,M/i);
	}
	cout<<best<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main() {
    string s,t;
    cin>>s>>t;
    int longs = s.size();
    int longt = t.size();
    int match = 0;
    for(int i=0;i<longs-t.size()+1;i++){
        int tmp = 0;
        int tmp2 = i;
        for(int j=i;j<tmp2+longt;j++){
            if(s[j]==t[j-i]){
                tmp++;
            }
            match = max(match,tmp);
        }
    }
    cout<<t.size()-match<<endl;
}

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

int main() {
   	int N, count=0;
  	cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++){
    	cin >> A[i];
    }
    bool check = 1;
    while (check){
      	for (int i=0; i<N; i++){
    		if (A[i]%2!=0) {
            	cout << count << endl;
                check = 0;
            	break;
            }
        }
        for  (int i=0; i<N; i++){
        	A[i]/=2;
        }
        count++;
    }
}

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

int main()
{
  map<string, int> mp;
  string keyword;
  cin >> keyword;
  while (1)
  {
    string s;
    cin >> s;
    if (s == "END_OF_TEXT")
    {
      break;
    }
    for (int i = 0; i < s.size(); i++)
    {
      s.at(i) = tolower(s.at(i));
    }
    mp[s]++;
  }
  cout << mp[keyword] << endl;
}


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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    ll now = 1000;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        if(i==0){
            continue;
        }else{
            if(a[i]>a[i-1]){
                now = now/a[i-1]*a[i]+now%a[i-1];
            }
        }
    }
    
    std::cout << now << std::endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	char cstr[1201];
	int cnt[26];
	string str;
	for(int i =0; i< 26;i++){
		cnt[i]=0;
	}


	while(true){
		cin.getline(cstr,sizeof(cstr));
		str = string(cstr);
		if(str=="") break;
		for (int i = 0; i < str.size(); ++i) {
			char c = str[i];
			if('A' <= c && c <= 'Z'){
				c += 32;
			}
			if('a' <= c && c <= 'z'){
				cnt[c-'a']++;
			}
		}
	}

	for(int i =0; i< 26;i++){
		printf("%c : %d\n",'a'+i,cnt[i]);
	}


	return 0;
}



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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi A(100001);
  
  int ans=0;
  rep(i,n){
    int a; cin>>a;
    if(a>100000) ans++;
    else A[a]++;
  }
  rep(i,100001){
    if(A[i]!=0) if(i!=A[i]) {
      if((i)<=A[i]) ans+=A[i]-i;
      else ans+=A[i];
    }
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    if(n%1000==0){
      System.out.println(0);
    }else{
      System.out.println(1000-(n%1000));
    }
  }
}


Measured memory_bytes: 35784
n = int(input())
s = input()

resultMax = 0
for i in range(n):
  s1 = set(s[:i])
  s2 = set(s[i:])
  result = 0
  for j in s1:
    for k in s2:
      if j == k:
        result += 1
        break
  if resultMax < result:
    resultMax = result

print(resultMax)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int64_t>>;
const int64_t NINF= -1e15;

string solve(const Graph &weights){
  const int N= weights.size();
  Graph dp= weights;
  for(int k=0; k<N; k++){
    for(int from=0; from<N; from++){
      for(int to=0; to<N; to++){
        if(dp.at(from).at(k) != NINF && dp.at(k).at(to) != NINF){
          dp.at(from).at(to)= max(dp.at(from).at(to), dp.at(from).at(k)+dp.at(k).at(to));
        }
      }
    }
  }

  bool is_inf= false;
  for(int v=0; v<N; v++){
    if(dp.at(0).at(v) != NINF && dp.at(v).at(v) > 0 && dp.at(v).back() != NINF){
      is_inf= true;
      break;
    }
  }

  string ans= is_inf ? "inf"
                     : to_string(dp.at(0).back());
  return ans;
}

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

  Graph rewards(N, vector<int64_t>(N, NINF));
  for(int v=0; v<N; v++){
    rewards.at(v).at(v)= 0;
  }
  int v1,v2,score;
  for(int j=0; j<M; j++){
    cin >> v1 >> v2 >> score;
    v1--; v2--; // 1-indexed -> 0-indexed
    rewards.at(v1).at(v2)= score;
  }

  cout << solve(rewards) << endl;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
      #define hell                         1000000007 
      #define M                            1000000007
      #define Maxi                      10000000000000000
      #define lcm(a,b)                     (a*b)/__gcd(a,b)
      #define ll                           long long
           
      #define vll                          vector<ll>
      #define vi                           vector<long long>
      #define pll                          vector< pair<ll,ll> >
      #define pb                           push_back
                  //#define mp                           make_pair
      #define all(v)                       v.begin(),v.end()
      #define lbnd                         lower_bound
      #define ubnd                         upper_bound
      #define bs                           binary_search
      #define F                            first
      #define S                            second
      #define rep(i,a,b)                   for(i=a;i<b;i++)
      #define parr(a,n)                    for(i=0;i<n;i++) cout<<a[i]<<" ";cout<<endl;
      #define pcont(a)                     for(auto i:a) cout<<i<<" ";cout<<endl;
      #define ret(x)                       return cout<<x,0;
      #define dbg(x)                       cout << #x << " is " << x << endl;
      #define endl                           '\n'
           
           
                  // Debug //
           
      #define trace(x)                 cerr << #x << ": " << x << endl;
      #define trace1(x)                cerr << #x << ": " << x << endl;
      #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
      #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
      #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
      #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
      #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
           
           
      using namespace std;
      
     #define pie 3.14159265
      int main()
          {
           
          ios_base::sync_with_stdio(false);
          cin.tie(NULL);cout.tie(NULL);
        
          cout<<setprecision(10);
          double a,b,x;
          cin>>a>>b>>x;
          if(a*a*b<=2*x)
          cout<<atan((2*(b-x/(a*a)))/a)*180/pie<<endl;
        else
        {
          double v;
          //cout<<"fdfd"<<endl;
          double val2=(2*x/(b*a));//<<endl;
          
          cout<<atan((a*b*b)/(2.0*x))*180/pie<<endl;
        }

       return 0;
        }

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

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		int P = in.nextInt();
		
		ArrayList<ArrayList<Edge>> edges = new ArrayList<>();
		for(int i=0; i<N; i++) {
			edges.add(new ArrayList<Edge>());
		}
		for(int i=0; i<M; i++) {
			Edge e = new Edge();
			e.A = in.nextInt()-1;
			e.B = in.nextInt()-1;
			e.C = in.nextInt()-P;
			edges.get(e.A).add(e);
		}
		
		long[] coins = new long[N];
		for(int i=0; i<N; i++) {
			coins[i] = Integer.MIN_VALUE;
		}
		coins[0] = 0;

		for(int t = 1; t<=N-1; t++) {
			for(ArrayList<Edge> edg : edges) {
				for(Edge e: edg) {
					coins[e.B] = Math.max(coins[e.B], coins[e.A]+e.C);
				}
			}
		}
		long ans = coins[N-1];
		for(int t = 1; t<=N-1; t++) {
			for(ArrayList<Edge> edg : edges) {
				for(Edge e: edg) {
					coins[e.B] = Math.max(coins[e.B], coins[e.A]+e.C);
				}
			}
		}
		
		System.out.println(
				(ans!=coins[N-1])? -1 : 
				(ans<0)? 0 : ans);
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	class Edge{
		public int A;
		public int B;
		public int C;
	}
}

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

using namespace std;

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

  int items[N];
  for (int i = 0; i < N; i++) {
    cin >> items[i];
  }

  sort(items, items + N);

  double answer = (items[0] + items[1]) / 2.0;
  for (int i = 2; i < N; i++) {
    answer = (answer + (double)items[i]) / 2.0;
  }

  cout << setprecision(10);
  cout << answer << endl;
}


Measured memory_bytes: 256