akhauriyash/Code-Regression huggingface dataset:
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 2e5 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll parCol[N], dp[N], a[N], n;
vl Points;
int main(){
	IOS;
	cin >> n;
	Points.pb(0);
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		if (a[i] != a[i - 1]){
			Points.pb(a[i]);
		}
	}
	dp[0] = 1;
	for (int i = 1; i < Points.size(); i++){
		dp[i] = dp[i - 1];
		dp[i] += parCol[Points[i]];
		dp[i] %= MOD;
		parCol[Points[i]] += dp[i - 1];
		parCol[Points[i]] %= MOD;
		
	}
	cout << dp[Points.size() - 1];
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 6640
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let x: Vec<i64> = (&mut iter).take(n).map(|x| x.parse().unwrap()).collect();
    
    let mut ret = 1i64 << 60;
    for left in (0..).take_while(|&i| k - 1 + i < n) {
        let right = k - 1 + left;
        let lr = x[left].abs() + x[right] - x[left];
        let rl = x[right].abs() + x[right] - x[left];
        ret = std::cmp::min(ret, std::cmp::min(lr, rl));
    }
    println!("{}", ret);
}

Measured memory_bytes: 6396
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int n;
  cin >> n;
  vector<int> v;
  while (n > 0)
  {
    if (n % 10 == 9)
      v.emplace_back(1);
    else
      v.emplace_back(9);

    n /= 10;
  }

  rep(i, v.size())
  {
    cout << v[v.size() - 1 - i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
ll ksm(ll a,ll n){
	ll ans=1;
	while(n){
		if(n&1) ans=ans*a;
		a=a*a;
		n>>=1;
	} 
	return ans;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	printf("%lld\n",1LL*k*ksm(k-1,n-1));
	return 0;
}

Measured memory_bytes: 3820
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
#define MAX 25000100
inline ll read()
{
    ll x=0;bool t=false;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
    if(ch=='-')t=true,ch=getchar();
    while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
    return t?-x:x;
}
ll f[MAX],n,gA,sA,bA,gB,sB,bB;
int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    while (cin >> n) {
        memset(f,0,sizeof(f));
        cin >> gA >> sA >> bA;
        cin >> gB >> sB >> bB;
        for(int i=0;i<=n;++i) {
            if(i+gA<=n&&gA<gB)f[i+gA]=max(f[i+gA],f[i]+gB);
            if(i+sA<=n&&sA<sB)f[i+sA]=max(f[i+sA],f[i]+sB);
            if(i+bA<=n&&bA<bB)f[i+bA]=max(f[i+bA],f[i]+bB);
        }
        ll mx=0;
        for(int i=0;i<=n;++i)mx=max(mx,f[i]-i);
        n+=mx;
        memset(f,0,sizeof(f));
        for(int i=0;i<=n;++i)
        {
            if(i+gB<=n&&gA>gB)f[i+gB]=max(f[i+gB],f[i]+gA);
            if(i+sB<=n&&sA>sB)f[i+sB]=max(f[i+sB],f[i]+sA);
            if(i+bB<=n&&bA>bB)f[i+bB]=max(f[i+bB],f[i]+bA);
        }
        mx=0;
        for(int i=0;i<=n;++i)mx=max(mx,f[i]-i);
        printf("%lld\n",mx+n);
    }
    return 0;
}


Measured memory_bytes: 195584
#include <iostream>
#include <stdio.h>
#include <math.h>

#define M_PI 3.141592653589793

#define MAX_LEN 100

int x[MAX_LEN];
int y[MAX_LEN];

int abs(int x)
{
    if(x>=0)return x;
    else return x*(-1);
}

double calc(int *x, int *y, int len, int p)
{
	if (p == 1)
	{
		double sum = 0;
		for (int i = 0; i < len; i++)
		{
			sum += abs(x[i] - y[i]);
		}
		return sum;
	}
	if (p == 2)
	{
		double sum = 0;
		for (int i = 0; i < len; i++)
		{
			sum += pow(abs(x[i] - y[i]), 2);
		}
		return sqrt(sum);
	}
	if (p == 3)
	{
		double sum = 0;
		for (int i = 0; i < len; i++)
		{
			sum += pow(abs(x[i] - y[i]), 3);
		}
		return pow(sum, 1.0 / 3.0);
	}
	double max = 0;
	for (int i = 0; i < len; i++)
	{
		if (abs(x[i] - y[i]) > max) max = abs(x[i] - y[i]);
	}
	return max;
}

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

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &y[i]);
	}

	double a = calc(x, y, n, 1);
	double b = calc(x, y, n, 2);
	double c = calc(x, y, n, 3);
	double d = calc(x, y, n, 4);

	printf("%lf\n", a);
	printf("%lf\n", b);
	printf("%lf\n", c);
	printf("%lf\n", d);

}


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

struct team {
	int nb, pt, pc;
};

bool nbsmaller(team lhs, team rhs) {
	return lhs.nb < rhs.nb;
}

bool ptgreater(team lhs, team rhs) {
	return lhs.pt > rhs.pt;
}

int main()
{
	int n;

	cin >> n;

	vector<team> w(n);
	int m = n * (n - 1) / 2;

	for (int i = 0; i < n; i++) {
		w[i].nb = i + 1;
		w[i].pt = 0;
	}

	for (int i = 0; i < m; i++) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;

		if (c > d)
			w[a - 1].pt += 3;
		else if (c < d)
			w[b - 1].pt += 3;
		else {
			w[a - 1].pt++;
			w[b - 1].pt++;
		}
	}

	sort(w.begin(), w.end(), ptgreater);

	int j = 1, k = 1;
	for (int i = 0; i < n; i++) {
		w[i].pc = j;
		if (i < n - 1 && w[i].pt > w[i + 1].pt) {
			j += k;
			k = 1;
		}
		else
			k++;
	}

	sort(w.begin(), w.end(), nbsmaller);

	for (int i = 0; i < n; i++)
		cout << w[i].pc << endl;

	return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define MOD 1000000007
using namespace std;
const int MAXN = 100005;
struct Edge{
    int to,next;
}e[MAXN<<1];
int head[MAXN],n,a[MAXN],cnt,ans=1,d[MAXN];
typedef long long ll;
inline void insert(int u,int v)
{
    e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
}
inline int add(int x,int a)
{
    return x+a>=MOD?x+a-MOD:x+a;
}
inline int mul(int x,int a)
{
    return (ll)x*a%MOD;
}
int vis[MAXN],cir[MAXN],stk[MAXN],top,bg,oncir[MAXN],size[MAXN];
void getcir(int x)
{
    vis[x]=true;
    stk[++top]=x;
    for(int i=head[x];i;i=e[i].next){
        int v=e[i].to;
        if(vis[v]){
            bg=v;
            return;
        }else{
            getcir(v);
            if(bg)return;
        }
    }
    --top;
}
namespace Rev{
    Edge e[MAXN];
    int cnt,head[MAXN];
    inline void insert(int u,int v)
    {
        e[++cnt].to=v,e[cnt].next=head[u],head[u]=cnt;
    }
}
int branch;
void getsize(int x)
{
    vis[x]=true;
    size[x]=1;
	int son=0;
    for(int i=Rev::head[x];i;i=Rev::e[i].next){
        int v=Rev::e[i].to;
        if(oncir[v])continue;
		++son;
        getsize(v);
        size[x]+=size[v];
    }
	branch=max(branch,son);
}
inline void fail()
{
    puts("0");
    exit(0);
}
int fac[MAXN],inv[MAXN];
inline int ksm(int x,int k)
{
    int ret=1;
    while(k){
        if(k&1)ret=mul(ret,x);
        x=mul(x,x);
        k>>=1;
    }
    return ret;
}
inline void init()
{
    fac[0]=1;
    for(int i=1;i<=100000;++i)fac[i]=mul(fac[i-1],i);
    inv[100000]=ksm(fac[100000],MOD-2);
    for(int i=99999;i>=0;--i)inv[i]=mul(inv[i+1],i+1);
}
inline int C(int n,int m)
{
    return mul(fac[m],mul(inv[m-n],inv[n]));
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i){scanf("%d",a+i);insert(i,a[i]);++d[a[i]];Rev::insert(a[i],i);}
    for(int i=1;i<=n;++i)if(d[i]>2)fail();
    for(int i=1;i<=n;++i){
        if(vis[i])continue;
        top=0,bg=0;
        getcir(i);
        int p=1;
        while(stk[p]!=bg)++p;
        for(int j=p;j<=top;++j)oncir[stk[j]]=1;
        bool foot=false;
        for(int j=p;j<=top;++j){
			branch=0;
            getsize(stk[j]);
            --size[stk[j]];
            if(size[stk[j]])foot=true;
			if(branch>1)fail();
        }
        if(!foot){
            ++cir[top-p+1];
            continue;
        }
        int blank=0;
        for(int j=top;j>=p;--j)if(!size[stk[j]])++blank;else break;
        for(int j=p;j<=top;++j){
            if(!size[stk[j]])++blank;
            else{
                if(blank<size[stk[j]]-1)fail();
                else if(blank>=size[stk[j]])ans=mul(ans,2);
                blank=0;
            }
        }
    }
    init();
    for(int i=1;i<=n;++i){
        if(!cir[i])continue;
        int tot=0;
        for(int j=0;j*2<=cir[i];++j){
            int now=0;
            now=add(now,mul(mul(mul(mul(C(2*j,cir[i]),fac[2*j]),ksm(ksm(2,MOD-2),j)),inv[j]),ksm(i,j)));
            if((i&1) && (i>1))now=mul(now,ksm(2,cir[i]-j*2));
            tot=add(tot,now);
        }
        ans=mul(ans,tot);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8704
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX

#include <bits/stdc++.h>

using namespace std;

#define db(x) cout << (x) << '\n';
#define all(x) x.begin(),x.end()
#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define LB(v,x) lower_bound(all(v),x)
#define UB(v,x) upper_bound(all(v),x)
#define endl "\n"
#define F first
#define S second
#define PB push_back
#define PF push_front
#define int long long
#define double long double
#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;

int dy[]={0,1,1,1,0,-1,-1,-1};
int dx[]={-1,-1,0,1,1,1,0,-1};
const int maxn = 1e5;
const int OO = 1e18;
const int mod = 1e9 + 7;
const double PI = acos(-1);

void maxself(int &a,int b)
{a=max(a,b);}
void minself(int &a,int b)
{a=min(a,b);}


int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

    int t;
    t = 1;
    while(t--)
    {
        int n;
        cin >> n;
        vi v(n);
        for(int i=0;i<n;i++)
            cin >> v[i];
            int sum = 0;
        for(int i=1;i<n;i++)
            if(v[i]<v[i-1])
                sum+=v[i-1]-v[i],v[i] = v[i-1];
        cout << sum;
    }

	return 0;
}



Measured memory_bytes: 4728
#include<stdio.h>
int main(void){
int i;
int a[50];
int n,p,c;
while(1){
scanf("%d %d",&n,&p);
if(!n && !p) break;
c = p;
for(i=0;i<n;i++) a[i] = 0; //????£???????????°?????????°????????????
i = 0;
do{
if(i==n)i=0; //????????????????¶???????????????????????????????
if(c>0){ //???????°???????????????¨???
a[i]++; //????£?????°????????????¨?????????
c--; //???????°???????????????????
}else{ //???????°???????????????¨???
c = a[i]; //????£?????°??????????????§????
a[i] = 0; //????£?????°???????????????????
}
i++;
}while(a[i-1]<p); //????£?????????????????°????????????£???????????? break
printf("%d\n",i-1);
}
return 0;
}

Measured memory_bytes: 600
using System;


public class Test
{

	public static void Main()
	{
       string line = Console.ReadLine();
       string[] buffer = line.Split(' ');
       int[] nums = new int[buffer.Length];
       for(int i=0;i<nums.Length;i++){
           nums[i] = int.Parse(buffer[i]);
       }
       
       int ans = 0;
       for(int x=0;x<nums.Length;x++){
           for(int y=x+1;y<nums.Length;y++){
            if(ans == 0){
                ans = nums[x]+nums[y];
            } else if (ans>(nums[x]+nums[y])){
            	ans = nums[x]+nums[y];
            }
           }
       }
       
       
       Console.WriteLine(ans);
       
	}

}

Measured memory_bytes: 11092
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int N;
  cin>>N;
  
  map<string,int> kaz;
  rep(i,N){
    string A;
    cin>>A;
    sort(A.begin(),A.end());
    kaz[A]++;
  }
  int64_t sum=0;
  for(auto & x: kaz){
    int64_t R=x.second;
    sum+=R*(R-1)/2;
  }
  cout<<sum<<endl;
    
    

    
  
  
}

Measured memory_bytes: 11196
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,W;cin >> n >> W;
	vector<int> w(n);
	vector<int> v(n);
	rep(i,n) cin >> w.at(i) >> v.at(i);
	vector<vector<ll>> dp(n+1,vector<ll>(100001,1000000000000000000));
	dp[0][0]=0;
	rep(i,n){
		rep(j,100001){
			if(j-v[i]>=0) dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
			else dp[i+1][j]=dp[i][j];
		}
	}
	int ans=0;
	rep(i,100001){
		if(dp[n][i]<=W) ans=i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n;
    long long ans=0;
    cin>>n;
    for(int i=1,j=0;i<=n;i++) {
	int x=gi();
	ans+=(x+j)/2;
	if(x&&(x+j)%2) j=1;
	else j=0;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <unordered_map>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N;
    string S;
    cin>>N;
    vector<string> s;
    unordered_map<string, ll> ma;
    rep(i, N){
        cin>>S;
        s.push_back(S);
    }
    rep(i, N){
        vector<char> chars;
        rep(j, s[i].size()) chars.push_back(s[i][j]);
        sort(all(chars));
        rep(j, s[i].size()) s[i][j]=chars[j];
    }
    sort(all(s));
    rep(i, N) ma[s[i]]++;
    ll count=0;
    for(auto itr : ma){
        count+=itr.second*(itr.second-1)/2;
    }
    cout<<count<<endl;
    return 0;
}


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

int main(){
  
  int m,f,r;
  
  while(1){
  cin >> m >> f >> r;
  if(m==-1&&f==-1&&r==-1){
    break;
  }  
  if(m==-1||f==-1){
    
    cout << 'F' << endl;
  }
  else if(m+f>=80){
    
    cout << 'A' << endl;
  }
  else if(m+f>=65&&m+f<80){
    
    cout << 'B' << endl;
  }
  else if(m+f>=50&&m+f<65||r>=50){
    
    cout << 'C' << endl;
  }
  else if(m+f>=30&&m+f<50){
    
    cout << 'D' << endl;
  }
  else if(m+f<30){
    
    cout << 'F' << endl;
  }
  }   
  
}


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;


public class Main {
  public static void main(String[] args) {
    InputReader_INTXOR ir = new InputReader_INTXOR(System.in);
    int n = ir.readInt();
    int a[] = new int[n+1];
    Map<Integer, Integer> map= new HashMap<>();
    for (int i = 1; i < n; i++) {
      a[i] = ir.readInt();
      map.put(a[i], map.getOrDefault(a[i], 0)+1);
    }
    for (int i = 1; i <= n; i++) {
      System.out.println(map.getOrDefault(i, 0));
    }
    System.out.flush();
  }
}
  class InputReader_INTXOR {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader_INTXOR(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 final int readInt() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long readLong() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c))
        c = read();
      StringBuilder res = new StringBuilder();
      do {
        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 double readDouble() {
      return Double.parseDouble(readString());
    }

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

    public String next() {
      return readString();
    }

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


Measured memory_bytes: 61616
#include<stdio.h>
int main(){
    int A;
    int B;
    scanf("%d",&A);
    scanf("%d",&B);
    if((A==1)&&(B==2)){
        printf("3\n");
    }else if((A==1)&&(B==3)){
        printf("2\n");
    }else if((A==2)&&(B==1)){
        printf("3\n");
    }else if((A==2)&&(B==3)){
        printf("1\n");
    }else if((A==3)&&(B==1)){
        printf("2\n");
    }else if((A==3)&&(B==2)){
        printf("1\n");
    }
}

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

int str_distance(int n,string s,string t){
  int d=0;
  for(int i=0;i<n;i++){
    if(s.at(i)!=t.at(i)){
      d++;
    }
  }
  return d;
}

int main(){
  string s,t;
  cin >> s >> t;
  int ans=1000;
  for(unsigned long int i=0;i<=s.size()-t.size();i++){
    if(str_distance(t.size(),s.substr(i,t.size()),t)<ans){
      ans=str_distance(t.size(),s.substr(i,t.size()),t);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	string S;
	char out[100];
	cin >> S;
	for (int i = 0; i < S.length(); ++i) {
		out[i] = 'x';
	}
	
	for (int i = 0; i < S.length(); ++i) {
		cout<<out[i] ;
	}
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair
# define int long long

using namespace std;

const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int n, d, b[N], a[N], f[N];

int binpow(int a, int n)
{
      int res = 1;
      while(n)
      {
            if(n & 1)
                  res = (res * a) % inf;
            a = (a * a) % inf;
            n >>= 1;
      }
      return res;
}


int Cnk(int n, int k)
{
      if(k > n) return 0;
      return f[n] * (binpow(f[k] * f[n - k] % inf, inf - 2) % inf) % inf;
}

main()
{
      f[0] = 1;

      for(int i = 1; i <= 1e5 + 5; i ++)
            f[i] = i * f[i - 1] % inf;

      cin >> n;

      for(int i = 1; i <= n + 1; i ++)
      {
            cin >> a[i];
            if(b[a[i]])
                  d = i - b[a[i]];
            b[a[i]] = i;
      }

      cout << n << endl;

      for(int i = 2; i <= n; i ++)
            cout << (Cnk(n + 1, i) - Cnk(n - d, i - 1) + inf) % inf << endl;
      cout << 1 << endl;
}


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

int main(){

	string t, h;
	int n;
	int ct=0, ch=0;

	cin >> n;

	for(int i=0; i<n; i++){
		cin >> t >> h;

		if(t == h){
			ct += 1;
			ch += 1;
		}
		else if(t > h){
			ct += 3;
		}
		else if(h > t){
			ch += 3;
		}
	}

	cout << ct << " " << ch << endl;
 }

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

int main() {

  bool sosu[1000000] = {false};
  for ( int i = 2; i < 1000000; i++ ) {

    if ( sosu[i] == false ) {
      for ( int j = i*2; j < 1000000; j+=i ) {
	sosu[j] = true;
      }
    }

  }

  int n;
  while( cin >> n ) {

    int cnt = 0;
    for ( int i = 2; i <= n; i++ ) {
      if ( sosu[i] == false ) cnt++;
    }

    cout << cnt << endl;

  }

  return 0;

}

Measured memory_bytes: 2144
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: usize = read();
    let mut avec: Vec<u32> = read_vec();
    let mut bvec: Vec<u32> = read_vec();
    let mut ab: Vec<Vec<u32>> = vec![];
    for i in 0..n {
        ab.push(vec![avec[i], bvec[i]]);
    }
    ab.sort_by(|a, b| a[0].partial_cmp(&b[0]).unwrap());
    avec.sort();
    bvec.sort();

    if avec[0] > bvec[0] {
        println!("No");
        return;
    }
    let mut b = false;
    for i in 1..n {
        if avec[i] > bvec[i] {
            println!("No");
            return;
        }
        if avec[i] <= bvec[i - 1] {
            b = true;
        }
    }
    if b {
        println!("Yes");
        return;
    }

    //println!("{:?}", avec);
    //println!("{:?}", bvec);
    //println!("{:?}", ab);
    let mut tmp: Vec<(u32, usize)> = vec![];
    for i in 0..n {
        tmp.push((ab[i][1], i));
    }
    //println!("{:?}", tmp);
    tmp.sort_by(|x, y| x.0.partial_cmp(&y.0).unwrap());
    //println!("{:?}", tmp);

    let mut id: usize = 0;
    for _ in 0..n - 1 {
        id = tmp[id].1;
        if id == 0 {
            println!("Yes");
            return;
        }
    }
    if tmp[id].1 != 0 {
        loop {}
    }
    println!("No");
}


Measured memory_bytes: 13572
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  int sum=0;
  int ma=0;
  rep(i,n) cin >> a.at(i);
  rep(i,n) sum+= a.at(i);
  rep(i,n) ma=max(ma,a.at(i));
  cout << sum - ma/2 << endl;
  
}


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

#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i = 0; i < n1; i++) L[i] = A[left + i];
  for (i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for (k = left; k < right; k++) {
    if (L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if (left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for (j = p; j < r; j++) {
    if (A[j].value <= x.value) {
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if (p < r) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);

  for (i = 0; i < n; i++) {
    if (A[i].suit != B[i].suit) stable = 0;
  }

  if (stable == 1)
    printf("Stable\n");
  else
    printf("Not stable\n");
  for (i = 0; i < n; i++) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}


Measured memory_bytes: 5512
#include <stdio.h>

long long int mypow(long long int a, long long int n){
  long long re = 1;
  while(n >= 1){
    if(n & 1)  re = re * a;
    a = a * a;
    n = n >> 1;
  }
  return re;
}


int main(){
  long long int h;  scanf("%lld", &h);
  long long int count = 0;
  long long int ans = 0;
  while(h){
    h /= 2;
    count = count + 1;
  }
  ans = mypow(2, count) - 1;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

int main() {
  ll H, cnt = 0, a;
  cin >> H;
  a = H;

  while(a != 1) {
    // cout << "a:" << a << endl;
    a /= 2;
    cnt++;
  }
  cnt++;
  // cout << cnt << endl;
  ll ans = 0;
  rep(i, cnt) {
    ans += pow(2, i);
    // cout << pow(2, i) << endl;
  }
  
  cout << ans << endl;

}


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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n, a, b;
deque <int> d;

int main() {

    scanf("%d", &n);
    scanf("%d %d", &a, &b);

    if (1ll * a * b < n || a + b > n + 1) {
        puts("-1");
        return 0;
    }

    for (int i = 1; i <= a; i++)
        d.push_back(i);

    int num = a + 1;
    for (int i = 1; i <= b - 1; i++) {
        int len = (n - a) / (b - 1);
        if (i <= (n - a) % (b - 1))
            len++;

        for (int j = num + len - 1; j >= num; j--)
            d.push_front(j);

        num = num + len;
    }

    for (int i = 0; i < n; i++) {
        printf("%d ", d.front());
        d.pop_front();
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3440
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    int min = 10000000;
    int max = -10000000;
    long long int sum = 0;

    for(int i=0;i<n;i++){
        sum+= a[i];
        if(min > a[i]) min = a[i];
        if(max < a[i]) max = a[i];    
    }

    cout << min << " " << max << " " << sum << endl;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int C[110][110];

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            std::cin >> C[i][j];
        }
    }

    ll cost = 0;
    
    for(int i=0;i<N;++i){
        for(int j=i+1;j<N;++j){
            cost += std::min(C[i][j], C[j][i]);
        }
    }

    std::cout << cost << std::endl;
}



Measured memory_bytes: 3200
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  int a,b,c,d,e;
  a=N/100;
  b=N-a*100;
  c=b/10;
  d=b-c*10;
  if(a==7){
    printf("Yes");
  }
  else if(c==7){
    printf("Yes");
  }
  else if(d==7){
    printf("Yes");
  }
  else{
    printf("No");
  }
}



Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Hen>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			Hen h = new Hen();
			h.u = Integer.parseInt(sa[0]) - 1;
			h.v = Integer.parseInt(sa[1]) - 1;
			h.s = Integer.parseInt(sa[2]);
			list.get(h.u).add(h);
			list.get(h.v).add(h);
		}
		br.close();

		Queue<Integer> que = new ArrayDeque<>();
		long min = 1;
		long max = Integer.MAX_VALUE;
		Long[] x = new Long[n];
		Long[] y = new Long[n];
		x[0] = 0L;
		que.add(0);
		while (!que.isEmpty()) {
			int cur = que.poll();
			for (Hen h : list.get(cur)) {
				int next = h.u;
				if (next == cur) {
					next = h.v;
				}
				if (x[cur] != null) {
					long alt = h.s - x[cur];
					if (y[next] == null) {
						y[next] = alt;
						max = Math.min(max, alt - 1);
						que.add(next);
					} else if (y[next] != alt) {
						System.out.println(0);
						return;
					}
				}
				if (y[cur] != null) {
					long alt = h.s - y[cur];
					if (x[next] == null) {
						x[next] = alt;
						min = Math.max(min, -alt + 1);
						que.add(next);
					} else if (x[next] != alt) {
						System.out.println(0);
						return;
					}
				}
				if (x[next] != null && y[next] != null) {
					long val = y[next] - x[next];
					if (val % 2 != 0) {
						System.out.println(0);
						return;
					}
					min = Math.max(min, val / 2);
					max = Math.min(max, val / 2);
				}
			}
		}
		System.out.println(Math.max(max - min + 1, 0));
	}

	static class Hen {
		int u, v, s;
	}
}


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

int main()
{
    int r,g,b,s;
    while(~scanf("%d%d%d",&r,&g,&b))
    {
        s=r*100+g*10+b;
        if(s%4==0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>

using namespace std;

int dp[1003][1003];
int visit[1003][1003];
int cave[1003][1003] = { 0 };
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, -1,  0, 1 };

int main() {
	ifstream fin("input.txt");
	ofstream fout("output.txt");

	//1~1000000の内素数ならtrue素数でないならfalse
	static int isPrime[1000001];
	for (int i = 0; i < 1000001; i++) {
		isPrime[i] = 1;
	}
	isPrime[0] = 0;
	isPrime[1] = 0;
	for (int i = 2; i <= 1000; i++) {
		if (isPrime[i]) {
			for (int j = 2; i * j < 1000001; j++) {
				isPrime[i * j] = 0;
			}
		}
	}

	int c = 1, d = 0;
	int x = 500, y = 500;
	bool end = false;
	while (true) {
		for (int dir = 0; dir < 4; dir++) {
			if (dir % 2 == 0) d++;
			for (int cnt = 1; cnt <= d; cnt++) {
				cave[x][y] = c;
				if (c == 1000000) {
					end = true;
					break;
				}
				c++;
				x = x + dx[dir];
				y = y + dy[dir];
			}
			if (end) break;
		}
		if (end) break;
	}

	while (true) {
		int all, num = 0, first, last = 0, f_x, f_y, l_x, l_y;
		cin >> all >> first;
		if (all == 0 && first == 0) break;

		for (int j = 0; j < 1003; j++) {
			for (int i = 0; i < 1003; i++) {
				dp[i][j] = 0;
				visit[i][j] = 0;
				if (cave[i][j] == first) {
					f_x = i;
					f_y = j;
					visit[i][j] = 1;
					if (isPrime[first] == 1) dp[i][j] = 1;
				}
				if (cave[i][j] == all) {
					l_x = i;
					l_y = j;
				}
			}
		}

		for (int y = f_y + 1; y <= 1002; y++) {
			for (int x = 1; x <= 1002; x++) {
				if (cave[x][y] <= all && cave[x][y] != 0) {
					if (!(visit[x - 1][y - 1] == 0 && visit[x][y - 1] == 0 && visit[x + 1][y - 1] == 0)) {
						dp[x][y] = max(visit[x - 1][y - 1] * dp[x - 1][y - 1], max(visit[x][y - 1] * dp[x][y - 1], visit[x + 1][y - 1] * dp[x + 1][y - 1]))
							+ isPrime[cave[x][y]];
						visit[x][y] = 1;
					}
				}
			}
		}

		for (int y = f_y; y <= 1002; y++) {
			for (int x = 1; x <= 1002; x++) {
				num = max(num, dp[x][y]);
			}
		}

		if (num != 0) {
			for (int y = f_y; y <= 1002; y++) {
				for (int x = 1; x <= 1002; x++) {
					if (dp[x][y] == num && isPrime[cave[x][y]] == 1) {
						last = max(last, cave[x][y]);
					}
				}
			}
		}
		//cout << endl;
		//for (int y = 0; y <= 10; y++) {
		//	for (int x = 0; x <= 10; x++) {
		//		cout << dp[x][y] << " ";
		//	}
		//	cout << endl;
		//}
		//cout << endl;
		//for (int y = 0; y <= 10; y++) {
		//	for (int x = 0; x <= 10; x++) {
		//		cout << visit[x][y] << " ";
		//	}
		//	cout << endl;
		//}

		cout << num << " " << last << endl;
	}

	return 0;
}

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

#define fi first
#define se second
#define all(X) X.begin(),X.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int maxn = 1e5 +5;
const int lg = 20;
const int mod = 1e9 + 7;

template<class T>
void smin(T &_x, const T &_y){
	_x = min(_x, _y);
}
template<class T>
void smax(T &_x, const T &_y){
	_x = max(_x, _y);
}

int a[maxn];
int dp[maxn];

int main(){
	ios_base::sync_with_stdio(false);cin.tie();
	int n;
	ll x;
	cin>>n>>x;
	ll ans = 0;
	for(int i = 0; i < n; i++){
		cin>>a[i];
		dp[i] = a[i];
		ans += a[i];
	}
	for(int j = 1; j < n; j++){
		ll sum = 0;
		for(int i = 0; i < n; i++){
			dp[i] = min(dp[i], a[(i - j + n) % n]);
			sum += dp[i];
		}
		smin(ans, sum + x * j);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
signed main(){
    long long n,i,s=0;
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        if(i%3==0 || i%5==0){
            s +=0;
        }else{
            s +=i;
        }
    }
    printf("%lld\n",s);
    return(0);
}

Measured memory_bytes: 1716
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128 l2;
//typedef long long l2;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int> tii;
typedef tuple<db,db,db> tdb;
typedef tuple<ll,ll,ll> tll;
typedef tuple<int,int,int,int> ti4;
typedef tuple<db,db,db,db> td4;
typedef vector<vector<ll>> mat;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //shuffle(a+1,a+1+n,rng)
uniform_int_distribution<> gen(1,100); //gen(rng)
const ll mod=1e9+7,inf=1e15;
const int N=5e5+5,M=1e5+5,K=1e5+5;
int n,m,a[N];
vector<int> cur;
multiset<int,greater<int>> st;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n; m=1<<n;
	for(int i=1;i<=m;i++) cin>>a[i];
	sort(a+1,a+1+m); reverse(a+1,a+1+m);
	cur.emplace_back(a[1]);
	for(int i=2;i<=m;i++) st.emplace(a[i]);
	for(int t=1;t<=n;t++){
		vector<int> N;
		for(auto x : cur){
			auto it=st.upper_bound(x);
			if(it!=st.end()){
				N.emplace_back(*it); st.erase(it);
			}
			else{
				cout<<"No"; return 0;
			}
		}
		for(auto x : N) cur.emplace_back(x);
		sort(cur.begin(),cur.end());
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 16908
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,m,sum[2000]={},res=1,a[2000],b[2000],c[2000][15],key[10000];
pair<long long int,long long int>pa[200000];
long long int dp[10000]={},two[20]={1};
int main() {
	cout << fixed << setprecision(10);
	cin>>n>>m;
	for(int i=1;i<=15;i++){
		two[i]=two[i-1]*2;
	}
	for(int i=0;i<m;i++){
		cin>>a[i]>>b[i];
		for(int j=0;j<b[i];j++){
			cin>>c[i][j];
			sum[i]+=two[c[i][j]-1];
		}
	}
	for(int j=0;j<two[n];j++){
		dp[j]=INF;
	}
	dp[0]=0;
	for(int i=0;i<m;i++){
		for(int j=0;j<two[n]-1;j++){
			dp[j|sum[i]]=min(dp[j|sum[i]],dp[j]+a[i]);
		}
	}
	if(dp[two[n]-1]==INF){cout<<-1<<endl;}
	else{cout<<dp[two[n]-1]<<endl;}
} 


Measured memory_bytes: 384
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = [inp() for _ in range(n)]
a.sort()
res = INF
for i in range(n-k+1):
    res = min(res, a[i+k-1] - a[i])
print(res)

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

using namespace std;

int main(){
    string S;
    bool flag = false;
    cin >> S;
    int nowlast = S.size()-1;
    while(1){
        if(nowlast==-1){
            flag = true;
            break;
        }else if(nowlast<4){
            break;
        }else if(S.substr(nowlast-4,5)=="dream"){
            nowlast -= 5;
        }else if(S.substr(nowlast-4,5)=="erase"){
            nowlast -= 5;    
        }else if(nowlast==4){
            break;
        }else if(S.substr(nowlast-5,6)=="eraser"){
            nowlast -= 6;
        }else if(nowlast==5){
            break;
        }else if(S.substr(nowlast-6,7)=="dreamer"){
            nowlast -= 7;
        }else{
            break;
        }
    }

    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

int main() {
  int N, R;
  cin >> N >> R;
  int R_2;
  
  if (N >= 10) {
    cout << R;
  }
  else {
    R_2 = R + 100 * (10 - N);
    cout << R_2;
  }
}

Measured memory_bytes: 3584
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include <sstream>
#include<map>
#include<cmath>
#include<queue>
#include <functional>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define PI 3.141592

using namespace std;

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

	vector<int> vNumA(N, 0);
	vector<int> vNumB(N, 0);
	vector<int> vNumC(N-1, 0);
	rep(i, N) cin >> vNumA[i];
	rep(i, N) cin >> vNumB[i];
	rep(i, N-1) cin >> vNumC[i];

	int prevIndex = -1;
	int result = 0;
	rep(i, N)
	{
		result += vNumB[vNumA[i]-1];
		if (prevIndex != -1)
		{
			if (vNumA[i] - 1 == prevIndex + 1)
			{
				result += vNumC[prevIndex];
			}
		}
		prevIndex = vNumA[i] - 1;
	}

	printf("%d", result);
}


Measured memory_bytes: 256
s = input()
 

if len(s) % 2:
    s = s[:-1]
else:
    s = s[:-2]
    
cnt = len(s)
    
    
while True:
    if s[:len(s) // 2] == s[len(s) // 2:]:
        break
    s = s[:-2]
    cnt -= 2
 
 
print(cnt)

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

using ll = long long;
using namespace std;

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

int main(void) {
	string s, t;
	cin >> s >> t;
	cout << t + s << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//228
	ull s;
	cin>>s;
	int cnt = 0;
	unordered_set<ull> se;
	while(se.count(s)==0) {
		se.insert(s);
		++cnt;
		if(s&1)s=3*s+1;
		else s>>=1;
	}
	cout<<cnt+1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s;
    while(cin >> n >> s, n | s)
    {
        set<vector<int>> st;
        for(int bit = 0; bit < (1<<10); bit++)
        {
            vector<int> v;
            int sum = 0;
            for(int i = 0; i < 10; i++)
            {
                if(bit & (1<<i))
                {
                    v.push_back(i);
                    sum += i;
                }
            }
            if(sum == s && v.size() == n)
            {
                sort(v.begin(), v.end());
                st.insert(v);
            }
        }
        cout << st.size() << endl;
    }
    return 0;
}




Measured memory_bytes: 3176
#include<stdio.h>
int main( ){
  int x,y;
  scanf("%d %d",&x,&y);
    if(x>y){
    	printf("a > b\n");
    }
	else if(x<y){
		printf("a < b\n");
    } 
	else{
		printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2060
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)
	arr := []int{}
	for i := 0; i < s; i++ {
		var a int
		fmt.Scan(&a)
		arr = append(arr, a)
	}
	min := 1000000000
	for {
		b := true
		if arr[0] < min {
			min = arr[0]
		}
		for i, v := range arr {
			if v%min != 0 {
				arr[i] = v % min
				if arr[i] < min {
					min = arr[i]
					b = false
				}
			}
		}
		if b || min == 1 {
			break
		}
	}
	fmt.Println(min)
}


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

const ll mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false);

	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char> (w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	vector<vector<ll>> dp(h, vector<ll> (w, 0));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i == 0 && j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if (a[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}
			if (i - 1 >= 0 && a[i - 1][j] == '.') {
				dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			}
			if (j - 1 >= 0 && a[i][j - 1] == '.') {
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
			}
		}
	}
	cout << dp[h - 1][w - 1];

	return 0;
}

Measured memory_bytes: 9088
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        Map<Character, Integer> map1 = new HashMap<>();
        Map<Character, Integer> map2 = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            map1.merge(s.charAt(i), 1, Integer::sum);
            map2.merge(t.charAt(i), 1, Integer::sum);
        }
        List<Map.Entry<Character, Integer>> list1 = new ArrayList<>(map1.entrySet());
        List<Map.Entry<Character, Integer>> list2 = new ArrayList<>(map2.entrySet());
        list1.sort(Map.Entry.comparingByValue());
        list2.sort(Map.Entry.comparingByValue());
        for (int i = 0; i < list1.size(); i++) {
            if (list1.get(i).getValue().compareTo(list2.get(i).getValue()) != 0) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 39300
#include <bits/stdc++.h>
using namespace std;
#define	rep(i,n)	for(int i=0;i<n;i++)
int main() {
  int n;	cin >> n;
  pair<pair<string,int>,int>	x[n];
  rep(i,n){
    string s;	cin >> s;
    int p;	cin >> p;	p*=-1;
    x[i].first.first=s;
    x[i].first.second=p;
    x[i].second=i+1;
  }
  sort(x,x+n);
  rep(i,n)	cout << x[i].second << endl;
}

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

DP = [10**9] * (2**n)
DP[0] = 0
for _ in range(m):
    cost, types = map(int, input().split())
    to_open = list(map(int, input().split()))

    openable = 0
    for open in to_open:
        openable += 1 << (open-1)

    for opened in range(2 ** n):
        pattern = opened | openable
        DP[pattern] = min(DP[pattern], DP[opened] + cost)

full_open = 2**n - 1
ans = DP[full_open]

if ans == 10 ** 9:
    ans = -1

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>

using namespace std;


int main() {
	long long int N;
	cin >> N;
	
	string S;
	cin >> S;
	string s = S;
	int Y = 0;
	for (int i = 0; i < N; i++) {
		
		if (S[i] == ')') {
			if (Y == 0) {
				s = '(' + s;
			}
			else {
				Y--;
			}
		}
		else {
			Y++;
		}
		
	}
	for (int i = 0; i < Y; i++) {
		s = s + ')';
	}
	
	cout << s << endl;
	return 0;
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N;
	cin >> N;
	
	vector< int > imos(100010, 0);
	for_(i,0,N) {
		int a, b;
		cin >> a >> b;
		imos[a-1]++;
		--imos[b];
	}
	
	for_(i,0,100010) imos[i+1] += imos[i];
		
	int ans = 0;
	for_(i,0,100010) if (i <= imos[i]) ans = i;
	cout << ans << endl;
}

Measured memory_bytes: 3092