akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template< class T >
struct CumulativeSum2D {
	vector< vector< T > > data;

	CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {}

	void add(int x, int y, T z) {
		++x, ++y;
		if (x >= data.size() || y >= data[0].size()) return;
		data[x][y] += z;
	}

	void build() {
		for (int i = 1; i < data.size(); i++) {
			for (int j = 1; j < data[i].size(); j++) {
				data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
			}
		}
	}

	T query(int sx, int sy, int gx, int gy) {
		return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]);
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	CumulativeSum2D<int> grid(4 * K, 4 * K);
	int x, y; char w;
	for (int i = 0; i < N; i++) {
		cin >> x >> y >> w;
		if (w == 'W') {
			x %= 2 * K;
			y %= 2 * K;
		}
		else {
			x += K;
			x %= 2 * K;
			y %= 2 * K;
		}
		grid.add(x, y, 1);
		grid.add(x + 2 * K, y, 1);
		grid.add(x, y + 2 * K, 1);
		grid.add(x + 2 * K, y + 2 * K, 1);
	}

	grid.build();

	int ans = 0;
	for (int row = 0; row < 2 * K; row++) {
		for (int col = 0; col < 2 * K; col++) {
			ans = max(ans, grid.query(row, col, row + K, col + K) + grid.query(row + K, col + K, row + 2*K, col + 2*K));
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 62976
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string s;
	cin>>s;
	long long cnt=0;
	loop(i,1,s.size()){
		if(s[i-1]!=s[i])cnt++;
	}
	cout<<cnt<<endl;
	return 0;
} 

Measured memory_bytes: 640
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n,c;

priority_queue< pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>> > q;
struct p {
    ll s,t,c;
};

p ps[100010];
ll pro[35][100010];

bool comp(const p x,const p y){
    return x.s < y.s;
}

int main() {
    cin >> n>>c;
    Fill(pro,-1);
    for (int i = 0; i < n; i++) {
        cin >> ps[i].s >> ps[i].t >> ps[i].c;
        
        if(pro[ps[i].c][ps[i].s] == -1 && pro[ps[i].c][ps[i].t] == -1 ){
            // 空なら更新
            pro[ps[i].c][ps[i].s] = i;
            pro[ps[i].c][ps[i].t] = i;
        }else if(pro[ps[i].c][ps[i].t] != -1 && pro[ps[i].c][ps[i].s] == -1){
            // 新しい方の終わりの方がからでなければ、以前の方の開始を伸ばして合体
            ps[ pro[ps[i].c][ps[i].t] ].s = ps[i].s;
            
            // 新しい開始に以前の値を入れる。
            pro[ps[i].c][ps[i].s] = pro[ps[i].c][ps[i].t];
            
            // 新しいやつは影響を与えないように再配置。
            ps[i].s = -2 * i -2;
            ps[i].t = -2 * i -1;
        }else if(pro[ps[i].c][ps[i].s] != -1 && pro[ps[i].c][ps[i].t] == -1){
            ps[ pro[ps[i].c][ps[i].s] ].t = ps[i].t;
            pro[ps[i].c][ps[i].t] = pro[ps[i].c][ps[i].s];
            
            ps[i].s = -2 * i -2;
            ps[i].t = -2 * i -1;
        }else{
            // stが間に入っている。先頭のやつに吸収させるか
            ll sen = pro[ps[i].c][ps[i].s];
            ll las = pro[ps[i].c][ps[i].t];
            
            // 先頭のやつの最後を最後にまで伸ばす。
            ps[sen].t = ps[las].t;
            pro[ps[i].c][ps[las].t] = sen;
            // いらんやつを再配置
            ps[i].s = -2 * i -2;
            ps[i].t = -2 * i -1;
            
            // いらんやつを再配置
            ps[las].s = i + (ll)1e7;
            ps[las].t = i + (ll)1e7 + 1;
        }
    }
    sort(ps,ps+n,comp);
    
    q.push({ps[0].t,ps[0].c});
    ll cnt =1;
    for (int i = 1; i < n; i++) {
        if(q.top().second == ps[i].c || q.top().first < ps[i].s){
            q.pop();
        }else{
            cnt++;
        }
        q.push({ps[i].t,ps[i].c});
    }
    std::cout << cnt << std::endl;
}


Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m;
    cin >> n >> m;
    string s;
    cin >> s;
    reverse(all(s));
    vector<int> a(0);
    int e=0;
    while(true){
        if (e+m>=n) {
            a.push_back(n-e);
            break;
        }
        for (int i=m;i>0;i--){
            if (s[e+i]=='0'){
                a.push_back(i);
                e+=i;
                break;
            }
            if (i==1) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    reverse(all(a));
    rep(i,a.size()){
        cout << a[i] << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1144
#include<iostream>
#include<stack>
#include<vector>
#include<map>

using namespace std;

pair<int, int> serch_land(vector<vector<int> >& maps){
  for(int i = 0; i < maps.size(); i++){
    for(int j = 0; j < maps[i].size(); j++){
      if(maps[i][j] == 1){
        return make_pair(i, j);
      }
    }
  }
  return make_pair(-1, -1);
}

void delete_land(vector<vector<int> >& maps, pair<int, int> start){
  int dh[8] = {1, 1, 1, 0, 0, -1, -1, -1};
  int dw[8] = {1, 0, -1, 1, -1, 1, -1, 0};

  stack< pair<int, int> > s;
  s.push(start);
  pair<int, int> cur;
  maps[start.first][start.second] = 0;

  while(!s.empty()){
    cur = s.top();
    s.pop();

    for(int i = 0; i < 8; i++){
      if(maps[cur.first + dh[i]][cur.second + dw[i]] == 1){
        maps[cur.first + dh[i]][cur.second + dw[i]] = 0;
        pair<int, int> next = make_pair(cur.first + dh[i], cur.second + dw[i]);
        s.push(next);
      }
    }
  }
}

int main(){
  int w, h;

  while(cin >> w >> h, !(w == 0 && h == 0)){
    vector<vector<int> > maps = vector<vector<int> >(h+2, vector<int>(w+2));
    pair<int, int> land;

    for(int i = 0; i < h+2; i++){
      for(int j = 0; j < w+2; j++){
        if(i == 0 || j == 0 || i == h+1 || j == w+1){
          maps[i][j] = 0;
        }else{
          cin >> maps[i][j];
        }
      }
    }


    int cnt = 0;
    while(land = serch_land(maps), land.first != -1){
      cnt++;
      delete_land(maps, land);
    }
    cout << cnt << endl;

  }
}



Measured memory_bytes: 3064
h, w = map(int, input().split())
a = []
for i in range(h):#h:高さ
    a.append([int(m) for m in input().split()])
n = 0
printlist= []
for i in range(h):
    for j in range(w):
        if i % 2 == 0 and j == w - 1:
            nx = j
            ny = i + 1
            if i == h - 1:
                break
        elif i % 2 == 0 and j != w - 1:
            nx = j + 1
            ny = i
        elif i % 2 != 0 and j == w - 1:
            j = w - j - 1
            nx = j
            ny = i + 1
            if i == h - 1:
                break
        elif i % 2 != 0 and j != w - 1:
            j = w - j - 1
            nx = j - 1
            ny = i
        if a[i][j] % 2 != 0:
            a[i][j] -= 1
            a[ny][nx] += 1
            printlist.append([i + 1, j + 1, ny + 1, nx + 1])
            n += 1

print(n)
for i in range(n):
    print(printlist[i][0], printlist[i][1], printlist[i][2], printlist[i][3])

Measured memory_bytes: 30120
#include<stdio.h>
#include<string.h>
int main()
{
	int n,m[110000],i,s4=0,s2=0,s1=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&m[i]);
		if(m[i]%4==0)
			s4++;
		else if(m[i]%2==0)
			s2++;
		else 
			s1++;		
	} 
	if(s4>=s1){
		puts("Yes");
	}else if(s4==s1-1){
		if(s2){
			puts("No");
		}else {
			puts("Yes");
		}
	}else 
		puts("No");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 int main(){
   int N,T,A;
   cin >>N>>T>>A;
	vector<double> vec(N);
	int c=0;
   for(int i=0;i<N;i++){
	int H;
     cin>>H;
     double S,s;
     s=A-(T-(H*0.006));
     if(s<0){
       S=-s;
     }
     else S=s;
     vec.at(i)=S;
     if(i>0){
       if(S<vec.at(c)){
         c=i;
       }
     }
   }
   cout<<c+1<<endl;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define int long long int

using namespace std;
typedef pair<int, int> PII;
typedef pair<PII, int> PPI;
typedef pair<int, PII> PIP;
typedef pair<PII, PII> PPP;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef vector<int> VI;
const int INF = 3e18;
const double PI = acos(-1);

int n, k;
bool d[10];

signed main()
{
  cin >> n >> k;
  for(int i = 0; i < k; i++){
    int _d;
    cin >> _d;
    d[_d] = true;
  }

  while(true){
    bool flag = false;
    int nown = n;
    while(nown > 0){
      int nownum = nown % 10;
      if(d[nownum]){
	flag = true;
      }
      nown /= 10;
    }

    if(flag){
      n++;
    }
    else{
      break;
    }
  }
  cout << n << endl;
  return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> K(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; ++i)
    {
        cin >> K[i];
        for (int j = 0; j < K[i]; ++j)
        {
            cin >> A[i][j];
        }
    }

    vector<int> like(M);
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = 0; j < K[i]; ++j)
        {
            like[A[i][j] - 1]++;
        }
    }

    for (int i = 0; i < M; ++i)
    {
        if (like[i] == N)
        {
            ans++;
        }
    }

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


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}


   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};
const ll MAX_N = 3e3;
ll N;
ll a[MAX_N] = {};
ll dp[MAX_N + 1][MAX_N + 1];

ll score(ll i, ll j){
  //ai, ai+1, ..., aj1が初期設定の時の得点
  if (i > j) return -INF;
  else if (dp[i][j] > -INF) return dp[i][j];
  else{
    if (i == j) dp[i][j] = a[i];
    else{
      dp[i][j] = max( a[i] - score(i + 1, j) , a[j] - score(i, j - 1));
    }
    return dp[i][j];
  }
}
int main(){
  cin >> N;
  REP(i, N){
    cin >> a[i];
  }
  REP(i, N + 1){
    REP(j, N + 1){
      dp[i][j] = -INF;
    }
  }
  cout << score(0, N - 1) << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,m,c;
	cin >> n >> m >> c;
	int a[n][m],b[m];
	int ans[n]={};
	int count=0;
	REP(i,m) cin >> b[i];
	REP(i,n){
		REP(j,m){
			cin >> a[i][j];
			ans[i]+=a[i][j]*b[j];
			//cout << ans[i] << endl;
		}
	}
	REP(i,n){
		//cout << ans[i] << endl;
		if(ans[i]+c>0) count++;
	}
	cout << count << endl;
/////////////////////////////////////////////
}

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

typedef long long int ll;




int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, x, y;
    cin >> n >> x >> y;
    int d[n] = {0};
    for (int i=1; i<n; i++) {
		for (int j=i+1; j<=n; j++) {
		/*	if ((i<x && j<=x) || (i>=y && j>y)) d[j-i] += 1;
			else if (i<=x && j>=y) d[x-i+1+j-y] += 1;
			else if (i<=x && j<y && j>x) d[min(j-i, x-i+1+j-y)] += 1;
			else if (i>x && i<y && j>=y) d[min(j-i, i-x+1+j-y)] += 1;
			else d[min(j-i, 1+i-x+)] */
			d[min(j-i, abs(x-i)+1+abs(j-y))] += 1;
		}
	}
	for (int i=1; i<n; i++) cout << d[i] << endl;
	cout << endl;
    
	
	
    return 0;
}


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

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std; int l[100009]; int dp[100009];
int main(){
	int n; cin >> n;
	for (int i=0; i<n; i++) cin >> l[i];
	dp[0]=0; dp[1]=abs(l[0]-l[1]);
	for (int i=2; i<n; i++) dp[i]=min(dp[i-1]+abs(l[i-1]-l[i]),abs(l[i-2]-l[i])+dp[i-2]);
	cout << dp[n-1];
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(H: int, W: int, K: int):
    # t[h][k]: h x W のあみだくじのうち, k+1本目にたどり着くパターンの総数
    t = [[0 for i in range(W)] for j in range(H+1)]
    t[0][0] = 1
    
    # d[w]: 縦w本のあみだくじに線をひくパターンの総数
    d = [0 for i in range(W+1)]
    d[0] = 1
    d[1] = 1
    for w in range(2, W+1):
        d[w] += d[w-1] #一番右に線を引かない場合
        d[w] += d[w-2] #一番右に線を引く場合

    for h in range(1, H+1):
        for k in range(W):
            if k > 0:
                # 左からくるパターン -*
                t[h][k] += t[h-1][k-1] * d[k-1] * d[W-k-1]
                t[h][k] %= MOD
            if k < W-1:
                # 右からくるパターン *-
                t[h][k] += t[h-1][k+1] * d[k] * d[W-k-2]
                t[h][k] %= MOD
            # 上からくるパターン ..
            t[h][k] += t[h-1][k] * d[k] * d[W-k-1]
            t[h][k] %= MOD

    print(t[H][K-1])
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(H, W, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, m, l, r, ls, rs;
  cin >> n >> m;
  ls = 0, rs = n;
  rep(i,m)
  {
    cin >> l >> r;
    ls = max(ls, l);
    rs = min(rs, r);
  }
  cout << max(0, rs - ls + 1);
}

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

ll n;


int main(){
  ll ans=0;
  cin >> n;
  ll t;
  REP1(i,n){
    if (i*i>=n){break;}
    t=n%i;
    if (t==0){
      ll m=(n/i-1);
      if ((n/m)==(n%m))
        ans+=(n/i-1);
    }
  }


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

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

int main(){
  int n;
  while(cin >> n){
    vector<int> v(n,0),ans(n);
    
    for(int i=0;i<n*(n-1)/2;i++){
      int a,b,c,d;
      cin >> a >> b >> c >> d;
      a--;
      b--;
      if(c > d) v[a] += 3;
      else if(c < d) v[b] += 3;
      else{
	v[a]++;
	v[b]++;
      }
    }

    int dr = -1, dr_c=0;
    for(int i=0;i<n;i++){
      int a = -1, b;
      for(int j=0;j<n;j++){
	if(a < v[j]){
	  a = v[j];
	  b = j;
	}
      }
      if(dr == v[b]) dr_c++;
      else dr_c = 0;
      ans[b] = i + 1 - dr_c;
      dr = v[b];
      v[b] = -1;
    }

    for(int i=0;i<n;i++) cout << ans[i] << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        if (!n)
            break;

        int id, p, q;
        vector<int> ord;
        bool flag = false;
        map<int, long long> worker;
        
        for (int i = 0; i < n; i++) {
            cin >> id >> p >> q;
            if (worker.find(id) == worker.end())
                ord.push_back(id);
            worker[id] += (long long)p * q;
        }

        for (int i = 0; i < ord.size(); i++) {
            if (worker[ord[i]] >= 1000000) {
                cout << ord[i] << endl;
                flag = true;
            }
        }
        if (!flag)
            cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

static int cnt;
int bubbleSort(int* A, int N)
{
	int flag=1;
	int i,tmp;
	while(flag){
		flag = 0;
		
		for(i=N-1;i>0;i--){
			if(A[i]<A[i-1]){
				tmp = A[i];
				A[i]=A[i-1];
				A[i-1]=tmp;
				flag=1;
				cnt++;
			}
		}
	}
	return 0;
}
int 
main(){
	int N;
	int A[100];	
	scanf("%d",&N);
	int i;
	for(i=0;i<N;i++)scanf("%d",&A[i]);
	
	bubbleSort(A,N);
	//printf("%d %d \n",k,j);
	for(i=0;i<N;i++){
	    if(i<N-1)printf("%d ",A[i]);
	    else printf("%d",A[i]);
	}
	printf("\n%d\n",cnt);
 return 0;
}


Measured memory_bytes: 2112
#include<stdio.h>
int main(){
  int n,a[101],sum=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(i%2==0&&a[i]%2==1){
      sum++;
    }
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 1736
use contest::io::Scanner;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n = sc.next::<usize>();
    let mut m = sc.next::<i64>();
    let mut v: Vec<(i64, i64)> = vec![];

    for _ in 0..n {
        v.push((sc.next(), sc.next()));
    }
    v.sort();
    let mut res = 0;
    for &(a, b) in &v {
        if m <= 0 {
            break;
        }
        for _ in 0..b {
            if m <= 0 {
                break;
            }
            m -= 1;
            res += a;
        }
    }
    println!("{}", res);
}
pub mod contest {
    pub mod io {
        /// Scanner
        ///
        /// # Example
        /// ```
        /// use contest::io::Scanner;
        /// let mut sc = Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
        /// assert_eq!("1".to_string(), sc.next::<String>());
        /// assert_eq!(2, sc.next());
        /// assert_eq!(3.5, sc.next());
        ///
        /// // To create a scanner from stdin:
        /// Scanner::new(std::io::stdin());
        /// ```
        use std;
        use std::io;
        use std::io::BufRead;

        pub struct Scanner<R: io::Read> {
            br: io::BufReader<R>,
            // Read tokens are stored in reversed order per line.
            buf: Vec<String>,
        }

        pub fn new<R: io::Read>(r: R) -> Scanner<R> {
            Scanner::new(r)
        }

        impl<R: io::Read> Scanner<R> {
            #[inline]
            pub fn new(r: R) -> Scanner<R> {
                Scanner {
                    br: io::BufReader::new(r),
                    buf: vec![],
                }
            }
            #[inline]
            pub fn next<T>(&mut self) -> T
            where
                T: std::str::FromStr,
                T::Err: std::fmt::Debug,
            {
                self.next_string()
                    .map(|s| s.parse::<T>().expect("Parse failed: "))
                    .expect("Unexpected EOF")
            }
            #[inline]
            pub fn next2<T1, T2>(&mut self) -> (T1, T2)
            where
                T1: std::str::FromStr,
                T2: std::str::FromStr,
                T1::Err: std::fmt::Debug,
                T2::Err: std::fmt::Debug,
            {
                (self.next(), self.next())
            }
            fn next_string(&mut self) -> Option<String> {
                self.buf.pop().or_else(|| match self.update() {
                    true => self.next_string(),
                    false => None,
                })
            }
            #[inline]
            fn update(&mut self) -> bool {
                let mut s = String::new();
                let res = self.br.read_line(&mut s);
                match res.expect("I/O error.") {
                    0 => false,
                    _ => {
                        self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                        true
                    }
                }
            }
        }

        #[test]
        fn test_next() {
            let mut sc = new("hoge".as_bytes());
            let s: String = sc.next();
            assert_eq!("hoge", s);
        }
    }
}


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

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define vs vector<string>
#define pb push_back
using namespace std;

int main(void){
  string s;
  cin>>s;
  bool f = false;
  rep(i,s.size()){
    f = f || s[i] == '9';
  }
  cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;

namespace adaptor = boost::adaptors;

void Main()
{
	string N;
  
  	cin >> N;
	
	if (N[2] == N[3] && N[4] == N[5]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	
	string N;
  
  	cin >> N;
	
	if (N[2] == N[3] && N[4] == N[5]) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

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

#define pb push_back
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define INF 1e18
#define MOD 1000000007
#define int long long
#define FOR(x, n) for(int i=x; i<n; i++)
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 

int dx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int dy[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };  
double PI = acos(-1); 

int32_t main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	string s; cin >> s;
	if(s.back() == 's')
		s += "es";
	else
		s += 's';
	cout <<s << "\n";
	return 0;
}

Measured memory_bytes: 3660
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val ln = readLine()!!.split(" ").map(String::toInt).toMutableList()
    val lRet = mutableListOf<Int>()
    while(ln.size > 0){
        for(i in ln.size.downTo(0)){
            if(i == 0){
                println(-1)
                return
            }
            if(ln[i - 1] == i){
                lRet.add(ln[i - 1])
                ln.removeAt(i - 1)
                break
            }
        }
    }
    lRet.reverse()
    lRet.forEach{
        println(it)
    }
}

Measured memory_bytes: 37992
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int X,Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
}

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

int main() {
  int a,b;
  char op;
  while (true) {
    cin >> a >> op >> b;
    if (op == '?') break;
    int ans{};
    switch (op) {
      case '+':
        ans = a + b;
        break;
      case '-':
        ans = a - b;
        break;
      case '*':
        ans = a * b;
        break;
      case '/':
      default:
        ans = a / b;
        break;
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3028
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
c1=b[a[0]-1]

for i in range(1,n):
    if (a[i]-a[i-1])==1:
        
        c1+=b[a[i]-1]+c[a[i-1]-1]
    else:
        c1+=b[a[i]-1]
print(c1)

        
        
    
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

const int INF = 1001001001;

int main() {
  int x,n;
  cin>>x>>n;
  set<int> p;
  REP(i, n) {
    int a;
    cin >> a;
    p.insert(a);
  }
  int num = INF;
  int ans;
  FORe(i, 0, 101) {
    bool ok = (p.count(i) == 0);
    if(!ok) continue;
    bool ch = chmin(num, abs(x-i));
    if(ch) ans = i;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3640
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val s1 = readLine()!!
    val s2 = readLine()!!
    val mod = 1000000007
    var ans = 1L
    var i = 0
    var vh = 'v'
    if(s1[i] == s2[i]){
        ans *= 3
        vh = 'v'
        i += 1
    }else{
        ans *= 6
        vh = 'h'
        i += 2
    }

    while (i < N){
        if(s1[i] == s2[i]){
            if(vh == 'v'){
                ans *= 2
                vh = 'v'
                i += 1
            }else{
                ans *= 1
                vh = 'v'
                i += 1
            }
        }else{
            if(vh == 'v'){
                ans *= 2
                vh = 'h'
                i += 2
            }else{
                ans *= 3
                vh = 'h'
                i += 2
            }
        }
    }
    println(ans % mod)
}

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

int main()
{
	ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a)
    cout<<k;
  else if(k>a && k<=(a+b))
    cout<<a;
  else 
    cout<<a-(k-(a+b));
    return 0; 
}
  
  

Measured memory_bytes: 3636
from sys import stdin

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    ans = 0
    for i, a in enumerate(A):
        ans += B[a-1]
        if i > 0 and A[i] - A[i-1] == 1:
            j = A[i-1] - 1
            ans += C[j]
    print(ans)

input = lambda: stdin.readline()[:-1]
main()


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

const int64_t MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

ll pCount(int x){
  if(x==0) return 1;
  return pCount(x-1)*2 + 1;
}

ll allCount(int x){
  if(x==0) return 1;
  return allCount(x-1)*2 + 3;
}


signed main() {
  ull n;
  cin >> n;
  
  map<int,int> factors;
  for(uint64_t i=1;i<=n;i++){
    list<uint64_t> tmpF;
	primeFactorization(i, tmpF);
    
    for(auto v:tmpF){
      factors[(int)v]++;
    }
  }

  // 4 4 2
  // 14 4
  // 24 2
  // 74
  int fourCount=0;
  int twoCount=0;
  int fourteenCount=0;
  int twentyFourCount=0;
  int seventyFourCount=0;
  for(auto f:factors){
    //cout << f.first << "," << f.second << endl;
    if(f.second>=4)fourCount++;
    if(f.second>=2)twoCount++;
    if(f.second>=14)fourteenCount++;
    if(f.second>=24)twentyFourCount++;
    if(f.second>=74)seventyFourCount++;
  }

  cout << fourCount*(fourCount-1)*(twoCount-2)/2
    + fourteenCount*(fourCount-1)
    + twentyFourCount*(twoCount-1)
    + seventyFourCount << endl;
  return 0;
}



Measured memory_bytes: 3648
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        Map<Integer, HashMap<Integer, Integer>> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            HashMap<Integer, Integer> m = new HashMap<>();
            for (int j = 0; j < A[i]; j++) {
                int a = sc.nextInt();
                int b = sc.nextInt();
                m.put(a, b);
            }
            map.put(i, m);
        }
        int[] x = new int[N];
        int[] y = new int[N];
        int ans = 0;
        int tmp = 0;

        for (int i = 0; i < (1 << N); i++) {
            int[] xy = new int[N];
            int count = 0;
            for (int j = 0; j < N; j++) {
                if ((i & (1 << j)) == (1 << j)) {
                    xy[j] = 1;
                    count++;
                }
            }
            boolean ok = true;
            for (int j = 0; j < N; j++) {
                if (xy[j] == 0) continue;
                HashMap<Integer, Integer> b = map.get(j);
                for (Map.Entry<Integer, Integer> e : b.entrySet()) {
                    if(xy[e.getKey() - 1] != e.getValue()){
                        ok = false;
                    };
                }
            }
            if (ok && ans <= count) {
                ans = count;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 36368
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int Q = sc.nextInt();

		int[][] C = new int[N + 1][N + 1];

		for(int i = 0; i < M; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			C[l][r]++;
		}

		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				C[i][j] += C[i][j - 1];
			}
		}
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= N; j++) {
				C[i][j] += C[i - 1][j];
			}
		}

		for(int i = 0; i < Q; i++) {
			int p = sc.nextInt();
			int q = sc.nextInt();
			System.out.println(C[q][q] - C[p - 1][q] - C[p][p - 1] + C[p - 1][p - 1]);
		}
	}
}

Measured memory_bytes: 154768
N=int(input())
B = list(map(int, input().split()))
A = [0 for i in range(N)]
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1,N-1):
  A[i] = min(B[i-1],B[i])
print(sum(A))


Measured memory_bytes: 3060
/// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;
		for(char c='a';c<='z';c++){
			bool left=false;
			bool right = false;
			for(int j=0;j<i;j++){
				if(s[j]==c) left =true;
			}
			for(int j=i;j<n;j++){
				if(s[j]==c) right =true;
			}
			if(left&&right) cnt++;
		}
		if(ans<cnt) ans =cnt;
	}
	cout<<ans<<endl;
	//cout<<endl<<"Time: "<<(float)clock()/CLOCKS_PER_SEC<<" seconds"<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

Measured memory_bytes: 3624
s = input()
leng = len(s)

cnt = 0
for i in range(leng):
    if i % 2 == 0 and s[i] == '0':
        cnt += 1
    elif i % 2 == 1 and s[i] == '1':
        cnt += 1

print(min(cnt, leng-cnt))

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int a,b,k;
  cin>>a>>b>>k;
  for(i=a;i<=min(b,a+k-1);i++)cout<<i<<endl;
  for(i=max(b-k+1,a+k);i<=b;i++)cout<<i<<endl;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> dp(n+1,0);
    for(int i=0;i<m;i++){
        ll l,r;
        cin>>l>>r;
        dp[l-1]++;
        dp[r]--;
    }
    for(int i=1;i<=n;i++){dp[i]+=dp[i-1];}
    ll ans=0;
    for(auto &I:dp){ans+=(I==m?1:0);}
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(){

    int n,k;
    scanf("%d %d",&n,&k);

    int judge = 0, i;
    for(i = 0; judge == 0; i++){
        if(n-pow(k,i) < 0){
            judge = 1;
        }
    }

    printf("%d",i-1);

    return 0;
}

Measured memory_bytes: 128
def main():
    n=int(input())
    a=[list(map(int,input().split())) for _ in [0]*n]
    m=(n*(n-1))//2
    d=dict()
    cnt=0
    for i in range(n-1):
        for j in range(i+1,n):
            d[(i,j)]=cnt
            cnt+=1
    g=[[] for _ in [0]*m]
    gr=[0]*m
    for i in range(n):
        temp=[]
        for j in a[i]:
            if i>=j:temp.append(d[(j-1,i)])
            else:temp.append(d[(i,j-1)])
        for j,k in enumerate(temp[1:]):
            g[temp[j]].append(k)
            gr[k]+=1
    q=[i for i,j in enumerate(gr) if j==0]
    cnt=0
    while q:
        cnt+=1
        qq=[]
        for i in q:
            for j in g[i]:
                gr[j]-=1
                if gr[j]==0:
                    qq.append(j)
        q=qq
    if sum(gr)==0:
        print(cnt)
    else:
        print(-1)
main()

Measured memory_bytes: 184928
import sys
from collections import deque
import itertools
from collections import deque
sys.setrecursionlimit(10 ** 9)

# map(int, sys.stdin.read().split())


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


def main():
    N = int(input())
    print(N*(N-1)//2)




if __name__ == "__main__":
    main()


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
    cerr << "[";
    for (auto e : aux) cerr << e << ' ';
    cerr << "]";
    return cerr;
}

const int maxN = 5011;
const ll inf = 1LL << 60;

int n;
int p[maxN];
ll A, B; // A right, B left
ll on_left[maxN];
ll on_right[maxN];
ll dp[maxN];

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%lld%lld", &n, &A, &B);
    for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
    p[n + 1] = n + 1;

    dp[0] = 0;
    for (int i = 1; i <= n + 1; i++) {
        dp[i] = inf;

        for (int j = i - 1; j >= 0; j--) {
            if (p[j] < p[i]) {
                if (on_left[j] + on_right[i] != i - j - 1) continue;
                dp[i] = min(dp[i], dp[j] + on_left[j] * B + on_right[i] * A);
            } else {
                on_left[j]++;
                on_right[i]++; 
            }
        }
    }

    printf("%lld", dp[n + 1]);




    return 0;
}


Measured memory_bytes: 384
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {

        var s = Console.ReadLine();
        var t = Console.ReadLine();
        var dic = new Dictionary<char, char>();
        var isok = true;
        for (int i = 0; i < s.Length; i++)
        {
            if (dic.ContainsKey(s[i]))
            {
                if (dic[s[i]] != t[i])
                {
                    isok = false;
                    break;
                }
            }
            else
            {
                dic.Add(s[i], t[i]);
            }
        }
        dic.Clear();
        for (int i = 0; i < s.Length; i++)
        {
            if (dic.ContainsKey(t[i]))
            {
                if (dic[t[i]] != s[i])
                {
                    isok = false;
                    break;
                }
            }
            else
            {
                dic.Add(t[i], s[i]);
            }
        }
        Console.WriteLine(isok ? "Yes" : "No");

        Console.ReadLine();
    }
    
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;


    public static void PrintArray(bool[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j] ? "#" : ".").Append("");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数（ll）
ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

//素因数分解
vector<pair<ll, int>>factorize(ll n){
  vector<pair<ll, int>> res;
  for(ll i = 2; i * i <= n; ++i){
    if(n % i) continue;
    res.emplace_back(i, 0);
    while(n % i == 0){
      n /= i;
      res.back().second++;
    }
  }
if(n != 1) res.emplace_back(n, 1);
return res;
}




int main(){
	int H, W, N;
	cin >> H >> W >> N;
	vector<vector<int>> M(H, vector<int>(W, 0));
	int color;
	int x = 0;
	for(int i = 1; i <= N; i++){
		cin >> color;
		for(int j = 0; j < color; j++){
			M.at(x / W).at(x % W) = i;
			x++;
		}
	}

	for(int i = 0; i < H; i++){
		if(i % 2 == 1){
			reverse(M.at(i).begin(), M.at(i).end());
		}
		for(int j = 0; j < W; j++){
			cout << M.at(i).at(j) << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 384
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
using P=pair<double,double>;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,ans=0;
  double x,l,pos=-2e9;
  cin >> n;
  P p[100005]={};
  for(int i=0; i<n; i++) {
    cin >> x >> l;
    p[i].first=x+l-0.1,p[i].second=x-l+0.1;
  }
  sort(p,p+n);
  for(int i=0; i<n; i++) {
    if(pos<p[i].second) {
      ans++;
      pos=p[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const int inf = 1e9; //1(1倍)e(指数)9(10^9)
int main() {
    int n;
    scanf("%d", &n);

    ll h[100010];
    rep(i, n) scanf("%lld", &h[i]);

    ll dp[100010];
    // 初期化 (最小化問題なので INF に初期化)
    rep(i, 100010) dp[i] = inf;

    // 初期条件 足場0からスタートするので、スタート時点でのコストは0
    dp[0] = 0;

    // [i-2] [i-1] i の3つの足場で考えて、iに行く最小のコストを導く
    // 仮定として「ノード i−2 やノード i−1 までの最適な進み方はわかっている」とする
    // i−1 から遷移して来た場合: dp[ i - 1 ] + abs( h[ i ] - h[ i - 1 ] )、 i−2 から遷移して来た場合: dp[ i - 2 ] + abs( h[ i ] - h[ i - 2 ] )
    // chmin は change minimum = a より b の方が小さかったら、a の値を b の値に置き換える (そして true を返す) そうでなかったら、何もしない (そして false を返す)
    // 各 i=1,2,…,N−1i=1,2,…,N−1 に対して順にループを回していけば、dp[ 1 ], dp[ 2 ], dp[ 3 ], ... の値が順々に決まって行く
    for (int i = 1; i < n; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2])); //2個以上になってはじめて1個飛ばしができる
    }

    printf("%lld\n", dp[n - 1]);
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;

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

  int n; cin >> n;
  int a[n];
  vector<vector<P> > v(n);
  rep(i, n) {
    cin >> a[i];
    rep(j, a[i]) {
      int x, y; cin >> x >> y;
      --x;
      v[i].emplace_back(make_pair(x, y));
    }
  }

  int ans = 0;
  rep(i, 1<<n) {
    vector<bool> b(n);
    rep(j, n) {
      b[j] = i>>j&1;
    }
    bool flag = 1;
    vector<int> tf(n, -1);
    rep(j, n) {
      if(tf[j] != -1) {
	if(b[j] ^ tf[j]) {
	  flag = 0;
	  break;
	}
      }
      if(b[j]) tf[j] = 1;
      else {
	tf[j] = 0;
	continue;
      }
      
      rep(k, a[j]) {
	if(tf[v[j][k].first] == -1) {
	  tf[v[j][k].first] = v[j][k].second;
	} else if(tf[v[j][k].first] != v[j][k].second) {
	  flag = 0;
	  break;
	}
      }
    }
    if(flag){
      int cnt = 0; rep(j, n) cnt += b[j];
      ans = max(ans, cnt);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n; cout << n * (n - 1LL) / 2LL << "\n";
    return 0;
}

Measured memory_bytes: 256