akhauriyash/Code-Regression huggingface dataset:
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int main(){
  lint I,O,T,J,L,S,Z;
  cin>>I>>O>>T>>J>>L>>S>>Z;

  lint res=0;
  {
    lint tmp=O+(J/2)*2+(L/2)*2+(I/2)*2;
    chmax(res,tmp);
  }
  if(J && L && I){
    lint tmp=3;
    --J,--L,--I;
    
    tmp+=O+(J/2)*2+(L/2)*2+(I/2)*2;
    chmax(res,tmp);
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    int r;
    cin>>r;
    cout<<3*r*r<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

ZEN = int(S[:2])
KOU = int(S[2:])
MM = list(range(1,13))
YY = list(range(100))



if ZEN in MM and KOU in MM:
    print("AMBIGUOUS")
elif ZEN in MM and KOU in YY:
    print("MMYY")
elif ZEN in YY and KOU in MM:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
/*
___mennat khoday ra azz o va jall ke taatash mojebe ghorbat ast o be shokr andarash mazide nemat.
___har nafasi ke foro miravad momedde hayatast o chon bar miayad mofarrahe zat.
___pas dar har nafasi 2 nemat mojod ast o bar har nematy shokry vajeb.

___az dast o zabane ke barayad ?
___kaz ohdeye shokrash be dar ayad !


___man be to dami gharar natvanam kard
___va ehsane to ra shomar natvanam kard
####################
___gar bar tane man zaban shavad har moyee
___yek shokre to az hezar natvanam kard

*/

#include <bits/stdc++.h>

#define pb push_back
#define SALI main
#define left(x) ((x)*2)
#define right(x) (((x)*2)+1)
//#define fuck(x) cout << #x << " : " << x << endl;
#define findLowVec(v,x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define findUpVec(v,x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define findLowArr(a,n,x) (lower_bound(a, a+n, x) - a)
#define findUpArr(a,n,x) (upper_bound(a, a+n, x) - a)
#define int long long

using namespace std;

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

template<class A, class B> ostream& operator <<(ostream& out, const pair<A, B> &p)
{return out << "(" << p.first << ", " << p.second << ")";}

template<class A> ostream& operator <<(ostream& out, const vector<A> &v)
{out << "[";for(int i = 0; i < v.size(); i++) {if(i) out << ", ";out << v[i];}return out << "]";}

template<class A,class B> ostream& operator <<(ostream& out, const set<A,B> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}

template<class A> ostream& operator <<(ostream& out, const set<A> &s)
{out << "[";for(auto i = s.begin(); i != s.end(); i++) {out << ", ";out << *i;}return out << "]";}


// there must be no adj ver both in black

const int N = 1e5 + 10;
const int mod = 1e9 + 7;
vector<int> G[N];
int mark[N];
int dp[2][N]; // dp[0][v] v is black ... dp[1][v] v is white

// dp[0][leaf] = 1
// dp[1][leaf] = 1

// dp[0][u] = u-v : dp[1][v1] * dp[1][v2] * ...
// dp[1][u] = u-v : (dp[1][v1] + dp[0][v1]) * (dp[1][v2] + dp[0][v2]) ...

void fuck(int &x) {x %= mod;}

void dfs(int u)
{
    mark[u] = dp[0][u] = dp[1][u] = 1;
    for(auto v : G[u]){
        if(mark[v] == 0){
            dfs(v);
            dp[0][u] *= dp[1][v];
            fuck(dp[0][u]);
            dp[1][u] *= dp[0][v] + dp[1][v];
            fuck(dp[1][u]);
        }
    }
}

int32_t SALI()
{
    int n; cin >> n;
    for(int i = 1; i < n; i++){
        int u,v; cin >> u >> v;
        G[u].pb(v); G[v].pb(u);
    }
    dfs(1);
    cout << (dp[0][1] + dp[1][1]) % mod;

}




/**< WRITEN BY ALI ADELKHAH */



Measured memory_bytes: 18328
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

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

    int c = 0;
    rep(i, min(a, b)) {
        int n = min(a, b) - i;
        if (a % n == 0 && b % n == 0) {
            c++;
            if (c >= k) {
                put(n);
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
map<ll,ll>x;
int main()
{
	int n;
	ll a,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld",&a);
		if(x[a])
		{
			ans--;
			x[a]=0;
		}
		else{
			ans++;
			x[a]=1;
		}
	}
	printf("%lld\n",ans);
    return 0;
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int  a[110];
int main() {
    int n,m;cin>>n>>m;
    int sum=0,suum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        suum+=a[i];
    }
    double xx=1.0*suum/(4.0*m);
    for(int i=1;i<=n;i++){
        if(a[i]*1.0>=xx){
            sum++;
        }
    }
    if(sum>=m){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, a[200001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int j, box[200001] = {}, sum = 0;
	for (i = N; i >= 1; i--) {
		for (j = 2; i * j <= N; j++) a[i] ^= box[i*j];
		box[i] = a[i];
		sum += box[i];
	}
	
	printf("%d\n", sum);
	for (i = 1; i <= N; i++) if (box[i] == 1) printf("%d ", i);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2432
// B - Shift only
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<int> A(N); rp(i, 0, N)cin>>A[i];
	bool active = true;
	int count = 0;
	while(active){
		rp(i, 0, N){
			if(A[i]&1){ active = false; break; }
			A[i]>>=1;
		}
		if(active) count++;
	}
	cout<< count <<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
score = 0

for i in range(N):
    j = A[i] - 1
    if i > 0 and A[i] - A[i-1] == 1:
        score += B[j] + C[j-1]
    else:
        score += B[j]
print(score)

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

int main() {
    int n,m; cin >> n >> m;
    vector<vector<int>> s(m);
    for(int i = 0; i < m; i ++) {
        int k; cin >> k;
        for(int j = 0; j < k; j ++) {
            int tmp; cin >> tmp; tmp --;
            s[i].push_back(tmp);
        }
    }
    vector<int> p(m);
    for(int i = 0; i < m; i ++) cin >> p[i];
    int ans = 0;
    for(int bit = 0; bit < (1<<n); bit ++) {
        bool ok = true;
        for(int i = 0; i < m; i ++) {
            int count = 0;
            for(auto v : s[i]) {
                if(bit & (1<<v)) count ++;
            }
            if(count%2 != p[i]) ok = false;
        }
        if(ok) ans ++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {

	int A, B, C, X;
	cin >> A >> B >> C >> X;

	vector<vector<vector<int>>> Z(A + 1, vector<vector<int>>(B + 1, vector<int>(C + 1)));
	int count = 0;

	for (int i = 0; i <= A; ++i)
	{
		for (int j = 0; j <= B; ++j)
		{
			for (int k = 0; k <= C; ++k)
			{
				Z[i][j][k] = 500 * i + 100 * j + 50 * k;
				if (Z[i][j][k] == X) count++;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 896
N = int(input())

S1 = input()
S2 = input()
MOD = 1000000007

if S1[0] == S2[0]:
    ans = 3
    pre = 1
else:
    ans = 6
    pre = 2
for i in range(1, N):
    if S1[i] == S1[i - 1]: continue
    if S1[i] == S2[i]:
        if pre == 1:
            ans *= 2
        pre = 1
    else:
        if pre == 1:
            ans *= 2
        else:
            ans *= 3
        pre = 2
    ans %= MOD
print(ans)


Measured memory_bytes: 38384
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, S);
    IN(ll, W);
    YES(W >= S, "unsafe", "safe");
}

Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 100
void printstate(int n,int A[]);
int main(void)
{
  int n;
  int i,j,key;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  printstate(n,A);
  for(i=1;i<n;i++)
    {
      key=A[i];
      j=i-1;
      while(j>=0&&A[j]>key)
	{
	  A[j+1]=A[j];
	  j--;
	}
      A[j+1]=key;
      printstate(n,A);
    }
  return 0;
}
void printstate(int n,int A[])
{
  int i;
  for(i=0;i<n;i++)
    {
      if(i>0) printf(" ");
      printf("%d",A[i]);
    }
  printf("\n");
}



Measured memory_bytes: 2036
n = int(input())
h = list(map(int, input().split()))
ans = 0
for k in range(100, 0, -1):
    ans += sum(hi == k for hi in h)
    ans -= sum(hi == hj == k for hi, hj in zip(h, h[1:]))
    h = list(map(lambda x: min(x, k - 1), h))
print(ans)


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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

struct edge{ll from,to,cost;};//?から?まで?コスト
edge es[5000];//辺

vector<ll> d(2501,0);//最短距離

ll N,E,P;//頂点数、辺数

void shortest_path(ll s){ //s番目の頂点からの各点の最短距離を出す
    rep(i,N+1) d[i]=INF;
    d[s]=0;
    rep(j,N*2){
        bool update=false;
        rep(i,E){
            edge e=es[i];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				if(j>=N) d[e.to]=-INF;

                update=true;
            }
        }
        if(!update) break;
		//rep1(i,N) cout<<d[i]<<endl;
    }
}

int main(){
	cin>>N>>E>>P;//辺数
    //Vコの辺の情報入力
    rep(i,E){
        ll from,to,cost; cin>>from>>to>>cost;
        es[i].from=from;
        es[i].to=to;
        es[i].cost=(cost-P)*(-1);
    }

	shortest_path(1);
	if(-d[N]<0) cout<<0;
	else if(-d[N]==INF) cout<<-1;
	else cout<<-d[N];
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	LL n=INT_MAX;
	REP(i,(int)s.size()){
		n=min(n,(LL)abs(753-stoll(s.substr(i,3))));
	}
	cout<<n<<endl;
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			String tmp = sc.nextLine();
			HashSet<String> w = new HashSet<>();
			String last = null;

			for (int i = 0; i < n; i++) {
				tmp = sc.nextLine();
				if (w.contains(tmp)) {
					System.out.println("No");
					return;
				}
				w.add(tmp);
				String first = tmp.substring(0, 1);
				if (last != null && !last.equals(first)) {
					System.out.println("No");
					return;
				}
				last = tmp.substring(tmp.length() - 1);
			}


			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n;
    cin>>n;
    vector<long long>h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    vector<long long>dp(n,INT_MAX);
    dp[0] = 0;
    for(long long i=0;i<n;i++){
        for(long long j=i+1;j<=i+2;j++){
           if(j<n){
               dp[j] = min(dp[j],dp[i] + abs(h[i]-h[j]));
           }
        }
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 4716
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int ans = 0;
        for(char c : s.toCharArray()) {
            if(c=='+') {
                ans++;
            } else if(c=='-') {
                ans--;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int num,A,B; cin >> num >> A >> B;
  int sum = 0;
  int cnt = 0;
  for ( int i = 1; i <= num; i++ ) {
    sum = 0;
    ostringstream oss;
    oss << i;
    string s = oss.str();
    for ( int j = 0; j < s.length(); j++ ) {

      sum += s[j] - '0';
    }

    if ( A <= sum && sum <= B ) {
      cnt+=i;

    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    int n;
    cin >> n;
    unordered_map<int, int> um;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        um[a]++;
    }
    int res = 0;
    for (auto p : um) {
        if (p.first <= p.second) {
            res += p.second - p.first;
        } else {
            res += p.second;
        }
    }
    cout << res << endl;
}




Measured memory_bytes: 7168
N,A,B=map(int,input().split())
s=str(input())
x = 0 #通過者数
y = 0
count = 0
for i in range(len(s)):
  if s[i] == 'a' and x+y < A+B:
    print('Yes')
    x += 1
  elif s[i] == 'b' and x+y < A+B and y < B:
    print('Yes')
    y += 1
  else:
      print('No')

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	string s;
	
	while(cin >> n, n){
		cin >> m >> s;
		
		string str = "I";
		REP(i, n) str += "OI";
		
		int cnt = 0;
		for(int i = 0; i < m; ++i){
			string::size_type t;
			if((t = s.find(str, i)) != string::npos){
				++cnt;
				i = t;
			}else{
				break;
			}
		}		
		
		cout << cnt << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2112
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int x; cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int n;
int c[500];
int s[500];
int f[500];

int main(){
    cin >> n;
    for(int i = 0; i < n-1; i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 0; i < n; i++){
        int t = 0;
        for(int j = i; j < n-1; j++){
            if(t < s[j]) t = s[j];
            else if(t%f[j] == 0);
            else t = t+f[j] - t%f[j];
            t += c[j];
        }
        cout << t << endl;;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<queue>
using namespace std;
typedef tuple<int,int,int> coord; // cost, x, y
char A[1000][1000];
long cost[1000][1000]={1000000};
int h, w;

bool push_around(std::priority_queue<coord, vector<coord>, greater<coord> > &q, int x, int y, int c){
    //cerr << "arnd : " << x << ", " << y << ", " << c << endl;
    int nx, ny;
    bool res=false;
    nx=x, ny=y-1;
    if( (nx>=0)&&(nx<w)&&(ny>=0)&&(ny<h) ){
        if( cost[ny][nx] > c+1 ){
            cost[ny][nx]=c+1;
            q.push(make_tuple(c+1, nx,ny));
            res=true;
        }
    }
    nx=x+1, ny=y;
    if( (nx>=0)&&(nx<w)&&(ny>=0)&&(ny<h) ){
        if( cost[ny][nx] > c+1 ){
            cost[ny][nx]=c+1;
            q.push(make_tuple(c+1, nx,ny));
            res=true;
        }
    }
    nx=x, ny=y+1;
    if( (nx>=0)&&(nx<w)&&(ny>=0)&&(ny<h) ){
        if( cost[ny][nx] > c+1 ){
            cost[ny][nx]=c+1;
            q.push(make_tuple(c+1, nx,ny));            
            res=true;
        }
    }
    nx=x-1, ny=y;
    if( (nx>=0)&&(nx<w)&&(ny>=0)&&(ny<h) ){
        if( cost[ny][nx] > c+1 ){
            cost[ny][nx]=c+1;
            q.push(make_tuple(c+1, nx,ny));            
            res=true;
        }
    }

    return res;
}
int main(){
    cin >> h >> w;
    priority_queue<coord, vector<coord>, std::greater<coord> > q;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cost[i][j]=1000000;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> A[i][j];
            if( A[i][j] == '#'){
                cost[i][j]=0;
                push_around(q, j, i, 0);
            }
        }
    }
    int res = 0;
    while(q.empty()==false){
        coord c = q.top();
        q.pop();
        //if( std::get<0>(c) > res ) res=std::get<2>(c);
        bool b = push_around(q, std::get<1>(c), std::get<2>(c), std::get<0>(c));
    }
    res=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            //cerr << cost[i][j] << ", ";
            if( res < cost[i][j]) res = cost[i][j];
        }
        //cerr << endl;
    }
    cout << res << endl;

}


Measured memory_bytes: 21996
#include <bits/stdc++.h>
using namespace std;
//actual solution is at bottom//
////<pbds>////
/*OPTIONAL
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using Tree = tree<T, null_type, less<T>, 
    rb_tree_tag, tree_order_statistics_node_update>; 
// change null_type for map
#define ook order_of_key
#define fbo find_by_order
*/
///</pbds>///

#define int long long int
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()

///<constants>///
const int MOD = 1e9+7; // 998244353; // = (119<<23)+1
const int MX = 2e5+5; 
const ll INF = 1e18; 
const ld PI = 4*atan((ld)1); 
const int xd[4] = {0,1,0,-1}, yd[4] = {1,0,-1,0};
///</constants>///

///<IO>/// 
namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
        // cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}
 
using namespace io;
///</IO>///

///<execution-time>///
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
/*example for clock usage
    clock_t z = clock();
    debug("Total Time: %.3f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
*/
///</execution-time>///

inline void google(int i){
    cout<<"Case #"<<i<<" :";
}
vector<vector<int>> adj;
vector<int> dp;
int mx=1;
vector<bool> v;
void dfs(int u){
    for(int i:adj[u])if(!v[i]&&i!=0)dfs(i);
    v[u]=1;
    int tmp=0;
    for(int i:adj[u]){
        if(i!=0)
        dp[u]=max(dp[u],1+dp[i]);
    }
    mx=max(mx,dp[u]);
}
signed main(){
    setIO("");
    int n,m;cin>>n>>m;
    adj.resize(n+1);
    dp.resize(n+1,1);
    v.resize(n+1,false);
    for(int i=0;i<m;i++){
        int u,v;cin>>u>>v;
        adj[u].pb(v);
    }
    for(int i=1;i<=n;i++){
        if(!v[i]){
            dfs(i);
        }
    }
    cout<<mx-1;
    return 0;
}
/* stuff you should look for
    * check whether you have read the problem correctly
    * int overflow, array bounds
    * special cases (n=1?), slow multiset operations
    * do smth instead of nothing and stay organized
*/

Measured memory_bytes: 11492
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  long long H, W;
  string C[300];

  cin >> H >> W;

  for (int i = 0; i < H; i++) {
    cin >> C[2*i];
    C[2*i+1] = C[2*i];
  }

  for (int i = 0; i < H*2; i++)
    cout << C[i] << endl;
  return 0;
}


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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int a, b;
string s, t, u;

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s) --a;
	if (u == t) --b;
	cout << a << " " << b << endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 256
N = int(input())
data = [list(map(int,input().split())) for i in range(N-1)]

G = {}

for i in range(1,N+1):
    G[i] = []

for i in range(N-1):
    G[data[i][0]].append((data[i][1],i+1))
    G[data[i][1]].append((data[i][0],i+1))

M = max(len(G[i]) for i in range(1,N+1))

print(M)

from collections import deque

E = [0]+[-1]*(N-1)  #辺
E[1] = 1
q = deque([[data[0][0],1],[data[0][1],1]])

while q:
    n,i = q.pop()
    c = 1
    for dn,di in G[n]:
        if E[di] != -1:
            continue
        else:
            if c == E[i]:
                E[di] = M
                c += 1
                q.append([dn,di])
            else:
                E[di] = c
                c += 1
                q.append([dn,di])
for i in range(1,N):
    print(E[i])

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

typedef long long ll;

int main() {
    int N, K, A, d, ans = 0;
    cin >> N >> K;
    vector<int> B(N, 1);
    rep(i, K) {
        cin >> d;
        rep(j, d) {
            cin >> A;
            B[A - 1] = 0;
        }
    }
    rep(i, N) ans += B[i];
    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll dp[100100][13];
void solve(){
    string s;
    cin >> s;
    int n=s.size();
    if(s[0]=='?'){
        rp(i,10){
            dp[0][i]=1;
        }
    }else{
        dp[0][s[0]-'0']=1;
    }
    repi(i,1,n){
        if(s[i]!='?'){
            int a=s[i]-'0';
            rp(j,13){
                dp[i][(j*10+a)%13]=dp[i-1][j];
            }
        }else{
            rp(a,10){
                rp(j,13){
                    dp[i][(j*10+a)%13]+=dp[i-1][j];
                    dp[i][(j*10+a)%13]%=Mod;
                }
            }
        }
    }
    print(dp[n-1][5]);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 10604
function Main (input) {
  var inputs = input.split(/\s/g);
  var strLength = inputs[0].length;
  var baseStr = inputs[0];
  var isSuccess = false;
  for (var index = 0; index < strLength; index += 1) {
    var newStr = baseStr.charAt(strLength - 1) + baseStr.slice(0, strLength - 1);
    if (newStr === inputs[1]) {
      isSuccess = true;
    } else {
      baseStr = newStr;
    }
  }
  console.log('%s',isSuccess ? 'Yes' : 'No');
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll gcd(ll a2,ll b2){
	ll t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}
ll lcm(ll a1,ll b1){
	if(a1*b1==0){return 0;}
	return (a1*b1/gcd(a1,b1));
}

int main() {

	int c[4][4],a[4];
	rep(i,3)rep(j,3)cin>>c[j][i];
	a[0]=0;
	a[1]=c[0][1]-c[0][0];
	a[2]=c[0][2]-c[0][0];
	rep(j,2){
		rep(i,2){
			if(a[i+1]!=c[j+1][i+1]-c[j+1][0]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

H,W=map(int,input().split())
sh,sw=map(int,input().split())
gh,gw=map(int,input().split())
MAP=[input().strip() for i in range(H)]

ANS=[[1<<30]*W for i in range(H)]

sh-=1
sw-=1
gh-=1
gw-=1

ANS[sh][sw]=0

Q=deque([(sh,sw)])

while Q:
    x,y=Q.popleft()

    for i,j in [(x-2,y-2),(x-2,y-1),(x-2,y),(x-2,y+1),(x-2,y+2),(x-1,y-2),(x-1,y-1),(x-1,y),(x-1,y+1),(x-1,y+2),(x,y-2),(x,y-1),(x,y+1),(x,y+2),(x+1,y-2),(x+1,y-1),(x+1,y),(x+1,y+1),(x+1,y+2),(x+2,y-2),(x+2,y-1),(x+2,y),(x+2,y+1),(x+2,y+2)]:
        if 0<=i<H and 0<=j<W:
            if MAP[i][j]=="." and abs(i-x)+abs(j-y)==1 and ANS[i][j]>ANS[x][y]:
                ANS[i][j]=ANS[x][y]
                Q.appendleft((i,j))
            elif MAP[i][j]=="." and abs(i-x)+abs(j-y)>1 and ANS[i][j]>ANS[x][y]+1:
                ANS[i][j]=ANS[x][y]+1
                Q.append((i,j))

if ANS[gh][gw]==1<<30:
    print(-1)
else:
    print(ANS[gh][gw])



Measured memory_bytes: 91556
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
#define vi vector<int>
#define vvi vector<vector<int>>
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    int ans =0;
    rep(i,1,k+1){
        rep(j,1,k+1){
          rep(l,1,k+1){
            ans+=__gcd(l,__gcd(j,i));
          }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.Scanner;

//Chebyshev's Theorem
public class Main{

	public static void main(String[] args) {
		boolean[] p = new boolean[123456*2+1];
		Arrays.fill(p, true);
		p[0]=p[1]=false;
		for(int i=2;i<p.length;i++)if(p[i])for(int j=i*2;j<p.length;j+=i)p[j]=false;
		int[] c = new int[p.length];
		for(int i=1;i<p.length;i++)c[i] = c[i-1]+(p[i]?1:0);
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			System.out.println(c[2*n]-c[n]);
		}
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n;cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  rep(i,n){
    cin>>s[i]>>t[i];
  }
  string x;cin>>x;
  int ans=0;
  bool tag=false;
  rep(i,n){
    if(!tag){
      if(s[i]==x)tag=true;
    }
    else{
      ans+=t[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

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

using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 max_len;
struct DirectedGraph{
    int V;

    vector<vector<int>> to;
    vector<vector<int>> from;

    vector<int> vs;
    vector<int> depth;
    vector<bool> used;
    vector<int> cmp;

    void dfs(int v){
        used[v]=true;
        for(auto t:to[v]) if(!used[t]) dfs(t);
        vs.push_back(v);//帰りがけ
    }
    //k:始点,rdfsがkに戻る→強連結成分
    int r_dfs(int v,int k){
        int ret=0;
        used[v]=true;
        cmp[v]=k;
        for(const auto t:from[v]){
            if(!used[t]) r_dfs(t,k);
            depth[v]=max(depth[v],depth[t]+1);
        }
    }
    DirectedGraph(int V) : V(V),
        to(vector<vector<int>>(V)),
        from(vector<vector<int>>(V)),
        cmp(vector<int>(V)),
        depth(vector<int>(V))
        {}
    
    void add_edge(int from_,int to_){
        to[from_].push_back(to_);
        from[to_].push_back(from_);
    }


    //強連結成分:任意の2頂点を行き来できる部分グラフ
    //順方向帰りがけdfsと逆方向行き止まりまでdfs
    //強連結成分分解O(|V|+|E|)
    int scc_num=-1;
    //scc_num:強連結成分の個数を返す
    int scc(){
        used=vector<bool>(V,false);
        vs.clear();
        for(int v=0;v<V;v++) if(!used[v]) dfs(v);
        used=vector<bool>(V,false);
        scc_num=0;
        for(int i=vs.size()-1;i>=0;i--)if(!used[vs[i]]){
            max_len=max(max_len,r_dfs(vs[i],scc_num++));
        }
        return scc_num;
    }

    //sccの後潰してトポロジカル順序のグラフを作る
    DirectedGraph makeTopologicalGraph(){
        DirectedGraph TG(scc_num);
        rep(s,V) for(auto t:to[s]){
            if(cmp[s]!=cmp[t]) TG.add_edge(cmp[s],cmp[t]);
        }
        return TG;
    }
};


int main(){
    int n;
    cin>>n;
    DirectedGraph g(n*n+1);

    rep(i,n){
        int a[n-1];
        rep(j,n-1){
            cin>>a[j];
            a[j]--;
        }
        //n進数2桁的なノリ
        rep(j,n-1) a[j]=min(i,a[j])*n+max(i,a[j]);
        rep(j,n-2) g.add_edge(a[j],a[j+1]);
    }
    int s=g.scc();
    if(s!=n*n+1){
        cout<<-1<<endl;return 0;
    }
    int ans=0;
    for(auto x:g.depth){ans=max(ans,x);}cout<<ans+1<<endl;
    return 0;
}


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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string a, b; cin >> a >> b;
    int n = a.size(), k =0;
    rep(i,n) k += (a[i] != b[i]);
    cout << k;
}



Measured memory_bytes: 3792
<?php
fscanf(STDIN, "%d", $k);
fscanf(STDIN, "%d %d", $a, $b);

for($i=$a;$i <= $b; $i++){
  if($i % $k == 0){
    $str = "OK";
    break;
  };
};

if($str == "OK"){
  echo $str;
} else {
  echo "NG";
};

?>

Measured memory_bytes: 16048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  vector<ll> a(N);
  ll sum = 0;
  REP(i,N){
    cin >> a[i];
    sum += a[i];
  }
  ll dist = 1e18;
  ll ans;
  IREP(i,N){
    if(abs(N*a[i]-sum)<=dist){
      dist = abs(N*a[i]-sum);
      ans = i;
    }
  }
  cout << ans << endl;
}

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

int main(void) {
	int n, m;
	scanf("%d %d", &n, &m);
	
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < m; j++) {
			std::string input;
			std::cin >> input;

			if (input == "snuke") {
				printf("%c%d\n", j + 'A', i);
			}
		}
	}

}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void){
    ll n;
    cin>>n;

    ll ans=0;
    vector<pair<ll,ll>> res;
    for(ll a=2;a*a<=n;a++){
        if(n%a==0){
            int ex=0;
            while(n%a==0){
                ++ex;
                n /=a;
            }
            res.push_back({a,ex});
        }
    }
    if(n !=1)res.push_back({n,1});
    
    for(auto i:res){
        int ex=1;
        while(i.second>=ex){
            i.second-=ex;
            ex++;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3596
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long N; cin >> N;
	vector<pair<long, long>> A(N);

	for (int i = 0; i < N; i++) {
		long a; cin >> a;
		A[i] = make_pair(a, i + 1);
	}

	sort(A.begin(), A.end());

    for (int i = 0; i < N; i++){
        cout << A[i].second;
        if (i == N - 1) cout << endl; else cout << " ";   
    }
}

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

int A, B, C, D;

int main(void){
    
    cin >> A >> B >> C >> D;
    int start = (A > C) ? A : C;
    int end = (B < D) ? B : D;
    if(end - start <= 0) cout << 0 << endl;
    else cout << end - start << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
#define mod 998244353
#define N 1002300
ll jc[N],inv[N];
ll qpow(ll base,ll n)
{
	if (n==1) return base%mod;
	if (n==0) return 1;
	ll ans=base%mod;n--;
	while(n)
	{
		if (n&1) ans=ans*base%mod;
		base=base*base%mod;
		n>>=1;
	}
	return ans%mod;
}
ll C(ll n,ll m)
{
	if (m==0) return 1;
	if (m>n) return 0;
	return jc[n]%mod*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	ll n,A,B,k,y,ans=0;
	scanf("%lld%lld%lld%lld",&n,&A,&B,&k);
	jc[0]=1;
	for (ll i=1;i<=n;++i) jc[i]=jc[i-1]*i%mod;
	inv[n]=qpow(jc[n],mod-2);
	for (ll i=n-1;i>=0;--i) inv[i]=inv[i+1]*(i+1)%mod;
	if ((A+B)*n<k)
	{
		printf("0");
		return 0;
	}
	if (k==0)
	{
		printf("1");
		return 0;
	}
	for (ll x=0;x<=n;++x)
	{
		y=(k-A*x)/B;
		if (y*B!=k-A*x||y<0||y>n) continue;
		ans=(ans+(C(n,x)*C(n,y)%mod))%mod;
	}
	printf("%lld",(ans%mod+mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  char c;
  cin >> c;
  if (islower(c)) cout << "a" << endl;
  else cout << "A" << endl;
  return 0;
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n, k;
  //string s;
  cin >> n >> k;
  //ll ans = n;
  
  if(n%k == 0)
    n = 0;
  else{

    
    ll m = k + n%k;
    
    rep(i,0,3){
      n = min(n, m);
      m = abs(m - k);
    }
  }

  
  cout << n << endl;
}





Measured memory_bytes: 384
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
Sunny
---+/
/+---test
Rainy
---+/

void main(string[] args) {
  const S = readln.chomp;
  [
    "Sunny":  "Cloudy",
    "Cloudy": "Rainy",
    "Rainy":  "Sunny",
  ][S].writeln;
}


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

using namespace std;

int dp[1 << 15][15];

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

    int INF = 15000;
    int V, E;
    cin >> V >> E;
    
    int d[V][V];
    for (int i = 0; i < V; ++i) {
        fill(d[i], d[i] + V, INF);
    }
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        cin >> d[s][t];
    }
    for (int s = 0; s < 1 << V; ++s) {
        fill(dp[s], dp[s] + V, INF);
    }

    dp[(1 << V) - 1][0] = 0;

    for (int s = (1 << V) - 2; s >= 0; --s) {
        for (int v = 0; v < V; ++v) {
            for (int u = 0; u < V; ++u) {
                if (!(s >> u & 1)) {
                    dp[s][v] = min(dp[s][v], dp[s | 1 << u][u] + d[v][u]);
                }
            }
        }
    }

    if (dp[0][0] < INF) {
        cout << dp[0][0] << '\n';
    } else {
        cout << -1 << '\n';
    }

    return 0;
}



Measured memory_bytes: 5096
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i=0;i<=(b);i+=(a))
using namespace std;
typedef long long ll;
int a,b,c,d,e,f;
int ans1, ans2;
double ans3=-1;
inline int re() {
	int x = 0; char ch = getchar(); bool f = 0;
	for(; ch>'9'||ch<'0'; ch = getchar()) if(ch=='-')f=1;
	for(; ch>='0'&&ch<='9'; ch = getchar()) x = (x<<1)+(x<<3)+ch-48;
	if(f) return -x;
	return x;
}
int main() {
	a = re(); b = re(); c = re(); d = re(); e = re(); f = re();
	ll tot = 0;
	for(int A = 0; ; A+=a) {
		tot += 100*A;
		if(tot>f) break;
		for(int B = 0; ; B+=b) {
			tot += 100*B;
			if(tot>f) {tot-=100*B; break;}
			for(int C = 0;; C+=c) {
				tot += C;
				if(tot>f||A+B==0||(double)C/(A+B)>e)
				{tot-=C; break;}
				for(int D = 0;; D+=d) {
					tot += D;
					if(tot>f || A+B==0 || (double)(C+D)/(A+B)>e){tot-=D; break;}
					if(ans3 < (double)(C+D)/(C+D+(A+B)*100)) {
						ans1 = tot;
						ans2 = C+D;
						ans3 = (double)(C+D)/(C+D+(A+B)*100);
					}
					tot -= D;
				}
				tot -= C;
			}
			tot -= 100*B;
		}
		tot -= 100*A;
	}
	printf("%d %d\n",ans1, ans2);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
const double PI=3.14159265358979323846;
 
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {

	int x;
	cin >> x;

	int fff = x / 500;
	int f = (x - fff*500) / 5;

	int ans = fff * 1000 + f * 5;

	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
int N,M,s[5],c[5],i,a=0;
int X[4];
X[1]=-1;
X[2]=-1;
X[3]=-1;

cin >> N >> M;
for(i=1;i<=M;i++){cin >> s[i] >> c[i];}

for(i=1;i<=M;i++){if((X[s[i]]==-1)||(X[s[i]]==c[i])){X[s[i]]=c[i];}else{a--;
break;}
    if(s[i]==1&&c[i]==0&&N!=1){a--;}
}
if(a==0){for(i=1;i<=N;i++){
if(i==1&&X[i]==-1&&N!=1){X[i]=1;}
if(i==1&&X[i]==-1&&N==1){X[i]=0;}
if((i==2||i==3)&&X[i]==-1){X[i]=0;}
}
}
if(a<0){cout << "-1";}else{
for(i=1;i<=N;i++){cout << X[i];}}
cout << endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    int a, b;
    std::cin >> a >> b;
    //tapは出力のtap数
    //outletは増える口の数
    int tap=0, outlet=1;

    while(outlet<b){
        outlet = outlet + a -1;
        tap++;
    }

    std::cout << tap << std::endl;
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto S = sread();
    long[2] cnt;
    foreach (c; S)
        cnt[c - 'A']++;
    writeln((cnt[0] * cnt[1] != 0) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int n;
int main(){
	scanf("%d",&n);
	int p=1,pp=1;
	for(int i=1,a;i<=n;i++){
		p*=3;
		scanf("%d",&a);
		if(a%2==0)pp*=2;
	}
	printf("%d",p-pp);
	return 0;
}

Measured memory_bytes: 128