akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;
vector<vector<pair<int,int>>> g(100005);
vector<int> x(100005),y(100005),z(100005);
vector<pair<int,int>> v(100005);
vector<bool> b(100005);

void dfs(int ver){
    b[ver] = true;
    for(auto x: g[ver]){
        if(b[x.first] == false){
            dfs(x.first);
        }
    }
}

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

    rep(i,n){
        v[i].first = 0;
        v[i].second = i;
    }

    rep(i,m){ 
        cin >> x[i] >> y[i] >> z[i];
        g[x[i]-1].push_back(mp(y[i]-1,z[i]));
        g[y[i]-1].push_back(mp(x[i]-1,z[i]));
    }
    rep(i,n){
        for(auto x: g[i]) v[i].first = g[i].size();
    }
    sort(v.begin(), v.end());
    
    rep(i,n) b[i] = false;
    //rep(i,n) cout << v[i].first << endl;
    int ans = 0;
    for(int i=0; i<n;i++){
        if(b[i] == false){
            ans++;
            dfs(i);
        }
    }
    
    /*
    for(int i=n-1; i>=0;i--){
        int ver = v[i].second;
        if(b[ver] == false){
            ans++;
            b[ver] = true;
            for(auto x: g[ver]){
                b[x.first] = true;
            }
        }
    }
    */
    cout << ans << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

/* プロトタイプ宣言 */
Node treeFind(Node u, int k);
void insert(int k);
void inorder(Node u);
void preorder(Node u);

#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void preorder(Node u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

void inorder(Node u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}

Node treeFind(Node u, int k) {
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

int main() {
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeFind(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 20472
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

int main() {
	int n = input();
	char s[100];
	scanf("%s", s);
	if(n < 3200)
		puts("red");
	else
		puts(s);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    string s;
    cin >> s;
    ll ans = 100;
    int len = s.size();
    for (int i = 0; i < len; i++) {
        char ch = s[i];
        int max = 0;
        int num = 0;
        for (int j = 0; j < len; j++) {
            if (s[j] != ch) {
                num++;
            } else {
                if (max < num) {
                    max = num;
                }
                num = 0;
            }
        }
        if (max < num) {
            max = num;
        }
        if (max < ans) {
            ans = max;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.array;

void main(){
	string[] input = readln.split;
	int N = input[0].to!int;
	int M = input[1].to!int;

	if(N == 1){
		write(readln.split[0]);
	}
	else{
		int[] A = new int[M];
		int K;
		int ij;
		for(int i = 0;i < N;i++){
			input = readln.split;
			K = input[0].to!int;
			for(int j = 0;j < K;j++){
				ij = input[j+1].to!int;
				A[ij - 1]++;
			}
		}
		int cnt;
		for(int i = 0;i < M;i++){
			if(A[i] == N) cnt++;
		}
		write(cnt);
	}
}

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

int main()
{
	long long n,h,w;
	cin>>n>>h>>w;
	long long x,y,cnt=0;
	for(int i=0;i<n;i++){
		cin>>x>>y;
		if(x>=h&&y>=w)cnt++;
	}
	cout<<cnt;
	return 0;
}


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

using namespace std;

#define Nil -1

struct Node {
  int parent;
  int left;
  int right;
  int sibling;
  int height;
  int depth;
};

int findRoot(Node nodes[]) {
  int i = 0;
  while (nodes[i].parent != Nil) {
    i = nodes[i].parent;
  }
  return i;
}

void setDepth(Node nodes[], int id, int depth) {
  nodes[id].depth = depth;
  if (nodes[id].left != Nil) setDepth(nodes, nodes[id].left, depth + 1);
  if (nodes[id].right != Nil) setDepth(nodes, nodes[id].right, depth + 1);
}

int setHeight(Node nodes[], int id) {
  int left = nodes[id].left;
  int right = nodes[id].right;
  int hl = -1, hr = -1;
  if (left != Nil) hl = setHeight(nodes, left);
  if (right != Nil) hr = setHeight(nodes, right);

  return nodes[id].height = max(hl, hr) + 1;
}

int main() {
  int N;
  cin >> N;
  Node nodes[N];
  for (int i = 0; i < N; i++) {
    nodes[i].parent = Nil;
    nodes[i].sibling = Nil;
    // nodes[i].height = 0;
    // nodes[i].depth = 0;
  }
  for (int i = 0; i < N; i++) {
    int id, left, right;
    cin >> id >> left >> right;
    nodes[id].left = left;
    nodes[id].right = right;
    if (left != Nil) {
      nodes[left].parent = id;
      nodes[left].sibling = right;
    }
    if (right != Nil) {
      nodes[right].parent = id;
      nodes[right].sibling = left;
    }
  }

  int root = findRoot(nodes);
  setDepth(nodes, root, 0);
  setHeight(nodes, root);

  for (int i = 0; i < N; i++) {
    cout << "node " << i << ": parent = " << nodes[i].parent << ", sibling = " << nodes[i].sibling << ", degree = ";
    if (nodes[i].left == Nil && nodes[i].right == Nil) {
      cout << 0;
    } else if (nodes[i].left == Nil || nodes[i].right == Nil) {
      cout << 1;
    } else {
      cout << 2;
    }
    cout << ", depth = " << nodes[i].depth << ", height = " << nodes[i].height << ", ";
    if (i == root) {
      cout << "root";
    } else if (nodes[i].left == Nil && nodes[i].right == Nil) {
      cout << "leaf";
    } else {
      cout << "internal node";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int main()
{
    int a,b;
    cin >> a >> b;
    cout << max({a + b, a * b, a - b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	char a,b,d;
	int k[3] = {1};
	int kari;
	int i,j;

	while (cin >> a >> d >> b) {
		if (a == 'A') {
			i = 0;
		} else if (a == 'B') {
			i = 1;
		} else if (a == 'C'){
			i = 2;
		} else {
			break;
		}

		if (d != ',') {
			break;
		}

		if (b == 'A') {
			j = 0;
		} else if (b == 'B') {
			j = 1;
		} else if (b == 'C'){
			j = 2;
		} else {
			break;
		}

		kari = k[i];
		k[i] = k[j];
		k[j] = kari;

	}

	if (k[0] == 1) {
		cout << 'A' << endl;
	} else if (k[1] == 1) {
		cout << 'B' << endl;
	} else {
		cout << 'C' << endl;
	}

	return 0;
}

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

int main() {
  int type;
  int moto;
  int cnt =0;
  
  cin >> type >> moto;
  vector<int> vec(type);
  
  for(int i = 0; i < type; i++){
    cin >> vec.at(i);
    moto -= vec.at(i); // 各1回分消費
  }
  
  // 1番消費が少ないので残りを消費
  sort(vec.begin(), vec.end());
  cnt = type + (moto / vec.at(0));
  
  cout << cnt;
}


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

#define inf 0x3f3f3f3f
#define INF 1000111000111000111LL
#define mod 1000000007
#define pi acos(-1.0)
#define eps 1e-8
#define endl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define all(cc) (cc).begin(),(cc).end()
using lli = long long int ;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vb = vector<bool> ;
using vvi = vector<vector<int>> ;
using vlli = vector<long long int> ;
using vpii = vector<pair<int, int>> ;

lli n, m, u, d, v, w, s, t, x, D, ans ;
vector<tuple<lli, lli, lli>> edges ;
vlli dpS, dpT, distS, distT ;
vector<pair<lli, lli>> temp ;
vector<vector<pair<lli, lli>>> adj ;
priority_queue<pair<lli, lli>, vector<pair<lli, lli>>, greater<pair<lli, lli>>> pq ;

void init()
  {
    adj.resize(n+1) ;
    dpS.assign(n+1, 0) ; dpT.assign(n+1, 0) ;
    distS.assign(n+1, INF) ; distT.assign(n+1, INF) ;
  }

void dijsktra(int start, vlli &dist, vlli &dp)
  {
    dist[start]=0 ;
    dp[start]=1 ;
    pq.push(mp(0LL, start)) ;
    while(!pq.empty())
      {
        tie(d, u)=pq.top() ; pq.pop() ;
        if(d>dist[u]) continue ;
        for(auto v:adj[u])
          if(dist[u]+v.se<dist[v.fi])
            {
              dist[v.fi]=dist[u]+v.se ;
              pq.push(mp(dist[v.fi], v.fi)) ;
              dp[v.fi]=dp[u] ;
            }
          else if(dist[u]+v.se==dist[v.fi]) dp[v.fi]=(dp[v.fi]+dp[u])%mod ;
      }
  }

void calc()
  {
    D=distS[t] ;
    assert(distS[t]==distT[s]) ;
    ans=(dpS[t]*dpS[t])%mod ;
    for(int i=1 ; i<=n ; i++)
      if(distS[i]==D/2 && distT[i]==D/2)
        {
          x=(dpS[i]*dpT[i])%mod ;
          ans=(ans-(x*x)%mod+mod)%mod ;
        }
    for(auto i:edges)
      {
        tie(u, v, w)=i ;
        if(distS[u]<D/2 && distT[v]<D/2 && distS[u]+distT[v]+w==D)
          {
            x=(dpS[u]*dpT[v])%mod ;
            ans=(ans-(x*x)%mod+mod)%mod ;
          }
        if(distS[v]<D/2 && distT[u]<D/2 && distS[v]+distT[u]+w==D)
          {
            x=(dpS[v]*dpT[u])%mod ;
            ans=(ans-(x*x)%mod+mod)%mod ;
          }
      }
  }

int main()
  {
    ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
    cin>> n >> m >> s >> t ;
    init() ;
    for(int i=1 ; i<=m ; i++)
      {
        cin>> u >> v >> w ;
        adj[u].pb(mp(v, w)) ;
        adj[v].pb(mp(u, w)) ;
        edges.pb(mt(u, v, w)) ;
      }
    dijsktra(s, distS, dpS) ;
    dijsktra(t, distT, dpT) ;
    calc() ;
    cout<< ans ;
  }


Measured memory_bytes: 24228
n = gets.to_i
a = Array.new(n) {
    gets.to_i
}

max = a.reduce([-1, -1]) {|acc, item|
    if item > acc[0] then
        [item, acc[0]]
    elsif item > acc[1] then
        [acc[0], item]
    else
        acc
    end
}

for i in 0...n do
    if max[0] != a[i] then
        puts max[0]
    else
        puts max[1]
    end
end


Measured memory_bytes: 4988
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void)
{
  int i,Dice[6],len,tmp;
  char ord[100];
  for(i=0;i<6;i++)
  {
    scanf("%d",&Dice[i]);
  }
    scanf("%s",ord);
    len=strlen(ord);
    for(i=0;i<len;i++)
    {
      tmp=Dice[0];
      switch(ord[i])
      {
        case 'N':
          Dice[0]=Dice[1];
          Dice[1]=Dice[5];
          Dice[5]=Dice[4];
          Dice[4]=tmp;
          break;
        case 'E':
          Dice[0]=Dice[3];
          Dice[3]=Dice[5];
          Dice[5]=Dice[2];
          Dice[2]=tmp;
          break;
        case 'S':
          Dice[0]=Dice[4];
          Dice[4]=Dice[5];
          Dice[5]=Dice[1];
          Dice[1]=tmp;
          break;
        case 'W':
          Dice[0]=Dice[2];
          Dice[2]=Dice[5];
          Dice[5]=Dice[3];
          Dice[3]=tmp;
          break;
      }
    }
  printf("%d\n",Dice[0]);
  return 0;
}



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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> t(N);
  for (int i=0;i<N;i++){
    cin >> t[i];
  }
  int ans=T;
  for (int i=0;i<N-1;i++){
    ans+=min(T,t[i+1]-t[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#解説ツイート
#A
#掛け算を普通にするだけです

#B
#いやらしい引掛けポイントがあります
#オーバーフロー対策のために途中で10^18を超えたら-1を出力する、と行きたいところですが、
#その後に0が出てきたら終わりです。
#対処法としてはソートしてから順番に掛けて、途中で10^18を超えたら-1を出力するという方針で行けばOKです。
#ソートすることによって、(A_1*...*A_k)≦(A_1*...A_{k+1})が成り立つようになります。

#C
#いやらしい問題その2です。
#浮動小数点数をそのまま扱うと誤差が出てくるのでペナルティが生えます
#よってBをinputする際に、"."でsplitすることによって整数として扱うことができます。
#その後は整数として計算すればOKです。そのために1.1を1.10というような表記をすることになっています。

#D
#まずは素因数分解します。
#素数pについてe=ord_p(N)に対して、
#e≧k*(k+1)/2となる最大のkを求めてpごとの総和を取ればOKです。

#E
#中央値の最小値と中央値の最大値を求めればOK
#それぞれの場合はX_i=A_iとすれば中央値最小になるしX_i=B_iとすれば中央値は最大となります。
#Nが偶数なら中央値は1/2刻み,Nが奇数なら中央値は1となるため、Nが偶数ならば全体を2倍して考えます。
#その後での最小値と最大値の間にある整数の数を出力すればOKです。X_iを適切に1ずらせば
#中央値の値の取らせ方はある程度の融通がききます。

#F
#dpです。python勢の人はpypyを使うことをおすすめします。以下のコードをpythonで提出したらTLEしました。
#dp[i][j]={1,...,i}の部分集合Uについて、Σ[x∈U]A_x=jとなるようなU全体の集合をP(j)としたときの
#Σ[U∈P(j)]2^(N-len(U)
#が答えとなり、結局dp[N][S]を出力すればよいです。jについてはSより大きいところは見る必要がないので
#計算量はO(NS)となります。

N,S=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
dp=[[0 for j in range(S+1)]for i in range(N+1)]
pow2N=pow(2,N,mod)
dp[0][0]=pow2N
inv2=pow(2,mod-2,mod)
for i in range(N):
    for j in range(S+1):
        if dp[i][j]!=0:
            dp[i+1][j]+=dp[i][j]
            dp[i+1][j]%=mod
            if j+A[i]<=S:
                dp[i+1][j+A[i]]+=(inv2*dp[i][j])%mod
                dp[i+1][j+A[i]]%=mod
print(dp[N][S])


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

using namespace std;

int N;
vector<int> p;
bool vis[55556];

    void  sieve(){

            for(int i = 2; i*i < 55559; i++){
                    if(!vis[i]){
                        vis[i] = true;
                        if(i%5==1) p.push_back(i);

                        for(int j = i*i; j <= 55555; j+=i){
                                 vis[j] = true;
                          }
                     }
                }


            for(int i = 2; i <= 55555; i++){
                if(!vis[i] && i%5==1)
                   p.push_back(i);
               }
          
          
          }

int main(){

   cin >> N;

   sieve();

   for(int i = 0; i < N; i++){
         cout << p[i] << " ";
     }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
int a,b,i,j,k;
char str[101][101],change[101],kekka[350]={"\0"};
scanf("%d %d",&a,&b);
for(i=0;i<a;i++){
scanf("%s",&str[i]);
}
for(i=0;i<=a;i++){
j = 0;
for(k=i+1;k<a;k++){
while(str[i][j]==str[k][j])j++;
if((int)str[i][j]>(int)str[k][j]){
strcpy(change,str[i]);
strcpy(str[i],str[k]);
strcpy(str[k],change);
}
j = 0;
}
}
for(i=0;i<a;i++){
printf("%s",str[i]);
}
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define M 998244353
#define MOD 1000000007
signed main()
{
    SPEED;
    int n,m;
    cin>>n>>m;
    int a,sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a;
        sum+=a;
    }
    if(sum<=n)
    {
        cout<<n-sum;
    }
    else
    {
        cout<<-1;
    }
}

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

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

    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if (A + B >= 2 * C) {
        ans += min(X, Y) * 2 * C;
        ans += A >= 2 * C ? (X - min(X, Y)) * 2 * C : (X - min(X, Y)) * A;
        ans += B >= 2 * C ? (Y - min(X, Y)) * 2 * C : (Y - min(X, Y)) * B;
    } else
        ans += X * A + Y * B;
    cout << ans << endl;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
a=0
s=0
if y/x>=2:
    for i in range(x+1):
        for k in range(x-i+1):
            a=4*i+2*k

            if a==y:
                s+=1
else:pass

if s>=1:
    print("Yes")

else:
    print("No")


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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

int N;
vector<vector<double>> dp(3010, vector<double>(3010, 0));
vector<double> p;

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

    cin >> N;
    p.resize(N, 0);

    REP(i, N) cin >> p.at(i);

    dp.at(0).at(0) = 1;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            dp.at(i + 1).at(j + 1) += dp.at(i).at(j) * p.at(i);
            dp.at(i + 1).at(j) += dp.at(i).at(j) * (1 - p.at(i)); 
        }
    }

    double ans = 0;

    for (int i = 0; i < (N + 1)/2; i++) {
        ans += dp.at(N).at(i);
    }

    cout << setprecision(10) << (double)1 - ans << endl;
    
    return 0;
}

Measured memory_bytes: 71168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int );
int pop (void);
int top,a[100];
int main()
{
  int a,b;
  char c[100];
  top=0;

  while(scanf("%s",c)!=EOF)
    {
      if(c[0]=='-')
	{
	  b=pop();
	  a=pop();
	  push(a-b);
	}
      else if(c[0]=='+')
	{
	  a=pop();
	  b=pop();
	  push(a+b);
	}
      else if(c[0]=='*')
	{
	  a=pop();
	  b=pop();
	  push(a*b);
	}
      else push(atoi(c));
      
    }
 
  
  printf("%d\n",pop());


  return 0;

  
}
void push(int x )
{
  a[++top]=x;
  
}
int pop (void)
{
  top--;

  return a[top+1];
}
  







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

int main() {
  string s;
  cin >> s;
  bool result = false;
  
  for (int i = 0; i < s.length(); i++){
    if (s.at(i) == '7'){
      result = true;
      break;
    }
  }
  
  if (result){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
	string s1,s2;
	cin >> s1;cin >> s2;
	string out =  "NO";
	if(s1.substr(0,1) == s2.substr(2,1) 
	&& s1.substr(1,1) == s2.substr(1,1) 
	&& s1.substr(2,1) == s2.substr(0,1)) out = "YES";
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	int n;
	cin >> n;
	int sum = 0;
	int m = 0;
	REP(i, n) {
		int x;
		cin >> x;
		m = max(m, x);
		sum += x;
	}
	cout << sum - m / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(s[k-1])

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  long int h,w;
  scanf("%ld%ld",&h,&w);
  long long t= ((h+1)/2)*((w+1)/2)+(h/2)*(w/2);

  if(h==1 || w==1){
    t=1;}
  printf("%lld\n",t);

  return 0;
}


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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

int main()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.rbegin(),a.rend());
	ll sum =0 ;
	rep(i,n){
		sum += a[i];
	}
	rep(i,m) {
		if(4*m*a[i] >= sum) {
			// ok
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_055_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 i      PIC 9(6).
    01 INF    PIC 9(10) VALUE 1000000007.
    01 N      PIC 9(6).
    01 tmp    PIC 9(16).
    01 ans    PIC X(10).

    01 ZS     PIC Z(17).
    01 DUMMY  PIC X(1).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    MOVE 1 TO tmp.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N < i
        MULTIPLY i BY tmp
        COMPUTE tmp = FUNCTION MOD(tmp, INF)
    END-PERFORM.

    MOVE tmp TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] l = new int[n];
        Arrays.setAll(l, i -> scanner.nextInt());
        Arrays.sort(l);

        long ans = 0;

        for (int i = 0; i < n - 2; i++) {
            for (int j = i + 1; j < n - 1; j++) {
                if (l[i] == l[j]) {
                    continue;
                }
                int standard = l[i] + l[j];
                for (int k = j + 1; k < n; k++) {
                    if (l[j] == l[k]) {
                        continue;
                    }
                    if (standard <= l[k]) {
                        break;
                    }
                    ans++;
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 36636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;

int main() {
	ll n, k, a[2000], right[2000] = {}, all[2000] = {}, c = 0;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
	}
	for(int i = 0; i < n - 1; i++) {
		for (int j = i; j < n; j++) {
			if (a[i] > a[j]) right[i]++;
		}
	}
	rep(i, n) {
		rep(j, n) {
			if (a[i] > a[j]) all[i]++;
		}
	}
	ll ans = 0;
	rep(i, n) {
		ll z = (k * (k - 1) / 2) % MOD;
		ans += k * right[i] + all[i] * z;
		ans %= MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};

/* ここからコード開始 */

int main(){
  kyopro;
  string S;
  cin >> S;
  ll s0{}, s1{};
  for(auto&& i : S){
    if(i == '0') s0++;
    if(i == '1') s1++;
  }
  cout << min(s0, s1) * 2 << rt;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxN = 100200;
int mem[maxN];
vector<int> nums(maxN);
int solve(int i,int n,int k){
	if(i == n - 1){
		return 0;
	}
	if(mem[i] != -1){
		return mem[i];
	}
	int res = INT_MAX;
	for(int j = i + 1; j <= i + k; j++){
		if(j < n){
			res = min(res,abs(nums[i] - nums[j]) + solve(j,n,k));
		}
	}
	return mem[i] = res;
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n ;i++){
		cin >> nums[i];
	}
	memset(mem,-1,sizeof(mem));
    cout << solve(0,n,k) << "\n";
}


Measured memory_bytes: 11860
#include<stdio.h>
int main(){
    int i;
    int k=0;
    int x[2000];
    int sum[1000]={0}; 
    do{
        int l=0;
        for( ; ; ){
            if((x[l++]=getchar())=='\n')break;
            x[l-1]=x[l-1]-'0';
            sum[k]+=x[l-1];
        }
        k++;
        //for(i=0; i<l; i++)printf("xxx%d", x[i]);
        //printf("\n");
    }while(x[0]!=0);
    for(i=0; i<k-1; i++)printf("%d\n",sum[i]);
    return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,a;
  int f = 0;
  int b = 0 ,c = 0;
  cin >> n;
  for(int j = 0;j < n;j++){
    f = 0;
    b = 0;
    c = 0;
    for(int i = 0;i < 10;i++){
      cin >> a;
      if(b < a)b = a;
      else if(c < a)c = a;
      else {
	f = 1;	
      }  
    }
    if(f == 1)cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}

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

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

  vector<int> A(N);
  for(auto& a: A){
    cin >> a;
  }
  vector<int> B(N);
  for(auto& b: B){
    cin >> b;
  }

  priority_queue<pair<int, int>> que;
  for(int i = 0; i < N; i++){
    que.push(make_pair(B[i], i));
  }

  long long ans = 0;
  while(!que.empty()){
    int top_idx = que.top().second;
    que.pop();

    int reducer = B[(top_idx + N - 1) % N] + B[(top_idx + 1) % N];
    if(reducer <= 0){
      continue;
    }

    int reduce_expected = B[top_idx] - A[top_idx];
    if(reduce_expected <= 0){
      continue;
    }

    int reduce_cnt = reduce_expected / reducer;
    if(reduce_cnt <= 0){
      continue;
    }
    B[top_idx] -= reduce_cnt * reducer;
    ans += reduce_cnt;
    que.push(make_pair(B[top_idx], top_idx));

    /*
    for(int i = 0; i < N; i++){
      cout << A[i] << ' ';
    }cout << endl;
    for(int i = 0; i < N; i++){
      cout << B[i] << ' ';
    }cout << endl;
    */
  }

  for(int i = 0; i < N; i++){
    if(A[i] != B[i]){
      ans = -1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<=(b); i++)

int main(){
    int A,B,n=0;
    cin >> A >> B;
    rep(i,0,(int)B/A+20){
        if(A*(i)-i+1 >= B){
            //cout << A * i - i +1 << endl;
            n = i;
            break;
        }
    }


    cout << n << endl;
}

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


int main(){
  int n;cin >>n;
  vector< vector<int> > dp(n,vector<int>(n,0));
  for(int i=0;i<n;i++){
    int k;cin >> k >> k;
    for(int j=0;j<k;j++){
      int l;cin >> l;
      dp[i][l-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=0)cout << " " << dp[i][j];
      else cout << dp[i][j];
    }
    cout << endl;
  }

}



Measured memory_bytes: 3136
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define fir first
#define sec second
#define mset(s,t) memset(s,t,sizeof(s))
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
const int N=3000005;
int a[N],n,k;
ll maxx[N],dp[N];
#define ls (u<<1)
#define rs (u<<1|1)
void update(int u,int l,int r,int pos,ll x){
  if(l==r){
    maxx[u]=max(maxx[u],x);
    return;
  }
  int mid=l+r>>1;
  if(pos<=mid)update(ls,l,mid,pos,x);
  else update(rs,mid+1,r,pos,x);
  maxx[u]=max(maxx[ls],maxx[rs]);
}
ll query(int u,int l,int r,int ql,int qr){
  if(ql<=l&&r<=qr)return maxx[u];
  int mid=l+r>>1;ll ret=0;
  if(ql<=mid)ret=max(ret,query(ls,l,mid,ql,qr));
  if(qr>mid)ret=max(ret,query(rs,mid+1,r,ql,qr));
  return ret;
}
int main(){
  n=read(),k=read();
  if(k<0)k=-k;
  for(int i=1;i<=n;i++){
    a[i]=read();
  }
  for(int i=1;i<=n;i++){
    dp[i]=1+query(1,-300000,300000,max(-300000,a[i]-k),min(300000,a[i]+k));
    update(1,-300000,300000,a[i],dp[i]);
  }
  printf("%d\n",maxx[1]);
  return 0;
}

Measured memory_bytes: 15528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,ok;
vector<int>edge[100005];
int d[100005],num;
void dfs(int v,int u,int dd){
	rep(i,edge[v].size()){
		if(edge[v][i]==u)continue;
		dfs(edge[v][i],v,1-dd);d[v]+=d[edge[v][i]];
	}
	d[v]+=dd?1:-1; if(abs(d[v])>=2) ok = 1;
}
int main(){
	cin>>n; if(n%2==1){puts("First"); return 0;}
	rep(i,n-1){
		int a,b;cin>>a>>b;edge[a].pb(b);edge[b].pb(a);
	}
	dfs(1,-1,0);
	puts(ok?"First":"Second");
}

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

int main(){
	string s;
	cin >> s;
	int sum = 700;
	if(s.at(0) == 'o') sum += 100;
	if(s.at(1) == 'o') sum += 100;
	if(s.at(2) == 'o') sum += 100;
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;

    int d[n][2];
    for(int i=0; i<n; i++){
        for(int j=0; j<2; j++){
            cin >> d[i][j];
        }
    }
 
    int cnt = 0;
    for(int i=0; i<n; i++){
        if(d[i][0] == d[i][1]) cnt++;
        else cnt = 0;
        if(cnt >= 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t p;cin>>p;
  vector<int64_t>a(p);
  for(int i=0;i<p;i++)
    cin>>a.at(i);
  vector<int64_t>b(p);
  vector<int64_t>c(p,1);
  for(int i=p-1;0<=i;i--){
  int B=0;
    for(int j=0;j<p;j++)
      B=(B+c[j]*a[j])%p;
    B=(p*p-B)%p;b[i]=B;
    for(int j=0;j<p;j++)
      c[j]=(c[j]*j)%p;
  }b[0]=(b[0]-b[p-1]+p)%p;
  for(int i=0;i<p-1;i++)
    cout<<b[i]<<" ";
  cout<<b[p-1]<<endl;
  return 0;
}


Measured memory_bytes: 3672
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1e17;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans=MOD,tmp=v[0],sum=Svec(v)-v[0];
  rep(i,n-2){
    chmin(ans,abs(tmp-sum));
    tmp+=v[i+1];
    sum-=v[i+1];
  }
  chmin(ans,abs(tmp-sum));
  cout<<ans<<endl;
  
  
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
   int n, sub, t1, t3, ans1=0, ans2=0, i, j, k;
   char t2[2];
   cin>>n>>sub;
   int ti[100005]={0}, penis[100005]={0};
   for(i=1;i<=sub;i++){
   	    cin>>t1>>t2;
   	    if(t2[0]=='A'){
   	    	if(ti[t1]==0) ti[t1]=1;
		   }
		else{
			if(ti[t1]==0) penis[t1]++;
		}
   }
   for(i=1;i<=n;i++){
   	ans1+=ti[i];
   	if(ti[i]) ans2+=penis[i];
   }
   cout<<ans1<<" "<<ans2<<endl;
   return 0;
}

Measured memory_bytes: 1024
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <string>

using namespace std;

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

const int MAX = INT_MAX;

int main()
{	
	string s;
	cin >> s;
	if (s[0] != '7' && s[1] != '7' && s[2] != '7')  cout << "No" << endl;
	else  cout << "Yes" << endl;
}


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

using namespace std;

pair<int, int> x[222222];
int a[222222];
int main() {
	a[0] = 1;
	int h, w, n;
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++)
		scanf("%d%d", &x[i].first, &x[i].second);
	sort(x, x + n);
	for (int i = 1; i <= w; i++) {
		for (a[i] = a[i - 1] + 1; a[i] <= h && !binary_search(x, x + n, make_pair(a[i], i)); a[i]++)
			if (!binary_search(x, x + n, make_pair(a[i], i + 1)))
				goto p;
		while (i < w) a[++i] = h + 1;
		break;
	p:;
	}
	int m = h + 1;
	for (int i = 0; i < n; i++)
		if (x[i].first >= a[x[i].second])
			m = min(m, x[i].first);
	cout << m - 1 << endl;
	return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

template <i64 p>
class fp {
    public:
    i64 x;
    fp() : x(0) {}
    fp(i64 x_) : x((x_ % p + p) % p) {}
    fp operator+() const { return fp(x); }
    fp operator-() const { return fp(-x); }
    fp& operator+=(const fp& y) {
        x += y.x;
        if (x >= p) x -= p;
        return *this;
    }
    fp& operator-=(const fp& y) { return *this += -y; }
    fp& operator*=(const fp& y) {
        x = x * y.x % p;
        return *this;
    }
    fp& operator/=(const fp& y) { return *this *= fp(inverse(y.x)); }
    fp operator+(const fp& y) const { return fp(x) += y; }
    fp operator-(const fp& y) const { return fp(x) -= y; }
    fp operator*(const fp& y) const { return fp(x) *= y; }
    fp operator/(const fp& y) const { return fp(x) /= y; }
    bool operator==(const fp& y) const { return x == y.x; }
    bool operator!=(const fp& y) const { return !(*this == y); }
    i64 extgcd(i64 a, i64 b, i64& x, i64& y) {
        i64 d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    i64 inverse(i64 a) {
        i64 x, y;
        extgcd(a, p, x, y);
        return (x % p + p) % p;
    }
};

template <i64 p>
i64 abs(const fp<p>& x) { return x.x; }

template <i64 p>
istream& operator>>(istream& is, fp<p>& x) {
    is >> x.x;
    return is;
}

template <i64 p>
ostream& operator<<(ostream& os, const fp<p>& x) {
    os << x.x;
    return os;
}

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "[";
    for (const auto& v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T& val) {
    fill((T*)ary, (T*)(ary + size), val);
}

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr long double eps = 1e-9;

// double(64bit浮動小数)のn分探索のループ回数の上限(2分探索なら50でも十分かもしれない). long double(80ビットの x87 浮動小数点型?)だと, 2分探索であってもこれだと足りないケースがある気がするので, もうちょっと余裕を持たせた方が良さそう.
constexpr i64 max_loop = 100;

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    long double R;
    cin >> R;

    cout << 2*acos(-1)*R << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3808
//Solution for aoj:0212 Highway Express Bus
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
typedef pair<int, int>P;
typedef pair < P, int > PP;
#define f first
#define s second

//struct S {
//	int cost, to, num;
//	S(int c, int t, int n) : cost(c), to(t), num(n){}
//	bool operator>(const S &s) const {
//		return cost > s.cost;
//	}
//};

const int INF = 1 << 29;
int c, n, m, s, d, ans;
int tocost[1000][100];
vector<P> town[1000];
priority_queue<PP, vector<PP>, greater<PP> > pq;


void dijkstra(){
	while (!pq.empty()){
		PP a = pq.top();
		pq.pop();
		for (int i = 0; i < town[a.f.s].size(); i++){
			int tt = town[a.f.s][i].f, cc = town[a.f.s][i].s;
			if (tocost[tt][a.s] > cc + a.f.f){
				tocost[tt][a.s] = cc + a.f.f;
				pq.push({ { cc + a.f.f, tt }, a.s });
			}
			if (a.s&&tocost[tt][a.s-1] > cc/2 + a.f.f){
				tocost[tt][a.s-1] = cc/2 + a.f.f;
				pq.push({ { cc / 2 + a.f.f, tt }, a.s - 1 });
			}
		}
	}
}
	int main(){
		while (cin >> c >> n >> m >> s >> d&&c&&n&&m&&s){
			for (int i = 0; i < 1000; i++)
				fill(tocost[i], tocost[i] + 100, INF);
			tocost[s][c] = 0;
			ans = INF;
			while (pq.size())
				pq.pop();
			for (int i = 0; i < 1000; i++)
				town[i].clear();
			for (int i = 0; i < m; i++){
				int a, b, c;
				cin >> a >> b >> c;
				town[a].push_back({ b, c });
				town[b].push_back({ a, c });
			}
			pq.push({ { 0, s }, c });
			dijkstra();
			for (int i = 0; i <= c; i++)
				ans = min(ans, tocost[d][i]);
			cout << ans << endl;
		}
		return 0;
	}

Measured memory_bytes: 1644
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

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


    if(s=="ABC")cout << "ARC" << endl;
    if(s=="ARC")cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m;

int main(){
  string a[60], b[60];
  cin >> n >> m;
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];

  rep(i, n-m+2) {
    rep(j, n-m+2) {
      bool flg = true;
      rep(x, m) {
        rep(y, m) {
          if(a[i+x][j+y] != b[x][y]) {
            flg = false;
            break;
          }
        }
      }
      if(flg) {
          cout << "Yes" << endl;
          return 0;
       }
    }
  }

  cout << "No" << endl;
  return 0;
}


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



int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<bool> fafa(N);
  vector<ll> H(N);
  rep(i, N){
    cin >> H[i];
    fafa[i] = true;
  }

  int a, b;

  rep(i, M){
    cin >> a >> b;
    a--;
    b--;
    if (H[a] <= H[b])
    {
      fafa[a] = false;
    }
    if (H[a] >= H[b])
    {
      fafa[b] = false;
    }
  }

  int count = 0;

  rep(i, N){
    if (fafa[i])
    {
      count++;
    }
    
  }
  
  cout << count << "\n";




  }




Measured memory_bytes: 3988
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_7_D: Reconstruction of a Tree

#include <cstdio>

using uint = unsigned int;
using uintp = uint*;

static void solve(const uintp i_begin, const uintp i_end,
                  const uintp p_begin, const uintp indices[],
                  const char* sep = "\n")
{
  if (i_begin >= i_end) {
    return;
  }
  const auto i_index = indices[*p_begin];
  const auto len = i_index-i_begin;
  auto i_begin1 = i_begin,   i_end1 = i_index, p_begin1 = p_begin+1;
  auto i_begin2 = i_index+1, i_end2 = i_end,   p_begin2 = p_begin+1+len;
  solve(i_begin1, i_end1, p_begin1, indices, " ");
  solve(i_begin2, i_end2, p_begin2, indices, " ");
  std::printf("%u%s", *i_index, sep);
}

int main()
{
  uint n;
  std::scanf("%u", &n);
  uint preorders[n];
  uint inorders[n];
  uintp indices[n+1]; // 0 not used.
  uint k;
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    preorders[i] = k;
  }
  for (auto i = 0u; i < n; ++i) {
    std::scanf("%u", &k);
    inorders[i] = k;
    indices[k] = &(inorders[i]);
  }

  solve(inorders, inorders+n, preorders, indices);
}

// eof

Measured memory_bytes: 2744
h,w,d = gets.split.map(&:to_i)
g = Array.new(h,"")
a = "RYGB"
h.times do |i|
    w.times do |j|
        s = 0
        s += 1 if (i+j)/d%2 > 0
        s += 2 if (i+j)/d%4 > 1
        s += 2 if (i-j)/d%2 > 0
        g[i] += a[s&3]
    end
    puts g[i]
end

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  int c = 0;
  bool ok = false;
  rep(i,n) {
    int x, y;
    cin >> x >> y;
    if (x == y) ++c;
    else c = 0;
    if (c == 3) ok = true;
  }
  cout << (ok?"Yes\n":"No\n");
}

Measured memory_bytes: 3656