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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<P>p(n);
  rep(i,0,n){
    cin>>p[i].fi;
    p[i].se=i;
  }
  sort(ALLR(p));
  multiset<ll>s;
  s.insert(p[0].se);
  s.insert(-1);
  s.insert(-2);
  s.insert(n);
  s.insert(n+1);
  rep(i,1,n){
    ll idx=p[i].se;
    auto itr=s.lower_bound(idx);
    ll r=*itr;
    ll r2=*(++itr);
    itr--;itr--;
    ll l=*itr;
    ll l2=*(--itr);
    ll x=0;
    if(r!=n)x+=(idx-l)*(r2-r);
    if(l!=-1)x+=(r-idx)*(l-l2);
    res+=p[i].fi*x;
    //cout<<l spa r spa x spa p[i].fi spa p[i].se<<endl;
    s.insert(idx);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s;
    cin >> s;
    for (auto &&i: irange(0U, (uint)s.size())){
        if (i%2==0)cout<<s.at(i);
    }
    return 0;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#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 <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

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

//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 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())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

char toch(int x){
  if(x < 0) return '?';
  if(x < 10) return x + '0';
  return (x-10) + 'A';
}

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

  int N, M, Q;
  while(cin>>N>>M>>Q,N){
	bool tab[36][1000];
	fill((bool*)tab, (bool*)tab+36*1000, true);
	string prv(M, '0');
	REP(q,Q){
	  string sw, bulb;
	  cin >> sw >> bulb;
	  VI same, diff;
	  REP(j,M)
		if(prv[j] == bulb[j]) same.PB(j);
		else diff.PB(j);
	  REP(i,N){
		if(sw[i] == '1'){
		  for(int idx:same)
			tab[i][idx] = false;
		}
		else{
		  for(int idx:diff)
			tab[i][idx] = false;
		}
	  }
	  prv = bulb;
	}
	REP(i,M){
	  int fl = -1;
	  REP(j,N){
		if(tab[j][i]){
		  if(fl != -1){
			fl = -1;
			break;
		  }
		  fl = j;
		}
	  }
	  cout << toch(fl);
	}
	cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1280
N = int(input())
nums=[int(input()) for _ in range(N)]
sum_num = sum(nums)
dp = [0] * (sum_num+1)
dp[0] = 1
for num in nums:
  for i in range(sum_num+1)[::-1]:
    if dp[i] == 1:
      dp[i+num] = 1
ans = 0
for i in range(sum_num+1):
  if dp[i] == 1 and i%10 != 0:
    ans = i
print(ans)


Measured memory_bytes: 3060
def insertion_sort(A, N):
    for i in range(1, N):
        v = A[i]
        j = i - 1
        # print('[start] i:', i, 'j:', j, 'v:', v)
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        # print('i:', i, 'v:', v, 'to:', j+1 ,A)
        print(*A)

N = int(input())
A = list(map(int, input().split()))
print(*A)
insertion_sort(A, N)


Measured memory_bytes: 5980
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll a[n];
	for(int i=0; i<n; i++) cin >> a[i];

	ll x[n];
	x[0]=0;
	for(int i=0; i<n; i++){
		if(i%2==0) x[0]+=a[i];
		else x[0]-=a[i];
	}
	for(int i=1; i<n; i++){
		x[i]=2*a[i-1]-x[i-1];
	}

	for(int i=0; i<n; i++){
		cout << x[i];
		if(i!=n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

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

using namespace std;

const int N = 555;

int c[N], f[N], s[N];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> c[i] >> s[i] >> f[i];
    }
    for (int i = 0; i < n; ++i) {
        int cur = 0, now = i;
        while (now < n - 1) {
            if (cur < s[now]) cur = s[now];
            while (cur % f[now] != 0) ++cur;
            cur += c[now];
            ++now;
        }
        cout << cur << '\n';
    }
}


Measured memory_bytes: 256
import sys
ls = list(str(input()))
a =ls[0]
b =ls[1]
c =ls[2]
d =ls[3]
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 1:
                s1 = "-"
            if j == 1:
                s2 = "-"
            if k == 1:
                s3 = "-"
            if i == 0:
                s1 = "+"
            if j == 0:
                s2 = "+"
            if k == 0:
                s3 = "+"
            e = eval(a+s1+b+s2+c+s3+d)
            if e == 7:
                print(a+s1+b+s2+c+s3+d + "=7")
                sys.exit()

Measured memory_bytes: 3064
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N = lread();
    alias T = Tuple!(string, long, long);
    auto sp = new T[](N);
    foreach (i; 0 .. N)
    {
        string s;
        long p;
        scan(s, p);
        sp[i] = T(s, -p, i + 1);
    }
    sp.sort();
    foreach (t; sp)
        writeln(t[2]);
}


Measured memory_bytes: 3672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int a[3];
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3);
    cout<<a[2]-a[0]<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(){
  int H, W;
  scanf("%d", &H);
  scanf("%d", &W);

  char output[101];

  for(int i=0; i<H; i++){
    scanf("%s", output);
    printf("%s\n", output);
    printf("%s\n", output);
  }

  return 0;
}


Measured memory_bytes: 1620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll n, k;
    cin >> n >> k;

    ll shou = n / k;
    ll amar = n % k; 

    ll ans = 0;
    for(int a=1; a<=n; a++){
        int a_mod_k = a % k;
        if((2 * a_mod_k) % k == 0){
            if(a_mod_k != 0 && a_mod_k <= amar){
                ans += pow(shou+1, 2);
            }
            else{
                ans += pow(shou, 2);
            }
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,len;
    int a,b;
    cin>>n;

    len = sqrt(n);
    bool ck = true;
    for(int i = 1; i<=len; i++)
    {
        if(n%i==0)
        {
            a = i;
            b = n/i;
        }
    }
    if(a>9 or b>9)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
char c[4]={'A','T','G','C'};
int main(){
  string S;
  cin >> S;
  int ans = 0;
  int N = S.length();

  for(int j=0;j<N;j++){
    int count = 0;
    for(int i=j;i<N;i++){
      if(S[i]=='A' || S[i]=='G' || S[i]=='C' || S[i]=='T'){
        count++;
        if(i==N-1) ans = max(ans, count);
      }else{
        ans = max(ans, count);  
        break;
      }
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	int n;
	cin >> n;
	vector<int>p(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
	}

	int ans = 0;

	for (int i = 0; i < n - 2; i++)
	{
		int a = 0, b = 0, c = 0;
		a = p[i];
		b = p[i + 1];
		c = p[i + 2];
		int x[3]; x[0] = a; x[1] = b; x[2] = c;
		sort(x, x+3);
		if (x[1] == b)
		{
			ans += 1;
		}
		


	}
	cout << ans << endl;
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

//DFS
vector<vector<int>> g;
vector<vector<int>> g2;
const int N = 1e5;
int used[N];
int col[N];


int uf(int pid){
  if (col[pid]==pid){
    return pid;
  }else{
    col[pid]=uf(col[pid]);
    return col[pid];
  }
}


ll n,m,k;
int main() {
  int ans=0;
  for(ll i=0;i<N;i++){
    col[i]=i;
  }

  cin >>n>>m>>k;

  g.resize(n);
  g2.resize(n);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b ;
    a--; b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);

    if ( uf(a)<uf(b) ){
      col[uf(b)]=uf(a);
    }else{
      col[uf(a)]=uf(b);
    }
  }

  


  //まとめ
  vi ninzu(n);
  for(ll i=0;i<n;i++){
    col[i]=uf(i);
    ninzu[col[i]]++;
  }


  
  //cd入力
  for(ll i=0;i<k;i++){
    int c, d;
    cin >> c >> d;
    c--; d--;
    g2[c].emplace_back(d);
    g2[d].emplace_back(c);
  }

  //出力
  int myc=0;
  for(ll i=0;i<n;i++){
    myc=col[i];
    ans=ninzu[myc]-1;
    
    ans-=g[i].size();
    for(auto t : g2[i]) {
      if (col[t]==myc)ans--;
    }
    cout<<ans<<" ";
  
  }

/*
  cout<<endl;
  cout<<endl;
  REP(i,n)
  {
    cout<<col[i]<<endl;
  }
  cout<<endl;
  REP(i,n)
  {
    cout<<ninzu[i]<<endl;
  }
  
  

*/



  




  return 0;
}

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


int main(int argc, char const *argv[])
{
	vector<int> a(3);
	rep(i, 3) cin >> a[i];
	sort(a.begin(), a.end());

	int ans = 0;
	rep(i, 2) {
		ans += a[i + 1] - a[i];
	}
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;

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

  int n;
  cin >> n;

  int temp;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> temp;
    a.at(temp-1) = i + 1;
  }

  for(int i = 0; i < n; i++){
    cout << a.at(i) << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

string S[100];
int h, w;

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

	int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
	int dy[8] = { 0,1,1,1,0,-1,-1,-1 };//反時計回り
	
	cin >> h >> w;
	char ans[100][100];

	for (int i = 0; i < h; i++)cin >> S[i];

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (S[i][j] == '#')ans[i][j] = '#';
			else {
				int cnt = 0;
				for (int x = 0; x < 8; ++x) {
					if (i + dy[x] >= h || i + dy[x] < 0 || j + dx[x] >= w || j + dx[x] < 0) continue;
					if (S[i + dy[x]][j + dx[x]] == '#')cnt++;
				}
				ans[i][j] = '0' + cnt;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int p[100005], y[100005];
int h[100005], l;
int comp_h(int a, int b)
{
	if (p[h[a]] > p[h[b]])
		return 1;
	if (p[h[a]] < p[h[b]])
		return -1;
	if (y[h[a]] > y[h[b]])
		return 1;
	else
		return -1;
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void f1(int n)
{
	h[l] = n;
	int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2()
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	for (i = 0; i < m; i++)
		scanf("%d %d", &p[i], &y[i]);
	l = 0;
	for (i = 0; i < m; i++)
		f1(i);
	int c[100005];
	for (i = 0; i < m; i++)
		c[i] = f2();
	int x[100005];
	x[c[0]] = 1;
	for (i = 1; i < m; i++)
	{
		if (p[c[i - 1]] != p[c[i]])
			x[c[i]] = 1;
		else
			x[c[i]] = x[c[i - 1]] + 1;
	}
	for (i = 0; i < m; i++)
		printf("%06d%06d\n", p[i], x[i]);
	return 0;
}

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

void Main() {
  char s[101];
  int i = 0;
  bool easy = true;
  std::cin >> s;

  while (1) {
    if (s[i] == '\0') {
      break;
    }
    if (i % 2 == 1) { // 偶数
      if (s[i] == 'R') {
        easy = false;
        break;
      }
    } else { //奇数
      if (s[i] == 'L') {
        easy = false;
        break;
      }
    }
    i++;
  }

  if (easy) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
}

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

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	int x, y, z;
	cin >> x >> y >> z;
	cout << z <<" "<< x <<" "<< y;





}

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

int main (void) {
    int n;
    scanf("%d", &n);
    char s[n];
    scanf("%s", s);

    long long ans;
    int i, j, k;
    int n_r=0, n_g=0, n_b=0;

    /* count each character */
    for ( i=0; i<n; i++ ) {
        if ( s[i] == 'R' )
            n_r++;
        if ( s[i] == 'G' )
            n_g++;
        if ( s[i] == 'B' )
            n_b++;
    }

    ans = (long long)n_r * n_g * n_b;

    for ( i=0; i<n; i++ ) {
        for ( j=i+1; j<n; j++ ) {
            k = j + (j - i);
            if ( k < n ) {
                if ( s[i] == s[j] || s[i] == s[k] || s[j] == s[k] )
                    continue;
                ans--;
            }
        }
    }

    printf("%lld\n", ans);
    return EXIT_SUCCESS;
}


Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=2e5+100;

void solve(){
	int k,l,r;scddd(k,l,r);
	int flag=0;
	for(int i=l;i<=r;i++)
		if(i%k==0)flag=1;
	if(flag)printf("OK");
	else printf("NG");
}
int main(){
    //IOS;
    //freopen("in.txt","r",stdin);
    //freopen("D:\\data.txt","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if (A <= 5) {
		cout << 0 << endl;
	}
	else if (A > 5 && A <= 12) {
		cout << B / 2 << endl;
	}
	else {
		cout << B << endl;
	}
}

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

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define ll long long
#define OK puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 7;


int a[N], ans, n;
ll s;

main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", a + i);
    sort(a + 1, a + n + 1);
    ans = n;
    for(int i = 1 ; i < n ; i ++)
    {
        s += a[i];
        if(s * 2 < a[i + 1])
            ans = n - i;
    }
    cout << ans << endl;


}





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

int main(){
  int n;
  string b;
  cin >> n;
  map<string,int>a;
  for(int i=0;i<n;i++){
    cin >> b;
    a[b]++;
  }
  int m=0;
  for(auto x:a)
    m=max(m,x.second);
  for(auto x:a){
    if(x.second==m)
      cout << x.first << endl;
  }
  return 0;
}

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

int main() {
	int a, b, c;
	int sum;
	cin >> a >> b >> c;
	sum = a + b + c;
	if (a > b) {
		if (a > c)
			cout << sum - a;
		else
			cout << sum - c;
	}
	else if (b > c)
		cout << sum - b;
	else
		cout << sum - c;
	
}

Measured memory_bytes: 256
open System

let n = Console.ReadLine() |> int

let ss =
    [ for i in 1 .. n -> Console.ReadLine() ]

let ans =
    let choose2 n = n * (n - 1L) / 2L

    let maps =
        ss
        |> List.map (fun s ->
            [0 .. s.Length - 1]
            |> List.map (fun i -> s.[i])
            |> List.fold (fun (m: Map<_, _>) c ->
                if m.ContainsKey c then
                    m |> Map.add c (m.[c] + 1L)
                else
                    m |> Map.add c 1L
                )
                (Map []))
        |> List.countBy id
        |> List.map (fun (m, n) -> (m, int64 n))

    maps
    |> List.fold (fun acc (_, n) -> acc + (choose2 n)) 0L

ans |> Console.WriteLine

Measured memory_bytes: 94596
'use strict'

function main(input){
  const lines = input.split('\n');
  const HW = lines.shift().split(' ').map(x => parseInt(x));
  const H = HW[0];
  const W = HW[1];
  const A = [];
  for(var i =0;i<H;i++){
    A.push(lines.shift().split(''));
  }
  const divider = 10e8+7;

  const dp=[];
  for(var i =0;i<H;i++){
    dp.push(Array(W).fill(0))
  }

  dp[0][0]=1;
  for(var i =0;i<H;i++){
    for(var j =0;j<W;j++){
      if( i>0 && A[i-1][j]!='#' ){ dp[i][j] += dp[i-1][j]; }
      if( j>0 && A[i][j-1]!='#' ){ dp[i][j] += dp[i][j-1]; }
      dp[i][j] %= divider
    }
  }

  let result = dp[H-1][W-1];
  console.log(result%divider);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 53280
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    string s, p;
    std::cin >> s >> p;
    int s_len, p_len;
    bool flag = false;
    s_len = s.length();
    p_len = p.length();
    for (int i=0; i<s_len; ++i){
        if(flag){
            break;
        }
        for (int j=0; j<p_len; ++j){
            if (i+j < s_len && (char)(s[i+j] - p[j]) != 0){
                break;
            }
            else if (i+j >= s_len && (char)(s[i+j-s_len] - p[j]) != 0){
                break;
            }
            if (j == p_len-1 && ((i+j < s_len && (char)(s[i+j] - p[j]) == 0) || (i+j >= s_len && (char)(s[i+j-s_len] - p[j]) == 0))){
                std::cout << "Yes" << endl;
                flag = true;
            }
        }
    }
    if(!flag){
        std::cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3212
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var readline_1 = __importDefault(require("readline"));
process.stdin.resume();
process.stdin.setEncoding('utf8');
var reader = readline_1.default.createInterface({
    input: process.stdin,
    output: process.stdout,
});
var lines = [];
reader.on('line', function (line) {
    lines.push(line);
});
reader.on('close', function () {
    var r = Number(lines[0]);
    console.log(Math.pow(r, 2));
});
//# sourceMappingURL=main.js.map

Measured memory_bytes: 11596
HP_t, ATT_t, HP_a, ATT_a = gets.split
tHP = HP_t.to_i
tATT = ATT_t.to_i
aHP = HP_a.to_i
aATT = ATT_a.to_i

while(aHP >= 0 || tHP >= 0)
    aHP = aHP - tATT
    if(aHP <=0)
        print 'Yes'
        break
    end
    tHP = tHP - aATT
    if(tHP <=0)
        print 'No'
        break
    end
end

Measured memory_bytes: 14376
function main()
	N=parse(Int,readline())
	X=zeros(Int,N,N)
	vis=zeros(Int,N,N)
	for i=1:N,j=1:N
		X[i,j]=min(i-1,j-1,N-i,N-j)
	end
	ans=0
	for p=map(x->parse(Int,x),split(readline()))
		x=div(p-1,N)+1
		y=(p-1)%N+1
		ans+=X[x,y]
		vis[x,y]=1
		Q=Pair{Int,Int}[x=>y]
		while !isempty(Q)
			nx,ny=popfirst!(Q)
			c=X[nx,ny]
			if vis[nx,ny]==0
				c+=1
			end
			for (tx,ty)=[nx-1=>ny,nx+1=>ny,nx=>ny-1,nx=>ny+1]
				if 1<=tx<=N&&1<=ty<=N&&X[tx,ty]>c
					X[tx,ty]=c
					push!(Q,tx=>ty)
				end
			end
		end
	end
	println(ans)
end
main()


Measured memory_bytes: 246268
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<string>
#include<cmath>
#include<cassert>
#include<cstdint>
#include<map>
using namespace std;

typedef int64_t i64;typedef int32_t i32;
typedef int16_t i16;typedef int8_t i8;
typedef uint64_t ui64;typedef uint32_t ui32;
typedef uint16_t ui16;typedef uint8_t ui8;

typedef i64 int__;
#define rep(i,j) for(int__ i=0;i<j;i++)
#define repeat(i,j,k) for(int__ i=(j);i<(k);i++)
#define all(v) begin(v),end(v)

const i32 INF=1<<30;//10E10

class Path{  
public:
  struct Edge{int to,cost,dist;Edge(int to_,int cost_,int d):to(to_),cost(cost_),dist(d){;}};

  int node_size;
  vector< vector<Edge> > E_list;//??\?¶??????????

  
  Path(int node_size_){E_list.resize(node_size_);node_size=node_size_;}
  
  void add_arc(int x,int y,int c,int d)
  {
    E_list[x].push_back(Edge(y,c,d));
  }
  void add_edge(int x,int y,int c,int d)
  {
    E_list[x].push_back(Edge(y,c,d));
    E_list[y].push_back(Edge(x,c,d));
  }
};

struct djk_state{
  int index;
  int cost;
  int money;
  djk_state(int i,int c,int m):index(i),cost(c),money(m){;}
  bool operator<(const djk_state &r)const{return cost<r.cost;}
  bool operator>(const djk_state &r)const{return cost>r.cost;}
};


int dijkstra(Path &Graph,int N,int M,int L){
  priority_queue< djk_state ,vector<djk_state>,greater<djk_state> > que;
  vector<int> ans;
  bool visited[101][101]={};//[money][index]
  
  que.push(djk_state(0,0,L));
    
  while(!que.empty()){
    djk_state now=que.top();que.pop();    

    //printf("index %d money %d\n",now.index,now.money);

    if(visited[now.money][now.index])continue;
    visited[now.money][now.index]=true;
    if(now.index==N-1){
      ans.push_back(now.cost);
      continue;
    }
    
    for(Path::Edge e : Graph.E_list[now.index]){
      if(now.money-e.dist>=0)
	que.push(djk_state(e.to,now.cost,now.money-e.dist));
      que.push(djk_state(e.to,now.cost+e.cost,now.money));
    }
    
  }
  int answer=INF;
  rep(i,ans.size())answer=min(answer,ans[i]);
  return answer;
}




int main()
{
  while(1){
    int N,M,L;
    cin>>N>>M>>L;
    if(N==0)break;
    Path G(N);
    rep(i,M){
      int a,b,d,e;
      cin>>a>>b>>d>>e;
      G.add_edge(a-1,b-1,e,d);
    }
    cout<<dijkstra(G,N,M,L)<<endl;
  }
  return 0;
}

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

int main(){
  int N,X;
  cin>>N>>X;
  int m[N];
  int sum=0;
  int min=0;
  for(int i=0;i<N;++i){
    cin>>m[i];
    if(i==0)min=m[i];
    else if(min>m[i])min=m[i];
    sum+=m[i];
  }

  int rest=X-sum;
  cout<<rest/min+N<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<cctype>
#include<climits>
#include<cstddef>
#include<typeinfo>

using namespace std;

int main()
{
	string w;
	string t;
	int count = 0;

	cin >> w;
	while (1) {
		cin >> t;
		if (t == "END_OF_TEXT") break;
		else {
			for (int i = 0; i < t.size(); i++)
				t[i] = tolower(t[i]);
			if (t == w) count++;
		}
	}
	cout << count << endl;

	return 0;
}


Measured memory_bytes: 1192
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,N) for(int i=0;i<N;i++)

using namespace std;

const int INF = 1001001001;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
  
    int n,W;
    cin >> n >> W;
  
    vector<int> w(n+1),v(n+1);
    rep(i,n) cin >> w[i+1] >> v[i+1];
  
    vector<vector<ll>> dp( n+1,vector<ll>(W+1) );
    //rep(i,n+1) dp[i][0] = 0;
    rep(i,n+1) if(i!=0){
      rep(j,W+1) if(j!=0){
        dp[i][j] = dp[i-1][j];
        if(j-w[i]>=0) dp[i][j] = max(dp[i][j],dp[i-1][j-w[i]] + v[i] );
      }
    }
  	//rep(i,n+1) cout << i << ":" << dp[i][W] << endl;
  
	cout << dp[n][W] << endl;
    return 0;
}

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

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int N, M;
  cin >> N >> M;
  vector <int> A(N);
  for (int i = 0; i < A.size(); i++) {
    cin >> A[i];
  }
  map <int, int> m;
  vector <int> SUM(N + 1);
  SUM[0] = 0;
  for (int i = 0; i < N; i++){
    SUM[i+1] = (SUM[i] + A[i]) % M;
  }
  ll ans = 0;
  for (int i = 0; i < N + 1; i++) {
    ans += m[SUM[i]];
    m[SUM[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
#include <iterator>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#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, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
//提出するときC++に帰る
//--------------------------



int main() {

  int a, b;
  cin >> a >> b;
  cout << a*b << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int a[100001];
int main()
{
    int n,i,sum,x1,x;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&a[i]);
    sum=0;
    for(i=1; i<=n; i++)
        sum+=a[i];
    sum/=2;
    x1=sum;
    for(i=n-1; i>=2; i-=2)
        x1-=a[i];
    printf("%d ",x1*2);
    x=x1;
    for(i=1; i<n; i++)
    {
        printf("%d ",(a[i]-x)*2);
        x=a[i]-x;
    }

    return 0;
}


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

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

using namespace std;

int main(void) {
	vector<pair<int, int> > in;
	while(1) {
		int H, W;
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		in.push_back(make_pair(H, W));
	}
	REP(i, in.size()) {
		REP(j, in[i].first) {
			if (j == 0 || j == in[i].first - 1) {
				REP(k, in[i].second) {
					cout << "#";
				}
			} else {
				REP(k, in[i].second) {
					if (k == 0 || k == in[i].second - 1) {
						cout << "#";
					} else {
						cout << ".";
					}
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const double PI=3.14159265358979323846;
 
int main() {
    double r; cin >> r;
    cout << fixed << setprecision(15) << r * PI * 2 << endl;
}


Measured memory_bytes: 3740
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

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

ll lcm(ll a,ll b)
{
   return a/gcd(a,b)*b;
}

void f(ll rest,string s){
    if(rest==0){
        cout<<s<<endl;
    }else{
        for(char c='a';c<='c';c++){
            f(rest -1,s+c);
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),c(n);
    rep(i,n) {
        cin>>a[i];
        c[i]=a[i];
    }
    rep(i,n) cin>>b[i];
    sort(ALL(a));
    ll suma=0,sumb=0;
    
    do{
        if(c == a) break;
        suma++;
    }while(next_permutation(ALL(a)));
    sort(ALL(a));
    do{
        if(a == b) break;
        sumb++;
    }while(next_permutation(ALL(a)));
    
    cout<<abs(suma-sumb)<<endl;
    return 0;
}


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

vector<bool > prime;

//primeListには素数は入ってません
void isPrime(ll N){
    prime[0] = false;
    prime[1] = false;

    //ルートN以下まで繰り返す
    for(ll i = 2; i < ceil(sqrt(N) + 0.1) ; i++){
        //素数になりえないとき
        if(prime[i] == false) continue;
        
        //Nまでのi(素数)の倍数を斑入り落とす
        for(ll j = i * i; j < N; j += i){
            prime[j] = false;
        }
        
    }
}

int main(){

    ll Q;
    cin >> Q;
    
    //cin >> N;
    prime.assign(100001, true);
    isPrime(100001);

    vector<ll > kukan(100001, 0);

    for(ll i = 2; i < prime.size(); i++){
        //cout << prime[i] << endl;
        if(prime[i] == true && i % 2 == 1){
            if(prime[(i + 1) / 2] == true){
                kukan[i] = kukan[i - 1] + 1;
            }else{
                kukan[i] = kukan[i - 1];
            }
        }else{
            kukan[i] = kukan[i - 1];
        }
    }

    vector<ll > ans(Q, 0);
    for(ll i = 0; i < Q; i++){
        ll l = 0; 
        ll r = 0;
        cin >> l >> r;
        //ans += kukan[r] - kukan[l - 1];
        ans[i] = kukan[r] - kukan[l - 1];
    }

    for(ll i = 0; i < Q; i++){
        cout << ans[i] << endl;
    }
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100000;

int main()
{
	int A, B, T;
	while(scanf("%d %d %d", &A, &B, &T) != EOF)
	{
		printf("%d\n", T / A * B);
	}
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

ss = S.split(//)
e = ss.count('E')
ets = ss.inject([e]){|a, s| a << (s == 'E' ? a[-1] -1 : a[-1])}.drop(1)
wts = ss.inject([0]){|a, s| a << (s == 'W' ? a[-1] + 1 : a[-1])}.take(N)
puts ets.zip(wts).map{|e, w| e + w}.min

Measured memory_bytes: 44288
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#define r(i,n) for(int i=0;i<n;i++)
#define debug(x) cerr << #x << ": " << x << endl;
using namespace std;

int main(){
  int r;
  cin >> r;
  if(r<1200){
    cout << "ABC";
  }else if(r<2800){
    cout << "ARC";
  }else{
    cout << "AGC";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-9
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

struct city {
	int p, y, i;
};

bool operator<(city a, city b) {
	return a.y < b.y;
}

int main() {
	speed;
	int n, m, p, y;
	cin >> n >> m;
	vector<city>v(m);
	for (int i = 0; i < m; ++i) {
		cin >> v[i].p >> v[i].y;
		v[i].i = i;
	}
	sort(v.begin(), v.end());
	vector<string>ans(m);
	vector<int>cnt(n + 1, 1);
	for (int i = 0; i < m; ++i) {
		string ps = to_string(v[i].p);
		ps = string(6 - ps.size(), '0') + ps;
		string cs = to_string(cnt[v[i].p]);
		cs = string(6 - cs.size(), '0') + cs;
		ans[v[i].i] = ps + cs;
		cnt[v[i].p]++;
	}
	for (auto i : ans)
		cout << i << '\n';
}

Measured memory_bytes: 6740
#include<stdio.h>

int main(void)
{
  int n,time[100001],x[100001],y[100001],i,j=0,spot[2]={0,0};
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    {
      scanf("%d %d %d",&time[i],&x[i],&y[i]);
    }

  for(i=1;i<=time[n-1];i++)
    {
      if(spot[0] < x[j])
	{
	  spot[0]++;
	}
      else if(spot[0] > x[j])
	{
	  spot[0]--;
	}
      else if(spot[1] < y[j])
	{
	  spot[1]++;
	}
      else if(spot[1] > y[j])
	{
	  spot[1]--;
	}
      else
	{
	  spot[0]++;
	}
      //debug
      //printf("%d %d %d %d %d\n",i,spot[0],spot[1],x[j],y[j]);
      if(i == time[j])
	{
	  if(spot[0] != x[j] || spot[1] != y[j]) //不一致なのでNG
	    {
	      printf("No\n");
	      return 0;
	    }
	  j++;
	}
    }
  printf("Yes\n");
  return 0;
}
      


Measured memory_bytes: 1280
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{
// n の素因数を (素因数, 個数) のペアで列挙して返す。O(sqrt(N))
map<i64, int> getPrimeFactors(i64 n)
{
    map<i64, int> pf;
    for (i64 i = 2; i * i <= n; ++i) {
        while(n % i == 0) {
            pf[i] += 1;
            n /= i;
        }
    }
    if (n != 1) pf[n] = 1;
    return pf;
}
// }}}
struct FastIO {
    FastIO() { cin.tie(nullptr); ios::sync_with_stdio(false); }
} fastIO_ydk ;

int N, M;
int s, t;
vector<int> G[100010];
int dist[100010][5];

signed main()
{
    cin >> N >> M;
    for (int i = 0 ; i < M; ++i) {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
    }
    cin >> s >> t;

    queue<pii> que;
    que.emplace(s, 0);

    memset(dist, INF, sizeof(dist));
    dist[s][0] = 0;

    while(!que.empty()) {
        const int u = que.front().first;
        const int k = que.front().second;
        const int nxtCost = dist[u][k] + 1;
        const int nxtK = (k+1) % 3;
        que.pop();

        for (int nxt : G[u]) {
            if (chmin(dist[nxt][nxtK], nxtCost)) {
                que.emplace(nxt, nxtK);
            }
        }
    }

    if (dist[t][0] >= INF) {
        cout << (-1) << endl;
    } else {
        cout << (dist[t][0] / 3) << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;

  int ans = 0;
  int min_val = 1000000;
  for(int i = 0; i < N; i++){
    int tmp; cin >> tmp;
    if(tmp <= min_val){
      ans++;
    }
    min_val = min(min_val, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
N = int(input())
A = list(map(int,input().split(" ")))
A.insert(0,0)
A.append(0)
total = 0
for i in range(1,len(A)):
    total += abs(A[i]-A[i-1])
for i in range(1,N+1):
    ans = abs(A[i+1]-A[i-1])-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]))
    print(ans+total)

Measured memory_bytes: 14176
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define see(x) cout<< #x <<" = "<< x <<' ';
#define seen(x) cout<< #x <<" = "<< x <<'\n';
#define UWU cout<<'\n';
int main(){
//ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    string s;cin>>s;
    if(s.size() <= n){
        cout<<s;
    }else{
        for(int i = 0 ; i < n ; ++i) cout<<s[i];
        cout<<"...";
    }

}


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

void f(){
    int n, i;
    vector<int> counts(50000);
    int j = 0;
    while(1){
        cin >> n;
        if (n == 0){
            for(i = 0; i < j; i++)
                cout << counts[i] << '\n';
            break;
        }

        vector<int> a(n);
        int sum = 0;
        for(i = 0; i < n; i++){
            cin >> a[i];
            sum += a[i];
        }
        double ave = sum / n;

        // ask below average number
        for(i = 0; i < n; i++){
            if(a[i] <= ave){
                counts[j]++;
            }
        }
        j++;
    }
}

int main(){
    f();
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll dp[101][100001];
//memset(dp,-1,sizeof(dp));

ll knapsack(ll wts[],ll val[],ll w,ll n)
{
     if(n==0||w==0)
     return 0;
     
     if(dp[n][w]!=-1)
     return dp[n][w];
     
     if(wts[n-1]<=w)
     {
          return dp[n][w]= max(knapsack(wts,val,w-wts[n-1],n-1)+val[n-1], knapsack(wts,val,w,n-1));
     }
     if(wts[n-1]>w)
     return dp[n][w]=knapsack(wts,val,w,n-1);
     
     
}



int main()
{
     tez;
     ll n,w;
     cin>>n>>w;
     for(ll i=0;i<101;i++)
{
     for(ll j=0;j<100001;j++)
     {
          dp[i][j]={-1};
     }
     
}
     ll val[n],wts[n];
     for(ll i=0;i<n;i++)
     {
          cin>>wts[i]>>val[i];
     }
    cout<< knapsack(wts,val,w,n);
}

Measured memory_bytes: 79232
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = b + min(a + b + 1, c);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(int)
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
for val in l:
    for i in range(1, len(val)):
        d[val[i]] += 1
count = 0
for k in d.keys():
    if d[k] == n:
        count += 1
print(count)

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

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll x;
    cin >> n >> x;;
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];
    ll r = 0;
    ll past = a[0];
    if(past > x) {
        r += past - x;
        past = x;
    }
    for(int i=1; i<n; i++) {
        ll b = a[i];
        ll d = past + b - x;
        if(d > 0) {
            r += d;
            b -= d;
        }
        past = b;
    }
    ll r2 = 0;
    past = a[n-1];
    if(past > x) {
        r2 += past - x;
        past = x;
    }
    for(int i=n-2; i>=0; i--) {
        ll b = a[i];
        ll d = past + b - x;
        if(d > 0) {
            r2 += d;
            b -= d;
        }
        past = b;
    }
    cout << min(r, r2) << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=22987653;
const LL mo=1e9+7;
int n,f[N+2];
LL qpow(LL x,LL k)
{
	LL ret=1;
	while(k){
		if(k&1) ret*=x,ret%=mo;
		x*=x; x%=mo; k>>=1;
	}
	return ret;
}
int main()
{
	scanf("%d",&n);
	int kt=1;
	for(int i=1;i<=8;i++){
		int now=min(N,kt*10);
		for(int j=kt;j<now;j++)
		  f[j]=i;
		kt*=10;
	}
	for(int i=1;i<N;i++) f[i]+=f[i-1];
	LL ans=0;
	for(int l=0,r=1;l<10000000-1;l++){
		while(f[r]-f[l]<n) r++;
		if(f[r]-f[l]==n) ans++;
	}
//	cout<<ans<<endl;
	for(int len=1;len<=n/8;len++){
		if(n%len==0)
		  ans=(ans+(9*qpow(10,n/len-1)-len+1)%mo+mo)%mo;
		else
		  ans=(ans+1)%mo;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 90112
#ALDS1_1_C:   Prime Numbers
import math
def prime(n):
    limit = math.sqrt(n)
    if n == 2: return 1
    if n < 2 or n % 2 == 0: return 0
    
    i = 3
    while i <= limit:
        if n % i == 0: return 0
        else:
            i += 2
    return 1
        
n = int(input())
res = 0
for _ in range(n):
    res += prime(int(input()))
print(res)


Measured memory_bytes: 5680
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b = a;
    sort(all(b));
    int l = b[n/2-1];
    int r = b[n/2];
    rep(i, n) {
        if (a[i] <= l) cout << r << endl;
        else cout << l << endl;
    }
}


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

int main(){
   int A,B,C; cin >> A >> B >> C;

  if(B > A){
     if( A < C && C < B){ 
               cout << "Yes" << endl;
     }
     else{
              cout << "No" << endl;
     }
  }
 if(B < A){
     if(B < C && C < A){
               cout << "Yes" << endl;
     }
     else{
              cout << "No" << endl;
     }
}
 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void set_num(int data[], int n){
    for(int i = 0; i < n; i++){
        scanf("%d", &data[i]);
    }
}

void count_block(int block[], int n){
    int cnt = 0, num = 1;
    for(int i = 0; i < n; i++){
        if(block[i] != num){
            cnt ++;
        }else{
            num ++;
        }
    }
    if(num == 1){
        printf("%d\n", -1);
        return ;
    }
    printf("%d\n", cnt);
}

int main(void){
    int n;
    scanf("%d", &n);
    int block[n];
    set_num(block, n);
    count_block(block, n);
    return 0;

}

Measured memory_bytes: 896