akhauriyash/Code-Regression huggingface dataset:
import numpy as np

N,K = [int(i) for i in input().split()]

ab = np.ones([N,2])

for i in range(N):
    ab[i,0], ab[i,1] = [int(i) for i in input().split()]

ab_sort = ab[np.argsort(ab[:,0])]

cout = 0

for i in range(N):
    cout += ab_sort[i,1]
    if cout >= K:
        print(int(ab_sort[i,0]))
        break


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

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

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

vector<edge> graph[1500];
int dist[1500][1500];
int N, R, maxDist;
bool ans[1500];

void dijkstra(int start)
{
    priority_queue<P, vector<P>, greater<P>> que;
    vector<bool> visited(N, false);
    dist[start][start] = 0;
    que.push({0, start});

    while (!que.empty())
    {
        int d, now;
        tie(d, now) = que.top();
        que.pop();

        if (visited[now])
            continue;

        visited[now] = true;

        for (auto e : graph[now])
        {
            if (dist[start][e.to] <= d + e.cost)
                continue;

            dist[start][e.to] = dist[start][now] + e.cost;
            que.push(P(d + e.cost, e.to));
        }
    }
}

void solve(int start)
{
    queue<int> que;
    vector<int> _visited(N, false);

    rep(i, N) if(dist[start][i] == maxDist)
    {
        que.push(i);
        _visited[i] = true;
    }

    while(!que.empty())
    {
        int now = que.front();
        que.pop();

        _visited[now] = true;
        ans[now] = false;

        for(auto e : graph[now])
        {
            if(!_visited[e.to] && dist[start][e.to] + e.cost == dist[start][now])
            {
                _visited[e.to] = true;
                que.push(e.to);
            }
        }
    }

    return;
}

int main()
{
    cin >> N >> R;

    rep(i, R)
    {
        int s, t, d;
        cin >> s >> t >> d;

        s--;
        t--;

        graph[s].push_back({t, d});
        graph[t].push_back({s, d});
    }

    rep(i, N) ans[i] = true;

    rep(i, N) rep(j, N) dist[i][j] = iINF;

    rep(i, N) dijkstra(i);
    rep(i, N) rep(j, N) maxDist = max(maxDist, dist[i][j]);

    vector<int> output;

    rep(i, N) solve(i);

    rep(i, N) if(ans[i]) output.push_back(i + 1);

    cout << output.size() << endl;

    rep(i, output.size()) cout << output[i] << endl;

    return 0;
}


Measured memory_bytes: 12108
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#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
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

struct Edge {
    int to, cost;
};

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<vector<Edge>> tree(N,vector<Edge>());
    vector<bool> visited(N, false);
    VI ans(N,-1);
    REP(i, N-1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--; v--;
        tree[u].emplace_back(Edge{v,w});
        tree[v].emplace_back(Edge{u,w});
    }
    queue<PII> que;
    ans[0] = 0;
    visited[0] = true;
    que.push(PII(0,0));
    while (!que.empty()) {
        PII q = que.front(); que.pop();
        ans[q.first] = q.second;
        for (int i = 0; i < tree[q.first].size(); i++)
        {
            if (!visited[tree[q.first][i].to]) {
                if (tree[q.first][i].cost % 2 == 0) {
                    que.push(PII(tree[q.first][i].to, q.second));
                }
                else {
                    que.push(PII(tree[q.first][i].to, 1 - q.second));
                }
                visited[tree[q.first][i].to] = true;
            }
        }
    }
    REP(i, N) {
        cout << ans[i] << endl;
    }
    getchar(); getchar();
}

Measured memory_bytes: 6912
# coding:UTF-8
import sys

if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    # a = int(input())    # 数字
    # a = input()     # 文字列
    aList = list(map(int, input().split()))     # スペース区切り連続数字
    # a = input().split()     # スペース区切り連続文字列
    # a = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    x = 5
    # a = [int(input()) for _ in range(x)] # 数字
    # a = [input() for _ in range(x)] # 文字
    # a = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # a = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # a = [[int(c) for c in input()] for _ in range(x)]  # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # a = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 処理 ------#
    a = aList[0]
    b = aList[1]
    c = aList[2]
    d = aList[3]
    m = max(a*c, a*d, b*c, b*d)

    # ------ 出力 ------#
    print("{}".format(m))


Measured memory_bytes: 9112
N=int(input())
S=list(str(input()))
ans=[]
for i in range(N-1):
  num=0
  l=[]
  s1=S[0:i+1]
  s2=S[i+1:N]
  if len(s1)<=len(s2):
    s1,s2=s1,s2
  else:
    s1,s2=s2,s1
  for j in range(len(s1)):
    if s1[j] not in l:
      l.append(s1[j])
  for j in range(len(l)):
    if (l[j] in s2)==True:
      num+=1
  ans.append(num)
print(max(ans))

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

#define mp                  make_pair
#define pb                  push_back
#define f                   first
#define s                   second
#define F                   first
#define S                   second
#define clr(a, b)           memset(a, b, sizeof(a))
#define fore(i, b, e)       for(ll i = b; i < e; i++)
#define forr(i, b, e)       for(ll i = b; i < e; i++)
#define forg(i, b, e,au)    for(ll i = b; i < e; i+=au)
using namespace std;


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ll> vi;
#define tam 1234
string txt[tam];
int marca[tam];
int n;
int bfs(int num)
{
    memset(marca,-1,sizeof marca);
    queue<int> cola;
    cola.push(num);
    int nodo,last;bool nop=false;
    marca[num]=1;
    while(!cola.empty())
    {
        nodo=cola.front();cola.pop();
        last=marca[nodo];
        //cout<<marca[nodo]<<" entro "<<nodo<<endl;
        forr(j,0,n)
        {
            //cout<<txt[nodo][j];
            if (txt[nodo][j]=='1')
            {
                if (marca[j]==-1){
                    //cout<<marca[nodo]+1<<" camino "<<j<<endl;
                    marca[j]=marca[nodo]+1;
                    cola.push(j);
                }
                else{
                    if (abs(marca[j]-marca[nodo])!=1)
                        nop=1;
                }


            }
        }
        //cout<<endl;
    }
    if (nop)return -1;
    return last;
}
int main()
{
    
    cin>>n;
    forr(i,0,n)
    {
        cin>>txt[i];
    }
    int maxx=-1;
    forr(i,0,n)
    {
        maxx=max(maxx,bfs(i));
    }
    cout<<maxx<<endl;
}   

Measured memory_bytes: 256
#include <stdio.h>

int change(char a);

int main(void){
    int A = 0,B = 0;
    char S[8];
    
    //scanf("%d %d",&N,&K);
    scanf("%s",S);
    //printf("%d %d %s\n",N,K,S);
    
    A = 10 * change(S[0]);
    A += change(S[1]);
    
    B = 10 * change(S[2]);
    B += change(S[3]);
    
    if(1 <= B && B <= 12){
        if(1 <= A && A <= 12){
            printf("AMBIGUOUS\n");
            return 0;
        }else{
            printf("YYMM\n");
            return 0;
        }
    }else{
        if(1 <= A && A <= 12){
            printf("MMYY\n");
            return 0;
        }else{
            printf("NA\n");
            return 0;
        }
    }
}


int change(char a){
    switch (a) {
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}



Measured memory_bytes: 128
A, B, C, D = list(map(int, input().split()))

flag = False

while A > 0 or C > 0:
  C = C - B
  if C <= 0:
    flag = True
    break

  A = A - D
  if A <= 0:
    flag = False
    break

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9184
#include<stdio.h>
int main(void)
{
    int W,H,x,y,r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if((x+r)<=W && (y+r)<=H && x>=r && y>=r)
{
        printf("Yes\n");
    }
    else 
{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>

int main(){
  int a,b,c,i,j,n;
 
  scanf("%d", &n);
 
  int g[n+2][n+2];
  for(i = 0; i < n+2; i++)
    for(j = 0; j < n+2; j++)
      g[i][j] = 0;
     
 
  for(i = 1; i <= n; i++){
    scanf("%d%d", &a, &b);
    for(j = 1; j <= b; j++){
      scanf("%d", &c);
      g[a][c] = 1;
    }
  }
 
  for(i = 1; i < n+1; i++){
    for(j = 1; j < n; j++){
      printf("%d ", g[i][j]);
    }
    printf("%d\n", g[i][j]);
  }
       
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

#define YES(condition) if(condition) cout << "YES" << endl; else cout << "NO" << endl
#define Yes(condition) if(condition) cout << "Yes" << endl; else cout << "No" << endl
#define POSS(condition) if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl
#define Poss(condition) if(condition)cout << "Possible" << endl; else cout << "Impossible" << endl
#define First(condition) if(condition)cout << "First" << endl; else cout << "Second" << endl
#define negative(condition, num) if(condition)cout << -1 << endl; else cout << num << endl
long power(long base, long exponent, long mod){ if(exponent % 2){ return power(base, exponent - 1, mod) * base % mod; }else if(exponent){ long root_ans = power(base, exponent / 2, mod); return root_ans * root_ans % mod; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define division long(1e9 + 7)

int main(){
    int N;
    cin >> N;
    int sum = 0, min_not_multiple_of_10 = 1e9;
    for(int i = 0; i < N; i++){
        int s;
        cin >> s;
        sum += s;
        if(s % 10){
            min_not_multiple_of_10 = min(min_not_multiple_of_10, s);
        }
    }
    if(sum % 10){
        cout << sum << endl;
    }else{
        cout << max(0, sum - min_not_multiple_of_10) << endl;
    }
}


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

using namespace std;

int main(){

string s;
  cin >> s;
int count_odd=0,count_even=0;
  
  for(int i=0;i<s.length();i++){
    if((i%2==0 && s[i]=='0')||(i%2==1 && s[i]=='1')){
      count_odd++;
    }
    else if((i%2==0 && s[i]=='1')||(i%2==1 && s[i]=='0')){
      count_even++;
    }
  }
   
  cout << s.length()-max(count_odd,count_even) << endl; 
}

Measured memory_bytes: 512
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double PI = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
    return 0;
}

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

 
int main(){
  /*int n;
  cin >> n;
  
  vector<int> A(n);

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }*/
  string S, an;
  cin >> S;
  int sz;
  an = "x";
  sz = S.size();
  
  for(int i=0; i<sz-1; i++){
    an = an + "x";
  }
  
  cout << an << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <math.h>
using namespace std;
 
int main(void){
    int N;
  	scanf("%d",&N);
  	int n = N%10;
  if(n==3){
      printf("bon");
  }else if(n==0||n==1||n==6||n==8){
    printf("pon");
  }else{
  	printf("hon");
  }
}

Measured memory_bytes: 3232
N = int(raw_input())
A = map(int, raw_input().split())
count = 0
flag = 1
while flag:
    flag = 0
    for j in range(N-1, 0, -1):
        if A[j] < A[j-1]:
            A_j = A[j]
            A[j] = A[j-1]
            A[j-1] = A_j
            flag = True
            count += 1
print " ".join(map(str, A))
print count

Measured memory_bytes: 6444
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] h = new Integer[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }

        int result = 0;
        int count = 0;
        for (int i = 1; i < n; i++){
            if (h[i-1] >= h[i]){
                count++;
                result = Math.max(result, count);
            } else{
                result = Math.max(result, count);
                count = 0;
            }
        }

        System.out.println(result);
    }
}


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

int main(){
  ll n;  cin >> n;
  if(n == 0){cout << 0 << endl; return 0;}
  
  string ans;
  while(n != 1){
    //cerr << n << endl;
    if(n < 0){
      if(n % 2 == 0){
        n = - n / 2;
        ans.push_back('0'); 
      }else{
        n = - (n-1) / 2;
        ans.push_back('1');
      }
    }else{
      if(n % 2 == 0){
        n = - n / 2;
        ans.push_back('0');
      }else{
        n = - (n-1) / 2;
        ans.push_back('1');
      }
    }
  }
  ans.push_back('1');
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=1e6+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main()
{
    ll a,b;
    cin>>a>>b;
    a+=b;
    if(a%2){cout<<"IMPOSSIBLE"<<endl;exit(0);}
    cout<<a/2<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
string str;
int cnt=0;
int x;
int main(){
  while(cin>>str){
    x=0;
    for(int i=0;i<=(int)str.size();i++){
      if('0'<=str[i]&&str[i]<='9'){
	x=x*10+str[i]-'0';
      }else{
	cnt+=x;
	x=0;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 1188
#ABC089-D Practical Skill Test
"""
全てのクエリをO(1)で求められるようにメモ化すればok
1~H*Wの数字がどのマスに書いてあるのかを求める。(数字→座標を調べられるようにする)
そうしたときに、D個前のコストを足し合わせる累積和という方法を用いて各クエリO(1)で求められるようになる
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

h,w,d = map(int,readline().split())
A = []
for i in range(h):
    A.append(list(map(int,readline().split())))

cor = [[] for _ in range(h*w)]
for i,a in enumerate(A):
    for j,b in enumerate(a):
        cor[b-1] = [i,j]

cost = [0]*(h*w)
for i in range(h*w):
    if i < d:
        continue
    cost[i] = cost[i-d] + abs(cor[i-d][0]-cor[i][0]) + abs(cor[i-d][1]-cor[i][1])


q = int(readline())
for i in range(q):
    l,r = map(int,readline().split())
    l,r = l-1,r-1
    res = cost[r]-cost[l]
    print(res)

Measured memory_bytes: 61804
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int siz,he[N],e,edg,col[N];
bool vis[N],flag;
struct sa{
	int ne,va,to;
} a[N];
long long ans=0,cot[3];
void add(int u,int v,int w){
	a[++e].to=v;
	a[e].va=w;
	a[e].ne=he[u];
	he[u]=e;
}
void dfs(int k){
	cot[col[k]]++;
	vis[k]=1;
	siz++;
	for(int i=he[k];i;i=a[i].ne){
		edg+=(a[i].va==1);
		int v=a[i].to;
		int rec=(3+col[k]+a[i].va)%3;
		if(!vis[v]){
		    col[v]=rec;
		    dfs(v);
	    }
	    else if(col[v]!=rec) flag=0;
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v,1);
		add(v,u,-1);
	}
	for(int i=1;i<=n;i++) if(!vis[i]){
		cot[1]=cot[0]=cot[2]=0;
		flag=1;
		edg=0;
		siz=0;
		dfs(i);
		if(!flag) ans+=(long long)siz*siz;
		else if(cot[0]&&cot[1]&&cot[2]) ans+=(long long) cot[0]*cot[1]+(long long) cot[0]*cot[2]+(long long) cot[1]*cot[2]; 
		else ans+=edg;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
       int n; cin >> n;
       std::vector<pii> v;
       for(int i = 1; i <= n; i++){
          int x,y; cin >> x >> y;
          v.push_back({x, y});
       }
       for(int i = 2; i < n; i++){
          if(v[i].first == v[i].second && v[i - 1].first == v[i - 1].second && v[i - 2].first == v[i - 2].second){
             cout << "Yes" << '\n';
             return 0;
          }
       }
       cout << "No" << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	int mod = 1000000007;

	void run() {
		for (;;) {
			int X = sc.nextInt();
			int Y = sc.nextInt();
			if ((X | Y) == 0) {
				return;
			}
			int[][] field = new int[Y][X];
			int[][] dp = new int[Y][X];
			for (int i = 0; i < Y; i++) {
				for (int j = 0; j < X; j++) {
					field[i][j] = sc.nextInt();
				}
			}
			for (int i = 0; i < X; i++) {
				if (field[0][i] == 0) {
					dp[0][i] = 1;
				}
			}
			for (int i = 1; i < Y; i++) {
				for (int j = 0; j < X; j++) {
					int cnt = 0;
					if (field[i][j] == 1) {
						continue;
					}
					if (j - 1 >= 0 && field[i][j] != 2
							&& field[i - 1][j - 1] != 1
							&& field[i - 1][j - 1] != 2) {
						cnt += dp[i - 1][j - 1];
					}
					if (field[i - 1][j] != 2) {
						cnt += dp[i - 1][j];
					}
					if (i - 2 > 0 && field[i - 2][j] == 2) {
						cnt += dp[i - 2][j];
					}
					if (j + 1 < X && field[i][j] != 2
							&& field[i - 1][j + 1] != 1
							&& field[i - 1][j + 1] != 2) {
						cnt += dp[i - 1][j + 1];
					}
					dp[i][j] = cnt;
				}
			}
			//System.out.println("------");
			//debug2(dp);
			int ans = 0;
			for (int i = 0; i < X; i++) {
				ans += dp[Y - 1][i];
				if (Y - 2 >= 0 && field[Y - 2][i] == 2) {
					ans += dp[Y - 2][i];
				}
			}
			System.out.println(ans);
		}
	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 17228
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
typedef long long ll;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int max, min;
    max = *max_element(A.begin(), A.end());
    min = *min_element(A.begin(), A.end());
    cout << max-min << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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(){
	cin.tie(0);
	ios::sync_with_stdio(false);

    ll N;
    string S;
    cin >> N >> S;

    int ruiseki_sharp[N + 1], ruiseki_dot[N + 1];
    memset(ruiseki_sharp, 0, sizeof(ruiseki_sharp));
    memset(ruiseki_dot, 0, sizeof(ruiseki_dot));

    rep(i, 0, N) {
        if(S[i] == '#') ruiseki_sharp[i + 1] = 1;
        else ruiseki_sharp[i + 1] = 0;
    }

    for(int i = N - 1; i >= 0; i--) {
        if(S[i] == '.') ruiseki_dot[i] = 1;
        else ruiseki_dot[i] = 0;
    }

    rep(i, 1, N + 1) ruiseki_sharp[i] += ruiseki_sharp[i - 1];
    for(int i = N; i > 0; i--) ruiseki_dot[i - 1] += ruiseki_dot[i];

    int rsl = 1e9, tmp = 0;
    rep(i, 0, N + 1) {
        tmp = ruiseki_sharp[i] + ruiseki_dot[i];
        chmin(rsl, tmp);
    }
    cout << rsl << endl;
}


Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int x[n],y[n];
    char c[n];
    vector<vector<int>>req(2*k+1,vector<int>(2*k+1,0));
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>c[i];
        if(c[i]=='W')x[i]+=k;
        req[x[i]%(2*k)+1][y[i]%(2*k)+1]++;
    }
    for(int i=0;i<=2*k;i++)for(int j=0;j<2*k;j++)req[i][j+1]+=req[i][j];
    for(int i=0;i<=2*k;i++)for(int j=0;j<2*k;j++)req[j+1][i]+=req[j][i];
    int ans=0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            ans=max({ans,
            2*req[i][j]-2*req[i][j+k]+req[i][2*k]
            -2*req[i+k][j]+2*req[i+k][j+k]-req[i+k][2*k]
            +req[2*k][j]-req[2*k][j+k]+req[2*k][2*k],
            n-(2*req[i][j]-2*req[i][j+k]+req[i][2*k]
            -2*req[i+k][j]+2*req[i+k][j+k]-req[i+k][2*k]
            +req[2*k][j]-req[2*k][j+k]+req[2*k][2*k])});
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 19868
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 5e5 + 10;

void solve(){
     int n,x;cin >> n >> x;
     vector<int>a(n);
     vector<int>dis(n);
     for(int i = 0;i<n;i++){
        cin >> a[i];
        dis[i] = abs(a[i]-x);
     }
     int ans = dis[0];
     for(int i = 1;i<n;i++) ans = gcd(ans,dis[i]);
     cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3892
#include<iostream>
using namespace std;
int dp[1001][1001];
int main(){
	int n,m,i,i2,i3,d[1000],c[1000],yamagutigumi,takahashi=2100000000;
	cin>>n>>m;
	for(i=0;i<n;i++){
		for(i2=0;i2<m;i2++){
			dp[i][i2]=2100000000;
		}
	}
	for(i=0;i<n;i++){
		cin>>d[i];
	}
	for(i=0;i<m;i++){
		cin>>c[i];
		dp[0][i]=c[i]*d[0];
	}
	for(i=1;i<n;i++){
		for(i2=0;i2<m;i2++){
			for(i3=i2;i3<m;i3++){
				if(i2==i3)i3++;
				if(i3>m)break;
				yamagutigumi=d[i]*c[i3]+dp[i-1][i2];
				if(dp[i][i3]>yamagutigumi){
					dp[i][i3]=yamagutigumi;
				}
			}
		}
	}
	/*for(i=0;i<n;i++){
		for(i2=0;i2<m;i2++){
			cout<<dp[i][i2]<<' ';
		}
		cout<<endl;
	}*/
	for(i=0;i<m;i++){
		takahashi=min(takahashi,dp[n-1][i]);
	}
	cout<<takahashi<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h.at(i);
    }
    long long dp[n + 10];
    dp[0] = 0;
    dp[1] = abs(h.at(0) - h.at(1));

    for (int i = 2; i < n; i++)
    {
        dp[i] = min(dp[i - 2] + abs(h.at(i - 2) - h.at(i)), dp[i - 1] + abs(h.at(i - 1) - h.at(i)));
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1408
s = input()
abcd = [int(a) for a in s]
flg = 0
for i in range(2**3):
    if flg != 0:
        break
    bin_i = format(i, '03b')
    ops = [int(a)*2-1 for a in bin_i]
    sum = abcd[0]
    for j in range(3):
        sum += ops[j]*abcd[j+1]
        if sum==7:
            flg = 1
            break

ans = s[0]
for j in range(3):
    if ops[j]==1:
        a = '+'
    else:
        a = '-'
    ans += a+s[j+1]
print(ans+'=7')


Measured memory_bytes: 3188
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b;

int main()
{
    cin >> a >> b;
    if(a <= 8 && b <= 8) puts("Yay!");
    else puts(":(");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> sum(N+1);
    rep(i,N) sum[i+1] = sum[i] + A[i];
    ll ans = LINF;
    repr(i,2,N-1){
        ll k = sum[i]/2;
        int d = lower_bound(sum.begin(),sum.end(),k)-sum.begin();
        ll k2 = (sum[N]+sum[i])/2;
        int d2 = lower_bound(sum.begin(),sum.end(),k2)-sum.begin();
        ll P = -1,Q = -1,R = -1,S = -1;
        rep(j,2)rep(r,2){
            int a = d-j;
            if(a >= 1 && a < i){
                P = sum[a];
                Q = sum[i]-sum[a];
            }
            int b = d2-r;
            if(b > i && b < N){
                R = sum[b]-sum[i];
                S = sum[N]-sum[b];
            }
            //cout << P << " " << Q << " " << R << " " << S << endl;
            if(P == -1 || Q == -1 || R == -1 || S == -1) continue;
            ans = min(ans,max({P,Q,R,S})-min({P,Q,R,S}));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int x;
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3572
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	string st = "SHCD";
	vector<vector<int>>oks(4, vector < int>(13));
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		char c; int a; cin >> c >> a;
		int n = st.find(c) - 0;
		a--;
		oks[n][a] = true;
	}
	for (int i = 0; i < 4; ++i) {
		for (int j = 0; j < 13; ++j) {
			if (!oks[i][j]) {
				cout << st[i] << " " << j + 1 << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3180
#![allow(dead_code)]
use std::io;

fn main() {
    solve_a();
}

fn solve_a() {
    let mut num = String::new();
    io::stdin().read_line(&mut num).unwrap();
    let mut num: Vec<_> = num.trim()
        .split_whitespace()
        .map(|s| s.parse::<u16>().unwrap())
        .collect();

    let mut cmd = String::new();
    io::stdin().read_line(&mut cmd).unwrap();

    for d in cmd.trim().chars() {
        let mut new = vec![0; 6];
        if d == 'N' {
            // t 0 => N 4
            new[4] = num[0];
            // s 1 => T 0
            new[0] = num[1];
            // e 2 => e 2
            new[2] = num[2];
            // w 3 => w 3
            new[3] = num[3];
            // n 4 => b 5
            new[5] = num[4];
            // b 5 => s 1
            new[1] = num[5];
        } else if d == 'S' {
            // t 0 => s 1;
            new[1] = num[0];
            // s 1 => b 5;
            new[5] = num[1];
            // n 4 => t 0;
            new[0] = num[4];
            // b 5 => n 4;
            new[4] = num[5];

            new[2] = num[2];
            new[3] = num[3];
        } else if d == 'E' {
            // t 0 => e 2;
            new[2] = num[0];
            // w 3 => t 0;
            new[0] = num[3];
            // b 5 => w 3;
            new[3] = num[5];
            // e 2 => b 5;
            new[5] = num[2];

            new[1] = num[1];
            new[4] = num[4];
        } else {
            // t 0 => w 3;
            new[3] = num[0];
            // e 2 => t 0;
            new[0] = num[2];
            // b 5 => e 2;
            new[2] = num[5];
            // w 3 => b 5;
            new[5] = num[3];

            new[1] = num[1];
            new[4] = num[4];
        }
        num = new;
    }
    println!("{}", num[0]);
}



Measured memory_bytes: 5032
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<functional>
#include<set>
#include<queue>
#include<limits.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
using namespace std;

signed main() {
	int n; cin >> n;
	string a, b, c; cin >> a >> b >> c;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		set<char>S;
		S.insert(a[i]);
		S.insert(b[i]);
		S.insert(c[i]);
		ans += S.size() - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
l = []
i = 1
while n > 0:
	n -= i
	t = i * (i - 1) // 2
	l += [list(range(t + 1, t + i + 1))]
	i += 1
if n < 0:
	print("No")
	exit()
print("Yes")
ans = []
i -= 1
for j in range(i):
	ans.append(list(map(str, [i] + l[j] + [l[k][j] for k in range(j + 1, i)])))
ans.append(list(map(str, [i] + [l[j][-1] for j in range(i)])))
print(i + 1)
print(*map(" ".join, ans), sep="\n")

Measured memory_bytes: 22260
#include <vector>
#include <iostream>
#include <map>


void f(std::vector<int> &vector, const int &count = 0){
	bool flag = true;
	std::map<int, int> freq;
	for (const auto &i : vector) {
		if (freq.find(i) == freq.end()) {
			freq[i] = 1;
		}
		else {
			++freq.at(i);
		}
	}
	for (auto &i : vector) {
		flag = (i == freq.at(i)) && flag;
		i = freq.at(i);
	}
	if (flag) {
		std::cout << count << "\n";
		for (auto i = 0; i < vector.size() - 1; ++i){
			std::cout << vector.at(i) << " ";
		}
		std::cout << vector.back() << "\n";
	}
	else {
		f(vector, count + 1);
	}
}
int main() {
	int n;
	std::cin >> n;
	while (n != 0) {
		std::vector<int> vec(n);
		for (auto &i : vec) {
			int temp;
			std::cin >> temp;
			i = temp;
		}
		f(vec);
		std::cin >> n;
	}
	return 0;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
        llin(r);
        llin(d);
        llin(x);
        FOR(i,0,9){
                x=r*x-d;
                sal(x);
        }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
ll rsept(int k)
{
    	ll value=7;
    	if(k%2==0 || k%5==0)
    	return -1;
    	for(ll i=1;i<1e9;i++)
    	{
	        if(value%k==0)
			{
			  return i;
			}
			else
			value=(value*10%k+7%k);
		}
	   return -1;
}
int main()
{
	ll k;
	cin>>k;
	cout<<rsept(k)<<endl;
	return 0;

}


Measured memory_bytes: 3616
package main

import "fmt"

func numDigits(i int64) int64 {
	if i < 10 {
		return 1
	}
	return numDigits(i/10) + 1
}

func main() {
	var n int64
	fmt.Scan(&n)

	min := int64(20)
	for i := int64(1); i*i <= n; i++ {
		if n%i == 0 {
			if v := numDigits(n / i); min > v {
				min = v
			}
		}
	}
	fmt.Println(min)
}


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

int main(){
   int n;
   int k;
   int count = 0;
   cin >> n >> k;
    int h[n];
   for(int i=0;i<n;i++){
       cin >> h[i];
       if(h[i] >= k){
           count += 1;
       }
   }
   cout << count;

    return 0;
}

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

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll res = (b-a) * (n-2) + 1;

    cout << max(0LL, res) << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let n: i32 = read();
    println!("{}", solve(n));
}

fn read<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

fn solve(n: i32) -> i64 {
    let mut counts: Vec<i32> = std::iter::repeat(0).take(n as usize + 1).collect();
    for i in 1..=n {
        for j in (i..=n).step_by(i as usize) {
            counts[j as usize] += 1;
        }
    }

    counts
        .iter()
        .enumerate()
        .map(|(i, &c)| (i as i64) * (c as i64))
        .sum()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_solve_1() {
        assert_eq!(23, solve(4));
    }

    #[test]
    fn test_solve_2() {
        assert_eq!(26879, solve(100));
    }

    #[test]
    fn test_solve_3() {
        assert_eq!(838627288460105, solve(10000000));
    }
}


Measured memory_bytes: 41072
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii, int> iii;
main(){
    int n,m,l;
    scanf("%lld%lld%lld",&n,&m,&l);
    vector<ii> adjlist[n];
    for (int i = 0; i < m; i++){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        a--; b--;
        if (c <= l){
            adjlist[a].push_back(ii(b,c));
            adjlist[b].push_back(ii(a,c));
        }
    }
    int ans[n][n];
    memset(ans,-1,sizeof(ans));
    for (int i = 0; i < n; i++){
        int dist[n];
        memset(dist,-1,sizeof(dist));
        dist[i] = 0;
        ans[i][i] = 0;
        priority_queue<iii,vector<iii>,greater<iii> > pq;
        pq.push(iii(ii(0,0),i));
        while (pq.size()){
            iii cur = pq.top(); pq.pop();
            ii d = cur.first;
            int dx = d.first, dy = d.second;
            int u = cur.second;
            //printf("%lld %lld %lld %lld\n",dx,dy,u,i);
            if (dx > ans[i][u] || (dx == ans[i][u] && dy > dist[u])) continue;
            for (auto v : adjlist[u]){
                if (dist[u]+v.second > l){
                    if (dist[v.first] == -1 || ans[i][v.first] > ans[i][u]+1 || (ans[i][v.first] == ans[i][u] + 1 && dist[v.first] > v.second)){
                        ans[i][v.first] = ans[i][u]+1;
                        dist[v.first] = v.second;
                        pq.push(iii(ii(ans[i][v.first],dist[v.first]),v.first));
                    }
                }
                else{
                    if (dist[v.first] == -1 || ans[i][v.first] > ans[i][u] || (ans[i][v.first] == ans[i][u] && dist[v.first] > dist[u]+v.second)){
                        ans[i][v.first] = ans[i][u];
                        dist[v.first] = dist[u]+v.second;
                        pq.push(iii(ii(ans[i][v.first],dist[v.first]),v.first));
                    }
                }
            }
        }
    }
    int q;
    scanf("%lld",&q);
    for (int i =0;  i< q; i++){
        int s,t;
        scanf("%lld%lld",&s,&t);
        s--; t--;
        printf("%lld\n",ans[s][t]);
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    using lint = long long int;
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// Bellman-Ford
// depend:edge
// 到達不可能:LLONG_MAX、負閉路を経由可能:LLONG_MIN
vector<lint> bellman_ford(vector<vector<edge>>& g, int s) {
    int n = g.size();
    vector<long long int> res(n, LLONG_MAX);
    res[s] = 0;
    for (int i = 0; i < 2 * n; i++) {
        for (int j = 0; j < n; j++) {
            if (res[j] == LLONG_MAX) continue;
            for (int k = 0; k < (int)g[j].size(); k++) {
                int c = g[j][k].cost, dest = g[j][k].to;
                if (i < n - 1) {
                    res[dest] = min(res[dest], res[j] + c);
                } else {
                    if (res[j] == LLONG_MIN || res[dest] > res[j] + c)
                        res[dest] = LLONG_MIN;
                }
            }
        }
    }
    return res;
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        g[a].push_back(edge(b, p - c));
    }
    vector<lint> dist = bellman_ford(g, 0);
    if (dist[n - 1] == LLONG_MIN) {
        cout << -1 << endl;
    } else {
        cout << max(-dist[n - 1], 0LL) << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <deque>
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+50;
const int inf=0x3f3f3f3f;
int n,k;
char s[10000];
ll a[200050];
bool vis[200050];
vector<int >g[200050];
void dfs(int t)
{
    vis[t]=1;
    for(int i=0;i<g[t].size();i++)
    {
        int v=g[t][i];
        if(!vis[v])
        {
            a[v]+=a[t];
            dfs(v);
        }
    }
}
int main()
{
    //freopen("/Users/zilongzhang/Desktop//l.txt","r",stdin);
    while(scanf("%d %d",&n,&k)!=-1)
    {
        memset(a,0, sizeof(a));
        memset(vis,0, sizeof(vis));
        for(int i=1;i<=n;i++)
            g[i].clear();
        for(int i=1;i<=n-1;i++) {
            int x, y;
            scanf("%d %d", &x, &y);
            g[x].push_back(y);
            g[y].push_back(x);
        }
        while(k--)
        {
            int x,y;
            scanf("%d %d",&x,&y);
            a[x]+=y;
        }
        dfs(1);
        for(int i=1;i<=n;i++)
            printf("%lld ",a[i]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 24448