akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct CWW{
    CWW(){
        cin.tie(0);
        ios_base::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    }
}STAR;

using D=double;

const D EPS=1e-8;
const D INF=1e9;

using Point=complex<D>;

struct Segment{
    Point p1,p2;
    Segment(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Line{
    Point p1,p2;
    Line(const Point &p1=Point(),const Point &p2=Point()):p1(p1),p2(p2){}
};

struct Circle{
    Point c;
    D r;
    Circle(const Point &c=Point(),const D &r=0.0):c(c),r(r){}
};

using Polygon=vector<Point>;

istream& operator>>(istream &is,Point &a){
    D x,y;
    is>>x>>y;
    a=Point(x,y);
    return is;
}

ostream& operator<<(ostream& os,const Point &a){
    os<<real(a)<<" "<<imag(a);
    return os;
}

istream& operator>>(istream &is,Line &l){
    Point p1,p2;
    is>>p1>>p2;
    l=Line(p1,p2);
    return is;
}



D dot(const Point &a,const Point &b){
    return real(a)*real(b)+imag(a)*imag(b);
}

D cross(const Point &a,const Point &b){
    return real(a)*imag(b)-imag(a)*real(b);
}

Point projection(const Point &a,const Point &b){
    return a*real(b/a);
}

Point projection(const Line &l,const Point &a){
    return l.p1+projection(l.p2-l.p1,a-l.p1);
}

Point reflection(const Line &l,const Point &a){
    Point p=projection(l,a);
    return 2.0*p-a;
}


int main(){
    Line L;
    cin>>L;
    int Q;cin>>Q;
    while(Q--){
        Point p;
        cin>>p;
        cout<<reflection(L,p)<<endl;
    }

    return 0;
}

Measured memory_bytes: 3304
#include<stdio.h>

int main(void)
{
	int x, y, w, h,n;
	int x1, y1, a;
	int i;
	x = 0;
	y = 0;
	scanf("%d%d%d", &w, &h, &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d%d%d", &x1, &y1, &a);
		switch (a)
		{
		case 1: 
		{
			if (x1 > x) x = x1;
			continue;
		}
		case 2:
		{
			if (x1 < w) w = x1;
			continue;
		}
		case 3:
		{
			if (y1 > y) y = y1;
			continue;
		}
		case 4:
		{
			if (y1 < h) h = y1;
			continue;
		}
		}
	}
	if (w <= x||h<=y) printf("0\n");
	else printf("%d\n", (w - x)*(h - y));
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
acwa=[[] for _ in range(n)]
for i in range(m):
    pp,ss = input().split()
    acwa[int(pp)-1].append(ss)

n_ac=0
n_wa=0
for i in range(n):
    if "AC" in acwa[i]:
        n_ac +=1
        n_wa +=acwa[i].index("AC")
print(n_ac,n_wa) 

Measured memory_bytes: 58144
import sys

n, y = map(int, sys.stdin.readline().split())
y //= 1000

def main():
    for i in range(n + 1):
        if 10 * i > y: break
        for j in range(n - i + 1):
            k = n - i - j
            if 10 * i + 5 * j + k == y:
                print(i, j, k)
                return
    print(-1, -1, -1)


if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

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

		 while(true){
		 int H = sc.nextInt();
		 int W = sc.nextInt();
		 if(H==0 && W==0) break;

		 for(int i=0 ; i<H ; i++){
			   for(int j=0 ; j<W ; j++) {
			    if((i+j)%2==0) {
			    System.out.print('#');
		    }else {
			      System.out.print('.');
			    }
			   }
			   System.out.println("");
		 }
		 System.out.println("");
		 }
	}
}


Measured memory_bytes: 39484
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int hp=0;
        while(x>=500){
            x-=500;
            hp+=1000;
        }
        while(x>=5){
            x-=5;
            hp+=5;
        }
        System.out.println(hp);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

string grade(const int mid, const int fin, const int retest) {
  const int sum = mid + fin;
  string g;

  if (mid == -1 || fin == -1) {
    g = "F";
  } else if (sum >= 80) {
    g = "A";
  } else if (sum >= 65) {
    g = "B";
  } else if (sum >= 50 || retest >= 50) {
    g = "C";
  } else if (sum >= 30) {
    g = "D";
  } else {
    g = "F";
  }

  return g;
}

int main() {
  while (true) {
    int mid, fin, retest;
    cin >> mid >> fin >> retest;
    if (mid == -1 && fin == -1 && retest == -1) break;
    cout << grade(mid, fin, retest) << endl;
  }
  return 0;
}



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

int main()
{
    cout << fixed << setprecision(12);
    int n,w;
    pair<double, pair<double,double> > a[100000];

    cin >> n >> w;
    for(int i=0;i < n;i++){
        cin >> a[i].second.first >> a[i].second.second;
        a[i].first = a[i].second.first/a[i].second.second;
    }
    
    sort(a,a+n);
    reverse(a,a+n);
    double ans=0;
    double rest=0;

    for(int i=0;i < n;i++){
        if(w-rest <= a[i].second.second){
            ans += a[i].second.first*(double)(w-rest)/a[i].second.second;
            break;
        }
        else{
            ans += a[i].second.first;
            rest += a[i].second.second;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
import java.util.*;
import java.io.*;
public class Main{
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	
	public static void main(String[] args) {
		FastReader in = new FastReader();
		
			int n = in.nextInt();
			int[] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = in.nextInt(); 
			}
			Arrays.sort(array);
			int ans = 0;
			for(int i = 0; i < n-2; i++){
				for(int j = i+1; j < n-1; j++){
					for(int k  = j+1; k < n; k++){
						if(array[i] + array[j] > array[k] && array[i]!=array[j] && array[j]!=array[k] && array[k]!=array[i]){
							ans++;
						}
					}
				}
			}
			System.out.println(ans);
	}
}

Measured memory_bytes: 33300
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;cin>>N;
  int R=pw(2,N);
  typedef pair<int,int> P;
  set<P> s;
  for(int i=0;i<R;i++){
    int a;cin>>a;a*=2;
    s.insert(P(a,i));
  }
  s.insert(P(-LINF,0));
  std::vector<P> w(R);
  w[0]=*(--s.end());s.erase(w[0]);
  for(int i=0;i<N;i++){
    for(int j=0;j<pw(2,i);j++){
      P p=*--s.lower_bound(P(w[j].first-1,0));
      if(p.first<-100000000)fin("No");
      w[j+pw(2,i)]=p;s.erase(p);
    }
  }
  fin("Yes");
}


Measured memory_bytes: 20736
n, m = map(int,input().split())
h_lst = list(map(int,input().split()))
ab_lst = [list(map(int,input().split())) for _ in range(m)]
lst = [1] * n

for i in range(m):
    a = ab_lst[i][0]
    b = ab_lst[i][1]
    h_a = h_lst[a-1]
    h_b = h_lst[b-1]

    if h_a==h_b:
        lst[a-1] = 0
        lst[b-1] = 0

    else:
        if h_a==min(h_a, h_b):
            lst[a-1] = 0
        else:
            lst[b-1] = 0

count = 0
for i in range(n):
    if lst[i]==1:
        count += 1

print(count)

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

int main()
{
    string S;
    cin >> S;
    int ans = 1 << 30;
    for (int j = 0; j < S.size()-2; ++j)
    {
        string s = S.substr(j, 3);
        int x = stoi(s);

        ans = min(ans, abs(753 - x));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e6+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

int q[6],p[6],r[6];
LL n;
bool cmp(const int a,const int b){
    return 1.0*q[a]/p[a] < 1.0*q[b]/p[b];
}

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif

    for(int i = 1 ; i <= 4 ; i++){
        scanf("%d",q+i);
        p[i] = i == 1 ? 1 : p[i-1] * 2;
        r[i] = i;
    }
    sort(r+1,r+5,cmp);
    scanf("%lld",&n);
    n<<=2;
    LL ans = 0;
    for(int i = 1 ; n && i < 5 ; i++ ){
        //printf("r[i] = %d , n = %d , p[r] = %d\n",r[i],n,p[r[i]]);
        if( n >= p[r[i]] ){
            LL cnt = n / p[r[i]];
            ans += cnt * q[r[i]];
            n -= cnt * p[r[i]];
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
// abc177_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


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


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<int> A(N);
    REP(i, N) cin >> A[i];

    bool pairwise = true;

    vector<int> res(1e6+1);
    REP(i, N){
        ll tmp = A[i];
        for (ll a = 2; a * a <= A[i]; a++) {
            int cnt = 0;
            while (tmp % a == 0){ cnt++; tmp /= a; }
            if (cnt > 0) {
                if (res[a] > 0) {
                  pairwise = false;
                  break;
                }
                res[a]++;
            }
        }
        if (tmp > 1) {
            if (res[tmp] > 0) {
                pairwise = false;
                break;
            }
            res[tmp]++;
        }

        if (pairwise == false) break;
    }
//    print(res);

//    for (auto e: res){
//        if (e.second >= 2){
//            pairwise = false;
//            break;
//        }
//    }

    if (pairwise){
        print("pairwise coprime");
        return 0;
    }

    int d = 0;
    REP(i, N){
        d = gcd(A[i], d);
    }

//    print(d);

    if (d == 1){
        print("setwise coprime");
    } else {
        print("not coprime");
    }


    return 0;
}


Measured memory_bytes: 11076
# Aizu Problem 0023: Circles Intersection
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def check_circles(xa, ya, ra, xb, yb, rb):
    dist = math.sqrt((xa - xb)**2 + (ya - yb)**2)
    if dist > ra + rb:
        return 0
    if ra > rb and dist < ra - rb:
        return 2
    if rb > ra and dist < rb - ra:
        return -2
    return 1
    
N = int(input())
for n in range(N):
    xa, ya, ra, xb, yb, rb = [float(_) for _ in input().split()]
    print(check_circles(xa, ya, ra, xb, yb, rb))

    

Measured memory_bytes: 7760
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=4*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
LL A[SIZE],B[SIZE],C[SIZE];

int main(){
	string s;
	LL x,y,z;
	LL ans;
	LL N,K;
	cin >> K >> N;
	if(K%2==0){
		REP(i,N){
			if(i) cout << " "<<K;
			else cout << K/2;
		}
		cout << endl;
	}
	else{
		LL C=N/2;
		REP(i,N) A[i]=K/2+1;
		int now=N-1;
		REP(i,C){
			if(A[now]){
			//	cout << now << " " <<A[now] << endl;
				A[now]--;
				if(A[now]==0) now--;	
				else if(now!=N-1){
					FOR(i,now+1,N) A[i]=K;
					now=N-1;
				}
			} 
		}
		REP(i,N){
			if(A[i]==0) break;
			if(i) cout << " "<<A[i];
			else cout <<A[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 4736
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		List<Integer> arrayCntJOI = new ArrayList<>();
		List<Integer> arrayCntIOI = new ArrayList<>();
		
		while(sc.hasNext()) {
			String str = sc.next();
			
			char[] charStr = str.toCharArray();

			int cntJOI = 0, cntIOI = 0;
			
			for(int i = 2; i < charStr.length; i++) {
				
				if(String.valueOf(charStr[i - 2] + "" + charStr[i - 1] + "" + charStr[i]).equals("JOI")) {
					cntJOI++;
				}
				
				if(String.valueOf(charStr[i - 2] + "" + charStr[i - 1] + "" + charStr[i]).equals("IOI")) {
					cntIOI++;
				}
			}
			
			arrayCntJOI.add(cntJOI);
			arrayCntIOI.add(cntIOI);
		}
		
		for(int i = 0; i < arrayCntJOI.size(); i++) {
			System.out.println(arrayCntJOI.get(i));
			System.out.println(arrayCntIOI.get(i));
		}
	}
}

Measured memory_bytes: 30096
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

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

    long long s=0, a,b,c,d,k;
    cin>>a>>b>>c>>k;
    if(a>=k && k!=0)
    {
        s=k;
        k=0;
    }
    else if(a<k && k!=0)
    {
        s=a;
        k-=a;
    }
    if(b>=k && k!=0)
    {
        k=0;
    }
    else if(b<k && k!=0 )
    {
        k-=b;
    }
    if(c>=k && k!=0)
    {
        s-=k;
    }
    else if(a<k && k!=0)
    {
        s-=c;
    }
    cout<<s;
    return 0;
}

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

int main()
{
    typedef std::numeric_limits< double > dbl;


    float circum, pi;
    int r;
    cin>>r;
    pi = 6.28318530717958623200/2;
    cout.precision(20);

//    cout.precision(dbl::max_digits20);

    cout<<2*pi*r<<fixed;


}




Measured memory_bytes: 3788
H, W = map(int, input().split())
HW_graph = [list(input()) for _ in range(H)]


def bfs(graph: list):
    one_steps = ((1, 0), (-1, 0), (0, 1), (0, -1))
    seen = set()
    seen.add((0, 0))
    todo = [(0, 0)]
    cost = {(0, 0): 1}
    while todo:
        x, y = todo.pop(0)
        for dx, dy in one_steps:
            nx, ny = x + dx, y + dy
            if not (0 <= nx < H) or not (0 <= ny < W):
                continue
            if (nx, ny) in seen:
                continue
            if graph[nx][ny] == ".":
                todo.append((nx, ny))
                seen.add((nx, ny))
                cost[(nx, ny)] = cost[(x, y)] + 1
                if nx == H - 1 and ny == W - 1:
                    return cost[(nx, ny)]
    return -1


white = 0
for line in HW_graph:
    white += line.count(".")

cost = bfs(HW_graph)
if cost == -1:
    print(cost)
else:
    print(white - cost)


Measured memory_bytes: 3700
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N, Q;
	cin >> N >> Q;
	vector<vector<ll>>V(N);
	for (int i = 0; i < N; i++) {
		ll S, T, X;
		cin >> S >> T >> X;
		V[i] = { X,S,T };
	}
	sort(all(V));

	vector<ll>D(Q);
	vector<ll>ans(Q,-1);
	set<ll>st;
	map<int, int>mp;
	for (int i = 0; i < Q; i++) {
		cin >> D[i];
		st.insert(D[i]);
		mp[D[i]] = i;
	}

	for (int i = 0; i < N; i++) {
		if (st.size() == 0)break;
		ll X = V[i][0];
		ll S = V[i][1];
		ll T = V[i][2];
		ll left = S - X ;
		ll right = T - X;
		auto idx = st.lower_bound(left);
		while (idx != st.end()) {
			ll cand = *idx;
			if (cand < right) {
				st.erase(cand);
				ans[mp[cand]] = X;
				idx = st.lower_bound(left);
			}
			else break;
		}
	}

	for (int i = 0; i < Q; i++)puts(ans[i]);


	return 0;
}

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

int main(){
  int h,w,k,i,j,ph,pw,s,t;
  cin >> h >> w >> k;
  char c[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> c[i][j];
    }
  }
  
  ph=1;
  pw=1;
  for(i=0;i<h;i++){
    ph *= 2;
  }
  for(j=0;j<w;j++){
    pw *= 2;
  }
  
  int bith[h],bitw[w],p,q,m,ans;
  ans=0;
  for(i=0;i<ph;i++){
    p=i;
    for(s=0;s<h;s++){
      bith[s]=p%2;
      p /= 2;
    }
    for(j=0;j<pw;j++){
      p=j;
      for(t=0;t<w;t++){
        bitw[t]=p%2;
        p /= 2;
      }
      m=0;
      for(s=0;s<h;s++){
        for(t=0;t<w;t++){
          if(bith[s]==1&&bitw[t]==1&&c[s][t]=='#'){
            m++;
          }
        }
      }
      if(m==k){
        ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

string s;
vector<char> d;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != 'B')
        {
            d.push_back(s[i]);
        }
        else
        {
            if (d.size())
            {
                d.pop_back();
            }
        }
    }
    for (int i = 0; i < d.size(); i++)
        cout << d[i];
}


Measured memory_bytes: 256
import numpy as np

A,B = [int(i) for i in input().split()]

xa = list(range(int(np.ceil(A/0.08)),int(np.ceil((A+1)/0.08))))
xb = list(range(int(np.ceil(B/0.1)),int(np.ceil((B+1)/0.1))))

ans=str()

for i in xa:
    if i in xb:
        ans = str(i)
        break
        
if len(ans)==0:
    ans="-1"
    
print(ans)

Measured memory_bytes: 21416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#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())

const ll INF = 1e15;
// vector<vector<ll>> nxt;
// a->bの最短経路復元
// REP(i, n) REP(j, n) { nxt[i][j] = j; }
// warshall_floyd(to);
// for (ll cur = a; cur != b; cur = nxt[cur][b]) {
//
// }
void warshall_floyd(vector<vector<ll>>& d) {
  ll n = SZ(d);
  REP(i, n) REP(j, n) REP(k, n) if (d[j][k] > d[j][i] + d[i][k]) {
    d[j][k] = d[j][i] + d[i][k];
    // nxt[j][k] = nxt[j][i];
  }
}

int main() {
  ll n, m, l;
  cin >> n >> m >> l;
  vector<vector<ll>> to(n, vector<ll>(n, INF));
  REP(i, n) { to[i][i] = 0; }
  REP(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    to[a][b] = c;
    to[b][a] = c;
  }
  warshall_floyd(to);
  REP(i, n) REP(j, n) {
    if (0 < to[i][j] && to[i][j] <= l) {
      to[i][j] = 1;
    }else if(to[i][j] > l){
      to[i][j] = INF;
    }
  }
  warshall_floyd(to);

  ll q;
  cin >> q;
  while (q--) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    cout << (to[s][t] == INF ? -1 : to[s][t] - 1) << endl;
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<vector<char>> data(3, vector<char>(3));
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin >> data.at(i).at(j);
    }
  }
  cout << data[0][0] << data[1][1] << data [2][2] << endl;
}

Measured memory_bytes: 256
import static java.util.Arrays.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	class IntArray {
		private int size;
		private int[] data;
		IntArray(int maxSize) {
			size = 0;
			data = new int[maxSize];
		}
		int size() { return size; }
		int get(int index) { return data[index]; }
		void add(int a) { data[size++] = a; }
		int back() { return data[size-1]; }
		void clear() { size = 0; }
	}

	boolean isLeapYear(int y) {
		return y % 400 == 0 || (y % 100 != 0 && y % 4 == 0);
	}

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 0 && b == 0) System.exit(0);
		IntArray ans = new IntArray(b - a + 1);
		for (int i = a; i <= b; i++) {
			if (isLeapYear(i)) {
				ans.add(i);
			}
		}
		if (ans.size() == 0) {
			out.println("NA");
		} else {
			for (int i = 0; i < ans.size(); i++) {
				out.println(ans.get(i));
			}
		}
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	MyScanner sc = null;
	PrintWriter out = null;
	public void run() throws Exception {
		sc = new MyScanner(System.in);
		out = new PrintWriter(System.out);
		boolean first = true;
		for (;sc.hasNext();) {
			if (!first) out.println();
			first = false;
			solve();
			out.flush();
		}
		out.close();
	}

	class MyScanner {
		String line;
		BufferedReader reader;
		StringTokenizer tokenizer;

		public MyScanner(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}
		public void eat() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					line = reader.readLine();
					if (line == null) {
						tokenizer = null;
						return;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		public String next() {
			eat();
			return tokenizer.nextToken();
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		public boolean hasNext() {
			eat();
			return (tokenizer != null && tokenizer.hasMoreElements());
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
	}
}

Measured memory_bytes: 16176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF=1e9+5;
int main()
{
    int n;
    scanf("%d",&n);
    vector<int> dp(3);
    for(int day=0; day < n; ++day)
    {
        vector<int> new_dp(3,0);
        vector<int> c(3);
        for(int i=0; i<3; i++) {
            scanf("%d",&c[i]);
        }
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(i!=j){
                    new_dp[j]=max(new_dp[j],dp[i]+c[j]);
                }
            }
        }
        dp=new_dp;
    }
    printf("%d\n",max({dp[0],dp[1],dp[2]}));
    //while(1);
    return 0;
}

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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  bool can = false;
  for(int i = 1; i<=b; i++){
    if(i*a%b==c) can = true;
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}

Measured memory_bytes: 3620
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var arr=(Arr.shift()).split(" ").map(Number);
   var sum=0;
   var flag=false;
   arr.forEach(function(v){
      if(v!=0)sum+=1;
      if(v>=2)flag=true;
   });
   console.log(flag?sum+1:"NA");
}

Measured memory_bytes: 22536
x, y, a, b, c = gets.chomp.split(" ").map(&:to_i)
p = gets.chomp.split(" ").map(&:to_i)
q = gets.chomp.split(" ").map(&:to_i)
r = gets.chomp.split(" ").map(&:to_i)
sum = 0

ans = p.sort.reverse![0..x-1] + q.sort.reverse![0..y-1] + r
ans = ans.sort.reverse
(x+y).times do |i|
  sum += ans[i]
end

puts sum

Measured memory_bytes: 34340
class _Node {
  constructor(key, left = null, right = null) {
    this.key = key;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      y[key < y.key ? 'left' : 'right'] = newNode;
    };
  }

  find(key, n = this.root) {
    if (n === null) return false;
    if (n.key === key) return true;
    return this.find(key, n[key < n.key ? 'left' : 'right']);
  }

  printByIneorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    const innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
    case 'i': tree.insert(Number(cmd.split(' ')[1])); break;
    case 'f': console.log(tree.find(Number(cmd.split(' ')[1])) ? 'yes' : 'no'); break;
    default: tree.print();
    }
  });
})();



Measured memory_bytes: 194904
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long A[N];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A,A+N);
    bool flag=0;
    for(int i=1; i<N; i++){
        if(A[i]==A[i-1]) flag=1;
    }
    if(flag){
        cout << "NO";
    }else{
        cout << "YES";
    }
    return 0;
}


Measured memory_bytes: 1792
#ifdef lolipop
    #define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, n) for(int i = 0; i < n; ++i)

using namespace std;
inline void Fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}


void solve() {
    /*int n;
    cin >> n;
    vector <int> a(n);
    loop(i, n) cin >> a[i];
    vector <int> p(n);
    loop(i, n) cin >> p[i];
    int m;
    cin >> m;
    vector <int> b(m);
    loop(i, m) cin >> b[i];
     */
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '7') {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";
}


signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    Fast_io();
#endif
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3128
a = [int(input()) for _ in range(5)]
ans,mgn = 0,0
for i in range(5):
    if(a[i]%10 == 0):
        ans += a[i]
    else:
        ans += int(a[i]//10+1)*10
        mgn = max(mgn, 10-(a[i]%10))
print(ans-mgn)

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

int main()
{
    ll N, P;
    cin >> N >> P;

    ll retv = 1;
    ll temp = P;
    ll maxv = powl(P, 1.0/(double)N)+1;
    for (ll i=maxv; i>=2 && temp>=8; --i)
    {
        ll p = powl(i, N);
        if (temp % p != 0) continue;
        temp /= p;
        retv *= i;
    }

    cout << retv << endl;

    return 0;
}


Measured memory_bytes: 384
/*
    oj d https://atcoder.jp/contests/abc165/tasks/abc165_a
    oj t
    oj s https://atcoder.jp/contests/abc165/tasks/abc165_a A.cpp
*/
#include <bits/stdc++.h>
using namespace std;

 
int main(){
    int K, A, B;
    cin >> K >> A >> B;

    for(int i=1;i<=1000;i++){
        if(A <= K*i && K*i <= B){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    cout << "NG" << endl;

}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> Q;

double ff(double t, Q q) {
	double v = q.first;
	double l = (q.second).first;
	double r = (q.second).second;

	if (t < l) {
		return v + (l - t);
	}
	else if (t > r) {
		return v + (t - r);
	}
	else {
		return v;
	}

}

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

	vector<Q> qq;
	qq.push_back(Q(0, P(0, 0)));
	int prev = 0;

	for (int i = 0; i < n; i++) {
		qq.push_back(Q(v[i], P(prev, prev + t[i])));
		prev += t[i];
	}

	qq.push_back(Q(0, P(prev, prev)));

	vector<double> a(2*prev+1);

	for (int i = 0; i < 2 * prev+1; i++) {
		double MIN = ff((double)i*0.5, qq[0]);
		for (int j = 0; j < qq.size(); j++) {
			MIN = min(MIN, ff((double)i*0.5, qq[j]));
		}
		a[i] = MIN;
	}

	double ans = 0.0;

	for (int i = 1; i < 2 * prev+1; i++) {
		ans += (a[i - 1] + a[i])*0.25;
	}

	printf("%.5f\n", ans);

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
	int n[9];
	for(int i=0;i<9;i++)cin>>n[i];
    int a;cin>>a;
    bool p[9]={0,0,0,0,0,0,0,0,0};
    for(int i=0;i<a;i++){
        int d;cin>>d;
        auto itr=find(n,n+9,d);
        if(itr!=end(n))
            p[distance(n,itr)]=1;
    }
    for(int i=0;i<9;i+=3){
        if(p[i]&&p[i+1]&&p[i+2]){cout<<"Yes";return 0;}
    }
    for(int i=0;i<3;i++){
        if(p[i]&&p[i+3]&&p[i+6]){cout<<"Yes";return 0;}
    }
    if((p[0]&&p[4]&&p[8])||(p[2]&&p[4]&&p[6])){cout <<"Yes";return 0;}
    cout<<"No";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
        cout << it << " ";        \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
#define deb3a(v)                               \
    cout << #v << "-->" << endl;               \
    for (auto it : v)                          \
    {                                          \
        cout << it.fi << " " << it.se << endl; \
    }
#define mod 1000000007
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}
vector<vector<int>> dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};


int fun(string s1,string s2){
    int ans = 0;
    fo(i,s1.size()){
        if(s1[i]!=s2[i]){
            ans++;
        }
    }
    return ans;
}
void solve()
{
    string s1, s2;
    cin >> s1 >> s2;
    int n = s1.size(), n2 = s2.size();
    int ans = n;

    fo(i,n){
 if(i+n2>n){
     continue;
 }
 ans = min(ans, fun(s1.substr(i, n2), s2));
    }
    cout << ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(time(0));

    // FILE *fin = freopen("ip.txt","r",stdin);
    // FILE *fout = freopen("op.txt","w",stdout);
    int t = 1, nn = 1;
    //cin >> t;
    while (t--)
    {
        // cout << "Case #" << nn << ":"
        //      << " ";
        // nn++;
        solve();
       
    }
}

Measured memory_bytes: 3656
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n;
    scn(n);

    vl a(n), b(n);

    ll sum_a = 0, sum_b = 0;

    rep(i, 0, n)
    lscn(a[i]), sum_a += a[i];

    rep(i, 0, n)
    lscn(b[i]), sum_b += b[i];

    ll need = 0;

    rep(i, 0, n) {
        if(b[i] > a[i])
            need += (b[i] - a[i] + 1) / 2;
    }

    if(sum_a > sum_b) {
        puts("No");
    } else if(need <= sum_b - sum_a) {
        puts("Yes");
    } else {
        puts("No");
    }
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int N,K;cin>>N>>K;
  string S;cin>>S;
  char s = S[K-1];
  // transform (s.begin (), s.end (), s.begin (), tolower);
  s=tolower(s);
  S[K-1] = s;
  p(S);
  return 0;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int start = Math.max(A, C);
		int end = Math.min(B, D);

		if (start > end){
			System.out.println("0");
		} else {
			System.out.println(end - start);
		}

	}

}


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

typedef long long ll;

using namespace std;

int main()
{

    ll a, b, k;

    cin >> a >> b >> k;

    if (a <= k)
    {
        k -= a;
        a = 0;
    }
    else
    {
        a -= k;
        k = 0;
    }

    if (b <= k)
    {
        k -= b;
        b = 0;
    }
    else
    {
        b -= k;
        k = 0;
    }

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    string s;
    cin >> s;
    
    //Aの後ろに"BC"が続いていればAを後に送る
    //Aがいれば合わせて送る
    ll ans = 0;
    ll count = 0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]=='A')
            count++;
        else if(s[i]=='B' && s[i+1]=='C'){
            ans += count;
            i++;
        }
        else
            count = 0;
    }
    cout << ans << endl;
    
    return 0;
}

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

int main(){
  int K, S;
  cin >> K >> S;
  
  //cout << "S-K: " << S-K << " S: " << S << endl;
  int ans = 0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      //for(int z=0; z<=K; z++){
      //  if(x+y+z == S) ans++;
      //}
      int z =(x+y);
      if(S-K <= z  && z <= S){
        ans++; //zは 0～Kまでなので，S-(x+y)が0~Kに収まっていれば+1すればよい
        //cout << "x: " << x << " y: " << y << endl;
      }
    }
  }
  
  cout << ans << endl;
}

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

typedef pair<int, int> P;
const int INF = 1e9;

int main() {
	int n; cin >> n;
	vector<vector<int>>graph(n);
	for (int i = 0, a, b; i < n - 1; i++) {
		cin >> a >> b; a--; b--;
		graph[a].push_back(b); graph[b].push_back(a);
	}
	int k; cin >> k;
	vector<int>num(n, -1);
	for (int i = 0, v, p; i < k; i++) {
		cin >> v >> p; num[v - 1] = p;
	}

	vector<int>dist(n, INF);
	priority_queue<P, vector<P>, greater<P>>que;
	for (int i = 0; i < n; i++)if(num[i]>=0) {
		dist[i] = num[i];
		que.push({ dist[i],i });
	}
	while (que.size()) {
		int v = que.top().second; que.pop();
		for (int u : graph[v])	if (dist[u] > dist[v] + 1) {
			dist[u] = dist[v] + 1;
			que.push({ dist[u],u });
		}
	}

	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (num[i] >= 0 && dist[i] != num[i])ok = false;
		for (int j : graph[i])if (dist[i] == dist[j])ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
	if (ok)for (auto&& x : dist)cout << x << endl;

	return 0;
}

Measured memory_bytes: 8308
N,M = map(int,input().split())
SC = [list(map(int,input().split())) for _ in range(M)]

ans = []
for i in range(N):
  ans.append('a')
for s,c in SC:
  s -= 1
  if (ans[s] != 'a' and ans[s] != c):
    print(-1)
    exit()
  else:
    ans[s] = c
if ans[0] == 0 and N > 1:
  print(-1)
  exit()
for i in range(N):
  if ans[i] == 'a':
    if i == 0 and N > 1:
      ans[i] = 1
    else:
      ans[i] = 0
print(*ans, sep ='')

Measured memory_bytes: 3064
def resolve():
    N, M, X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    cost1 = len([a for a in A if a > X])

    cost2 = len([a for a in A if a < X])
    print(min(cost1, cost2))

    return
 

resolve()

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

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

    if (a <= 0 && 0 <= b) cout << "Zero" << endl;
    else if (b > 0) cout << "Positive" << endl;
    else cout << ((b - a + 1) % 2 == 0 ? "Positive" : "Negative") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int main(void)
{
	int i,j,k,n,m;
	scanf("%d%d",&n,&m);
	printf("%d\n",(n-1)*(m-1));
	return 0;
 } 

Measured memory_bytes: 128
while True:
    try:
        b = input()
        a=list(b)
        for i in range(10):
            a[i]=int(a[i])
        n=9
        for i in range(10):
            d = 1
            for j in range(n):
                c=a[j]+a[d]
                c=c%10
                a[j]=c
                d+=1
            n-=1
        print(a[0])
    except:break


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

using namespace std;

#define MAX 100010
typedef long long ll;

int main(){
  ll N,M,P[MAX],A[MAX],B[MAX],C[MAX];
  cin >> N >> M;
  for(int i = 0 ; i < M ; i++){
    cin >> P[i]; P[i]--;
  }
  for(int i = 0 ; i < N-1 ; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  int dp[MAX] = {0};
  for(int i = 0 ; i < M-1 ; i++){
    ll arr[2] = {P[i],P[i+1]};
    if(P[i] > P[i+1]){ swap(arr[0],arr[1]); }
    dp[arr[0]]++; dp[arr[1]]--;
  }
  for(int i = 1 ; i < N ; i++){
    dp[i] += dp[i-1];
  }
  ll res = 0LL;
  for(int i = 0 ; i < N ; i++){
    res += min(A[i]*dp[i],B[i]*dp[i]+C[i]);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4680
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(scanf("%d",&n) , n){
    bool login[1001] = {};
    int cost[1001] = {}, prev[1001];
    while(n--){
      int time, U, h, m, id;
      char buff;
      scanf("%d/%d %d:%d %c %d",&U,&U,&h,&m,&buff,&id);
      time = h * 60 + m;
      if(login[id]){
        if(!id) for(int i = 1 ; i < 1001 ; i++ ){
          if(login[i]) cost[i] += time - max(prev[0],prev[i]);
        }else if(login[0]) cost[id] += time - max(prev[0],prev[id]);
      }else prev[id] = time;
      login[id] = !login[id];
    }
    printf("%d\n",*max_element(cost+1,cost+1000));
  }
}

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

#define MAXN (100010)

char str[MAXN];

int main(){
	scanf("%s", str);
	int ans = 0;
	for(int i = 1, sz = strlen(str); i < sz; ++ i){
		ans += str[i] != str[i - 1];
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<int> V(N);
  VEC<int> C(N);
  VEC<int> d(N);
  REP(i, 0, N) { cin >> V[i]; }
  REP(i, 0, N) {
    cin >> C[i];
    d[i] = V[i] - C[i];
  }
  int sum =0;
  REP(i,0,N){
    if(d[i]>0){
      sum+=d[i];
    }
  }
  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,m,c;
  	ci(n>>m>>c);
  vll A(m);
  FOR(i,0,m){
	ci(A[i])
  }
  
  ll ans=0;
  
  FOR(i,0,n){
    vll B(m);
    ll sum=0;
    FOR(j,0,m){
      ci(B[j]);
      sum+=A[j]*B[j];
    }
    if(sum>-c) ans++;
  }
  co(ans)
}
      

Measured memory_bytes: 256
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
using namespace std;
typedef long long LL;
const int N=1000010;
template<typename T>inline T chkmax(T A,T B){return A>B?A:B;}
template<typename T>inline T chkmin(T A,T B){return A<B?A:B;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n;
int bgn[N],nxt[N<<1],to[N<<1],E,SG[N];
inline void add_edge(int x,int y)
{
	nxt[++E]=bgn[x],bgn[x]=E,to[E]=y;
}
inline void dfs(int u,int f)
{
	SG[u]=0;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==f)continue;
		dfs(v,u);
		SG[u]^=SG[v]+1;
	}
}
int main()
{
	int x,y;
	read(n);
	For(i,2,n)
	{
		read(x),read(y);
		add_edge(x,y);add_edge(y,x);
	}
	dfs(1,0);
	if(SG[1])puts("Alice");
	else puts("Bob");
	return 0;
}


Measured memory_bytes: 13312