akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    int N, A, B, C;
    readf("%d %d %d %d", &N, &A, &B, &C);
    readln;

    int[] ls;
    ls.length = N;
    foreach (i; 0..N) ls[i] = readln.chomp.to!int;
    sort(ls);

    int mp = int.max;
    do {
        foreach (a; 1..N-1) {
            foreach (b; a+1..N) {
                foreach (c; b+1..N+1) {
                    int as, bs, cs;
                    foreach (i; 0..a) as += ls[i];
                    foreach (i; a..b) bs += ls[i];
                    foreach (i; b..c) cs += ls[i];

                    mp = min(mp, (a-1)*10 + (b-a-1)*10 + (c-b-1)*10 + abs(A - as) + abs(B - bs) + abs(C - cs));
                }
            }
        }
    } while (nextPermutation(ls));

    writeln(mp);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int dp[5000][5000];


void lcs(string s1,string s2){
	
	for(int i=1;i<=s1.size();i++){
		for(int j=1;j<=s2.size();j++){
			if(s1[i-1]==s2[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
		}
	}

}

int main(){
	string s1;
	string s2;

	getline(cin,s1);
	getline(cin,s2);

	
	lcs(s1,s2);

	int i = s1.size();
	int j = s2.size();
	string s3 = "";                  	

	while(i > 0 && j > 0){
		if(s1[i-1] == s2[j-1]) {
			s3 = s1[i-1] + s3;
			i--;
			j--;
		}
		else if(dp[i-1][j] > dp[i][j-1]) i--;
		else j--;
		
	}

	cout << s3 << '\n';

	return 0;

}



Measured memory_bytes: 50808
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll l = 0, r = MOD;
    while(l + 1 < r) {
        ll m = (l + r) / 2;
        ll sum = 0;
        for(int i = 0; i < n; i++) {
            sum += (a[i] - 1) / m;
        }
        if(sum <= k) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 4752
def main():
    n, k, *x = map(int, open(0).read().split())
    l = x[k - 1] - x[0] + min(abs(x[k - 1]), abs(x[0]))

    for i, j in zip(x, x[k - 1:]):
        y = j - i + min(abs(i), abs(j))
        if y - l < 0:
            l = y

    print(l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14052
from collections import Counter
n = int(input())
ns = list(map(int, input().split()))
cum = []
a = 0
for i in ns:
    a += i
    cum.append(a)
c = Counter(cum)
ans = 0
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
for value in c.values():
    if value > 1:
        ans += cmb(value, 2)
print(ans + c[0])


Measured memory_bytes: 113324
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    int ans=N%1000;
    if(ans!=0){
        ans=1000-ans;
    }
    
    cout<<ans<<endl;;


    return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n,t[N],m,p[N],x[N],sum,tsum;
int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d",&n);
	for(int i = 1;i <= n; ++i) {
		scanf("%d",&t[i]);
		sum += t[i];
	}
	scanf("%d",&m);
	for(int i = 1;i <= m; ++i){
		scanf("%d%d",&p[i],&x[i]);
		tsum = sum - t[p[i]] + x[i];
		printf("%d\n",tsum);
	}
	return 0;
}

Measured memory_bytes: 256
//AC 

//答案错误 ,原因：题意不清，理解错误，如果x,y在矩形中心就可以有多条切割 
#include<stdio.h>
int main()
{
	double n,m,x,y;
	while(~scanf("%lf%lf%lf%lf",&n,&m,&x,&y)){
		printf("%lf ",n*m/2);
		if(x==n/2&&y==m/2){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}
}

Measured memory_bytes: 256
/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

//----------------------------------------------------------//

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

//-----------------------------------------------------------//

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)
#define      PI                         acos(-1)

//-----------------------------------------------------------//

int main()
{
    //string ;
    int a,b,i,count=0;
    cin>>a>>b;
    cout<<(a+(b*2))/(b*2+1)<<endl;
    return 0;
}




Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); <-- PUT IN main()/solve()!

using namespace std;

int h,w;
char a[1005][1005];
int dp[1005][1005];
class HGrid1 {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> h >> w;
		f(i,0,h)
			f(j,0,w)
			{
				in >> a[i][j];
				dp[i][j]=-1;
			}
		dp[h-1][w-1]=1;
		out << solve(0,0) << "\n";
	}
	int solve(int x,int y)
	{
		if(a[x][y]=='#'||x==h||y==w)
			return 0;
		else if(dp[x][y]==-1)
		{
			dp[x][y]=solve(x+1,y)+solve(x,y+1);
			if(dp[x][y]>MOD)
				dp[x][y]%=MOD;
		}
		return dp[x][y];
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	HGrid1 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;

int main()
{
    int H,N,sum=0;
    cin>>H>>N;
    int arr[N];
    for(int i=0;i<N;i++)
    {
        cin>>arr[i];
        sum += arr[i];
    }
    if(sum>=H)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 640
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[10005],f[1000005],mod=1e9+7;
int inv[1000005];
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int t=a[i];
		for(int j=2;j*j<=a[i];j++){
			if(t%j==0){
				int sum=0;
				while(t%j==0){
					t/=j;sum++;
				}
				f[j]=max(f[j],sum);
			}
		}
		if(t!=1){
			if(!f[t])f[t]=1;
		}
	}
	int p=1;
	for(int i=2;i<1000000;i++){
		for(int j=0;j<f[i];j++)p=p*i%mod;
	}
	inv[1]=1;
	for(int i=2;i<=1000000;i++)inv[i]=mod-inv[mod%i]*(mod/i)%mod;
	int ans=0;
	for(int i=1;i<=n;i++){
		ans=ans+p*inv[a[i]];
		ans=ans%mod;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 14976
n = int(raw_input())
  
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
  
def BFS(s):
    for e in range(n):
        if M[s][e] == 1:
            if d[e] > d[s] + 1:
                d[e] = d[s]+1
                BFS(e)
  
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
  
d[0] = 0
for s in range(n):
        BFS(s)
for s in range(n):
    if d[s] == 99999:
        d[s] = -1
for s in range(n):
    print'{0} {1}'.format(s+1, d[s])
 

 

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

int main() {
	// your code goes here
	int n,m,i,j,max,k,x;
	cin>>n;
	string a[n],p;
	for(i=0;i<n;i++)
	cin>>a[i];
	cin>>m;
	string b[m];
	sort(a,a+n);
	for(i=0;i<m;i++)
	cin>>b[i];
	sort(b,b+m);
	max=0;
	x=0;
	for(i=x;i<n;i++)
	{
	    p=a[i];
	    k=0;
	    for(j=i;j<n;j++)
	    {
	        if(p==a[j])
	        {
	        k++;
	        x=j+1;
	        }
	        else
	        break;
	    }
	    for(j=0;j<m;j++)
	    {
	        if(p==b[j])
	        k--;
	    }
	    if(max<k)
	    max=k;
	}
	cout<<max<<endl;
	return 0;
}


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


const int MAX_N = 100001;



int D[MAX_N];// (HL分解後にあるnodeとあるnodeが同じHeavyPathに含まれているかどうか)
int find(int a){return a-D[a]?(D[a]=find(D[a])):a; }
  
struct node{
  int id;
  vector<int> to;
  int h;//深さ
  int size;
  node(){ h = -1; }
  bool operator<(const node& n) const{
    return h < n.h;
  }
};
  
struct HL_node{
  int h;
  vector<int> v;//sortされる
  int np;//Light-edgeで結ばれた親
};
  
bool used[MAX_N];
int vid[MAX_N];
node G[MAX_N];//子への辺をもつ
HL_node HL[MAX_N];
int V;//頂点数

  
int dfs(int id,int h){
  if( G[id].h>-1 ) return 0;
  G[id].h = h;
  G[id].size = 1;
  for(int i=0;i<(int)G[id].to.size();i++){
    G[id].size+=dfs(G[id].to[i],h+1);;
  }
  if( G[id].size == 1 ) return G[id].size;
  for(int i=0;i<(int)G[id].to.size();i++){
    if( G[id].size/2 <= G[G[id].to[i]].size ){
      D[G[id].to[i]] = find(id);break;    
    }
  }
  return G[id].size;
}

void HeavyLightDecomposition(int root){
  for(int i=0;i<V;i++) D[i] = i;
  memset(used,0,sizeof(used));
  dfs(root,0);
  sort(G,G+V);
  vector<int> vs;//after_hl
  for(int i=0;i<V;i++) vid[G[i].id] = i;
  for(int i=0;i<V;i++){
    int now = G[i].id;
    used[now] = true;
    HL[find(now)].v.push_back(now);
    for(int j=0;j<(int)G[vid[now]].to.size();j++){
      int to = G[vid[now]].to[j];
      if( used[to] ) continue;
      if( find(to) == find(now) ) continue;
      HL[find(to)].np = now;
      HL[find(to)].h = HL[find(now)].h+1;
    }  
  }

}
  
int HeavyLightLCA(int a, int b){
  for(; HL[find(a)].h != HL[find(b)].h ; HL[find(a)].h>HL[find(b)].h?(a=HL[find(a)].np):(b=HL[find(b)].np) );
  for(; find(a) != find(b) ; a = HL[find(a)].np, b = HL[find(b)].np );
  return vid[a]<vid[b]?a:b;
}

int main(){
  cin >> V;
  for(int i=0;i<V;i++){
    G[i].id = i;
    int k; cin >> k;
    for(int j=0;j<k;j++){
      int c;
      cin >> c;
      G[i].to.push_back( c );
    }
  }
  HeavyLightDecomposition(0);
  int Q;
  cin >> Q;
  for(int i=0;i<Q;i++){ 
    int u,v; cin >> u>> v;
    cout << HeavyLightLCA(u,v) << endl;    
  }
}

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    int sum=0;
      int digitSum;
    for (int i=1;i<=N;i++){
     digitSum=0;

    int x=i;
    while(x>=1){

        digitSum+=(x%10);
        x /=10;
    }
    if(A<=digitSum && digitSum <=B)sum+=i;
    }
    cout <<sum <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k;
    cin >> n >> k;
    vector<P> vp(n);
    rep(i, n) cin >> vp[i].second >> vp[i].first;
    sort(all(vp));
    reverse(all(vp));
    int sum = 0;
    int cnt[100010] = {};
    rep(i, k)
    {
        sum += vp[i].first;
        cnt[vp[i].second]++;
    }
    int var = 0;
    rep(i, 100010) if (cnt[i] != 0) var++;
    int ans = sum + var * var, pos1 = k, pos2 = k - 1;
    Rep(i, var + 1, 100010)
    {
        bool f = true;
        P tmp;
        Rep(j, pos1, n)
        {
            if (cnt[vp[j].second] == 0)
            {
                tmp = vp[j];
                cnt[vp[j].second]++;
                sum += vp[j].first;
                pos1 = j + 1;
                f = false;
                break;
            }
        }
        if (f)
            break;
        f = true;
        repr(j, pos2)
        {
            if (cnt[vp[j].second] > 1)
            {
                cnt[vp[j].second]--;
                sum -= vp[j].first;
                vp[j] = tmp;
                pos2 = j;
                f = false;
                break;
            }
        }
        if (f)
            break;
        //cout << sum + i * i << endl;
        ans = max(ans, sum + i * i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int x = scan.nextInt();
	int y = scan.nextInt();
	if (x < y) {
	    int tmp = y;
	    y = x;
	    x = tmp;
	}
	while (x % y != 0) {
	    int tmp = y;
	    y = x % y;
	    x = tmp;
	}
	System.out.println(gcd(x, y));
    }
    static int gcd (int x, int y) {
	for (int i = x; i > 0; i--) {
	    if (y % i == 0 && x % i == 0) {
		return i;
	    }
	}
	return 1;
    }
}

Measured memory_bytes: 26232
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
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            out.println((1000 - n % 1000) % 1000);
        }

    }

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

        public FastReader(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 int nextInt() {
            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 boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }
}



Measured memory_bytes: 32488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
   char a[99999];
   int s,i,m;
   while(~scanf("%s",&a))
   {
       m=strlen(a);
       s=0;
       for(i=0;i<m;i++)
       {
           if(a[i]=='-')
            s=s-1;
           else
            s=s+1;
       }
       printf("%d\n",s);
   }
    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 998244353;

LL powm(LL x, LL y){
  if(y <= 0) return 1ll;
  return powm(x*x%MOD, y/2) * (y%2?x:1ll) % MOD;
}

bool ison(PLL p1, PLL p2, PLL q){
  p1.FF -= q.FF;
  p1.SS -= q.SS;
  p2.FF -= q.FF;
  p2.SS -= q.SS;
  return p1.FF * p2.SS - p1.SS * p2.FF == 0;
}

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

  LL N;
  cin >> N;
  vector<PLL> xs(N);
  cin >> xs;

  LL ans = (powm(2, N) + MOD - N - 1) % MOD;
  set<PLL> memo;
  REP(i,N) REP(j,i){
	VI ps;
	REP(k,N){
	  if(ison(xs[i], xs[j], xs[k])){
		ps.PB(k);
	  }
	}
	SORT(ps);
	auto p = MP(ps[0], ps[1]);
	if(memo.count(p)) continue;
	memo.insert(p);
	ans = (ans + MOD - (powm(2, SZ(ps)) - SZ(ps) - 1)) % MOD;
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long
//typedef long long ll;
#define double long double
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
typedef vector<int> vi;
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e6 + 3;
const double EPS = static_cast<double>(1e-9);
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))

//************************************
#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false); cin.tie();
	//auto beginProgram = chrono::steady_clock::now();
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	int n; cin >> n;
	vi c(n,0), v(n, 0);
	FOR(i, 0, n) { cin >> v[i]; }
	FOR(i, 0, n) { cin >> c[i]; }
	FOR(i, 0, n) { v[i] -= c[i]; }
	int ans = 0;
	FOR(i, 0, n) ans += max(v[i], 0);
	
	cout << ans << endl;
	
  //auto endProgram = chrono::steady_clock::now();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

   int h1, h2, m1, m2, k;

   cin >> h1 >> m1 >> h2 >> m2 >> k;

   int st = h1*60 + m1;
   int en = h2*60 + m2;

   cout << en - st - k << endl;;

   return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
using namespace std;
#define N 3
#define N2 9

struct Puzzle{
int f[N2];
int space;
string path;

bool operator < (const Puzzle &p)const{
for(int i=0;i<N2;i++){
if(f[i]==p.f[i])continue;
return f[i]>p.f[i];
}
return false;
}
};

static const int dx[4]={-1,0,1,0};
static const int dy[4]={0,-1,0,1};
static const char dir[4]={'u','l','d','r'};

bool isTarget(Puzzle p){
for(int i=0;i<N2;i++)
if(p.f[i]!=(i+1))return false;
return true;
}
string bfs(Puzzle s){
queue<Puzzle>Q;
map<Puzzle,bool>V;
Puzzle u,v;
s.path="";
Q.push(s);
V[s]=true;
while(!Q.empty()){
  u=Q.front();
  Q.pop();
  if(isTarget(u))return u.path;
  int sx=u.space/N;
  int sy=u.space%N;
  for(int r=0 ; r<4 ; r++){
    int tx=sx+dx[r];
    int ty=sy+dy[r];
    if(tx<0 || ty<0 || tx>=N || ty>=N)continue;
    v=u;
    swap(v.f[u.space], v.f[tx*N+ty]);
    v.space=tx*N+ty;
    if(!V[v]){
      V[v]=true;
      v.path+=dir[r];
      Q.push(v);
    }
  }
}
return "unsolvable";
}

int main(){
  Puzzle in;
  for(int i=0 ; i<N2 ; i++){
    cin >> in.f[i];
    if(in.f[i]==0){
    in.f[i]=N2;
    in.space=i;
    }
  }
  string ans=bfs(in);
  cout << ans.size() << endl;
  return 0;
}




Measured memory_bytes: 30608
a=input()
b=input()
c=len(a)
d=len(b)

for i in range(c-d+1):
  e=a[c-d-i:c-i]
  for j in range(d+1):
    if j==d:
      print((a[:c-d-i]+b+a[c-i:]).replace("?", "a"))
      exit()
    if e[j]=='?':
      continue
    elif e[j]!=b[j]:
      break
      
print("UNRESTORABLE")


Measured memory_bytes: 3064
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
       break
    for j in range(h):
        for i in range(w):
            if i == 0 or j == 0 or i == w-1 or j == h-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define MOD 1000000000
#define MaX 10000005
#define ll long long
#define slld(t) scanf("%I64d",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%I64d\n",t)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define pb(x) push_back(x)
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define clr(x) memset(x,0,sizeof(x))
#define sws ios::sync_with_stdio(false); cin.tie(0)
#define pi acos(-1)
#define rep(I, N) for (int I = 0; I < (N); ++I)
#define repp(I, a, B) for (int I = (a); I <= (B); ++I)
#define t1(x)                cout<<#x<<": "<<x<<endl
#define t2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
ll pwr(ll base, ll p, ll mod = MOD)
{
    ll ans = 1;
    while(p)
    {
        if(p & 1)   ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        p /= 2;
    }
    return ans;
}
// for inverse modulo : if (1/b)%mod then ans is (b^(mod-2))%mod
ll gcd(ll a, ll b)
{
    if(b == 0)  return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a*b) / gcd(a, b);
}
/*bool isPrime[MaX];
void sieve(int n) 
{
    for(int i = 0; i <= n;++i) 
    {
        isPrime[i] = true;
    }
    isPrime[0] = false;
    isPrime[1] = false;
    for(int i = 2; i * i <= n; ++i) 
    {
         if(isPrime[i] == true) 
         {
             for(int j = i * i; j <= n ;j += i)
                 isPrime[j] = false;
        }
    }
}*/
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.first > b.first);
}
const ll N = 2e5 + 5 ;
int main()
{
    sws;
    //clock_t clk;
    //clk = clock();
    
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
 
    int n, k;
    cin >> n >> k;
    int s = 1;
    rep(i,n) s = min(s+s,s+k);
    cout << s;
 
    //clk = clock() - clk;
    //cout << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

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

int n, m;
vector<vector<int>> roads;
vector<int> d;
set<int> visited;
queue<int> to_visit;
vector<int> orient;
void bfs(int node) {
  to_visit.pop();

  for (int i : roads[node]) {
    if (visited.find(i) != visited.end()) continue;
    d[i] = d[node] + 1;
    orient[i] = node;
    to_visit.push(i);
    visited.insert(i);
  }
  if (to_visit.empty()) return;
  bfs(to_visit.front());
}

int main() {
  cin >> n >> m;
  roads.resize(n);
  d.resize(n);
  orient.resize(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    roads[a].push_back(b);
    roads[b].push_back(a);
  }
  d[0] = 0;
  visited.insert(0);
  to_visit.push(0);
  bfs(0);

  //for (int id : d) cout << id << endl;
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++)
    cout << orient[i] + 1 << endl;
  return 0;
}

Measured memory_bytes: 24664
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int k;
	cin >> k;
	vector<ll> a(k);
	REP(i, k) cin >> a[i];
	ll mi = 2, ma = 2;
	for(int i = k-1; i >= 0; i--){
		ll shomi = (mi + a[i] - 1) / a[i];
		mi = a[i] * shomi;
		ll shoma = ma / a[i];
		ma = a[i] * shoma + a[i] - 1;
	}
	if(mi <= ma) cout << mi << " " << ma << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    if (n == 1){
        cout << "YES" << endl;
        return 0;
    }

    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x % 2 != 0) ++cnt;
    }

    cout << (cnt % 2 == 0?"YES":"NO") << endl;
}

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

int main() {
	int n;
	int l[200];
	int sum=0;
	cin >> n;
	for (int i = 0; i < 2*n; ++i) {
		cin >> l[i];
	}
	sort(l, l + 2 * n, [](int x, int y) {return x < y; });
	for (int i = 0; i < 2 * n; i += 2) {
		sum += l[i];
	}
	cout << sum << endl;
	return 0;
}

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

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e12;
const ll mod = 1e9 + 7;

double graph[1005][1005];

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

    ll xs, ys, xt, yt;

    cin >> xs >> ys >> xt >> yt;

    ll n; cin >> n;

    pair<ll, pair<ll, ll> > pos[n + 2];

    pos[0] = mp(0, mp(xs, ys));

    for (int i = 0; i < n; i++) {
        ll x, y, r;

        cin >> x >> y >> r;

        pos[i + 1] = mp(r, mp(x, y));
    }

    pos[n + 1] = mp(0, mp(xt, yt));


    for (int i = 0; i <= n + 1; i++) {
        for (int j = i+1; j <= n + 1; j++) {
            graph[i][j] = max((sqrt((pos[i].s.f - pos[j].s.f) * (pos[i].s.f - pos[j].s.f)  + (pos[i].s.s - pos[j].s.s) * (pos[i].s.s - pos[j].s.s)) - pos[i].f - pos[j].f), 0.0);
            graph[j][i] = graph[i][j];

            //cout << graph[i][j] << endl;
        }
    }

    //do dijkstras

    bool mark[n+10];


    double dists[n+10];

    dists[0] = 0;
    mark[0] = 0;

    for (int i = 1; i <= n + 1; i++) {
        dists[i] = 1e18;
        mark[i] = 0;
    }

    priority_queue<pair<double, ll>, vector<pair<double, ll> >, greater<pair<double, ll> > > pq;

    pq.push(mp(dists[0], 0));

    while (!pq.empty()) {
        ll u = pq.top().s;

//        cout << u << endl;

        pq.pop();
        if (mark[u]) continue;

        mark[u] = true;

        for (int i = 0; i <= n + 1; i++) {
            if (i == u) continue;

            if (dists[i] > dists[u] + graph[i][u]) {
                dists[i] = dists[u] + graph[i][u];
                pq.push(mp(dists[i], i));
            }
        }

    }

    std::cout << std::setprecision(1000);
    cout << fixed;



    cout << dists[n + 1] << endl;



}


Measured memory_bytes: 15264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define M1 1000000007
#define M2 998244353

#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define bfl(i,a,b) for(ll i=b-1;i>=a;i--)
#define f(i,n)     for(int i=0;i<n;i++)
#define bf(i,n)    for(int i=n-1;i>=0;i--)


#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl

#define bn "\n"

//------------------------------------------------------------------------ 
// #define V(a) vector<a>
// #define vt() vector< tuple < int ,int ,int > > ;
// #define vector< int ,int > pv;
// vector< pair <int,int> > vect;


//------------------------------------------------------------------------

ll modI(ll a,ll m);
ll gcd(ll a,ll b);
ll powM(ll x,ll y,ll m);
ll swap(ll a,ll b);

void swap(ll& a,ll& b)
{
    ll tp=a;
    a=b;
    b=tp;
}

ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    ll ans=1,r=1;
    x%=m;
    while(r>0&&r<=y)
    {
        if(r&y)
        {
            ans*=x;
            ans%=m;
        }
        r<<=1;
        x*=x;
        x%=m;
    }
    return ans;
}
 
ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

//---------------------------------------------------------------------------

// variable = Expression1 ? Expression2 : Expression3
// max = (n1 > n2) ? n1 : n2; 
// (n>m) ? cout<<"True"<<endl:cout<<"false"<<endl ;

// ---------------------------------------------------------------------------	

// int n;cin>>n;int a[n];for(int i=0;i<n;i++)cin>>a[i];    
// for(int i=0;i<n;i++)cout<<a[i];
// int a,b;cin>>a>>b;   

//----------------------------------------------------------------------------

// vector< tuple < int ,int ,int > > tv;
// vector< int ,int > pv;


//----------------------------------------------------------------------------


int main() {
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int tt=1;
   // cin>>tt;
	while(tt--)
	{
	    int k;
	    cin>>k;
	   string s;
	   cin>>s;
	   if(s.length()<=k)
	   cout<<s<<bn;
	   else 
	   {
	       f(i,k)
	       cout<<s[i];
	       cout<<"..."<<bn;
	   }
	   
	   
	   
	    
	}
	
	return 0;
}


Measured memory_bytes: 3648
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const data = input.split('\n').map(v => v.trim())
  const n = Number(data[0].trim())
  const students = data[1].trim().split(' ').map(v => Number(v))
  const order = new Array(n)
  for (let i = 0; i < n; i++) {
    const position = students[i] - 1
    order[position] = i + 1
  }
  console.log(order.join(' '))
}
main()

Measured memory_bytes: 34160
import math          #mathモジュールをインポート

a, b = input().split()#2(空白)16など二つの数値入力する時に　input().split()
x = int(a+b)            #下記の①参照

if math.sqrt(x)%1 == 0: #sqrt()は、数値xの平方根を返します。
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>

using namespace std;

int main() {

	string st;
	int stlen;

	while (cin >> st) {
		stlen = st.size();
		for (int i = stlen - 1; i >= 0; i--) {
			cout << st[i];
		}
		putchar('\n');
	}
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(int, r);

  cout << 3 * r * r << endl;

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);


typedef pair<pii,pii> pp;
int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int main(){
	int h,w;
	while(cin>>w>>h,h|w){
		vs lfield(h);
		vs rfield(h);
		pii rs,ls,rg,lg;
		REP(i,h){
			cin>>lfield[i];
			cin>>rfield[i];
			REP(j,w){
				switch(lfield[i][j]){
				case 'L':
					ls=make_pair(i,j);break;
				case '%':
					lg=make_pair(i,j);break;
				}
				switch(rfield[i][j]){
				case 'R':
					rs=make_pair(i,j);break;
				case '%':
					rg=make_pair(i,j);break;
				}
			}
		}
		static int visited[50][50][50][50]={};
		REP(i,50)REP(j,50)REP(k,50)REP(l,50){
			visited[i][j][k][l]=0;
		}
		visited[ls.first][ls.second][rs.first][rs.second]=1;
		queue<pp> q;
		q.push(make_pair(ls,rs));
		while(!q.empty()){
			pp p=q.front();q.pop();
			pii lp=p.first;
			pii rp=p.second;
			REP(d,4){
				int ly=lp.first+dy[d];
				int lx=lp.second+dx[d];
				int ry=rp.first+dy[d];
				int rx=rp.second+dx[(d+2)%4];
				if(ly<0||lx<0||ly>=h||lx>=w||lfield[ly][lx]=='#'){
					ly=lp.first;
					lx=lp.second;
				}
				if(ry<0||rx<0||ry>=h||rx>=w||rfield[ry][rx]=='#'){
					ry=rp.first;
					rx=rp.second;
				}
				if(!visited[ly][lx][ry][rx]){
					if(!(ly==lg.first&&lx==lg.second&&!(ry==rg.first&&rx==rg.second))&&!(ry==rg.first&&rx==rg.second&&!(ly==lg.first&&lx==lg.second))){
						visited[ly][lx][ry][rx]=1;
						q.push(make_pair(make_pair(ly,lx),make_pair(ry,rx)));
					}
				}
			}
		}
		cout<<(visited[lg.first][lg.second][rg.first][rg.second]?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 26576
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

r = arr_data[0][0]
g = arr_data[0][1]
b = arr_data[0][2]

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




Measured memory_bytes: 3064
//  Be name khoda
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>
using namespace std;

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

#define F first
#define S second
#define MP make_pair

const int MAX = 1e5+9;
const ll MOD = 1e9+7;
const ll inf = 1e9;

vector <pii> g[MAX];
ll s[MAX], num[MAX], ans;
int n, m, vis[MAX], vertex = -1;

void dfs0 (int v) {
	if (vis[v] == -1)
		vis[v] = 0;
	for (auto x : g[v]) {
		int u = x.F;
		if (vis[u] == -1) {
			vis[u] = 1 - vis[v];
			dfs0(u);
			continue;
		}
		if (vis[u] == vis[v])
			vertex = v;
	}
}

void dfs1 (int v) {
	if (vis[v] == -1)
		vis[v] = 0;
	for (auto x : g[v]) {
		int u = x.F;
		int id = x.S;
		if (vis[u] == -1) {
			vis[u] = 1 - vis[v];
			num[u] = s[id] - num[v];
			dfs1(u);
			continue;
		}
		if (u == vertex && vis[u] == vis[v])
			ans = s[id] - (num[v] + num[vertex]);
	}
}

bool ok() {
	for (int v = 0; v < n; v++) {
		if (num[v] <= 0)
			return false;
		for (auto x : g[v]) {
			int u = x.F;
			int id = x.S;
			if (s[id] != num[v] + num[u])
				return false;
		}
	}
	return true;
}

bool ok2() {
	for (int v = 0; v < n; v++) {
		for (auto x : g[v]) {
			int u = x.F;
			int id = x.S;
			if (s[id] != num[v] + num[u])
				return false;
		}
	}
	return true;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u;
		cin >> v >> u >> s[i];
		--v;
		--u;
		g[v].push_back(MP(u, i));
		g[u].push_back(MP(v, i));
	}
	// check odd cycle, if found, jigh bezan
	memset(vis, -1, sizeof vis);
	dfs0(0);
	if (vertex + 1) { // less than one answer
		memset(vis, -1, sizeof vis);
		num[vertex] = 0;
		dfs1(vertex);
		if (ans % 2)
			return cout << "0\n", 0;
		memset(vis, -1, sizeof vis);
		num[vertex] = ans/2;
		dfs1(vertex);
		if (ok())
			return cout << "1\n", 0;
		cout << "0\n", 0;
	} else { // no odd cycle
		memset(vis, -1, sizeof vis);
		vertex = 0;
		num[vertex] = 0;
		dfs1(vertex);
		if (!ok2())
			return cout << "0\n", 0;
		ll mn1 = inf, mn2 = inf;
		for (int i = 0; i < n; i++) {
			if (vis[i] != vis[vertex])	
				mn1 = min(mn1, num[i]-1);
			if (vis[i] == vis[vertex]);
				mn2 = min(mn2, num[i]);
		}
		ll res = max((ll)0, mn1-(-mn2+1)+1);
		cout << res << "\n";
	}
}



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

int main() {
  int N, M;
  cin >> N >> M;
  int A[10000];
  int work_day = 0;
  int rest_day = 0;
  for (int i = 0; i < M; i++) {
    cin >> A[i];
    work_day += A[i];
  }
  if (N >= work_day) {
    rest_day = N - work_day;
  } 
  else {
    rest_day = -1;
  }
  cout << rest_day << endl;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1)
    {
        cout << "Odd" << endl;
    }
    else
    {
        cout << "Even" << endl;
    }
    return 0;
}

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

int compareAbs(int a, int b)
{
  return abs(a) < abs(b) ? a : b;
}

int main()
{
  int N, L;
  cin >> N >> L;
  
  int planned = (L - 1) * N + N * (N + 1) * 1 / 2;

  int minimum = 300;
  for(int i = 1; i <= N; ++i)
  {
    minimum = compareAbs(minimum, L + i - 1);
  }
  
  cout << planned - minimum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
vector<lli> fact;
lli modInverse(lli a, lli m)
{
    
    return llipowerp(a,m-2,m);
    
}
lli nck(lli n,lli k){
    lli ans=1;
    ans=fact[n];
    ans=(ans*modInverse(fact[k],mod2))%mod2;
    ans=(ans*modInverse(fact[n-k],mod2))%mod2;
    return ans;
}
int main(){
    lli n,m,k;
    cin>>n>>m>>k;
    fact.resize(n+1,1);
    fact[0]=1;

    for(lli i=1;i<=n;i++){
        fact[i]=(fact[i-1]*i)%mod2;
    }
    lli ans=0;

    for(lli i=0;i<=k;i++){
       // cout<<ans<<endl;
        ans=(ans+(((nck(n-1,i) * m)%mod2)*llipowerp(m-1,n-i-1,mod2))%mod2 )%mod2;
    }
   // ans=(ans*m)%mod2;
    cout<<ans<<endl;

       
}

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

#define endl '\n'

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

    int n; cin >> n;
    string s; cin >> s;
    for (int i=0; i<s.size(); i++){
        s[i] = (s[i] - 'A' + n)%26 + 'A';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <queue>
using namespace std;

int main(){
    int Q;
    priority_queue<int> que_l;
    priority_queue<int,vector<int>,greater<int>> que_r;
    int64_t sum_l=0,sum_r=0;
    cin>>Q;
    int64_t B=0;
    for(int i=0;i<Q;i++){
        int q;
        cin>>q;
        if(q==1){
            int a,b;
            cin>>a>>b;
            B+=b;
            if(que_l.empty()||a<=que_l.top()){
                que_l.push(a);
                sum_l+=a;
            }else{
                que_r.push(a);
                sum_r+=a;
            }
            while(que_l.size()<que_r.size()){
                int n = que_r.top();
                sum_l+=n; sum_r-=n;
                que_r.pop();
                que_l.push(n);
            }
            while(que_l.size()>que_r.size()+1){
                int n = que_l.top();
                sum_l-=n; sum_r+=n;
                que_l.pop();
                que_r.push(n);
            }
        }else{
            int x=que_l.top();
            int64_t fx = x*que_l.size()-sum_l+sum_r-x*que_r.size()+B;
            cout<<x<<' '<<fx<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

int main(void) {
    int a, b;
    cin >> a >> b;

    int sockets = 1;
    int strips = 0;
    while (sockets < b) {
        sockets--;
        sockets += a;
        strips++;
    }
    cout << strips << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n;
    cin >> n;
    vector <long long> a(n);
    rep(i,n) cin >> a[i];

    if(n==1){
        cout << 1 << endl;
        return 0;
    }

    vector <int> b(n-1);

    for(int i=0; i<=n-2; i++){
        if((a[i+1]-a[i])>0){
            b[i] = 1;
        }
        else if((a[i+1]-a[i]) == 0){
            b[i] = 0;
        }
        else{
            b[i] = -1;
        }
    }
    
    int tmp = b[0];
    int ans = 1;
    for(int i=1; i<n-1; i++){
        if(tmp == 0){
            if(b[i] == 1){
                tmp = 1;
            }
            if(b[i] == -1){
                tmp = -1;
            }
        }
        if(tmp == 1){
            if(b[i] == -1){
                ans++;
                if(i+1<n){
                    tmp = b[i+1];
                }
            }
        }
        if(tmp == -1){
            if(b[i] == 1){
                ans++;
                if(i+1<n){
                    tmp = b[i+1];
                }
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1408
#include<cstring>
#include<iostream>
#include<set>
using namespace std;

int n,m,ans=0;

set<int> s[10];
void search(bool res[], int cur){
  bool check=true;
  for(int i=0;i<n;i++){
    if(!res[i]){
      check=false;
      if(s[cur].find(i)!=s[cur].end()){
        bool tmp[9];
        for(int j=0;j<n;j++){
          tmp[j] = res[j];  
        }
        tmp[i]=true;
        search(tmp, i);
      }
    }
  }
  if(check)ans++;
}

int main(){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a, b;
    cin >> a >> b;
    a--;b--;
    s[a].insert(b);
    s[b].insert(a);
  }
  bool tmp[9];
  memset(tmp, false, sizeof(tmp));
  tmp[0] = true;
  search(tmp, 0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	mysort(a) ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(i==n-1){
			if(k==a.at(i)) ans++ ;
		}else{
			if(k>=a.at(i)){
				ans++ ;
				k -= a.at(i) ;
			}else{
				break ;
			}
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
// #define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e5 + 5;

int n, m;
int a[N], f[N];
int pos[N];

int find(int x) {
	return f[x] == x ? f[x] : f[x] = find(f[x]);
}

void Union(int x, int y) {
	int fx = find(x), fy = find(y);
	if(fx != fy) f[fx] = fy;
}

std::vector<int> v[N];

void run() {
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) f[i] = i, v[i].clear();
	for(int i = 1; i <= m; i++) {
		int x, y; cin >> x >> y;
		Union(x, y);
	}
	for(int i = 1; i <= n; i++) {
		pos[i] = find(i);
		v[find(i)].push_back(a[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(auto it : v[i]) {
			if(pos[it] == i) ++ans;
		}
	}
	cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n >> m) run();
    return 0;
}


Measured memory_bytes: 6912
#include <stdio.h>
#include <math.h>


int main(int argc, char const *argv[])
{
    int x;
    scanf("%d", &x);
    int a;
    scanf("%d", &a);

    if(x < a){
        printf("%d\n", 0);
    }
    else{
        printf("%d\n", 10);
    }

    
    return 0;
} 



Measured memory_bytes: 128