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

int main() {
    int K;
    int64_t ans = 1;
    int64_t x = 0;
    cin >> K;
    unordered_set<int> a;
    while (true) {
        x = (10 * x + 7) % K;

        if (a.count(x)) {
            cout << -1 << endl;
            exit(0);
        }
        a.insert(x);
        if (x == 0) {
            cout << ans << endl;
            exit(0);
        }

        ans++;
    }
}


Measured memory_bytes: 43072
s = input()

def put_key(x,ans):
  if x =="0":
    return ans + "0"
  elif x== "1":
    return ans + "1"
  else:
    ls = list(ans)
    if len(ls) == 0:
      return ans
    else:
      ls[-1] = ""
      return  "".join(ls)

ans =str("")
for t in range(len(s)):
  ans = put_key(s[t],ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e3 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int d[4][2] = {0 , 1 , 0 , -1 , 1 , 0 , -1 , 0} ;
char s[N][N] ;
int dis[N][N] ;
int work()
{
  int n , m , cx , cy , dx , dy;
  scanf("%d%d%d%d%d%d" , &n , &m , &cx , &cy , &dx , &dy) ;
  for(int i = 1; i <= n ;i ++ ) scanf("%s" , s[i] + 1) ;
  memset(dis , 0x3f , sizeof dis) ;
  dis[cx][cy] = 0 ;
  deque<PII> q ;
  q.push_back({cx , cy}) ;
  while(q.size()) {
    int x = q.front().x , y = q.front().y ;
    q.pop_front() ;
    for(int i = 0 ;i < 4 ;i ++ )
     {
       int tx = x + d[i][0] , ty = y + d[i][1] ;
       if(tx < 1 || ty < 1 || tx > n || ty > m || s[tx][ty] == '#') continue ;
       if(dis[tx][ty] > dis[x][y]) {
         dis[tx][ty] = dis[x][y] ;
         q.push_front({tx , ty}) ;
       }
     }
     for(int i = -2 ;i <= 2; i ++ ) {
       for(int j = -2 ;j <= 2; j ++ ) {
         int tx = x + i , ty = y + j ;
         if(tx < 1 || ty < 1 || tx > n || ty > m || s[tx][ty] == '#') continue ;
         if(dis[tx][ty] > dis[x][y] + 1) {
           dis[tx][ty] = dis[x][y] + 1 ;
           q.push_back({tx , ty}) ;
         }
       }
     }
  }
  if(dis[dx][dy] == INF) dis[dx][dy] = -1 ;
  cout << dis[dx][dy] << endl ;
  return 0 ;
}
int main()
{
  //   freopen("C:UsersspnooyseedDesktopin.txt" , "r" , stdin) ;
  //   freopen("C:UsersspnooyseedDesktopout.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 8240
N, M = map(int, input().split())

wa_stock = [0] * N
ac = 0
wa = 0
stat = ['NA'] * N

for _ in range(M):
    p, S = input().split()
    key = int(p) - 1
    if S == 'WA':
        wa_stock[key] += 1
    elif stat[key] != 'AC' and S == 'AC':
        stat[key] = 'AC'
        ac += 1
        wa += wa_stock[key]

print(ac, wa)


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

int main() {
  int N;
  cin >> N;
  vector<int> grid(N);
  for (int i=0; i<N; ++i) {
    cin >> grid[i];
  }

  int count = 0;
  int x = 0;
  for (int i=0; i<N-1; ++i) {
    if (grid[i] >= grid[i+1]) {
      ++x;
    } else {
      count = max(x, count);
      x = 0;
    }
  }

  cout << max(count, x) << "\n";

  return 0;
}


Measured memory_bytes: 768
fun main(args: Array<String>) {
    val L = nextInt()
    var l = L
    var dl = 0
    var ce = 0
    val te = BooleanArray(20)
    val str = StringBuilder()
    while (l > 0) {
        if (l and 1 != 0) {
            te[dl] = true
            ce += 1
        }
        l /= 2
        dl += 1
    }
    str.append("${dl} ${(dl - 1) * 2 + ce - 1}\n")
    l = L
    var t = 1
    for (n in 1 until dl) {
        str.append("${n} ${n + 1} ${0}\n")
        str.append("${n} ${n + 1} ${t}\n")
        if (te[n - 1]) {
            str.append("${n} ${dl} ${l - t}\n")
            l -= t
        }
        t *= 2
    }
    print(str.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 33780
// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);

int main()
{
    io;
    ll x, k, d;
    cin >> x >> k >> d;
    ll mm = x / d;
    mm = (mm < 0 ? -mm : mm);

    if (x <= 0)
    {
        if (k <= mm)
        {
            x += k * d;
        }
        else
        {
            x += mm * d;
            k -= mm;
            if (k & 1)
                x += d;
        }
    }
    else if (x > 0)
    {
        if (k <= mm)
        {
            x -= k * d;
        }
        else
        {
            x -= mm * d;
            k -= mm;

            if (k & 1)
                x -= d;
        }
    }

    cout << (x < 0 ? -x : x);
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int f(int a) {
  if (a == 2) return 2;
  if (a == 4 || a == 6 || a == 9 || a == 11) return 1;
  return 0;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  int ca = f(a), cb = f(b);
  if (ca == cb) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    T = readstr()
    T = T.translate(str.maketrans({'?': 'D'}))
    print(T)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, h;
    cin >> n >> h;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> bs(n);
    int amax = 0;
    int amaxi = 0;
    rep(i, n){
        cin >> a.at(i) >> b.at(i);
        if(a.at(i) > amax){
            amax = a.at(i);
            amaxi = i;
        }
    }
    int k = 0;
    rep(i, n){
        if(i != amaxi){
            bs.at(k) = b.at(i);
            k++;
        }
    }
    sort(bs.begin(), bs.end());
    reverse(bs.begin(), bs.end());
    int cou = 0;
    if(h-b.at(amaxi) <= 0){
        cou++;
        cout << cou << endl;
        return 0;
    }
    rep(i, n-1){
        if(bs.at(i) > a.at(amaxi)){
            h -= bs.at(i);
            cou++;
            if(h <= 0){
                cout << cou << endl;
                return 0;
            }
            if(h-b.at(amaxi) <= 0){
                cou++;
                cout << cou << endl;
                return 0;
            }
        }
    }
    if(a.at(amaxi) < b.at(amaxi)){
        h -= b.at(amaxi);
        cou++;
        if(h <= 0){
            cout << cou << endl;
            return 0;
        }
    }
    if(h%a.at(amaxi) == 0){
        cou += h/a.at(amaxi);
    }else{
        cou += h/a.at(amaxi);
        cou++;
    }
    cout << cou << endl;
    return 0;
}

Measured memory_bytes: 1408
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy

def main():
    n, *x = map(int, read().split())
    if n == 2:
        print(x[1])
        print(x[0])
        sys.exit()

    x2 = deepcopy(x)
    x2.sort()
    r1 = x2[n//2-1]
    r2 = x2[n//2]
    for xe in x:
        if xe > r1:
            print(r1)
        else:
            print(r2)
if __name__ == '__main__':
    main()

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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string red, blue;
  cin >> red >> blue;

  ll A, B;
  cin >> A >> B;

  string U;
  cin >> U;

  if (U == red) {
    A--;
  } else {
    B--;
  }

  cout << A << " " << B << endl;

  return 0;
}


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

const ll INF = 100100100100;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (auto &h : H) cin >> h;
  vector<ll> C(N, INF);
  C[0] = 0;
  rep(i, N - 2) {
    int h1 = abs(H[i + 1] - H[i]);
    C[i + 1] = min(C[i + 1], C[i] + h1);
    int h2 = abs(H[i + 2] - H[i]);
    C[i + 2] = min(C[i + 2], C[i] + h2);
  }
  C[N - 1] = min(C[N - 1], C[N - 2] + abs(H[N - 1] - H[N - 2]));
  cout << C[N - 1] << endl;
}

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

int main()
{
  int n;
  cin>>n;
  int a,count=0,nEven=0;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    if(a%2==0)
    {
      count++;
      if(a%3==0 || a%5==0)
        nEven++;
    }
  }
 
  if(count==nEven)
    cout<<"APPROVED\n";
  else
    cout<<"DENIED\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b;
	cin>>a>>b;
	int x=a*b;
	bool flg=false;
	for(int i=1;i<=3;i++){
		if((x*i)%2!=0){
			flg=true;
		}
	}
	cout<<((flg)?"Yes":"No")<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int llint;
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}

int main(void){
	llint n,i,q,ans=1;cin>>n;
	for(i=0;i<n;i++){cin>>q;ans=lcm(ans,q);}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i++) {
    if (i != s.find(s[i])) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
}


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

int main() {
    string s;
    cin >> s;
    string a = s.substr(0,2);
    string b = s.substr(2,2);
    if ("01"<=a&&a<="12" && "01"<=b&&b<="12") cout << "AMBIGUOUS" << endl;
    else if(b!="00"&&b<"13") cout << "YYMM" << endl;
    else if (a!="00"&&a<"13") cout << "MMYY" << endl;
    else cout << "NA" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(m), c(m);
    rep(i, m) cin >> b[i] >> c[i];
    priority_queue<P> q;
    rep(i, n) {
        q.push(make_pair(a[i], 1));
    }
    rep(i, m) {
        q.push(make_pair(c[i], b[i]));
    }
    ll ans = 0;
    rep(i, n) {
        auto p = q.top();
        q.pop();
        ans += p.first;
        if(p.second > 1) {
            --p.second;
            q.push(p);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6484
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N, M;
    cin >> N;
    unordered_map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        ++mp[p];
    }
    cin >> M;
    for (int i = 0; i < M; ++i) {
        int p;
        cin >> p;
        --mp[p];
        if (mp[p] < 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8520
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main(){
    int n;
    int cnt1=0,cnt2=0,cnt3=0,cnt4=0;
    cin>>n;
    string s;

    rep(i,n){
        cin>>s;
        if(s=="AC") cnt1++;
        else if(s=="WA") cnt2++;
        else if(s=="TLE") cnt3++;
        else if(s=="RE") cnt4++;
    }
    cout<<"AC  x  "<<cnt1<<endl;
    cout<<"WA  x  "<<cnt2<<endl;
    cout<<"TLE  x  "<<cnt3<<endl;
    cout<<"RE  x  "<<cnt4<<endl;
    return 0;
}

Measured memory_bytes: 3640
//
// Created by Myabu on 2020/01/23.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N,A,B;

    cin>>N>>A>>B;
    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        int hitoketa = i % 10;
        int jyuu = i % 100 / 10;
        int hyaku = i % 1000 / 100;
        int sen = i %10000 / 1000;
        int man = i % 100000 / 10000;

        int temp = hitoketa + jyuu + hyaku +sen + man;

        if(temp >= A && temp<=B){
            ans+=i;
        }
    }

    cout<<ans<<endl;

    return 0;
}

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


int main()
{
	const int MOD=1e9+7;
	int N;
	cin>>N;
	map<int,int> m;
	rep(i,N)
	{
		int a;
		cin>>a;
		m[a]++;
	}
	int res=0;
	if(N%2==1)
	{
		if(m[0]!=1)
		{
			cout<<0<<endl;
			return 0;
		}
		res=2;
	}
	else
	{
		res=1;
	}
	int ans=1;
	while(res<=N)
	{
		if(m[res]!=2)
		{
			cout<<0<<endl;
			return 0;
		}
		ans*=2;
		ans%=MOD;
		res+=2;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6556
#include <stdio.h>
 
int ans,Sum;
 
void dfs(int i,int s,int n)
{
    if(s == Sum && n == 0)
    {
        ans++;
        return;
    }
 
    if(i == 10 || n == 0)
        return;
 
    dfs(i+1,s+i,n-1);
    dfs(i+1,s,n);
}
 
int main(void)
{
    int n;
 
    while(scanf("%d %d",&n,&Sum) != EOF)
    {
        if (n == 0 && Sum == 0)
            break;
 
        ans = 0;
        dfs(0,0,n);
 
        printf("%d\n", ans);
    }
 
    return 0;
}

Measured memory_bytes: 600
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 Silviase
 */
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);
    ABC126DEvenRelation solver = new ABC126DEvenRelation();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC126DEvenRelation {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      PotentialUnionFind puf = new PotentialUnionFind();
      StringBuilder sb = new StringBuilder();
      int n = in.nextInt();
      int[] u = new int[n];
      int[] v = new int[n];
      long[] w = new long[n];
      puf.init(n);
      for (int i = 0; i < n - 1; i++) {
        u[i] = in.nextInt() - 1;
        v[i] = in.nextInt() - 1;
        w[i] = in.nextLong();
        puf.union(u[i], v[i], w[i]);
      }

      for (int i = 0; i < n; i++) {
        sb.append(((puf.potential(i) % 2)+2)%2);
        sb.append("\n");
      }
      out.println(new String(sb));

    }

  }

  static class UnionFind {

    int[] par;
    int[] rank;

  }

  static class PotentialUnionFind extends UnionFind {

    private long[] pot;

    void init(int n) {
      par = new int[n];
      rank = new int[n];
      pot = new long[n];
      for (int i = 0; i < n; i++) {
        par[i] = i; // はじめは全員が根である
        rank[i] = 0;
        pot[i] = 0;
      }
    }

    int root(int x) {
      if (par[x] == x) {
        return x;
      } else {
        int r = root(par[x]);
        pot[x] += pot[par[x]];
        par[x] = r;
        return par[x];
      }
    }

    void union(int x, int y, long w) {
      w = w + potential(x) - potential(y);
      int rx = root(x);
      int ry = root(y);
      if (rx == ry) {
        return;
      }
      if (rank[rx] < rank[ry]) {
        int tmp = rx;
        rx = ry;
        ry = tmp;
        w = -w;
      }
      if (rank[rx] == rank[ry]) {
        rank[rx]++;
      }
      par[ry] = rx;
      pot[ry] = w;
    }

    long potential(int x) {
      root(x);
      return pot[x];
    }

  }
}



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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;

	ll MAX = 1;
	ll WOM = 2;

	vector<string> isu(N);

	string S;
	ll l = 0;
	ll r = N-1;

	std::cout << l << std::endl;
	cin >> S;
	if (S == "Vacant") return 0;
	isu[l] = S;
	
	while (true)
	{
		if (r - l <= 1)
		{
			std::cout << r << std::endl;
			cin >> S;
			if (S == "Vacant") return 0;
		}

		ll mid = (l + r) / 2;

		std::cout << mid << std::endl;
		cin >> S;
		if (S == "Vacant") return 0;
		isu[mid] = S;

		ll diff = mid - l - 1;;

		if (diff % 2 == 0)
		{
			if (isu[l] == isu[mid])
			{
				r = mid - 1;
			}
			else
			{
				l = mid;
			}
		}
		else
		{
			if (isu[l] == isu[mid])
			{
				l = mid;
			}
			else
			{
				r = mid - 1;
			}
		}
	}
}
 


Measured memory_bytes: 1620
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n, x;
    cin >> n >> x;
    vi l;
    forn(i, n) {
        int t;
        cin >> t;
        l.pb(t);
    } 

    int ret = 1;
    int cur = 0;
    
    forn(i, n) {
        cur += l[i];
        if (cur <= x) ret++;
        else break;
    }

    cout << ret << endl;

    return 0;
}



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

int main(){
	
  double a;
  double b;
  cin>>a;
    cin>>b;
    int c;
    c=std::ceil((a+b)/2);
    
    //c=ceil((a+b)/2)
  cout<<c<<endl;
return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i=0; i<N; i++)
			a[i] = sc.nextInt();
		
		int min = Integer.MAX_VALUE;
		
		for(int i=-100; i<=100; i++) {
			int sum = 0;
			for(int j=0; j<N; j++)
				sum += (a[j]-i)*(a[j]-i);
			min = Math.min(min, sum);
		}
		
		System.out.println(min);
		sc.close();
	}
}


Measured memory_bytes: 9680
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n;
	rl(n);
	VL arr(n);
	ll prod=1;
	double inv=0;
	fr(i,0,n)
	{
		rl(arr[i]);
		prod*=arr[i];
		inv+=(double)1/(double)arr[i];
	}
	double sum=0;
	// fr(i,0,n)
	// {
	// 	sum+=(double)prod/(double)arr[i];
	// }
	double ans=(double)1/inv;
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  map<int, int> count = {{1, 0}, {9, 0}, {7, 0}, {4, 0}};
  int n;
  REP(i, 4) {
    cin >> n;
    if (count.find(n) == count.end()) {
      cout << "NO" << endl;
      return 0;
    }
    ++count.at(n);
  }

  for (auto const &it : count) {
    if (it.second != 1) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Earth Invasion Diary of Miyabi-sensei
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());

		int k = 0;
		while (N > Math.pow(3, k)) k++;
		System.out.println(k);
	}
}

Measured memory_bytes: 24296
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, m;
string s;
vector<int> ans;
signed main() {

    cin >> n >> m;
    cin >> s;

    int u = n;
    bool f = false;
    while(u and !f) {
        f = true;
        for(int i = min(m, u); i > 0 and f; i--) {
            if(s[u-i]=='0') {
                u -= i;
                ans.bash(i);
                f = false;
            }
        }
    }

    if(u) cout << -1 << endl;
    else{
        reverse(ALL(ans));
        for(auto i: ans)
            cout << i ___ ;
    }    
    
    return 0;
}



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

int main() {
  int A,B;
  cin >> A >> B;
  int sum;
  
  for (int i = 0;i < B - A + 1;i++) {
    int x = A + i;
    x /= 1000;
    x = x / 10 + x % 10 * 10;
    int y = A + i;
    y %= 100;
    
    if (x == y) {
      sum++;
    }
  }
  
  cout << sum << endl;
      

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

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

    int a[20] = {};
    int x[20][20] = {}, y[20][20] = {};

    rep(i, n){
        cin >> a[i];
        rep(j, a[i]){
            cin >> x[i][j] >> y[i][j];
        }
    }

    int d[20] = {};

    int ans = 0;
    rep(i, 1<<n){
        int cnt = 0;
        int ii = i;
        rep(j, n){
            d[j] = ii%2;
            ii /= 2;
            cnt += d[j];
        }

        bool flag = true;
        rep(j, n){
            if(d[j]==1){
                rep(k, a[j]){
                    if(y[j][k]==1){
                        if(d[x[j][k]-1]!=1){
                            flag = false;
                            // printf("%d %d %d\n", i, j, k);
                        }
                    }else{
                        if(d[x[j][k]-1]!=0){
                            flag = false;
                            // printf("%d %d %d\n", i, j, k);
                        }
                    }
                }
            }
        }
        // printf("%d\n", i);
        if(flag){
            // printf("%d %d \n", i, cnt);
            ans = max(ans, cnt);

        }
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
# 入力
N = int(input())
gA, sA, bA = map(int, input().split())
gB, sB, bB = map(int, input().split())

A = (gA, sA, bA)
B = (gB, sB, bB)


# 各貴金属について、買う／売る可能性のある取引所は一意に定まることを用いて
# 全探索により解を求める
def f(n, r):
    R = len(r)
    if R == 0:
        return n
    elif R == 1:
        return n + (r[-1][1] - r[-1][0]) * (n // r[-1][0])
    elif R == 2:
        dr0 = r[0][1] - r[0][0]
        dr1 = r[-1][1] - r[-1][0]
        res = 0
        for x in range(n // r[0][0] + 1):
            res = max(res, dr0 * x + dr1 * ((n - r[0][0] * x) // r[-1][0]))
        return n + res
    else:
        dr0 = r[0][1] - r[0][0]
        dr1 = r[1][1] - r[1][0]
        dr2 = r[-1][1] - r[-1][0]
        res = 0
        for x in range(n // r[0][0] + 1):
            m = n - r[0][0] * x
            for y in range(m // r[1][0] + 1):
                res = max(
                    res,
                    dr0 * x + dr1 * y + dr2 * ((m - r[1][0] * y) // r[-1][0])
                )
        return n + res


ans = f(
    f(
        N,
        [
            (a, b)
            for a, b in zip(A, B)
            if a < b
        ]
    ),
    [
        (b, a)
        for b, a in zip(B, A)
        if a > b
    ]
)

# 出力
print(ans)


Measured memory_bytes: 39280
n = int(input())

l = []
for i in range(1, int(n ** 0.5)+1):
    if n % i == 0:
        l.append([i, n//i])

res = float('inf')
for a, b in l:
    res = min(res, max(len(str(a)), len(str(b))))

print(res)

Measured memory_bytes: 67096
data_XN = input()
data_p = input()

XN = data_XN.strip().split()
X = int(XN[0])
N = int(XN[1])
p = data_p.strip().split()

for i in range(101):
    a = X - i
    b = X + i
    forbidden_a = False
    forbidden_b = False
    for j in range(N):
        if a == int(p[j]):
            forbidden_a = True
        if b == int(p[j]):
            forbidden_b = True
    if forbidden_a == True and forbidden_b == True:
        pass
    elif forbidden_a == True and forbidden_b == False:
        print(b)
        break
    elif forbidden_a == False and forbidden_b == True:
        print(a)
        break
    else:
        print(a)
        break

        

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

ll a[200100],b[200100];

int main()
{
    ll n,i,j,k,cnt=0,mx=0,pp;

    cin>>n>>k;
   for(i=0; i<k; i++)
   {
       cin>>a[i];
   }
   a[k]=n+a[0];
 sort(a,a+k+1);

 for(i=1; i<=k; i++)
 {
     b[i]=abs(a[i]-a[i-1]);
 }

 sort(b+1, b+k+1);

 for(i=1; i<k; i++)
    mx+=b[i];

 cout<<mx<<endl;



}








Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define INF (INT_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n, m;
  cin >> n >> m;

  int s = 100 * (n - m) + 1900 * m;
  cout << (1 << m) * s << endl;

  return 0;
}

Measured memory_bytes: 256
#D
N=int(input())
ans=0
D=[[0 for i in range(10)] for j in range(10)]

for i in range(1,10):
    for j in range(1,10):
        for k in range(1,N+1):
            if str(i)==str(k)[0] and str(j)==str(k)[-1]:
                D[i][j]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=D[i][j]*D[j][i]
print(ans)

Measured memory_bytes: 42460
S = input()[::-1]
T = input()[::-1]

for i in range(len(S)-len(T)+1):
    for j in range(len(T)):
        if T[j] != S[i+j] != '?':
            break
    else:
        break
else:
    print('UNRESTORABLE')
    exit()

ans = (S[:i] + T + S[i+len(T):])[::-1]
ans = ans.replace('?', 'a')
print(ans)

Measured memory_bytes: 3064
#include <iostream>
 using namespace std;
 
 int main(){
     int w,h,x,y,r;
     cin >> w >> h >> x >> y >> r;
     
     if (( x-r>=0 && x+r<=w) && ( y-r>=0 && y+r<=h)){
         cout << "Yes" << endl;
     }else{
         cout << "No" << endl;
     }
     return 0;
 }


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a>b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;


int main() {
  int n;
  cin>>n;
  string s[1010];
  int time[1010];
  rep(i,n){
      cin>>s[i]>>time[i];
  }
  string f;
  cin>>f;
  ll sum=0;
  repr(i,n){
      if(f==s[i]){
          break;
      }
      sum+=time[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for op1 in "-+":
    for op2 in "-+":
        for op3 in "-+":
            e = 0
            e += a + b if op1 == '+' else a - b
            e += c if op2 == '+' else -c
            e += d if op3 == '+' else -d
            if e == 7:
                s = str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d)
                print(s + "=7")
                exit(0)




Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// BIT stands for binary indexed tree.
type BIT []int

func newBIT(n int) BIT {
	return make([]int, n)
}

func (bit BIT) add(i, v int) {
	for i++; i <= len(bit); i += i & -i {
		bit[i-1] += v
	}
}

func (bit BIT) sum(i int) int {
	result := 0
	for i++; i > 0; i -= i & -i {
		result += bit[i-1]
	}
	return result
}

func (bit BIT) query(start int, stop int) int {
	return bit.sum(stop-1) - bit.sum(start-1)
}

func main() {
	defer flush()

	N := readInt()
	Q := readInt()

	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = readInt()
	}

	lr := make([][3]int, Q)
	for i := 0; i < Q; i++ {
		l := readInt() - 1
		r := readInt() - 1
		lr[i] = [3]int{i, l, r}
	}
	sort.Slice(lr, func(i, j int) bool { return lr[i][2] < lr[j][2] })

	result := make([]int, Q)
	bit := newBIT(N)
	mr := map[int]int{}
	k := 0
	for i := 0; i < N; i++ {
		if j, ok := mr[c[i]]; ok {
			bit.add(j, -1)
		}
		bit.add(i, 1)
		mr[c[i]] = i
		for k < Q && lr[k][2] == i {
			result[lr[k][0]] = bit.query(lr[k][1], lr[k][2]+1)
			k++
		}
	}

	for i := 0; i < Q; i++ {
		println(result[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 72684
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;
const double EPS = 1e-5;

typedef double Number;
typedef vector<Number> Array;
typedef vector<Array> Matrix;

void pMat(Matrix &a){
	REP(i,a.size()){
		REP(j,a[0].size()) cout << a[i][j] << ":";
		cout << endl;
	}
	cout << endl << endl;
}

Matrix mul(const Matrix &a, const Array &b){
	Matrix res(a.size(), Array(1));
	REP(i, a.size()){
		REP(k, a[0].size()){
				res[i][0] += a[i][k] * b[k];
		}
	}
	return res;
}
struct LUinfo {
  vector<Number> value;
  vector<int> index;
};
LUinfo LU_decomposition(Matrix A) {
  const int n = A.size();
  LUinfo data;
  for (int i = 0; i < n; ++i) {
    int pivot = i;
    for (int j = i+1; j < n; ++j)
      if (abs(A[j][i]) > abs(A[pivot][i])) pivot = j;
    swap(A[pivot], A[i]);
    data.index.push_back(pivot);
    for(int j = i+1; j < n; ++j) {
      A[j][i] /= A[i][i];
      for(int k = i+1; k < n; ++k)
        A[j][k] -= A[i][k] * A[j][i];
      data.value.push_back(A[j][i]);
    }
  }
  for(int i = n-1; i >= 0; --i) {
    for(int j = i+1; j < n; ++j)
      data.value.push_back(A[i][j]);
    data.value.push_back(A[i][i]);
  }
  return data;
}
Array LU_backsubstitution(const LUinfo &data, Array b) {
  const int n = b.size();
  int k = 0;
  for (int i = 0; i < n; ++i){
    swap(b[data.index[i]], b[i]);
    for(int j = i+1; j < n; ++j)
      b[j] -= b[i] * data.value[k++];
  }
  for (int i = n-1; i >= 0; --i) {
    for (int j = i+1; j < n; ++j)
      b[i] -= b[j] * data.value[k++];
    b[i] /= data.value[k++];
  }
  return b;
}


int d;

int calc(){
	vector<double> v(d+3);
	int ds = d+1;
	REP(i, d+3) cin >> v[i];
	REP(i, d+3){
		for(int j = i + 1; j < d+3; j++){
			Matrix A(ds, Array(ds, 0));
			Array B(ds);
			int id = 0;
			REP(k, d+3){
				if(k == i || k == j) continue;
				REP(l, ds) A[id][l] = pow(k, ds-l-1);
				B[id] = v[k];
				id++;
			}
			Array y = LU_backsubstitution(LU_decomposition(A), B);
			Matrix C(2, Array(ds, 0));
			REP(l, ds) C[0][l] = pow(i, ds-l-1);
			REP(l, ds) C[1][l] = pow(j, ds-l-1);
			
			Matrix z = mul(C, y);
/*
cout << "i : " << i << "j : " << j << endl;
cout << "C : " << endl;
pMat(C);
cout << "z : " << endl;
pMat(z);
*/
			if((abs(z[0][0] - v[i]) < EPS) && (abs(z[1][0] - v[j]) > EPS)) return j;
			if((abs(z[0][0] - v[i]) > EPS) && (abs(z[1][0] - v[j]) < EPS)) return i;
		}
	}
	return -1;
}

int main(void){
	while(cin>>d, d){
		cout << calc() << endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int a[100004];
int main()
{
	int n;
	scanf("%d",&n);
	int h=0;
	int t=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]); 
	}
	for(int i=1;i<=n;i++)
	{
		if(i==a[i])
		{
			t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
			h++;
		}
		
	}
	printf("%d\n",h);
	return 0;
} 

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int inv[3005],finv[3005],f[3005],mod,n,po[3005][3005];
void init(){
	finv[1]=1;f[0]=1;f[1]=1;finv[0]=1;inv[1]=1;
	FOR(i,2,n){
		inv[i]=mod-inv[mod%i]*(mod/i)%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
		f[i]=f[i-1]*i%mod;
	}
}
int C(int x,int y){
	RE f[x]*finv[y]*finv[x-y]; 
}
int ans[3005];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;mod=n;
	init();
	bool x;
	int t;
	FOR(i,0,n){
		po[i][0]=1;
		FOR(j,1,n){
			po[i][j]=po[i][j-1]*i%mod;
		}
	}
	FOR(i,1,n){
		cin>>x;
		if(!x)continue;
		FOR(j,1,n){
			t=po[n-i+1][n-j];
			t=t*C(n-1,j-1)%mod;
			ans[j]=(ans[j]-t+mod)%mod;
		}
		ans[1]=(ans[1]+1)%mod;
	}
	FOR(i,1,n)cout<<ans[i]<<' ';
	RE 0;
}




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

int main(){
	ll N;
	cin >> N;
	ll div = 5;
	ll ans = 0;

	if(N % 2 == 1)cout << 0 << endl;
	else{
		ll p = N / 10; 
		ans += N / 10;
		//cout << ans << endl;
			while( p /div != 0){
				//cout << "div:" << div << ", p/div2:" << p/div << ", ans:" << ans << endl; 
				ans += p/div ;
				div *= 5;
			}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int n,x[105],y[105],h[105],H,u,cx,cy,s; 
int main(){
    cin>>n;
    for(int i=1;i<=n;++i) 
	{
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0) u=i; 
	}
    for(int xi=0;xi<=100;++xi)
    	for(int yi=0;yi<=100;++yi) 
        {
    	    cx=xi,cy=yi;
    	    H=h[u]+abs(x[u]-cx)+abs(y[u]-cy);
    	    for(int i=1;i<=n;++i)
    	    {
    	    	if(h[i]!=max(H-abs(x[i]-cx)-abs(y[i]-cy),s)) break;
    	    	if(i==n) {cout<<cx<<" "<<cy<<" "<<H;return 0;}
			}
	    }
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> VI;
typedef vector<VI> VVI;

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int x,y;
    x = s1.size(); y = s2.size();
    VVI dp(y+1,vector<long long>(x+1,0));

    for (int i = 0; i < y; i++){
        for(int j = 0; j < x; j++){
            if (s1[j] == s2[i]){
                dp[i+1][j+1] = dp[i][j] +1;
            }
            else{
                dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
            }
        }
    }
    int ii = y, jj = x;
    vector<char> str(dp[y][x]);
    while ( ii != 0 && jj != 0){
        if ( dp[ii-1][jj] == dp[ii][jj]) {
            ii--;
        }
        else if (dp[ii][jj-1] == dp[ii][jj]){
            jj--;
        }
        else {
            str[dp[ii][jj]-1] = s2[ii-1];
            ii--;jj--;
        }


        /*if (s1[jj] != s2[ii]){
            if(dp[ii-1][jj] > dp[ii][jj-1]){
                ii--;                
            }
            else jj--;
        }
        else {
            str[dp[ii][jj]-1] = s1[jj];
            ii--;jj--; 
        }*/
    }

    for (char c : str) {
        cout << c;
    }

    return 0;
}
   


Measured memory_bytes: 70784
#include <stdio.h>
 
int main(){
    int countTable[256] = {0};
    char ch;
 
    while((ch = getchar()) != EOF){
                countTable[ch]++;
    }
    for(int i = 97; i <=122;i++)printf("%c : %d\n",i,countTable[i]+countTable[i-32]);
}


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

using namespace std;
using ll = long long;

int main() {
    ll H, W;
    cin >> H >> W;

    ll ans = H * W;
    ll s[3];
    for (int i = 0; i < 2; ++i) {
        for (ll h = 1; h < H; ++h) {
            // まずは縦割り
            s[0] = h * W;
            s[1] = (H - h) * (W / 2);
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);

            // 次いで横割り
            s[0] = h * W;
            s[1] = ((H - h) / 2) * W;
            s[2] = H * W - (s[0] + s[1]);
            sort(s, s + 3);
            ans = min(ans, s[2] - s[0]);
        }
        // 板チョコを90度回す
        swap(H, W);
    }
    cout << ans << endl;
    return 0;
}

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

bool incycle[200000];
vector<int> edge[200000];
int visit[200000];
int val[200000];
bool dfs(int x,int p){
	visit[x]=1;
	for(int i:edge[x])
		if(visit[i]==1){
			incycle[x]=true;
			visit[x]=2;
			return true;
		}
		else if(visit[i]==0)
			if(dfs(i,x)){
				incycle[x]=true;
				visit[x]=2;
				return true;
			}
	visit[x]=2;
	return false;
}

void dfs2(int x){
	set<int> tmp;
	for(int i:edge[x]){
		if(!incycle[i])
			dfs2(i),tmp.insert(val[i]);
	}
	for(int i=0;;i++)
		if(tmp.find(i)==tmp.end()){
			val[x]=i;
			break;
		}
}
set<int> s;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0,p;i<n;i++){
		cin>>p;
		p--;
		edge[p].emplace_back(i);
	}
	for(int i=0;i<n;i++)
		if(!visit[i])
			dfs(i,-1);
	int cnt=0;
	for(int i=0;i<n;i++)
		if(incycle[i])
			dfs2(i),s.insert(val[i]),cnt++;
	if(s.size()!=1||cnt%2==0)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;
	
}


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

int main(){
    int n,m,a,b;
    cin>>n>>m;
    vector<int>l(n);
    for(int i=0;i<n;i++){
        l.at(i)=0;
        }
    for(int i=0;i<m;i++){
        cin>>a>>b;
        l.at(a-1)++;
        l.at(b-1)++;
        }
    for(int i=0;i<n;i++){
        cout<<l.at(i)<<endl;;
        }
    }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	char a[101]={0};
	char b[101]={0};
	cin >> a;
	cin >> b;
	
	for(int i = 0; i < (int)strlen(a); i++) {
		char c = a[strlen(a)-1];
		for(int j = strlen(a)-1; j >= 1; j--) a[j]=a[j-1];
		a[0]=c;
		if (strcmp(a,b)==0){
			printf("Yes\n");
			return 0;
		}
	}
	
	printf("No\n");
	
	return 0;
}


Measured memory_bytes: 256
n=int(input())
t,x,y=0,0,0
flag=True
for i in range(n):
    a,b,c=map(int,input().split())
    if abs(x-b)+abs(y-c)>(a-t):
        print('No')
        flag=False
        break
    else:
        if (a-t)%2==(abs(x-b)+abs(y-c))%2:
            flag=True
            t=a
            x=b
            y=c
        else:
            print('No')
            flag=False
            break
if flag:
    print('Yes')


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

int n;
ll k;

vl A, F;

bool check(ll score){
    ll ans = 0;
    lp(i, 0, n){
        if (A[i]*F[i] > score)
            ans += A[i]-score/F[i];
    }
    return (ans <= k);
}

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

    cin>>n>>k;
    A.resize(n);
    F.resize(n);

    lp(i, 0, n) cin>>A[i];
    lp(i, 0, n) cin>>F[i];

    sort(all(A));
    sort(all(F), greater<int>());

    ll maxi = 0;
    ll L = 0, R;
    lp(i, 0, n) R = max(R ,A[i]*F[i]);

    ll ans = R;
    while (L<=R) {
        ll mid = L + (R-L)/2;
        if (check(mid)){
            ans = mid;
            R = mid-1;
        }
        else L = mid + 1;
    }

    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#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(){
    ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n) rep(j,m) cin >> a[i][j];
    int ans = 0;
    rep(i,n) {
        int num = c;
        rep(j,m) num+= a[i][j]*b[j];
        if(num>0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256