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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int x;
    cin >> x;
    if (x == 7 or x == 5 or x == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);
using Graph = vector<vector<int>>;

struct UnionFind{
  vector<int> Par;
 
  //N個の独立した根として初期化
  UnionFind(int N) : Par(N) {
    for( int i = 0; i < N; i++ ) Par.at(i) = -1;
  }
 
  //どこの根に属するか得る再帰関数
  int root(int X){
    if( Par.at(X) < 0 ) return X;
    else return Par.at(X) = root(Par.at(X));
  }
 
  //XとYが同じ根に属するか判定
  bool same(int X, int Y){
    return root(X) == root(Y);
  }
 
  //XとYの木を合体　サイズを持つ
  bool merge(int X, int Y){
    X = root(X);
    Y = root(Y);
    if( X == Y ) return false;
    if( Par.at(X) > Par.at(Y) ) swap(X, Y); //小さいほうから大きいほうに繋ぎ変える
    Par.at(X) += Par.at(Y);
    Par.at(Y) = X;
    return true;
  }
 
  //所属する木のサイズを取得
  int size(int X){
    return -Par.at(root(X));
  }
};

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  
  vector<int> f(n);
  UnionFind Tree(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    f[a]++;
    f[b]++;
    Tree.merge(a, b);
  }
  
  Graph block(n);
  rep(i,k){
    int c,d;
    cin >> c>> d;
    c--;
    d--;
    block[c].push_back(d);
    block[d].push_back(c);
  }
  
  rep(i,n){
    int ans = Tree.size(i)-f[i];
    rep(j,block[i].size()){
      if(Tree.same(i,block[i][j]) ) ans--;
    }
    cout << ans-1 << " ";
  }
   
}


Measured memory_bytes: 6784
S = input()

if S.count("A") == 1 and S.count("C") == 1:
    if S[0] == "A" and 2 <= S.find("C") <= len(S)-2:
        rmS = S.replace("A", "")
        rmS = rmS.replace("C", "")
        if rmS == rmS.lower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")

else:
    print("WA")


Measured memory_bytes: 2940
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
L = [A,B,C,D,E]
L.sort()
M = 0
H = N % L[0]
if(H == 0):
  print(N//L[0]+4)
else:
  print(N//L[0]+5)

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

inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}

int main() {
	char x;
	scanf("%c",&x);
	if (x>='a'&&x<='z') puts("a");
	else puts("A");
	return 0;
}

Measured memory_bytes: 3756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ADigitsSum {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int sum = 0;
            boolean lack = false;
            for (int i = 0; i < s.length(); i++) {
                char c = s.charAt(i);
                if (i == 0 && c == '1') {
                    lack = true;
                } else if (i != 0 && c != '0') {
                    lack = false;
                }
                sum += c - 48;
            }
            out.println(lack ? "10" : sum);
        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
bool debug;
#define all(x) (x).begin(), (x).end()
#define ll long long

#define db(x) if(debug)cout << " " << (x) <<" "
#define dbn(x) if(debug)cout << "\n" << (#x) << " is " << (x) << endl
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
// fill(all(vec), 1);
//vec.resize(unique(all(vec))-vec.begin())
const int N = 3e6;

void solve()
{
    ll a, b, m, i, j, z;
    cin >> a >> b >> m;
    std::vector<ll> x(a), y(b);
    // std::vector<ll> v;
    ll ans = 1e18, l = 1e18, r = 1e8;
    rep(i, a) cin >> x[i], l = min(x[i], l);
    rep(i, b) cin >> y[i], r = min(y[i], r);
    rep(i, m)
    {
        cin >> a >> b >> z;
        ans = min(ans, x[a - 1] + y[b - 1] - z);
    }
    cout << min(ans, l + r);

}



int main()
{



    if(debug)
    {
#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
#endif
    }

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;


    while(t--)
    {
        solve();
        // cout << endl;
    }


}

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

const int MAX_N = 10;

int N, M;
int adj[MAX_N][MAX_N];
bool used[MAX_N];

bool check() {
    bool ret = true;
    for (int i = 1; i <= N; i++) {
        if (!used[i]) ret = false;
    }
    return ret;
}

int dfs(int s) {
    used[s] = true;
    if (check()) {
        used[s] = false;
        return 1;
    }

    int ret = 0;
    for (int i = 1; i <= N; i++) {
        if (adj[s][i] == 1 && !used[i]) {
            ret += dfs(i);
        }
    }

    used[s] = false;
    return ret;
}

int main(void) {

    for (int i = 0; i < MAX_N; i++) {
        for (int j = 0; j < MAX_N; j++) {
            adj[i][j] = 0;
        }
    }
    for (int i = 0; i < MAX_N; i++) used[i] = false;

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        adj[a][b] = 1;
        adj[b][a] = 1;
    }

    cout << dfs(1) << endl;

    // for (int i = 1; i <= N; i++) {
    //     for (int j = 1; j <= N; j++) {
    //         cout << adj[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T>inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    vector<string> S={"Sunny","Cloudy","Rainy","Sunny"};
    string s;cin>>s;
    rep(i,4){
        if(s==S[i]){
            cout<<S[i+1]<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) ll aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) string aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main() {
	
	int N;
  cin>>N;
	vec(P)
	fx(N){
		vecp(P)
	}
	int ans=0;
	fx(N){
		if(P.at(x)==x+1){
			ans++;
			if(x+1<N&&P.at(x+1)==x+2){
				x++;
			}
		}
	}
	ce(ans)

}

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

using namespace std;

int main(void)
{
    int goods_count;
    int selects_count;
    vector<int> votes;

    int actual_selects_count = 0;

    cin >> goods_count >> selects_count;

    int votes_sum = 0;
    for(int i = 0; i < goods_count; i++){
        int v;
        cin >> v;
        votes_sum += v;
        votes.push_back(v);

    }

    for(int i = 0; i < goods_count; i++){
        if(4 * selects_count * votes[i] >= votes_sum){
            actual_selects_count += 1;
        }
    }
    
    if(actual_selects_count >= selects_count){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0, m, x, y, v;
  set<ll> se[26];
  srand(time(NULL));
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    t[i] = i % 26;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
  }
  for (int i = 0; i < 26; i++) {
    se[i].insert(d + 1);
  }
  for (int i = 0; i < 20000000; i++) {
    x = i % d + 1;
    y = i % 26;
    v = 0LL;
    ans += s[x - 1][y] - s[x - 1][t[x - 1]];
    set<ll>::iterator it = se[t[x - 1]].find(x);
    it--;
    ll z = *se[t[x - 1]].upper_bound(x);
    v -= c[t[x - 1]] * (z - x) * (x - *it);
    it = se[y].lower_bound(x);
    it--;
    v += c[y] * (*se[y].lower_bound(x) - x) * (x - *it);
    if (v > 0LL) {
      ans += v;
      se[t[x - 1]].erase(x);
      t[x - 1] = y;
      se[y].insert(x);
    }
  }
  for (int i = 0; i < d; i++) {
    cout << t[i] + 1 << endl;
  }
}

Measured memory_bytes: 3700
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
p = na()
a = 0

for i in range(1,n-1):
    mi = min(p[i-1],p[i],p[i+1])
    ma = max(p[i-1],p[i],p[i+1])
    if p[i] != mi and p[i] != ma:
        a+=1

print(a)

Measured memory_bytes: 3316
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for i in range(m)]
    path = [[] for i in range(n)]
    ans = 0
    for i in range(m):
        path[ab[i][0]-1].append(ab[i][1]-1)
        path[ab[i][1]-1].append(ab[i][0]-1)
    for i in path:
        if not (i):
            i.append(-1)
    for i, ele in enumerate(path):
        if ele[0] == -1:
            ans += 1  #一本の道を使ってたどり着ける展望台がない
            continue
        high = []
        for j in ele:
            high.append(h[j])
        if h[i] > max(high):
            ans += 1
    print(ans)



if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 50008
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Distance
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            double x1 = double.Parse(input[0]);
            double y1 = double.Parse(input[1]);
            double x2 = double.Parse(input[2]);
            double y2 = double.Parse(input[3]);

            Console.WriteLine(Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2)));
            

            
        }
    }
}



Measured memory_bytes: 15992
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string s;
  int l=0;
  
	cin >> s;
    
    for (int i=0; i<s.size()/2; i++){
    	if (s[i]!=s[s.size()-i-1])
        	l++;
    }
    
  	cout << l << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;

    if(v<=w){
        cout<<"NO"<<endl;
        return 0;
    }

    ll k=(v-w)*t;
    if(abs(a-b)<=k) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}


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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class COneQuadrillionAndOneDalmatians {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      n--;
      ll base = 26;
      ll sum = 0;
      int len = 1;
      while(sum+base<=n) {
        sum += base;
        base *= 26;
        len++;
      }
      n -= sum;
      string ans;
      while(len--) {
        ans.push_back('a' + n%26);
        n /= 26;
      }
      reverse(all(ans));
      cout << ans << endl;


    }
};

signed main() {
  COneQuadrillionAndOneDalmatians solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3652
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin


def main():
    n = str(input())
    for i in range(len(n)):
        if n[i] == "7":
            print("Yes")
            return
    print("No")


def input(): return stdin.readline().rstrip()


main()


Measured memory_bytes: 9392
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

char s[30];
map<char,int>q;

int main()
{
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
    {
        if(q[s[i]]==0)q[s[i]]=1;
        else
        {
            printf("no");
            exit(0);
        }
    }
    printf("yes");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	static boolean[] maybe;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		int[] a = new int[q];
		int[] b = new int[q];
		for (int i = 0; i < q; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		maybe = new boolean[n + 2];
		maybe[1] = true;
		maybe[2] = true;
		int now = 1;
		for (int i = 0; i < q; i++) {
			if (a[i] == now) {
				now = b[i];
			} else if (b[i] == now) {
				now = a[i];
			}
			swap(a[i], b[i]);
			maybe[now + 1] = true;
			maybe[now - 1] = true;
		}
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			if (maybe[i]) {
				sum++;
			}
		}
		System.out.println(sum);
	}
	static void swap(int i, int j) {
		boolean tmp = maybe[i];
		maybe[i] = maybe[j];
		maybe[j] = tmp;
	}
}

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

signed main()
{
    ll n;
    //ios_base::sync_with_stdio(0),cin.tie(0);
    while(cin>>n)
    {
        ll res=0;
        rep1(i,n)
        {
            ll tmp;
            cin>>tmp;
            if(tmp!=i) res++;
        }
        if(res>2) cout<<"NO\n";
        else cout<<"YES\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

bool isACGT(char ipt) {
	return ipt == 'A' || ipt == 'C' || ipt == 'G' || ipt == 'T';
}

int main() {
	string s; cin >> s;
	int mx = 0;
	int cnt = 0;
	REP(i, s.size()) {
		if (isACGT(s[i])) {
			cnt++;
		}
		else cnt = 0;

		if (mx < cnt)mx = cnt;
	}
	print(mx);


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-13
#include <time.h>
using namespace std;
long long read(){
    long long x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}


long long n,k,m;
long long num[100];
long long lat[100];

int main(){
	n=read();
	for (int i=1;i<=n;i++){
		num[i]=read();
	}
	k=0;
	for (int i=1;;i++){
		long long tmp=0;
		for (int i=1;i<=n;i++){
			tmp+=num[i]/n;
			lat[i]=num[i]/n;
			num[i]%=n;
		}
		for (int i=1;i<=n;i++){
			num[i]+=tmp-lat[i];
		}
		k+=tmp;
		if (tmp==0)	break;
	}
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
a=[[0]*m for i in range(n)]
b=[[0]*l for i in range(m)]
c=[[0]*l for i in range(n)]
kekka=[0*l]
for row in range(n):
	work=list(map(int,input().split()))
	for col in range(m):
		a[row][col]=work[col]
for row in range(m):
	work=list(map(int,input().split()))
	for col in range(l):
		b[row][col]=work[col]		

for i in range(n):
	for j in range(l):   
		c[i][j]=0	
		for k in range(m):
			c[i][j]+=a[i][k]*b[k][j]
for r in range(n):
    print(' '.join(map(str, c[r])))


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

#define nl "\n";
int m = 1000000007;
ll ans = 0;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// problem statements implementation
	ll n;
	cin >> n;
    long long int ans1 = 1, ans2 = 2, ans3 = 1;
    for(int i=1; i<=n; ++i){
    	ans1 *= 10, ans1 %= m;
    	ans2 *= 9, ans2 %= m;
    	ans3 *= 8, ans3 %= m;
    }
    ans1 -= ans2 - ans3;

	cout << (m+ans1)%m << nl;
	return 0;
}

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

int main() {
    string S;
    int Q;
    cin >> S;
    cin >> Q;
    int T, F;
    char C;
    vector<char> s(S.begin(), S.end());
    bool reversed = false;
    for(int i = 0; i < Q; i++) {
        cin >> T;
        if(T == 1) {
            reversed = !reversed;
        } else {
            cin >> F >> C;
            if(F == 1) {
                if(reversed) {
                    s.push_back(C);
                } else {
                    s.insert(s.begin(), C);
                }
            } else {
                if(reversed) {
                    s.insert(s.begin(), C);
                } else {
                    s.push_back(C);
                }
            }
        }
    }
    if(reversed) {
        reverse(s.begin(), s.end());
    }

    for(char c : s) {
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1084
#include "iostream"

using namespace std;

int N,M;
long long int a[51], b[51], c[51], d[51];
long long int box[51];

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= M; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			if (j == 1)box[i] = 1;
			if (abs(a[i] - c[box[i]]) + abs(b[i] - d[box[i]]) > abs(a[i] - c[j]) + abs(b[i] - d[j]) && j != 1)box[i] = j;
		}
	}
	for (int i = 1; i <= N; i++) {
		cout << box[i] << endl;
	}
}

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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	int cnt1=0,cnt2=0,cnt3=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]==1)cnt1++;
		if(a[i]==2)cnt2++;
		if(a[i]==3)cnt3++;
	}

	cout.precision(10);
	vector<vector<vector<double> > > dp(n+1,vector<vector<double> >(n+1,vector<double>(n+1,0)));
	dp[0][0][0]=0.0;
	for(int k=0;k<=n;k++){
		for(int j=0;k+j<=n;j++){
			for(int i=0;i+j+k<=n;i++){
				if(i==0&&j==0&&k==0)continue;
				dp[i][j][k]=n*1.0/(i+j+k);
				if(i-1>=0)
					dp[i][j][k]+=dp[i-1][j][k]*1.0*i/(i+j+k);
				if(j-1>=0)
					dp[i][j][k]+=dp[i+1][j-1][k]*1.0*j/(i+j+k);
				if(k-1>=0)
					dp[i][j][k]+=dp[i][j+1][k-1]*1.0*k/(i+j+k);

			}
		}
	}
	cout<<dp[cnt1][cnt2][cnt3]<<endl;
}

Measured memory_bytes: 216960
#include <iostream>

int main() {

    std::string s;

    std::cin >> s;

    if(s[0] == s[1] and s[1] != s[2] and s[2] == s[3] or s[0] == s[2] and s[1] != s[2] and s[1] == s[3] or s[0] == s[3] and s[1] != s[3] and s[1] == s[2])
        std::cout << "Yes";
    else
        std::cout << "No";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#define MAX_NODES 500000

using namespace std;
//think easy make easy

int n;//num of nodes

void maxHeapify(int A[],int i){//i is index of root
	int l,r;
	int largest;
	int tmp;

	l = 2 * i;
	r = l + 1;

	if(l <= n && A[l] > A[i]) largest = l;
	else largest = i;

	if(r <= n && A[r] > A[largest]) largest = r;

	if(largest != i){
		tmp = A[i];
		A[i] = A[largest];
		A[largest] = tmp;
		maxHeapify(A,largest);
	}

	
}

void buildMaxHeap(int A[]){
	for(int i=n/2;i>0;i--){//1~n/2が左右の子少なくとも一方が存在する範囲
		maxHeapify(A,i);
	}
}

int main(){
	//1オリジン(添え字が1からはじまる)のためナル文字分の+1に加えさらに+1する
	int H[MAX_NODES+1+1];
	
	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%d",&H[i]);//1オリジンであることに注意

	buildMaxHeap(H);

	for(int i=1;i<=n;i++) cout <<" " <<H[i];
	cout <<endl;

	return 0;
}

Measured memory_bytes: 3160
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        ans += sc.nextInt();
        ans += sc.nextInt();
        ans += sc.nextInt();
        System.out.println(ans < 22 ? "win" : "bust");
        sc.close();

    }

}


Measured memory_bytes: 23124
#include <iostream>
#include <array>
using namespace std;
 
int main(){
    int n,m,sum=0;
    array<int,10000> working_day;
    cin >> n >> m;
    for(int i=1;i<=m;i++){
        cin >>  working_day[i];
        sum += working_day[i];
    }
    if(n >= sum ){
        cout << n - sum;
    }else{
        cout << -1;
    }
    return 0;
 
}

Measured memory_bytes: 3676
n,k = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(n)])
i = 0
while(k>0):
  if ab[i][1] < k:
    k -= ab[i][1]
  else:
    print(ab[i][0])
    break
  i += 1

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

int pow(int a,int b){
	int ans = 1;
	for(int i=0;i<b;i++) ans *= a;
	return ans;
};

int main(){
	int dp[31] = {0} , n;
	dp[0] = 0;
	
	for(int i=1;i<=30;i++){
		dp[i] = dp[i-1] + pow( 3 , (i-1)/2 );
	}
	while(cin >> n) cout << dp[n] << endl;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <limits.h>

int binarysearch(int x, int n, int *a) {
  if (n <= 1) {
    return 1;
  }
  int tmp = n/2;
  if(a[tmp] <= x) {
    return tmp + binarysearch(x, (n+1)/2, a+tmp);
  } else {
    return binarysearch(x, n/2, a);
  }
}

int main() {
  int n, x, ans;
  scanf("%d%d", &n, &x);
  int l, d[n+2];
  d[0] = 0;
  d[n+1] = INT_MAX;
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &l);
    d[i+1] = d[i] + l;
  }
  ans = binarysearch(x, n+2, d);
  printf("%d\n", ans);
  return 0;
}


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

int main() {
    int S;
    cin >> S;
    int h = S / 3600;
    int m = S / 60 - 60 * h;
    int s = S - 3600 * h - 60 * m;

    cout << h << ":" << m << ":" << s << endl;
}

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

using namespace std;

int main()
{
	int n, q, m, mx, t, s;
	bool a[51][101], f;
	
	while(1){
		cin >> n >> q;
		if(n == 0 && q == 0){
			break;
		}
		mx = 0;
		fill(&a[0][0], &a[50][100], false);
		
		for(int i = 0; i < n; i++){
			cin >> m;
			for(int j = 0; j < m; j++){
				cin >> t;
				a[i][t] = true;
			}
			if(t > mx){
				mx = t;
			}
		}
		m = 0;
		f = true;
		for(int i = 1; i <= mx; i++){
			t = 0;
			for(int j = 0; j < n; j++){
				if(a[j][i]){
					t++;
				}
			}
			if(m < t){
				m = t;
				s = i;
			}
		}
		
		if(m >= q){
			cout << s << endl;
		} else {
			cout << 0 << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

#include <vector>
using ll = long long;
vector<vector<ll>> get_combination(int N)
{
    vector<vector<ll>> pascal(N + 1, vector<ll>(N + 1));
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            if (j == 0 || j == i)
                pascal[i][j] = 1;
            else
                pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
            pascal[i][j] %= mod;
        }
    }
    return pascal;
}

int N, K;

int main()
{
    cin >> N >> K;
    vector<vector<ll>> com = get_combination(N);
    for (int i = 1; i <= K; i++)
    {
        cout << (com[K - 1][i - 1] * com[N - K + 1][i]) % mod << endl;
    }
}

Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, 3) {
    if(S[i] == T[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    int n;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    sort(l,l+n);
    int sum=0;
    for(int i=0;i<n-1;i++) sum+=l[i];
    if(l[n-1]<sum) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  int A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  bool ok = true;
  rep(i,A+B+1){
    if(i<A||i>A){
      int t = S[i] - '0';
      if(t<0||t>=10) ok = false;
    }
    else {
      if(S[i]!='-') ok = false;
    }
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

// main.cpp

int main() {
  std::int_fast64_t N, K;
  std::cin >> N >> K;

  std::int_fast64_t answer = 0;
  for (std::int_fast64_t b = K + 1; b <= N; ++b) {
    answer += (N / b) * (b - K) + std::max<std::int_fast64_t>(0, (N - (N / b) * b) - K + 1) - (K == 0 ? 1 : 0);
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 256
INFTY = float('inf')
count = 0

def merge(A, left, mid, right):
    L = A[left:mid] + [INFTY]
    R = A[mid:right] + [INFTY]
    i, j = 0, 0  
    global count 
    
    for k in range(left, right):
        count += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
S = list(map(int, input().split()))

mergeSort(S, 0, n)
print(*S)
print(count)


Measured memory_bytes: 61652
import std.functional,
       std.algorithm,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

void main() {
  int[] inputs = readln.chomp.split.to!(int[]);
  int N = inputs[0],
      L = inputs[1];
  string[] S;

  foreach (_; N.iota) {
    S ~= readln.chomp;
  }

  sort(S);
  writeln(S.join);
}


Measured memory_bytes: 380
# AGC033A
# http://drken1215.hatenablog.com/entry/2019/05/05/223200
# を参考に解いた
# 多点スタートと考えて解く

from collections import deque
# 入力
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

# 4方向を定義
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

# BFSのためのデータ構造
dist = [[-1] * W for _ in range(H)]
que_x = deque()     # H
que_y = deque()     # W

# 多点スタート地点を決める
# スタート地点は0とする
for i in range(H):
    for k in range(W):
        if field[i][k] == "#":
            dist[i][k] = 0
            que_x.append(i)
            que_y.append(k)

# 多点スタート
# 0のところから順に1を増やしていく
# ex): 3地点a, b, cからスタートとすると
# aから周囲4箇所に1をつける -> bから周囲4箇所に1をつける -> cから周囲4箇所に1をつける
# aの周囲4箇所の内1点から周囲4箇所に2をつける -> aの周囲4箇所の内2点目から周囲4箇所に2をつける
# aの周囲4箇所が終われば次はbの周囲4箇所，それが終わればcの周囲4箇所
while que_x and que_y:
    x = que_x[0]
    y = que_y[0]
    que_x.popleft()
    que_y.popleft()
    for direct in range(4):
        nx = x + dx[direct]
        ny = y + dy[direct]
        if nx < 0 or H <= nx or ny < 0 or W <= ny:      # 場外はスルー
            continue
        if dist[nx][ny] == -1:      # まだ見ていない時
            que_x.append(nx)
            que_y.append(ny)
            dist[nx][ny] = dist[x][y] + 1       # 距離の更新

# distの最大値が答え (= 最も遠いところ)
tmp = [0] * H
for i in range(H):
    tmp[i] = max(dist[i])

print(max(tmp))

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

int main() {
    long long N;
    cin >> N;
    vector <long long> F(N+1);
    for (long long x=1; x<N; x++) {
        for (long long y=1; y<N; y++) {
            for (long long z=1; z<N; z++) {
                long long f = pow(x,2)+pow(y,2)+pow(z,2)+x*y+y*z+z*x;
                if (f<=N) F.at(f)++;
                else break;
            }
        }
    }
    for (long long i=0; i<N; i++) cout << F.at(i+1) << endl;
}

Measured memory_bytes: 3576
a,b,k=map(int,input().split())

if b-a+1>=2*k:
    aa=[a+i for i in range(k)]
    bb=[b-i for i in range(k)]
    cc=sorted(aa+bb)
    for s in cc:
        print(s)
else:
    for n in range(a,b+1):
        print(n)


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

int a, b, c;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c;
	if((a == b && b == c) || (a != b && b != c && c != a)) cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;
    map<pair<int, int>, int> store ;
    for (int i=0; i<n; i++){
        double no;
        long long lno;
        cin >> no;
        lno = llround(no*1e9);
        int two = 0, five = 0;
        while(lno%2==0)
            two++, lno >>= 1;
        while(lno%5==0)
            five++, lno /= 5;
        store[{two, five}]++;
    }
    long long ans = 0;
    for (auto i: store)
        for (auto j: store)
            if (i.first.first+j.first.first>=18 && i.first.second+j.first.second>=18){
                if (i.first<j.first)
                    ans += 1ll*i.second*j.second;
                else if (i.first==j.first)
                    ans += 1ll*i.second*(i.second-1)/2;
            }
    cout << ans <<"\n";
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE=30000020;
int bufpos;
char buf[MAXSIZE];
void init(){
	buf[fread(buf,1,MAXSIZE,stdin)]='\0';
	bufpos=0;
}
int readint(){
	bool isneg;
	int val=0;
	for(;!isdigit(buf[bufpos]) && buf[bufpos]!='-';bufpos++);
	bufpos+=(isneg=(buf[bufpos]=='-'))?1:0;
	for(;isdigit(buf[bufpos]);bufpos++)
		val=val*10+buf[bufpos]-'0';
	return isneg?-val:val;
}
char readchar(){
	for(;isspace(buf[bufpos]);bufpos++);
	return buf[bufpos++];
}
int readstr(char* s){
	int cur=0;
	for(;isspace(buf[bufpos]);bufpos++);
	for(;!isspace(buf[bufpos]);bufpos++)
		s[cur++]=buf[bufpos];
	s[cur]='\0';
	return cur;
}
bool from[200001],to[200001];
int main(){
	init();
	int n=readint(),m=readint();
	while(m--){
		int x=readint(),y=readint();
		if (x>y)
			swap(x,y);
		if (x==1)
			from[y]=true;
		if (y==n)
			to[x]=true;
	}
	for(int i=1;i<=n;i++)
		if (from[i] && to[i])
			return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
}

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

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b; cin>>a>>b;
  if(a*b==0||(a<0&&0<b)){
    cout<<"Zero"<<endl;
  }else if(0<a){
    cout<<"Positive"<<endl;
  }else if(b<0){
    if((abs(a-b)+1)%2) cout<<"Negative"<<endl;
    else cout<<"Positive"<<endl;
  }
}

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

//*** constant value ***
const long double PI = 3.141592653589793238;

//*** constant value ***




//****** define ********
#define ll long long
#define dd double
#define vc vector<ll>
#define f(i,a,b) for( i=a;i<b;i++)
#define f1(i,a,b) for( i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vp vector<pll>
#define sf(a) scanf("%d",&a)
#define sfl(a) scanf("%lld",&a)
#define sfd(a) scanf("%Lf",&a)
#define ss(s) scanf("%s",s)
//****** define ********

bool isPrime(ll n)
{
    ll i,q;
    q = sqrt(n);
    f(i,2,q+1)
    {
        if(n%i==0)
            return false;
    }
}

int main()
{
    ll n;
    cin>>n;
    while(1)
    {
         if(isPrime(n))
            break;
         else
            n++;
    }
    cout<<n<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int x[30];

int main()
{
    int n, m;
    cin >> n >> m;
    rep(i, n) {
        int k;
        cin >> k;
        rep(j, k) {
            int a;
            cin >> a;
            a--;
            x[a]++;
        }
    }
    int ans = 0;
    rep(i, m){
        if(x[i] == n) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
//#define INFTY 5
#define WHITE 0
#define GRAY 1
#define BRACK 2
static const int INFTY = (1<<21);

int n,M[N][N];

main(){

  int i,j,u,k,v,c,minv;
  int d[N],p[N],color[N];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }


  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=WHITE;

  while(1){
    u=-1;
    minv=INFTY;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]==WHITE){
	u=i;
	minv=d[i];
      }
    }

    if(u==-1) break;
    color[u]=GRAY;

    for(i=0;i<n;i++){
      if(M[u][i]+d[u]<d[i]&&color[i]==WHITE){
	d[i]=M[u][i]+d[u];
	p[i]=u;
      }


    }
  }

 for(i=0;i<n;i++){
   printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
 }
 return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;


ll a[1100000];
int main(){
  string s,t;
  ll ans=0;
  cin>>s>>t;
  rep(i,0,3)if(s[i]==t[i])ans++;
  cout<<ans;
}

Measured memory_bytes: 764
/*#include<utility>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<iostream>
#include<string.h>*/
#include<bits/stdc++.h>
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
using namespace std;
typedef long long LL;
set<int> v[200005];
int main(){
    int h,w,n;
    scanf("%d %d %d",&w,&h,&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        swap(x,y);
        v[x].insert(y);
    }
    for(int i=1;i<=h;i++){
        v[i].insert(w+1);
     //   sort(v[i].begin(),v[i].end());
    }
  /*  for(int i=1;i<=h;i++){
        printf("i:%d ",i);
        for(auto it:v[i])
        printf("%d ",it);
        printf("\n");
    }*/
    int ans=(*v[1].begin()-2)*2+1;
    if(*v[1].begin()==2){
        printf("1\n");
        return 0;
    }
    int now=2;
    for(int i=2;i<=h;i++){
        while(v[i].find(now)!=v[i].end())now++;
        if(now>=w)
        break;
        int y=*v[i].upper_bound(now)-1;
        if(y==now)
        ans=min(ans,(y-1)*2+2);
        else
        ans=min(ans,(y-1)*2+1);
        //ans=min(ans,y-1+i-1);
     //   printf("%d %d %d\n",i,y,now);
        now++;
    }
    printf("%d\n",(ans+1)/2);
}
/*
0 1 0
0 0 1
1 0 1
*/

Measured memory_bytes: 28416
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif
 
int main(){
	std::vector<int> c(3);
	std::vector<int> all_cards(10);

	for(int i = 0; i < 10; i++){
		all_cards[i] = i + 1;
	}

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> c[0] >> c[1] >> c[2]){
#else
	while(std::cin >> c[0] >> c[1] >> c[2]){
#endif
		std::vector<int> remaining_cards;
		int t = 20 - c[0] - c[1];
		int all_counter = 0;
		int t_counter = 0;

		std::sort(c.begin(), c.end());
		std::set_difference(all_cards.begin(), all_cards.end(), c.begin(), c.end(), std::inserter(remaining_cards, remaining_cards.begin()));

		for(int i = 0; i < remaining_cards.size(); i++){
			if(remaining_cards[i] <= t){
				t_counter++;
			}
			all_counter++;

		}
		if(double(t_counter) / all_counter >= 0.5){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}
 
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int k, t, ans=0;
    cin >> k >> t;
    REP(i,t){
        int a;
        cin >> a;
        if(k%2==0)ans = max(ans,min(a,(a-k/2)*2)-1);
        else ans = max(ans, min(a,(a-k/2-1)*2));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()
check = 0

if N%2 == 1:
    for i in range(N):
        if A[i] == ((i+1)//2) * 2:
            pass
        else:
            check = 1
else:
    for i in range(N):
        if A[i] == (i//2) * 2 + 1:
            pass
        else:
            check = 1

if check == 0:
    ans = 1
    for i in range(N//2):
        ans *= 2
        ans %= 1000000007
else:
    ans = 0

print(ans)

Measured memory_bytes: 14008
#include<iostream>
#include<queue>
#include<limits>
// #include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<cmath>
#include<math.h>
#include<iomanip>  
#include<deque> 
#include<stack>
#include<string> 
#include<string.h>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#define ll long long
#define tc(t)  while(t--)
#define V vector
#define Vp vector< pair<int,int> >
#define pb push_back
#define UM unordered_map
#define IT iterator
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define PQ priority_queue
#define _FI ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

 char ar[140000];
vector<ll> SieveOfEratosthenes(ll n) 
{ 
  vector<ll> result;
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    int count=1;
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        {  
            for (ll i=p*p; i<=n; i += p) 
                {
                  prime[i] = false; 
                }
            count++;
        } 
    } 
  
    for (ll p=2; p<=n; p++) 
       if (prime[p]) 
          {
            result.push_back(p);
          }
    return result;
}



vector<ll> Divisors (ll n)
{
  vector<ll> res;
  for(ll i=1;i<=sqrt(n);i++)
  {
    if(n%i==0)
    {
      if(n/i==i)
      {
        res.pb(i);
      }
      else
      {
        res.pb(i);
        res.pb(n/i);
      }
    }
  }

  return res;
}

int a[4][2]={ {1,0}, {1,-1}, {1,1}, {2,0} } ;
bool validPoint(int x,int y, int N)
{
    return (x>=0 && x<N && y>=0 && y<N);
}


 
int main()
{
  _FI 
  
  ll h;
  cin>>h;

  unsigned ll moves=0;
  if(h==1)
  {
    cout<<1<<endl;
  }
  else if(h==2)
  {
    cout<<3<<endl;
  }
  else
  {
    ll count=0;
    while(h!=1)
    {
      h=h/2;
      count++;
    }
    cerr<<"Count is: "<<count<<endl;
    for(int i=0;i<count;i++)
    {
      moves+= pow(2,i);
    }
    moves=moves+pow(2,count);
    cerr<<"moves is: ";
    cout<<moves<<endl;

  } 

  return 0;
}












 // V<double> arr(2*n);
 //  V<double> proper;
 //  V<double> improper;
 //  double sum=0;
 //  for(int i=0;i<2*n;i++)
 //  {
 //      cin>>arr[i];
 //      sum+=arr[i];
 //      if(arr[i]-floor(arr[i])==0)
 //        proper.pb(arr[i]);
 //      else
 //        improper.pb(arr[i]);
 //  }


Measured memory_bytes: 3296
my $s = <>;
my ($N,$M,$X) = split(/ /,$s);
my @DB;
for(my $i=0; $i<$N;$i++){
   $s = <>;
   my @dat = split (/ /,$s);
   $DB[$i] = \@dat;
}
my @list;
$list[0][0] = 0;
for(my $i=0; $i<$N;$i++){
  my @newlist;
  for(my $j=0;$j<=$#list;$j++){
    my @new = @{$list[$j]};
    my @new2 = @new;
    push (@new, 0);
    push (@new2, 1);
    push (@newlist,\@new);
    push (@newlist,\@new2);
  }
  @list = @newlist;
}
my $mncost =10**7;
for(my $k=1; $k<=$#list;$k++){
   #print "@{$list[$k]}\n";
   my @skill;
   my $cost =0;
   for(my $j=1;$j<=$#{$list[$k]};$j++){
       #print "$list[$k][$j]\n";
       if( $list[$k][$j]){
           $cost = $cost + $DB[$j-1][0];
           for(my $m=0;$m<$M;$m++){
               $skill[$m] = $skill[$m]+ $DB[$j-1][$m+1];
           }
       }
   }
   my $flag = 1;
   #print "skill ck\n";
   for(my $m=0;$m<$M;$m++){
       #print "$skill[$m] ";
       if( $skill[$m] < $X  ){ $flag = 0;}
    }
   if($flag){
     if($mncost >$cost){
         $mncost = $cost;
     }
   }
}
if( $mncost == 10**7){
    print "-1";
}else{
    print "$mncost";
}


Measured memory_bytes: 8256