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

int a[100009];
map<int,int> s;
main(){
    int n;
    cin >> n;
    int S = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        S^=a[i];
        s[a[i]]++;
    }
    sort(a+1,a+n+1);

    if(s.size() > 3) {cout<<"No"<<endl; return 0;}
    if(s.size() == 1){
        if(a[1] == 0) cout<<"Yes"<<endl; else
            cout<<"No"<<endl;
        return 0;}
    if(s.size() == 2){
        if(a[1] == 0 && s[0] * 2 == s[a[n]]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    if(s.size()==3){
        for(int i = 1; i <= n-1; i++)
            if(s[a[i]] != s[a[i+1]] || S) {cout<<"No"<<endl; return 0;}
            cout<<"Yes"<<endl;
    }



}


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

#define ll long long

int main(void){
    int n;
    cin >> n;
    int t,a;
    cin >> t >> a;
    double tmp = 1000000;
    int ans = 1;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        double temperature = abs(a - (t - 0.006 * h));
        if(temperature < tmp){
            tmp = temperature;
            ans = i+1;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
x=input()
A=x.split()
S=[]
L=[]
for i in A:
    s=A.count(i)
    S.append(s)
    l=len(i)
    L.append(l)
M=max(S)
m=max(L)
Y=S.index(M)
y=L.index(m)
print(A[Y],A[y])


Measured memory_bytes: 5556
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp;
    int l = N.length.to!int;
    int r, p;
    foreach (int i, c; N) {
        auto n = c-48;
        if (n) {
            r = max(r, p + n-1 + (l-i-1)*9);
            p += n;
        }
    }
    writeln(max(r, p));
}

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

using namespace std;

int n, r, g, b;

int main() {
	scanf("%d%d%d%d", &r, &g, &b, &n);
	
	int res = 0;
	
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int tot = i * r + j * g;
			if (tot <= n && (n - tot) % b == 0) res++;
		}
	}
	
	printf("%d\n", res);
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(x - a) > abs(x - b)) cout << 'B' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 3600
def fac(n,k,p):
    ans=1
    for i in range(n-k+1,n+1):
        ans=(ans*i)%p
    return ans

def makeinv(length,p):
    L=[0,1]
    for i in range(2,length+1):
        x=p-((L[p%i]*(p//i))%p)
        L.append(x)
    return L

def comb(n,k,p):
    if k==0:
        return 1
    else:
        ans=fac(n,k,p)
        inv=makeinv(k,p)
        for i in range(1,k+1):
            ans=(ans*inv[i])%p
        return ans

N,K=map(int,input().split())
P=10**9+7

for i in range(1,K+1):
    x=comb(K-1,i-1,P)
    if N-K+1>=i:
        y=comb(N-K+1,i,P)
        print((x*y)%P)
    else:
        print(0)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
 
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())
#define FOR(i,a,n) for (int i=(a);i<(n);++i)
#define MEMS(a, b) memset(a, b, sizeof(a))
 
template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }
 
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;
const int mod = 1e9 + 7;
 
 
#define FILENAME ""
 

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
   	int n;
   	cin >> n;
   	vector <pair<int, int>> a;
   	for (int i = 0; i < n; i++) {
   	 	int x;
   	 	cin >> x;
   	 	a.pb(mp(x, i));
   	}
   	sort(all(a));
   	for (int i = 0; i < n; i++) {
   	 	cout << a[i].se + 1 << " ";
   	}
    return 0;
}

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

#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

struct UnionFind{
	vector<int> r,p;
	UnionFind(){}
	UnionFind(int size){init(size);}
	void init(int size){
		r.resize(size,0);
		p.resize(size,0);
		for(int i=0;i<size;i++) r[i]=1,p[i]=i;
	}
	int find(int x){
		return (x==p[x]?x:p[x]=find(p[x]));
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y) return;
		if(r[x]<r[y]) swap(x,y);
		r[x]+=r[y];
		p[y]=x;
	}
};
struct edge{
	int from,to,cost;
	edge(){}
	edge(int from,int to,int cost):from(from),to(to),cost(cost){}
	bool operator<(const edge& e) const{
		return cost<e.cost;
	}
};
int kruskal(int N,vector<edge> edges){
	int res=0;
	sort(edges.begin(),edges.end());
	UnionFind uf(N+1);
	for(int i=0;i<(int)edges.size();i++){
		edge e=edges[i];
		if(!uf.same(e.from,e.to)){
			res+=e.cost;
			uf.unite(e.from,e.to);
		}
	}
	return res;
}


int main(){
	int n = in();
	vector<pii> x(n), y(n);
	rep(i, n) {
	 int u = in(), v = in();
 	 x[i].fs = u; x[i].sc = i;
	 y[i].fs = v; y[i].sc = i;
	}

	sort(all(x));
	sort(all(y));

	int V = n, E = (n - 1);
	vector<edge> edges(4 * E);

	rep(i, E) {
		edges[i].to = x[i].sc;
		edges[i].from = x[i + 1].sc;
		edges[i].cost = abs(x[i].fs - x[i + 1].fs);

		edges[i + E].to = y[i].sc;
		edges[i + E].from = y[i + 1].sc;
		edges[i + E].cost = abs(y[i].fs - y[i + 1].fs);
		
		edges[i + 2 * E].from = x[i].sc;
		edges[i + 2 * E].to = x[i + 1].sc;
		edges[i + 2 * E].cost = abs(x[i].fs - x[i + 1].fs);

		edges[i + 3 * E].from = y[i].sc;
		edges[i + 3 * E].to = y[i + 1].sc;
		edges[i + 3 * E].cost = abs(y[i].fs - y[i + 1].fs);
	}

	//for(int i = 0; i < E; i++)
		//cin >> edges[i].from >> edges[i].to >> edges[i].cost;
	cout << kruskal(V, edges) <<endl;
	return 0;
}



Measured memory_bytes: 11904
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());
            if (A != 1 && B != 1) Console.WriteLine(1);
            if (A != 2 && B != 2) Console.WriteLine(2);
            if (A != 3 && B != 3) Console.WriteLine(3);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int show=0;
int w,h,sx,sy,gx,gy,d[101][101],dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},C;
int field[101][101];
const int INF=9999999;
typedef pair<int,int> P;

void bfs(){
	queue<P> que;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)d[i][j]=INF;
	que.push(P(sy,sx));
	d[sy][sx]=0;
	while(!que.empty()){
		P p=que.front(); que.pop();
		if(p.first==gy&&p.second==gx)break;
		for(int i=0;i<4;i++){
			int ny=p.first+dy[i],nx=p.second+dx[i];
			if(1<=ny&&ny<=h&&1<=nx&&nx<=w&&field[ny][nx]==C&&d[ny][nx]==INF){
			que.push(P(ny,nx));
			d[ny][nx]=d[p.first][p.second]+1;
			}
		}
	}
	if(d[gy][gx]==INF)cout<<"NG"<<endl;
	else cout<<"OK"<<endl;
}

int main() {
	while(cin>>w>>h){
		if(!h)return 0;
		int n,c,di,x,y;
		cin>>sx>>sy>>gx>>gy>>n;
		for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)field[i][j]=0;
		for(int i=0;i<n;i++){
			cin>>c>>di>>x>>y;
			for(int j=y;j<y+2+di*2;j++)for(int k=x;k<x+2+!di*2;k++)field[j][k]=c;
		}
		C=field[sy][sx];
		if(!C)cout<<"NG"<<endl;
		else bfs();
		if(show){
			for(int i=1;i<=h;i++){for(int j=1;j<=w;j++){if(field[i][j])cout<<field[i][j];else cout<<" ";}cout<<endl;}
			for(int i=1;i<=h;i++){for(int j=1;j<=w;j++){if(d[i][j]<INF)cout<<d[i][j]<<" ";else cout<<"  ";}cout<<endl;}
		}
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os,pair<T,S>a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}

//char inv(char c){
//    return c^32;
//}
//string inv(string &a){
//    auto res = a;
//    for(auto &x:res) x^=32;
//    reverse(res.begin(),res.end());
//    return res;
//}
//string product(const string &a,const string &b){
//    auto res = a;
//    for(auto x:b){
//        if(res.size() and inv(x) == res.back())res.erase(res.begin()+res.size()-1);
//        else res.push_back(x);
//    }
//    return res;
//    
//}

vector<int> id(const int n){
    vector<int> res(n);
    rep(i,n)res[i] = i;
    return res;
}
vector<int> inv(const vector<int> &a){
    vector<int> res(a.size());
    rep(i,a.size()){
        res[a[i]] = i;
    }
    return res;
}
vector<int> product(const vector<int> &a, const vector<int> &b){
    vector<int> res(a.size());
    rep(i,a.size()){
        res[i] = a[b[i]];
    }
    return res;
}
vector<int> power(const vector<int> &a, ll p){
    if(p == 0)return id((int)a.size());
    auto res = a;
    auto temp = a;
    p--;
    for(int i = 0; i < 30; i++){
        if(p >> i & 1){
            res = product(res, temp);
        }
        temp = product(temp, temp);
    }
    return res;
}
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int>p(n),q(n);
    rep(i,n)scanf("%d",&p[i]),p[i]--;
    rep(i,n)scanf("%d",&q[i]),q[i]--;
    auto g = product(q,product(inv(p),product(inv(q),p)));
    g = power(g,(k-1)/6);
    auto a = product(g,product(p,inv(g)));
    auto b = product(g,product(q,inv(g)));
    int now = 1 + (k-1)/6*6;
    while(now != k){
        auto c = product(b,inv(a));
        a = b;
        b = c;
        now++;
    }
    rep(i,n)printf("%d ",a[i]+1);
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <stdlib.h>

int linearsearch(int *, int, int);

int main()
{
  int n, q, i, count = 0;
  int *s, *t;

  scanf("%d", &n);
  s = (int *)malloc(n*sizeof(int));
  for(i=0; i<n; i++) {
    scanf("%d", &s[i]);
  }
  scanf("%d", &q);
  t = (int *)malloc(q*sizeof(int));
  for(i=0; i<q; i++) {
    scanf("%d", &t[i]);
  }

  for(i=0; i<q; i++) {
    if(linearsearch(s, n, t[i]))
      count++;
  }
  printf("%d\n", count);
  return 0;
}

int linearsearch(int *s, int n, int key)
{
  int i = 0;
  s[n] = key;
  while(s[i] != key) {
    i++;
  }
  if(i == n)
    return 0;
  return 1;
}

Measured memory_bytes: 632
n = int(input())
a = list(map(int, input().split()))
cnt,st,d = 0,-1,0
for i in range(n):
  if st < 0:
    st = i
    continue
  elif d == 0:
    if a[i]-a[st] != 0:
      r = i
      d = a[r]-a[st]
    continue
  else:
    if (a[i]-a[i-1])*d < 0:
      cnt += 1
      st,d = i,0
if st != -1:
  cnt += 1
print(cnt)

Measured memory_bytes: 14224
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n;ll a;
    cin>>n>>a;
    lvec x(n);
    rep(i,n)cin>>x[i];
    sort(all(x));
    int m=ub(all(x),a)-x.begin();
    ll ans;
    if(m==0){
        ans=x[0]-a;
        for(int i=0;i<n-1;i++)ans=__gcd(ans,x[i+1]-x[i]);
    }else if(m==n){
        ans=a-x[n-1];
        for(int i=n-1;i>0;i--)ans=__gcd(ans,x[i]-x[i-1]);
    }else{
        ans=a-x[m-1];
        for(int i=m-1;i>0;i--)ans=__gcd(ans,x[i]-x[i-1]);
        ans=__gcd(ans,x[m]-a);
        for(int i=m;i<n-1;i++)ans=__gcd(ans,x[i+1]-x[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1152
import sys
S = sys.stdin.readline().strip()
dp = [False] * (len(S) + 1)
dp[0] = True

ws = ['dream', 'dreamer' ,'erase' ,'eraser']
for i, c in enumerate(S):
    for w in ws:
        j = i-len(w) + 1
        if j >= 0 and dp[j] and S[j:i+1] == w:
            dp[i+1] = True
        if dp[i+1]:
            break
print('YES' if dp[len(S)] else 'NO')


Measured memory_bytes: 3956
import sys

sys.setrecursionlimit(100000)

def dps(u,p,c):
  x[c]= u
  u = k-(1 if p<0 else 2)
  for i in range(len(l[c])):
    if l[c][i]!=p:
      if u>0:
        dps(u,c,l[c][i])
        u-=1
      else:
        break
  return

n,k=map(int,input().split())

l=[[] for i in range(n)]
x=[0]*n

for i in range(n-1):
  a,b= map(int,input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

dps(k,-1,0)

t=1
for i in range(n):
  t=(t*x[i])%(10**9+7)

print(t)


Measured memory_bytes: 87468
#include<cstdio>
const int MAXN = 10000;
int main() {
	int N, x, ans = 0;
	scanf("%d", &N);
	for(int i=1;i<=N;i++) {
		scanf("%d", &x);
		while( x % 2 == 0 )
			x /= 2, ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val num = StdIn.readInt()
    val input = StdIn.readLine().split(" ").map(_.toInt)
    insertionSort(input,num)
  }

  def insertionSort(A: Array[Int],N: Int): Unit = {
    println(A.mkString(" "))
    for(i <- 1 to N - 1){
      val v = A(i)
      var j = i - 1
      while(j >= 0 && A(j) > v){
        A(j+1) = A(j)
        j = j - 1
      }
      A(j+1) = v
      println(A.mkString(" "))
    }
  }
}

Measured memory_bytes: 46100
s = input().split()
x_min = int(s[0])
x_max = int(s[1])

y_min = int(s[2])
y_max = int(s[3])

if(x_max>0 and y_max>0 and x_min>0 and y_min>0):
	print(x_max*y_max)
elif(x_max<0 and y_max < 0 and x_min<0 and y_min < 0):
  	print(x_min * y_min)
elif(x_max < 0 and y_min > 0):
  	print(x_max * y_min)
elif(x_min > 0 and y_max < 0):
  	print(x_min * y_max)
else:
	if(x_min * y_min > x_max * y_max):
		print(x_min * y_min)
	else:
		print(x_max * y_max)


Measured memory_bytes: 9200
#!/usr/bin/python
# -*- coding: utf-8 -*-

s = raw_input()
n, m, x, y = [int(x) for x in s.split()]
xx = [int(a) for a in raw_input().split()]
yy = [int(a) for a in raw_input().split()]
xx = sorted(xx)
yy = sorted(yy)

if xx[-1] >= y or yy[0] <= x or xx[-1] >= yy[0]:
    print 'War'
else:
    print 'No War'

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

int main(){
    int n,q;
    cin >> n >> q;
    
    vector<char> s(n);
    rep(i,n) cin >> s[i];
    
    vector<pair<int,int>> vec(q);
    rep(i,q) cin >> vec[i].first >> vec[i].second;
    
    vector<int> ans(n,0);
    
    for(int i = 0; i < n - 1; i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            ans[i+1]++;
        }
    }
    
    vector<int> t(n);
    t[0] = ans[0];
    for(int i = 0; i < n - 1; i++){
        t[i+1] = t[i] + ans[i+1];
    }
    
    for(int i = 0; i < q; i++){
        int l,r;
        tie(l,r) = vec[i];
        l--;
        r--;
        cout << t[r] - t[l] << endl;
    }
    
    
}


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


signed main(){
	string str,s1,s2;int a,b;
	cin>>s1>>s2>>a>>b>>str;
	if(str==s1) cout<<a-1<<" "<<b;
	else  cout<<a<<" "<<b-1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll x, y;
    cin >> x >> y;
    print(x + y/2);
   
  return 0;
}

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

public class Main {
	public static void main(String[] args) {


		String num = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
		String [] numbers = num.split(",");
		ArrayList<String> numList= new ArrayList<>();
		for(String number:numbers) {
			numList.add(number);
		}

		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();

		System.out.println(numList.get(K-1));
	}
}

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


int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,int(s.size())){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3800
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;

    string s = to_string(n);
    int m = s.length();

    bool ok = false;
    for (int i = 0; i < m; ++i) {
        int cnt = 1;
        while (i + 1 < m && s[i + 1] == s[i]) {
            ++i;
            ++cnt;
        }
        if (cnt >= 3) {
            ok = true;
        }
    }

    if (ok) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> cities[100001];
	for (int i = 0; i < M; ++i) {
		int p, y; cin >> p >> y;
		cities[p].push_back({y, i});
	}
	pair<int, int> ans[100001];
	for (int i = 1; i <= N; ++i) {
		sort(all(cities[i]));
		for (int j = 0; j < cities[i].size(); ++j) {
			ans[cities[i][j].second] = {i, j + 1};
		}
	}
	for (int i = 0; i < M; ++i) {
		printf("%06d%06d\n", ans[i].first, ans[i].second);
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>  v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(all(v));

  int i=0;
  int ans=0;
  while(i<n&&v[i]<=m){
    ans++;
    m-=v[i];
    i++;
  }

  if(ans==n&&m>0) ans--;

  cout<<ans<<endl;
}


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

int main(){
  int N,M,i;
  cin >> N >> M;
  vector<vector<int>> c(N+1);
  vector<int> p(N+1,-1);
  vector<int> d(N+1,-1);
  int a,b;
  for(int i=0;i<M;i++){
    cin >> a >> b;
    c[a].push_back(b);
    c[b].push_back(a);
  }
  p[1] = 1;
  queue<int> que;
  que.push(1);
  //cout << "q:" << que.front() << endl;
  
  while(!que.empty()){
    i = que.front();
    que.pop();
    for(auto n:c[i])
      if (p[n] == -1){
        que.push(n);
        //cout << "n:" << n << endl;
        p[n] = p[i]+1;
        d[n] = i;
      }
  }
  for(i=2;i<=N;i++)
    if(d[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  cout << "Yes" << endl;
  for(i=2;i<=N;i++)
    cout << d[i] << endl;

  return 0;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//　斜交座標系から直交座標系に変換
pair<int, int> change(int a, int b) {
    return make_pair((2*a-b)/3, (2*b-a)/3);
}

int main() {
    COMinit();
    int x, y;
    long long ans;
    cin >> x >> y;
    if ((x + y) % 3 == 0) {
        int nx, ny;
        tie(nx, ny) = change(x, y);
        if (nx < 0 || ny < 0) {
            ans = 0;
        }
        else if (nx == 0 || ny == 0) {
            ans = 1;
        }
        else {
            int n = nx + ny;
            int r = nx;
            ans = COM(n, r);
        }
    }
    else {
        ans = 0;
    }
    cout << ans << endl;
}


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

int main() {
  int N, Q;
  cin >> N >> Q;
  char S[N];
  cin >> S;
  
  vector<int> Got_index;
  for (int i = 0; i < strlen(S) - 1; ++i) {
    if (S[i] == 'A' && S[i+1] == 'C') { Got_index.push_back(i); }
  }
  
  // cout << ;
  
  for (int i = 0; i < Q; ++i) {
    int l, r;
    cin >> l >> r;
    
    int a = distance(lower_bound(Got_index.begin(), Got_index.end(), l-1),
            lower_bound(Got_index.begin(), Got_index.end(), r-1));
    cout << a << endl;
  }
 
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define rFORq(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size,-1) { }

    int root(int x){
        if (data[x] < 0) return x;
        else return data[x] = root(data[x]);
    }

    int size(int x){
        return -data[root(x)];
    }

    bool isConnect(int x,int y){
        return root(x) == root(y);
    }

    bool connect(int x , int y){
        x = root(x);
	    y = root(y);
	
        if(x==y) return false;
        
        if(data[x] > data[y]){
            x ^= y;
            y ^= x;
            x ^= y;
        }
        
        data[x] = data[x] + data[y]; // membersize++
        data[y] = x;
        return true;
    }
};


int main(){
    UnionFind U(100002);
    int N,M; SCD2(N,M);
    vector< vector<int> > lan(M+2);

    REP(i,N){
        int K; SCD(K);
        REP(j,K){
            int l; SCD(l);
            lan[l].PB(i+1);
        }
    }
    
/*     FORq(i,1,M){
        printf("L[%d] = {",i);
        REP(j,lan[i].size()){
            
            printf("%d ",lan[i][j]);
        }
        printf("}\n");
    } */

    FORq(i,1,M){
        if (lan[i].size() == 0) continue;
        REP(j,lan[i].size() - 1){
            U.connect(lan[i][j],lan[i][j+1]);
        }
    }

    if (U.size(1) == N){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int q;

bool shit(int x) {  // LOOOOL
	for(int i = 2; i * i <= x; i++)
		if(x % i == 0)
			return false;
	return true;
}

int psum[maxn];
bool is[maxn];
int ans[maxn];
set<int> st;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> q;
	for(int i = 2; i < maxn; i++)
		if(shit(i))
			is[i] = true;
	for(int i = 3; i < maxn; i++) {
		if(is[i] && is[(i + 1) / 2]) {
			ans[i] = 1;
			st.insert(i);
		}
	}
	int l, r;
	psum[0] = 0;
	for(int i = 1; i < maxn; i++) {
		psum[i] = psum[i - 1] + ans[i];
	}
	while(q--) {
		cin >> l >> r;
		auto i = st.lower_bound(l);
		if(i == st.end()) {
			cout << 0 << '\n';
			continue;
		}
		auto j = st.upper_bound(r);
		if(j == st.begin()) {
			cout << 0 << '\n';
			continue;
		}
		j--;
//		cout << *i << " : " << *j << '\n';
		if(*i > *j) {
			cout << 0 << '\n';
			continue;
		}
		else if(*i == *j) {
			cout << ans[*i] << '\n';
			continue;
		}
		int res = psum[*j] - psum[*i - 1];
		cout << res << '\n';
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    ll sum = 0;
    cin >> n >> m;
    vector<ll> vec(n, 0);
    rep(i, n)
    {
        cin >> vec.at(i);
        sum += vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    string s = "No";
    if ((vec.at(m - 1)) * 4 * m >= sum)
    {
        s = "Yes";
    }
    cout << s << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        h1: usize,
        m1: usize,
        h2: usize,
        m2: usize,
        k: usize,
    }
    let (wake, asleep) = (h1*60+m1, h2*60+m2);
    println!("{}", asleep-wake-k);
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REPR(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)
#define FORR(i, n, m) for (ll i = (m) - 1; i >= (n); --i) 
#define FORE(x, xs) for (auto &x: (xs))
#define ALL(v) v.begin(), v.end()
#define ZERO(a) memset(a,0,sizeof(a))

const int INF = 1000000009;
const int MOD = 1000000007;
const double EPS = 1e-14;
const double PI = acos(-1);

const int MAX = 2e5;

ll N;
int a[100000];
vector<ii> pairs;

int main() {
  cin >> N;
  REP (i, N) {
    cin >> a[i];
    pairs.push_back(make_pair(a[i], i));
  }

  sort(ALL(pairs));

  int ans = 0;
  REP (i, N) if ((i+pairs[i].second)%2==1) ans++;
  cout << ans/2 << endl;

  return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K; cin >> N >> K;
    vector<ll> h(N); rep(i, N){cin >> h.at(i);}
    sort(h.begin(), h.end());

    ll ans = INF;
    rep(i, N - K + 1){
        auto start = h.begin() + i;
        auto end = h.begin() + i + K;
        ll tmp = h.at(i + K - 1) - h.at(i);
        if (tmp < ans){ans = tmp;}
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			list.add(x);
		}
		List<Integer> temp = new ArrayList<>(list);
		Collections.sort(temp);
		Integer min = temp.get(n / 2 - 1);
		Integer max = temp.get(n / 2);
		for (int i = 0; i < n; i++) {
			if (list.get(i) <= min) {
				System.out.println(max);
			} else if (list.get(i) >= max) {
				System.out.println(min);
			}
		}
	}
}


Measured memory_bytes: 94660
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;
class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		I = I.Select(x => x - 1).ToArray();
		Console.WriteLine(I[0] * I[1]);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  for(buf=1;n!=1;){
    n/=2;
    buf*=2;
  }
  cout<<buf<<endl;

  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

bool perm[MX];

ll qpow(ll b, ll e) {
    if (!e) return 1;
    if (e&1) return (qpow(b, e-1)*b)%MOD;
    ll res = qpow(b, e/2)%MOD;
    return (res*res)%MOD;
}

ll invmod(ll a) {
    return qpow(a, MOD-2);
}

ll divide (ll a, ll b) {
    return (a*invmod(b))%MOD;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n; cin >> n;

    multiset<int> ms;
    F0R(i, n) {
        int x; cin >> x;
        ms.insert(x);
    }

    if (1) {
        bool ok = true;
        FOR(i, 1, n+1) {
            if (perm[i]) continue;
            int x = ms.count(abs((i-1)-(n-i)));

            if (abs((i-1)-(n-i)) == 0) {
                ok = n&1;
                if (x > 1) {
                    ok = false;
                } else {
                    perm[i] = 1;
                    ms.erase(abs((i-1)-(n-i)));
                }
            } else {
                if (x != 2) {
                    ok = false;
                } else {
                    perm[i] = perm[n-i+1] = 1;
                    ms.erase(abs((i-1)-(n-i)));
                }
            }

            if (!ok) break;
        }

        FOR(i, 1, n+1) if (!perm[i]) ok = false;

        if (!ok) {
            cout << "0\n";
        } else {
            cout << qpow(2, n/2) << "\n";
        }
    }
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

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

int N;
int A[212345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);

	rep(i, N) {
		if (i == 0 && A[0] != 0) {
			printf("-1\n");
			return 0;
		}
		else if (A[i - 1] < A[i] - 1) {
			printf("-1\n");
			return 0;
		}
	}

	ll count = 0;

	rep(i, N) {
		if (i) {
			if (A[i] <= A[i - 1]) count += A[i - 1];
		}
		if (i == N - 1) {
			count += A[i];
			printf("%lld\n", count);
			return 0;
		}

	}

	return 0;
}


Measured memory_bytes: 1024
use proconio::input;
use proconio::marker::Usize1;
use std::cmp::min;

fn main()
{
    input! {
    n:usize,
    m:usize,
    l:i64,
    edge:[(Usize1,Usize1,i64);m],
    q:usize,
    query:[(Usize1,Usize1);q],
    }

    let inf = 1i64 << 60;
    let mut v = vec![vec![inf; n]; n];
    for (a, b, c) in edge {
        v[a][b] = c;
        v[b][a] = c;
    }
    for i in 0..n {
        v[i][i] = 0;
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                v[i][j] = min(v[i][j], v[i][k] + v[k][j]);
            }
        }
    }

    let mut dist = vec![vec![inf; n]; n];
    for i in 0..n {
        for j in 0..n {
            if v[i][j] <= l {
                dist[i][j] = 1;
            }
        }
    }

    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    for (s, t) in query {
        let ans = if dist[s][t] == inf {
            -1
        } else {
            dist[s][t] - 1
        };
        println!("{}", ans);
    }
}

Measured memory_bytes: 6452
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
bool is_same(char x[], char y[])
{
    if (strcmp(x, y)) //同でなければ非０(-1か1)を返す
    {
        return false;
    }
    return true;
}
void print(char str[], int a, int b)
{
    for (int i = a; i <= b; i++)
    {
        printf("%c", str[i]);
    }
    printf("\n");
}
void reverse(char str[], int a, int b) //おかしいので後程検討
{
    int j = 0;
    for (int i = 0; i < (b - a + 1) / 2; i++)
    {
        char tmp = str[a + j];
        str[a + j] = str[b - j];
        str[b - j] = tmp;
        j++;
    }
}
void replace(char str[], int a, int b, char p[])
{
    int j = 0;
    for (int i = a; i <= b; i++)
    {
        str[i] = p[j];
        j++;
    }
}
int main(void)
{
    char str[1001];
    char prt[] = "print";
    char rev[] = "reverse";
    int q; //命令の数

    scanf("%[^\n]%*c", str);
    scanf("%d", &q);

    for (int i = 0; i < q; i++)
    {
        char order[8]; //入力される命令
        int a, b;
        scanf("%s %d %d", order, &a, &b);

        if (is_same(order, prt))
        {
            print(str, a, b);
        }
        else if (is_same(order, rev))
        {
            reverse(str, a, b);
        }
        else
        {
            char p[1001];
            scanf("%s", p);
            replace(str, a, b, p);
        }
    }

    return 0;
}


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

int main(){
  int n,k; cin>>n>>k;
  int a[n];
  bool b=0;
  rep(i,0,n){
    cin>>a[i];
    if(a[i]%2==1) b=1;
  }
  ll ans=1;
  if(b==0){
    if(k==1) cout<<0<<endl;
    else{
      rep(i,0,n){
        ans*=2;
      }
      cout<<ans<<endl;
    }
  }
  else{
    rep(i,0,n-1){
      ans*=2;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 256
A, B = list(map(int, input().split()))
cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if cards.index(A) > cards.index(B) :
  print("Alice")
elif cards.index(B) > cards.index(A) :
  print("Bob")
else :
  print("Draw")

Measured memory_bytes: 3060
//package atcoder;
import java.util.*;
class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
	
		int b=sc.nextInt();
		int t=sc.nextInt();
		//String s=sc.next();
		System.out.println((t/a)*b);
		

		
			
		
	}

}


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

const int maxn = 1e5 + 500;

int a[maxn];

int main(){
    int N;cin>>N;
    for(int n=1;n<=N;n++){
        int ans=0;
        for(int i=1;i<=100;i++){
            for(int j=1;j<=100;j++){
                int res=i*i+j*j+i*j,b=i+j;
                if(res>n)continue;
                res-=n;

                int t=b*b-4*res,tt;
                //cout<<b<<" "<<res<<" "<<t<<endl;
                if(t>=0){
                    tt=sqrt(t);
                    if(tt*tt==t){
                        if(tt>b&&(tt-b)%2==0)ans++;
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 3560
import Control.Applicative
import Control.Monad
import Data.List

main = do
  s <- getLine
  if s !! 0 == s !! 1 || s !! 1 == s !! 2 || s !! 2 == s !! 3 then 
    putStrLn "Bad"
  else 
    putStrLn "Good"
  

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n; cin >> n;
    cout << n/3 << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin >> n;
	ll a[n + 1];
	for(int i = 0 ; i < n ; i++)
  		cin >> a[i];
  	
  	int ptr = 0;
  	int ans = 0;
  	for(int i = 1 ; i < n ; i++){
  		if(a[i] > a[i - 1]){
  			ptr = i;
  		}
  		ans = max(ans , i - ptr );
  	}
  	cout << ans << endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll                      long long int
#define i(a,n)                  int a=n;
#define l(a,n)                  ll a=n;
#define d(a,n)                  double a=n;
#define s(a)                    string a;
#define c(a)                    ll a; cin>>a;a
#define cd(a)                   double a; cin>>a;
#define cs(a)                   string a; cin>>a;
#define ci(a)                   cin>>a;
#define co(a)                   cout<<a;
#define cos(a)                  cout<<a<<" ";
#define con(a)                  cout<<a<<endl;
#define yes                     cout<<"YES"<<endl
#define no                      cout<<"NO"<<endl
#define nl                      cout<<endl;
#define ca(arr,n)               for(ll i=0;i<n;i++) cin>>arr[i];
#define f0(i,a,n)               for(ll i=a;i>=n;i--)
#define f(i,n)                  for(ll i=0;i<n;i++)
#define f1(i,a,n)               for(ll i=a;i<n;i++)
#define T                       ll t=1; cin>>t; while(t--)
#define lcm(a,b)                (a*b)/__gcd(a,b)
#define fast                    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ret(x)                  return cout<<x,0;
using namespace std;
/*
int main()
{
    fast;
    ll k,x=1,n=7;
    cin>>k;
    if(k%2==0 || k%5==0) x=-1;
    else
    {
        while(n%k!=0)
        {
            n*=10;
            n+=7;
            n%=k;
            x++;
        }
    }
    cout<<x;
    
    return 0;
}
*/
int main()
{
    fast;
    ll k;
    cin >> k;
    ll rem=0;
    f1(i,1,1000005)
    {
    	ll r=(10*rem+7)%k;
    	if(r==0) ret(i);
    	rem=r;
    }
    ret(-1);
}
/*It's not who I am underneath, but what I do that defines me

MMMMMMMMMMMMMMMMMMMMM.                             MMMMMMMMMMMMMMMMMMMMM
 `MMMMMMMMMMMMMMMMMMMM           M\  /M           MMMMMMMMMMMMMMMMMMMM'
   `MMMMMMMMMMMMMMMMMMM          MMMMMM          MMMMMMMMMMMMMMMMMMM'
     MMMMMMMMMMMMMMMMMMM-_______MMMMMMMM_______-MMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
      MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
     .MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM.
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
                   `MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM'
                          `MMMMMMMMMMMMMMMMMM'
                              `MMMMMMMMMM'
                                 MMMMMM 
                                  MMMM
                                   MM
*/


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

struct UnionFind{
private:
  vector<int> par, rank, sizes;
public:
  UnionFind(int n) : par(n, -1), rank(n, 0), sizes(n, 1){}
  int find(int x) { return (par[x] < 0) ? x : (par[x] = find(par[x])); }
  bool unite(int x, int y){
    x = find(x), y = find(y);
    if(x==y) return false;
    else if(rank[x]<rank[y]){
      par[x] = y;
      sizes[y] += sizes[x];
    } else if(rank[x]>rank[y]){
      par[y] = x;
      sizes[x] += sizes[y];
    } else{
      par[y] = x;
      rank[x] += 1;
      sizes[x] += sizes[y];
    }
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main() {
  int h, w; cin>>h>>w;
  vector<string> s(h);
  for (int i = 0; i < h; i++) cin>>s[i];
  UnionFind uf(h*w);

  queue<int> q;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#') q.push(i*w+j);
    }
  }

  while (!q.empty()) {
    int t = q.front(); q.pop();
    int y = t / w, x = t % w;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (0 <= nx and nx < w and 0 <= ny and ny < h) {
        if (s[y][x] != s[ny][nx] and not uf.same(y*w+x, ny*w+nx)) {
          q.push(ny*w + nx);
          uf.unite(y*w+x, ny*w+nx);
        }
      }
    }
  }

  vector<int> white(h*w, 0), black(h*w, 0);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int root = uf.find(i*w + j);
      if (s[i][j] == '#') ++black[root];
      else ++white[root];
    }
  }

  long long ans = 0;
  for (int i = 0; i < h*w; i++) ans += (long long)white[i]*black[i];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4224
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

count=0
for i in range(N):
  A=list(map(int,input().split()))
  ans=0
  for j in range(M):
    ans += A[j]*B[j]
  if ans+C > 0:
    count+=1
print(count)

Measured memory_bytes: 3060