akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define ALL(i) (i).begin(),(i).end()
#define RALL(i) (i).begin(),(i).end(),greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
#define TENFIVE2 200005
// #define int long long
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double EPS = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
using vii = vector<vector<int> >;
using vl = vector<long long>;
using vp = vector<pint>;

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




typedef pair<int, int> P;

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

  vector<P>red((size_t)N,P(0,0)), blue( (size_t)N,P(0,0));
  rep(i,N){
    int x,y;
    cin>>x>>y;
    red[i] = P(x,y);

  }
  // print(red[0].isUsed);
  
  rep(i,N){
    int x,y;
    cin>>x>>y;
    blue[i] = P(x,y);
  }
  vector<bool> isUsed (N, false);
  sort(ALL(red) );
  sort(ALL(blue));
  
  // rep(i,red.size()){print(red[i].x);}
  cout<<endl;
  // rep(i,N){
  //   cout<<red[i].fst<<" "<<red[i].sec<<endl;
  // }
  // cout<<endl;
  //   rep(i,N){
  //   cout<<blue[i].fst<<" "<<blue[i].sec<<endl;
  // }
  int ans =0;
  rep(i,N){
    
    int maxidx = -1;
    int max = -1;
    rep(j,N){
      if( red[j].fst < blue[i].fst && red[j].sec < blue[i].sec && !isUsed[j] ){
        // cout<<red[j].fst<<" "<<red[j].sec<<endl;
        // cout<<blue[i].fst<<" "<<blue[i].sec<<endl;
        
        if(max < red[j].sec ){ maxidx = j; max = red[j].sec;}        
      }
    }

    if(maxidx != -1){
      isUsed[maxidx]= true;
      ans++;        
    }
  }
  print(ans);
  return 0;
}


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

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = 1e18;
const lint MOD = 1e9 + 7;
const lint inv = 1e9 + 5;

struct unionFind{

    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

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

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if(rank[rx] < rank[ry]){
            par[rx] = ry;
        }else if(rank[rx] == rank[ry]){
            par[rx] = ry;
            rank[ry]++;
        }else{
            par[ry] = rx;
        }
        return;
    }

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

};

bool solve(string s, string t){
    if(s.size() != t.size()){
        return false;
    }
    unionFind ufs, uft;
    ufs.init(s.size());
    uft.init(t.size());
    map<char, int> mps, mpt;
    for(char c = 'a' ; c <= 'z' ; c++){
        mps[c] = -1;
        mpt[c] = -1;
    }
    rep(i, s.size()){
        if(mps[s[i]] >= 0){
            ufs.unite(mps[s[i]], i);
        }
        mps[s[i]] = i;
    }
    rep(i, t.size()){
        if(mpt[t[i]] >= 0){
            uft.unite(mpt[t[i]], i);
        }
        mpt[t[i]] = i;
    }
    rep(i, s.size()){
        if(ufs.root(i) != uft.root(i)){
            return false;
        }
    }
    return true;
}

int main(){
    string s, t;
    cin >> s >> t;
    if(solve(s, t)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4232
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int current = 0;
        foreach (var item in a)
        {
            if (item == current + 1) current++;
        }
        Console.WriteLine(current == 0 ? -1 : n - current);
    }
}


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


int main()
{
long long int k,s=0;
cin>>k;
for(int i=1;i<=k;i++)
{
    for(int j=1;j<=k;j++)
    {
        for(int l=1;l<=k;l++)
        {
            s+=__gcd(i,__gcd(j,l));
        }
    }
}
cout<<s;

}


Measured memory_bytes: 3632
import math
from collections import deque
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH = sorted(XH)
total = 0
D = 2*D
ans = 0
q = deque()
for x, h in XH:
  while len(q) and q[0][0] < x:
    total -= q.popleft()[1] 
  h -= total

  if h > 0:
    num = math.ceil(h/A)
    ans += num
    damage = num*A
    total += damage
    q += [[x+D, damage]]
print(ans)


Measured memory_bytes: 117564
/*
*/
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  // 標準入力
  //H:敵の体力。< 10^12
  long H;
  cin >> H;
  long answer = 0;
  //ループカウンタ＝常に半分となった個体を攻撃したとき、何回目の攻撃かを示す
  int counter = 0;
  //分裂する数
  long two=2;
  while (true) {

    //１の場合終了
    if (H == 1) {
      answer+=pow( two,counter);
      break;
    }
    //１回で体力が半分になると考える
    H /= 2;
    //一方、個体数は２倍になり、その分回数も倍となる
    answer+=pow(two,counter);
    counter++;
  }


  cout << answer;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a + b + c >= 22) {
		cout << "bust" << '\n';
	} else {
		cout << "win" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
w, h, x, y, r = map(int, input().split())

x_min = x - r
x_max = x + r
y_min = y - r
y_max = y + r

if x_min >= 0 and x_max <= w:
    if y_min >= 0 and y_max <= h:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 5596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
int main(void){
    int n, m;
    cin >> n >> m;
    vector< vector< int > > edg(n, vector<int>());
    vector< int > grp(n, -1);
    for(int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        edg[u].push_back(v);
        edg[v].push_back(u);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        if(grp[i] != -1) continue;
        queue<int> q({i});
        grp[i] = i;
        int sz = 1;
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for(int w: edg[v]){
                if(grp[w] == -1){
                    grp[w] = i;
                    q.push(w);
                    sz++;
                }
            }
        }
        ans = max(ans, sz);
    }
    cout << ans << endl;

}


Measured memory_bytes: 15252
N = int(input())
if 1<= N <= 1000:
    print(1000 - N)
elif 1000 < N <= 2000:
    print(2000 - N)
elif 2000 < N <= 3000:
    print(3000 - N)
elif 3000 < N <= 4000:
    print(4000 - N)
elif 4000 < N <= 5000:
    print(5000 - N)
elif 5000 < N <= 6000:
    print(6000 - N)
elif 6000 < N <= 7000:
    print(7000 - N)
elif 7000 < N <= 8000:
    print(8000 - N)
elif 8000 < N <= 9000:
    print(9000 - N)
elif 9000 < N <= 10000:
    print(10000 - N)

Measured memory_bytes: 61872
from collections import defaultdict
n,q=map(int,raw_input().split())
va=defaultdict(set)
av=defaultdict(int)
for i in range(q):
    a,v=map(int,raw_input().split())
    try:
        va[av[a]].remove(a)
        if va[av[a]]==set([]):
            del va[av[a]]
    except KeyError:
        pass
    av[a]+=v
    va[av[a]].add(a)
    m=max(va.keys())
    t=min(va[m])
    print t,m

Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, W; cin >> n >> W;
  V<> w(n), v(n); for (int i = 0; i < n; ++i) cin >> w[i] >> v[i];
  VV<lint> dp; assign(dp, n + 1, W + 1, 0);
  for (int i = 0; i < n; ++i) for (int j = 0; j <= W; ++j) {
    dp[i + 1][j] = dp[i][j];
    if (j >= w[i]) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
    }
  }
  cout << dp[n][W] << '\n';
}

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


public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int d=sc.nextInt();
			int sum=0;
			for(int i=1;600>=d*(i+1);i++){
				sum+=Math.pow(i*d,2)*d;
			}
			System.out.println(sum);
		}
		sc.close();
	}
}

Measured memory_bytes: 26436
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    char[][] map = new char[h][w];
    int sum = 0;
    for(int i=0;i<h;i++){
      map[i] = sc.next().toCharArray();
      for(int j=0;j<w;j++){
        if(map[i][j]=='#'){
          sum++;
        }
      }
    }
    int[][] isVisited = new int[h][w];
    Queue<int[]> queue = new ArrayDeque<>();
    queue.add(new int[]{0,0});
    isVisited[0][0] = 1;
    int[] p;
    int[][] vec = {{1,0},{0,1}};
    int tox,toy;
    while(queue.size()>0){
      p = queue.poll();
      for(int i=0;i<2;i++){
        toy = p[0] + vec[i][0];
        tox = p[1] + vec[i][1];
        if(toy < h && tox < w && isVisited[toy][tox] == 0 && map[toy][tox]=='#'){
          isVisited[toy][tox] = isVisited[p[0]][p[1]]+1;
          queue.add(new int[]{toy,tox});
        }
      }
    }
    if(isVisited[h-1][w-1]==sum){
      System.out.println("Possible");
    }else{
      System.out.println("Impossible");
    }
    
  }
}

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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

char f(char c){
  if(c == 'r') return 'p';
  if(c == 's') return 'r';
  if(c == 'p') return 's';
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  string ans;
  for(int i = 0; i < n; i++){
    if(i < k){
      ans += f(t[i]);
      continue;
    }
    if(f(t[i]) != ans[i - k]){
      ans += f(t[i]);
    }
    else{
      ans += '#';
    }
  }
  debug() << imie(ans);
  long long sum = 0;
  for(int i = 0; i < ans.size(); i++){
    if(ans[i] == 'r') sum += r;
    if(ans[i] == 's') sum += s;
    if(ans[i] == 'p') sum += p;
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b,c;cin>>a>>b>>c;
    bool flag=false;
    if(a==b){
        if(a!=c){
            flag=true;
        }
    }else if(a==c){
        flag=true;
    }else{
        if(b==c){
            flag=true;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

int N; long long D; vector<long long> L;
void input()
{
    cin >> N >> D;
    L.resize(N);
    for (int i = 0; i < N; ++i){
        long long x,y; cin >> x >> y;
        L[i] = x*x + y*y;
    }
}

void solve()
{
    int sum = 0;
    for (int i = 0; i < N; ++i){
        if (L[i] <= D*D) ++sum;
    }
    cout << sum << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 4756
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        String[] s = sc.next().split("");

        int count = 0;
        String last = "";
        for (int i = 0; i < s.length; i++) {
            if (!s[i].equals(last)) {
                count++;
                last = s[i];
            }
        }

        System.out.println(count - 1);
    }
}

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

/*
L-1~0までを作る
数字を全部から0を出すとしよう
50こ残る
50こでL-1~1まで作る
選択肢をL個以上
0~L/2  L/2~L
とするとlog2Lこの区間に分割できそう
log10^3L=
19から20がL/2
18~19がL/4
5  1,2,
*/


int main(void){
    int a,n;
    scanf("%d",&n);
    scanf("%d",&a);
    n = n%500;
    if(a>=n){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int kk = 0;
    while (b <= a) {
        b = b * 2;
        kk++;
    }
    while (c <= b) {
        c = c * 2;
        kk++;
    }

    if (kk <= k && (a < b && b < c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  priority_queue<ll> que;
  vector<ll> p(A), q(B), r(C);
  FOR(i, A) cin >> p[i];
  FOR(i, B) cin >> q[i];
  FOR(i, C) cin >> r[i];
  sort(all(p), greater<ll>());
  sort(all(q), greater<ll>());
  sort(all(r), greater<ll>());
  FOR(i, X) que.push(p[i]);
  FOR(i, Y) que.push(q[i]);
  FOR(i, C) que.push(r[i]);
  ll ans = 0;
  FOR(i, X + Y) {
    ans += que.top();
    que.pop();
  }

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


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

const int DIM = 1e6 + 5;
const int MOD = 1e9 + 7;

int fct[DIM], inv[DIM], pwr[DIM];

int lgput( int x, int n ) {
    if( n == 0 )
        return 1;
    
    int y = lgput( x, n >> 1 );
    y = ( 1LL * y * y ) % MOD;
    
    if( n & 1 )
        y = ( 1LL * y * x ) % MOD;
    
    return y;
}

inline int comb( int n, int k ) {
    int ans = fct[n];
    ans = ( 1LL * ans * inv[k] ) % MOD;
    ans = ( 1LL * ans * inv[n - k] ) % MOD;
    
    return ans;
}

int main( void ) {
    
    int n, m, k;
    cin >> n >> m >> k;
    
    fct[0] = inv[0] = pwr[0] = 1;
    for( int i = 1; i <= n + m + k; i ++ ) {
        fct[i] = ( 1LL * fct[i - 1] * i ) % MOD;
        pwr[i] = ( 3LL * pwr[i - 1] ) % MOD;
    }
    
    inv[n + m + k] = lgput( fct[n + m + k], MOD - 2 );
    for( int i = n + m + k - 1; i >= 1; i -- )
        inv[i] = ( 1LL * inv[i + 1] * (i + 1) ) % MOD;
    
    int ans = 0, aux = 1;
    for( int i = 0; i <= m + k; i ++ ) {
        if( i != 0 ) {
            aux = ( aux << 1 ) % MOD;
            
            if( i > m )
                aux = ( aux - comb( i - 1, m ) + MOD ) % MOD;
            if( i > k )
                aux = ( aux - comb( i - 1, k ) + MOD ) % MOD;
        }
        
        ans = ( 1LL * aux * comb( i + n - 1, i ) % MOD * pwr[m + k - i] + ans ) % MOD;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11520
#include <stdio.h>
int main (){
int n;
double sum;
scanf("%d",&n);
int a[100];
int tmp;
for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
}
for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (a[i] > a[j]) {
        tmp =  a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
}
sum=(double)a[0];
for(int i=1;i<n;i++){
    sum=(double)(sum+a[i])/2;
}
printf("%lf",sum);

return 0;
}


Measured memory_bytes: 128
//package test;

import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		if (2 * X <= Y && Y <= 4 * X && Y % 2 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}

Measured memory_bytes: 35804
program monsters_battle_royale
  implicit none
  integer :: n, a(100000) = 0, i, g
  read(*,*) n
  read(*,*) a(1:n)
  g = a(1)
  do i = 2, n
    g = gcd(g,a(i))
  end do
  write(*,'(i0)') g
contains
  integer function gcd(a,b)
    integer, intent(in) :: a, b
    integer :: x, y
    x = max(a,b)
    y = min(a,b)
    do while (y > 0)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program monsters_battle_royale

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	string tmp;
	for (int i = t.size() - 1; i >= 0; i--) tmp.push_back(t[i]);
	if (s < tmp) cout << "Yes" << endl;
	else cout << "No" << endl;
	//cout << s << endl << tmp;
}


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

#define int long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()   
#define tak return
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k , i >= n ; --i)
#define sv_cheats ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string S;                                                                
typedef double D;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<pair<int,int> >PII;
typedef map<int,int> MII;
typedef unsigned long long ull;

const int blyat = 0 ;
const int N = 1e5 + 17;
const int mod = 1e9 + 7;
const int INF = 2e9 - 19;
const int P = 37;
const double p = 3.141592653589793238462643383279 ;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll MX=(ll)1e10,MN=(ll)-1e10;

 // varibles
 	bool a[20] ;
//F(x)
	bool check(int n){
		while(n){
			if(a[n % 10])return false;
			else n/=10;
		}
		return 1;
	}

main(){
	sv_cheats;
	int n;
	int  m , x;
	bool ok = 0 ;
	cin >> n >> m ;
	
	for(int i = 1 ; i <= m ; ++i ){
		cin >> x ;
		a[x] = 1 ;
	}
	for(int i = n ; i <= 999999; ++i ){
		if(check(i)){
			cout << i;
			return 0 ;
		}
	}
}

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

ll solve(ll h) {
  if(h == 1) {
    return 1;
  }
  return 1 + solve(h / 2) * 2;
}

int main() {
  ll H;
  cin >> H;
  ll ans = solve(H);
  cout << ans << endl;
  return 0;
}

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

int main()
{
    map<string,int> M{};
    int a,b;
    string s,t[110];
    cin >> a;
    for(int i=0; i<a; i++){
        cin >> t[i];
        M[t[i]]++;
    }
    cin >> b;
    for(int i=0; i<b; i++){
        cin >> s;
        M[s]--;
    }
    int ans = 0;
    for(int i=0; i<a; i++){
        ans = max(ans,M[t[i]]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Aizu Vol-5 0532: Time Card
// 2017.8.30 bal4u@uu

#include <stdio.h>

int main()
{
	int h, m, s;
	int i, j, t[2];

	for (i = 0; i < 3; i++) {
		for (j = 0; j < 2; j++) {
			scanf("%d%d%d", &h, &m, &s);
			t[j] = 3600*h + 60*m + s;
		}
		t[1] -= t[0];
		printf("%d %d %d\n", t[1]/3600, (t[1] % 3600)/60, t[1] % 60);
	}
	return 0;
}

Measured memory_bytes: 600
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vpl PS(N);
    rep(i, N){
        ll p; cin >> p; PS[i] = {p, i};
    }
    sort(ALL(PS), greater<PL>());
    
    ll ans = 0;
    multiset<ll> s;
    s.insert(-1); s.insert(-1);
    s.insert(N); s.insert(N);
    rep(i, N){
        ll idx = PS[i].ss;
        auto r1 = s.upper_bound(idx);
        auto r2 = next(r1);
        auto l1 = --s.lower_bound(idx);
        auto l2 = prev(l1);
        ll tmp1 = (*r2-*r1)*(idx-*l1);
        ll tmp2 = (*l1-*l2)*(*r1-idx);
        ans += PS[i].ff*(tmp1+tmp2);
        s.insert(idx);
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    string ans = (s.length() % 2 == 0) ^ (s.front() == s.back()) ? "Second" : "First";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
a = [int(s) for s in input().split()]
g = {i: [] for i in range(1, a[0] + 1)}

for i in range(a[1]):
    c = [int(s) for s in input().split()]
    g[c[0]].append(c[1])
    g[c[1]].append(c[0])

j = 0
d = {i: False for i in range(1, a[0] + 1)}

for i in range(1, a[0] + 1):
    if d[i] == False:
        j += 1 
        d[i] = True
        if g[i] != []:
            Q = [i]
            while(Q != []):
                r = Q.pop(0)
                if g[r] != []:
                    for m in g[r]:
                        if d[m] == False:
                            d[m] = True
                            Q.append(m)
print(j)

Measured memory_bytes: 46916
#include <stdio.h>
#define N 2000001

int A[N], B[N], C[10001];

void CountingSort(int k, int n){
  int i;
  for(i=0;i<=k;i++) C[i]=0;
  for(i=0;i<n;i++) C[A[i]]=C[A[i]]+1;
  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]=C[A[i]]-1;
  }
}

int main(){
  int n,k;
  int i;
  k=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(k<A[i]) k=A[i];
  }
  CountingSort(k,n);
  printf("%d",B[0]);
  for(i=1;i<n;i++) printf(" %d",B[i]);
  printf("\n");
  return 0;
}




Measured memory_bytes: 17464
def form_check(t):
    plus = t.index('+')
    equal = t.index('=')
    n = [t[:plus], t[plus + 1:equal], t[equal + 1:]]
    for a in n:
        if len(a) > 1 and a[0] == 'X':
            return False
    return True

def check(t):
    if eval(t.replace('=', ' == ')):
        return True
    else:
        return False

while True:
    try:
        line = raw_input()
    except EOFError:
        break

    if form_check(line):
        nums = range(0, 10)
    else:
        nums = range(1, 10)
    a = -1
    for num in nums:
        if check(line.replace('X', str(num))):
            a = num
    if a >= 0:
        print a
    else:
        print 'NA'

Measured memory_bytes: 8216
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	static BufferedReader reader;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		String[] s = readLine();
		int[] nums = new int[Integer.parseInt(s[0])];
		s = readLine();
		for(int i=0;i<s.length;i++) {
			nums[i]=Integer.parseInt(s[i]);
		}
		Arrays.sort(nums);
		int N = nums.length;
		print(nums[N/2]-nums[N/2-1]);
	}

	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
}


Measured memory_bytes: 38028
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}

	int i = 0;
	int counter = 0;

	while(true){
		i = a[i];
		counter++;
		if(i == 1){
			cout << counter << endl;
			break;
		}
		if(counter > 2*n){
			cout << -1 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
#define REP(asd,fgh) for(int asd=0; asd<fgh; asd++)

int main(void){
  vector< vector<string> > defeat;
  string handlist[] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};
  map<string, int> hand;
  REP(i, 15){
    hand[handlist[i]] = i;
  }
  
  int N;
  while(cin >> N, N){
    vector<string> players(N);
    string ans = "Draw";
    REP(i, N){
      cin >> players[i];
    }
    string same = players[0];
    bool draw = true;
    REP(i, N){
      if(players[i] != same) draw = false;
    }
    if(draw){
      cout << ans << endl;
      continue;
    }
    REP(i, N){
      bool flg = true;
      REP(j, N){
	if(i == j) continue;
	if(!(((hand[players[j]] - hand[players[i]])+15)%15 <= 7)){
	  flg = false;
	}
      }
      if(flg)
	ans = players[i];
    }
    cout << ans << endl;
  }

  return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> H(N);
  for (ll i = 0; i < N; i++) cin >> H.at(i);
  for (ll i = N-2; i >= 0; i--) {
    if (H.at(i) <= H.at(i+1)) {
    }else if (H.at(i) == H.at(i+1) + 1) {
      H.at(i)--;
    }else {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";

  return 0;
}



Measured memory_bytes: 3992
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<queue>
#include<stack>
#include<list>
#include<limits>
#include<iomanip>

using namespace std;

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

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)


//#define min(a,b) a>b?b:a
//#define max(a,b) a>b?a:b
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a);
        a = (a*a);
        b = b/2;
    }
    return ans;
}

ll gcd(ll a,ll b)
{
    if(a%b==0)
        return b;
    else
        return gcd(b,a%b);
}


signed main()
{
    fastio;
    
    int n;
    cin >> n;
    
    vector<int> arr(n);
    
    F(i,n)
    cin >> arr[i];
    
    vector<int> cost(n);
    
    cost[0] = 0;
    cost[1] = abs(arr[1] - arr[0]);
    
    for(int i = 2;i<n;i++)
    {
        cost[i] = min(cost[i-1] + abs(arr[i] - arr[i-1]),cost[i-2] + abs(arr[i] - arr[i-2]));
    }
    
    cout << cost[n-1] << endl;
    
    return 0;
}


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

int main()
{
	ll n;
	cin>>n;
	ll h[n+1];
	for(ll i=1;i<=n;i++)
		cin>>h[i];
	ll dp[n+1];
	dp[0]=-1;
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(ll i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 5144
#include<stdio.h>
int main(){
  int i,j,k;
  int a[100];
  int flag=1;
  int swap;
  int con=0;
  scanf("%d",&i);
  for(j=0;j<i;j++){
    scanf("%d",&a[j]);
  }
  while(flag){
    flag=0;
    for(j=i-1;0<j;j--){
      if(a[j]<a[j-1]){
	swap=a[j];
	a[j]=a[j-1];
	a[j-1]=swap;
	flag=1;
	  con+=1;
      }
    }
  }
    for(j=0;j<i;j++){
       if(j==0) printf("%d",a[j]);
       else printf(" %d",a[j]);
    }
      printf("\n");
    printf("%d\n",con);
  }



Measured memory_bytes: 2140
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            string[] input = Console.ReadLine().Split(' ');
            double W = double.Parse(input[0]);
            double H = double.Parse(input[1]);
            double x = double.Parse(input[2]);
            double y = double.Parse(input[3]);

            if (x > W / 2)
                x = W - x;

            if (y > H / 2)
                y = H - y;

            double answer = 0.0;
            int possible = 0;

            //辺上にあれば1/2で確定
            if (x == 0 || x == W / 2 || y == 0 || y == H / 2)
            {
                answer = W * H / 2.0;
                if (W / 2 == x && H / 2 == y)
                    possible = 1;
                else
                    possible = 0;
            }
            else
            {
                answer = W * H / 2.0;
                possible = 0;
            }

            Console.WriteLine(answer.ToString() + ' ' + possible.ToString());
        }
    }

Measured memory_bytes: 13140
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
      //取得
	  int H1 = sc.nextInt();
      int M1 = sc.nextInt();
      int H2 = sc.nextInt();
      int M2 = sc.nextInt();
      int K = sc.nextInt();
      //分換算
      int okiru = H1*60+M1;
      int neru = H2*60+M2;
      //起きてる時間
      int time = neru-okiru;
      
      System.out.println(time-K);
    }
}

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

#define ll long long
int main() {
    ll x,d;
    cin>>x>>d;
    int c=0;
    ll s = d*d;
    ll low = (d-1)*(d-1);
    while(x--){
        ll a,b;
        cin>>a>>b;
        if(a<0) a*=-1;
        if(b<0) b*=-1;
        unsigned ll sum = a*a + b*b;
        if(sum<=s) c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct PalindromicTree{
  struct node{
    map<char,int> nxt;
    int len,suf,hei,app,cnt;
  };
  string s;
  vector<node> v;
  vector<int> ord;
  int n,suff;
  PalindromicTree(){}
  PalindromicTree(string s_){init(s_);build();}
  bool addchar(int pos){
    char ch=s[pos];
    int cur=suff;
    while(1){
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch) break;
      cur=v[cur].suf;
    }
    if(v[cur].nxt.count(ch)){
      suff=v[cur].nxt[ch];
      v[suff].cnt++;
      return false;
    }
    suff=n++;
    v[suff].len=v[cur].len+2;
    v[suff].app=pos-v[suff].len+1;
    v[suff].cnt=1;
    v[cur].nxt[ch]=suff;
    
    if(v[suff].len==1){
      v[suff].suf=1;
      v[suff].hei=1;
      return true;
    }
    while(1){
      cur=v[cur].suf;
      if(pos-1-v[cur].len>=0&&s[pos-1-v[cur].len]==ch){
	v[suff].suf=v[cur].nxt[ch];
	break;
      }
    }
    v[suff].hei=v[v[suff].suf].hei+1;
    return true;
  }
  
  void init(string s_){
    s=s_;
    v.clear();
    v.resize(s.length()+10);

    n=2;
    suff=1;
    v[0].app=v[1].app=-1;
    v[0].len=-1;v[1].len=0;
    v[0].suf=v[1].suf=0;
    v[0].hei=v[1].hei=0;
  }
  
  void calcOrder(){
    ord.clear();
    ord.push_back(0);
    ord.push_back(1);
    for(int i=0;i<(int)ord.size();i++){
      for(auto &p:v[ord[i]].nxt) ord.push_back(p.second);
    }
  }
  
  void calcCount(){
    assert(ord.size());
    for(int i=(int)ord.size()-1;i>=0;i--){
      v[v[ord[i]].suf].cnt+=v[ord[i]].cnt;
    }
    v[0].cnt=v[1].cnt=0;
  }

  void build(){
    for(int i=0;i<(int)s.size();i++) addchar(i);
    calcOrder();
    calcCount();
  }
  
};

struct RollingHash{
  typedef unsigned long long ull;
  string S;
  ull B;
  vector<ull> hash,p;
  int len;
  RollingHash(){}
  RollingHash(string S,ull B=1000000007LL):S(S),B(B){init();};
  void init(){
    len=S.length();
    hash.resize(len+1);
    p.resize(len+1);
    hash[0]=0;p[0]=1;
    for(int i=0;i<len;i++){
      hash[i+1]=hash[i]*B+S[i];
      p[i+1]=p[i]*B;
    }
  }
  //S[l,r)
  ull find(int l,int r){
    return hash[r]-hash[l]*p[r-l];
  }
};


signed main(){
  string s,t;
  cin>>s>>t;
  PalindromicTree p1(s),p2(t);
  RollingHash r1(s),r2(t);
  map<int,int> m1[55555],m2[55555];
  for(int i=0;i<(int)p1.n;i++){
    PalindromicTree::node& u=p1.v[i];
    if(u.app<0) continue;
    m1[u.len][r1.find(u.app,u.app+u.len)]=u.cnt;
  }
  for(int i=0;i<(int)p2.n;i++){
    PalindromicTree::node& u=p2.v[i]; 
    if(u.app<0) continue;
    m2[u.len][r2.find(u.app,u.app+u.len)]=u.cnt;
  }
  int ans=0;
  for(int i=1;i<=(int)s.length();i++){
    for(auto p:m1[i]){
      ans+=m2[i][p.first]*p.second;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 34916
import sys
 
l, r = map(int, input().split())
ans = 10 ** 10
for i in range(l, r+1):
  for j in range(i+1, r+1):
    if (i * j) % 2019 == 0:
      print(0)
      sys.exit()
    ans = min(ans, (i*j) % 2019)
print(ans)

Measured memory_bytes: 9104
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int, int>;

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

  map<char, ll> mp;

  rep(i, n) {
    string s;
    cin >> s;
    mp[s[0]]++;
  }

  ll ans = 0;
  ans += mp['R'] * mp['C'] * mp['H'];
  ans += mp['A'] * mp['C'] * mp['H'];
  ans += mp['R'] * mp['A'] * mp['H'];
  ans += mp['C'] * mp['A'] * mp['R'];  // m~
  ans += mp['M'] * mp['C'] * mp['H'];
  ans += mp['M'] * mp['H'] * mp['R'];
  ans += mp['M'] * mp['C'] * mp['R'];  // A~
  ans += mp['M'] * mp['A'] * mp['H'];
  ans += mp['M'] * mp['A'] * mp['C'];
  ans += mp['M'] * mp['A'] * mp['R'];

  cout << ans;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <queue>
#include <set>

using namespace std;

#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main(){
    int c[3][3];
    rep(i, 3) rep(j, 3) cin >> c[i][j];
    bool answer=true;
    rep(i, 2){
        if (c[0][i] - c[0][i + 1] != c[1][i] - c[1][i + 1] || c[1][i] - c[1][i + 1] != c[2][i] - c[2][i + 1])
            answer = false;
        if (c[i][0] - c[i + 1][0] != c[i][1] - c[i + 1][1] || c[i][1] - c[i + 1][1] != c[i][2] - c[i + 1][2])
            answer = false;
    }
    if (answer) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
  int num;
  string str;
  string tmpStr;
  int cnt = 0;
  int tmpCnt = 0;
  cin >> num;
  cin >> str;
  
  for(int i = 0; i < num - 1; i++){
    tmpCnt = 0;
    tmpStr = "";
    for(int j = 0; j <= i; j++){
      // 同じ文字はスキップ
      if(tmpStr.find(str.at(j)) == string::npos){
        tmpStr = tmpStr + str.at(j);
      }else{
        continue;
      }
      for(int k = i + 1; k < num; k++){
        if(str.at(j) == str.at(k)){
          tmpCnt++;
          break;
        }
      }
    }
    if(cnt < tmpCnt) cnt = tmpCnt;
  }
  
  cout << cnt;
}


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

int main() {
    int64_t N;
    cin>>N;
    int64_t sum =0;
    for(int i=0;i<N+1;i++){
        if(i%3 !=0 && i%5 !=0){
sum=sum+i;

        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3672
N = int(input())
A = [int(x) for x in input().split()]
l = [0]*N
ans = 0
for a in A:
    l[a-1] += 1
for j in l:
    ans += int(j*(j-1)/2)
for k in range(N):
    print(ans - l[A[k]-1] + 1)

Measured memory_bytes: 26268
/*input
2
xy
*/
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <iterator>
#include <limits>
#include <deque>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <climits>
#define ff first
#define ss second
#define MAX 10005
#define endl "\n"
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#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;
using namespace std;

int solve(string str) { 
    int n = str.length(); 
    int dp[n+1][n+1] = {0}; 
      string res; 
    int res_length  = 0; 

    int i, index = 0; 
    for (i=1; i<=n; i++) { 
        for (int j=i+1; j<=n; j++) {  
            if (str[i-1] == str[j-1] && dp[i-1][j-1] < (j - i)){ 
                dp[i][j] = dp[i-1][j-1] + 1; 

                if (dp[i][j] > res_length) { 
                    res_length = dp[i][j]; 
                    index = max(i, index); 
                } 
            } 
            else
                dp[i][j] = 0; 
        } 
    } 

    if (res_length > 0) 
        for (i = index - res_length + 1; i <= index; i++) 
            res.push_back(str[i-1]); 
  
    return res.length(); 
} 

signed main(){
 	ios_base::sync_with_stdio(false);	
 	cin.tie(0);
	cout.tie(0);
    int n;
    string str;
    cin>>n>>str;
    cout << solve(str); 
    return 0; 
} 

Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main(){
  ll n,a[100000],s=0;
  cin>>n;
  for(ll i=0;i<n;i++)cin>>a[i],s+=a[i];
  if(s%(n*(n+1)/2))cout<<"NO"<<endl;
  else{
    s/=n*(n+1)/2;
    ll ans=1,ss=0;
    for(ll i=0;i<n;i++){
      if(-a[(i+1)%n]+a[i]+s>=0)
	ss+=(-a[(i+1)%n]+a[i]+s)/n;
    }
    if(ss==s)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
  long long int a,b,c,d,lcm,t;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  int C=c;
  int D=d;
  while(C!=0&&D!=0){
    lcm=D;
    D=C%D;
    C=lcm;
  }
lcm=c*d/lcm;
t=b/c+b/d-b/lcm-(a-1)/c-(a-1)/d+(a-1)/lcm;
printf("%lld\n",b-a+1-t);
return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() { 
    
    int a,b;
    char ch;

    cin >> a >> ch >> b;

    while(ch != '?'){
    	if(ch == '+'){
    		cout << a+b << endl;
    	}else if(ch == '-'){
    		cout << a-b << endl;
    	}else if(ch == '*'){
    		cout << a*b << endl;
    	}else{
    		cout << a/b << endl;
    	}

    	cin >> a >> ch >> b;
    }



    


    return 0;
}


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

using namespace std;

const int maxN = 3003;

#define int long long

long long DP[maxN][maxN];
int A[maxN];
int n;
const long long INF = 1e16;

void solve() {
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> A[i];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            DP[i][j] = -INF;
    for(int k = 0; k < n; k++){
        for(int i = 0; i < n-k; i++){
            if(k == 0) DP[i][i+k] = A[i];
            //if(i >= n) break;
            else{
                DP[i][i+k] = max(DP[i+k][i+k] - DP[i][i+k-1], DP[i][i] - DP[i+1][i+k]);
            }

        }
    }
    cout << DP[0][n-1] << "\n";
}

#undef int

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    bool multitest = false;
    //multitest = true;
    if (multitest) {
        int t; cin >> t;
        while (t--)
            solve();
    }
    else
        solve();
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int ,int>> v(n);
    for(int i=0;i<n;i++)
    {
        cin >> v[i].first >> v[i].second;
    }
    sort(all(v));
    vector<int> x(n), y(n);
    for(int i=0;i<n;i++)
    {
        x[i] = v[i].first;
        y[i] = v[i].second;
    }
    vector<int> z(n, 0);
    int ans = 0, curr = 0;
    for(int i=0;i<n;i++)
    {
        y[i] -= curr*a;
        curr += z[i];
        if(y[i] <=0) continue;
        int times = y[i]/a;
        if(y[i]%a) times++;
        ans += times;
        int till = lower_bound(all(x), x[i]+2*d) - x.begin();
        if(till == n) till--;
        if(x[till] > x[i]+2*d) till--;
        if(till != i)
            curr+=times;
        z[till] -= times;
    }
    cout << ans << "\n";
        
    return 0;
}



Measured memory_bytes: 8064