akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int64_t Check(std::string s){
  int64_t result=0;
  for(int i=1;i<s.size();i++){
    if(s[i-1]==s[i]){
      s[i]='*';
      result++;
    }
  }
  return result;
}

int64_t CheckFrontReprace(std::string s){
  int64_t result=1;
  s[0]='*';
  return result+Check(s);
}

int64_t CheckBackReprace(std::string s){
  int64_t result=1;
  s[s.size()-1]='*';
  return result+Check(s);
}

struct Data{
  int result_backreplaced;
  int result_frontreplaced;
  int result_normal;
  Data(int b,int f,int n):result_backreplaced(b),result_frontreplaced(f),result_normal(n){}
};



int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  std::string s;
  int64_t k;
  cin>>s>>k;
  if(k==1){
    cout<<Check(s)<<endl;
    return 0;
  }

  int frontstr_back=-1;
  int backstr_front=-1;
  for(int i=1;i<s.size();i++){
    if(s[i-1]!=s[i]){
      frontstr_back=i-1;
      break;
    }
  }
  for(int i=s.size()-1;i>=1;i--){
    if(s[i]!=s[i-1]){
      backstr_front=i;
      break;
    }
  }

  if(frontstr_back==-1||backstr_front==-1){
    cout<<s.size()*k/2<<endl;

  }else{
    std::string fs=s.substr(0,backstr_front);
    std::string bf=s.substr(backstr_front,s.size()-backstr_front)+s.substr(0,frontstr_back+1);
    std::string mid=s.substr(frontstr_back+1,backstr_front-frontstr_back-1);
    std::string sb=s.substr(frontstr_back+1, s.size()-frontstr_back-1);
    cout<<Check(fs)+Check(bf)*(k-1)+Check(mid)*(k-2)+Check(sb)<<endl;
  }






  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

char field[55][55];
int w,h;
int dx[8] = {1,1,0,-1,-1,-1,0,1};
int dy[8] = {0,1,1,1,0,-1,-1,-1};

void dfs(int x, int y){
    field[x][y] = '0';
    rep(t,0,8){
        int nx = x + dx[t];
        int ny = y + dy[t];
        if(nx >= 0 && nx < h && ny >= 0 && ny < w){
            dfs(nx,ny);
        }
    }
}


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    pair<int,int> p[100100];
    rep(i,0,m){
        int a,b; cin >> a >> b;
        p[i] = mp(b,a);
    }
    sort(p,p+m);
    int left = 1;
    int ans = 0;
    rep(i,0,m){
        if(p[i].second >= left){
            ans++;
            left = p[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> p(N);
	for(i = 0; i < N; i++){
		scanf("%d", &p[i]);
	}
	int ans = 0;
	for(i = 1; i < N - 1; i++){
		if(max({p[i - 1], p[i], p[i + 1]}) != p[i] && min({p[i - 1], p[i], p[i + 1]}) != p[i]){
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  string s;
  cin >> s;
  
  string x = "";
  for(int bit = 0; bit < (1 << 3); bit++){
    int seven = s[0] - '0';
    x += s[0];
    for(int i = 1; i < 4; i++){
      if(bit & (1 << (i-1))){
        seven += s[i] - '0';
        x += '+'; 
        x += s[i];
      }else{
        seven -= s[i] - '0';
        x += '-';
        x += s[i];
      }//eles
    }//for
   
    if(seven == 7){
      break;
    }
    seven = 0;
    x = "";
  }//for
  
  cout << x << "=7" << endl;
}

Measured memory_bytes: 3640
import math

def main():
    N = int(input())
    min_steps = N
    for i in range(1, math.floor(math.sqrt(N))+1):
        if N % i == 0:
            a, b = i, N//i
            min_steps = min(min_steps, a-1+b-1)
    print(min_steps)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
// CF2017B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n, m,k;
    cin >> n >> m>>k;
    bool ok = false;

    for(int i=0;i<=n;i++) {
        for(int j=0;j<=m;j++) {
            if (i * (m - j) + j * (n - i) == k) {
                ok = true;
                break;
            }
        }
    }
    if (ok) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
  
int main (void) 
{
  int i, j, k, l, n;
  int p[101], m[101][101];
    
  scanf("%d", &n); 
  for(i = 1; i <= n; i++){
    scanf("%d %d", &p[i - 1], &p[i]);
  }
    
  for(i = 0; i <= n; i++){
    m[i][i] = 0;
  }
    
  for(l = 2; l <= n; l++){
	for(i = 1; i <= n-l+1; i++){
      int j = i+l-1;
      m[i][j] = 10000000000;
        
      for(k = i; k <= j-1; k++){
        if( m[i][j] < m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]){
          m[i][j] = m[i][j] ;
        } else {
          m[i][j] = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        }
      }
    }
  }
    
  printf("%d\n", m[1][n]);
    
  return 0;
}

Measured memory_bytes: 1880
N = int(input())
S = input()

num_to_alphabet = {
    "1": "A",
    "2": "B",
    "3": "C",
    "4": "D",
    "5": "E",
    "6": "F",
    "7": "G",
    "8": "H",
    "9": "I",
    "10": "J",
    "11": "K",
    "12": "L",
    "13": "M",
    "14": "N",
    "15": "O",
    "16": "P",
    "17": "Q",
    "18": "R",
    "19": "S",
    "20": "T",
    "21": "U",
    "22": "V",
    "23": "W",
    "24": "X",
    "25": "Y",
    "26": "Z",
}


alphabet_to_num = {
  "A": "1",  
  "B": "2",  
  "C": "3",  
  "D": "4",  
  "E": "5",  
  "F": "6",  
  "G": "7",  
  "H": "8",  
  "I": "9",  
  "J": "10",
  "K": "11",
  "L": "12",
  "M": "13",
  "N": "14",
  "O": "15",
  "P": "16",
  "Q": "17",
  "R": "18",
  "S": "19",
  "T": "20",
  "U": "21",
  "V": "22",
  "W": "23",
  "X": "24",
  "Y": "25",
  "Z": "26",
}
answer = ""
for s in S:
    if int(alphabet_to_num[s])+N <= 26:
        answer += num_to_alphabet[str(int(alphabet_to_num[s])+N)]
    else:
        answer += num_to_alphabet[str(int(alphabet_to_num[s]) + N - 26)]

print(answer)

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

int main()
{
  int _, g, b;
  cin >> _ >> g >> b;
  if ((g * 10 + b) % 4 == 0)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }  

  return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    string s;
    cin>>s;
    sort(ALL(s));
    if(s=="abc")cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main(){
	char ch;
	int counter[26]={0};
	while( scanf("%c", &ch) != EOF ){
		if( isupper(ch) ) 
			ch = tolower(ch);
	
		if('a'<=ch && ch<='z') 
			++counter[ ch-'a' ];

	}

	for(int i=0; i<26; ++i)
		printf("%c : %d\n", 'a'+i, counter[i]);

	return 0;
}



Measured memory_bytes: 2688
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N, K; cin >> N >> K;
  string S; cin >> S;

  vector <int> zero, one;
  if (S[0] == '0') one.push_back(0);

  int cnt0 = 0, cnt1 = 0;
  for (int i = 0; i < S.length(); i++){
    if (S[i] == '0'){
      if (cnt1 > 0) one.push_back(cnt1);
      cnt0++; cnt1 = 0;
    }else{
      if (cnt0 > 0) zero.push_back(cnt0);
      cnt0 = 0; cnt1++;
    }
  }
  if (cnt0 > 0){
    zero.push_back(cnt0);
    one.push_back(0);
  }else{
    one.push_back(cnt1);
  }

  int ans = one[0], sum = one[0];
  if (zero.size() > 0){
    for (int i = 0; i < zero.size(); i++){
      sum += zero[i] + one[i + 1];
      if (i >= K){
        sum -= one[i - K] + zero[i - K];
      }
      ans = max(sum, ans);
    }
  }

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


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200000+5;
struct Edge{
    int x,y;
    int dis;
    Edge(){}
    Edge(int x,int y,int dis):x(x),y(y),dis(dis){}
    bool operator <(const Edge &rhs)const{
        return dis<rhs.dis;
    }
}edge[N];
int tot;
struct Node{
    int x,y;
}node[N];
int father[N];
 
bool cmpX(int a,int b){
    return node[a].x<node[b].x;
}
bool cmpY(int a,int b){
    return node[a].y<node[b].y;
}
int Find(int x){
    if(father[x]!=x)
        return father[x]=Find(father[x]);
    return x;
}
int n;
int Kruskal(){
    for(int i=1;i<=n;i++)
        father[i]=i;
 
    int mst=0;
    sort(edge+1,edge+1+tot);
    for(int i=1;i<=tot;i++){
        int x=Find(edge[i].x);
        int y=Find(edge[i].y);
        if(x!=y){
            mst+=edge[i].dis;
            father[x]=y;
        }
    }
    return mst;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&node[i].x,&node[i].y);
 
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpX);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].x-node[x].x;
        edge[++tot]=Edge(x,y,dis);
    }
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpY);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].y-node[x].y;
        edge[++tot]=Edge(x,y,dis);
    }
 
    int mst=Kruskal();
    printf("%d\n",mst);
    return 0;
}

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

void solve()
{
   int a, b, c;
   cin>>a>>b>>c;
   swap(a,b);
   swap(a,c);
   cout<<a<<" "<<b<<" "<<c<<endl;
}
int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();

    double prob = 0;
    for( int i=0 ; i < N ; i++ ){
      int pt = i+1 ;//ある得点ptが出たとき
      int times = 0;
      for( int j=0 ; j >= 0 ; j++ ){
        if (pt >= K){break; }//得点がK以上ならば終わり
        else{ pt*=2; }//得点を2倍
        times = j+1;
      }
      prob += 1 / (double)N / ( Math.pow(2, times) ) ;
    }
    System.out.println(prob);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <stdio.h>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}

int Range(){
	int a, b,c;
	bool flag = true;

	cin >> a >> b >> c;
	if (!(0 <= a && a <= 100)) return 1;
	if (!(0 <= b && b <= 100)) return 1;
	if (!(0 <= c && c <= 100)) return 1;

	if (!(a < b)) flag=false;
	if (!(b < c)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	//SmallLargeOrEqual();
	Range();
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
using namespace std;
 
int main() {
    int m, f, r;
    int m_, f_, r_;
    int score;
    while (true) {
        cin >> m >> f >> r;
        m_ = m==-1;
        f_ = f==-1;
        r_ = r==-1;
        score = m+f;
        if ( m_+f_+r_ == 3 ) {
            break;
        }
        if (m_ == 1 || f_ == 1) {
            cout << "F" << endl;
            continue;
        }
        char grade;
        if (score >= 80) {
            grade = 'A';
        } else if (score >= 65) {
            grade = 'B';
        } else if (score >= 50) {
            grade = 'C';
        } else if (score >= 30) {
            if (r >= 50) {
                grade = 'C';
            } else {
                grade = 'D';
            }
        } else {
            grade = 'F';
        }
        cout << grade << endl;
    }
    return 0;
}



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

using namespace std;
int main(void){
    // Your code here!
    long long A,B,K;
    cin>>A>>B>>K;
    if(K<A)A-=K;
    else if(K>=A){
        long long t=B-K+A;  B=B-K+A; A=0;
       if(t<0)B=0;
      
    }
    cout<<A<<" "<<B<<endl;
    return 0;
    
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 1e5+5;

int N;
int A[MX_N], B[MX_N];
map<int,int> sa;
vector<int> ord;

struct UnionFind {
    vector<int> s, p;
    UnionFind(int n) { s.assign(n,1); p.resize(n); iota(ALL(p),0); }
    int findset(int i) { return (p[i] == i) ? i : (p[i] = findset(p[i])); }
    bool unionset(int i, int j) {
        int x = findset(i), y = findset(j);
        if (x != y) {
            if (s[x] > s[y]) p[y] = x, s[x] += s[y];
            else p[x] = y, s[y] += s[x];
            return true;
        } else return false;
    }
};

int main() {
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    FOR(i,1,N){ cin >> A[i]; A[0] ^= A[i]; }
    FOR(i,1,N){ cin >> B[i]; }

    FOR(i,0,N) ord.push_back(A[i]);
    sort(ALL(ord));
    ord.resize(unique(ALL(ord))-ord.begin());
    FOR(i,0,N){
        A[i] = lower_bound(ALL(ord),A[i])-ord.begin();
        ++sa[A[i]];
    }
    FOR(i,1,N){
        auto it = lower_bound(ALL(ord),B[i])-ord.begin();
        if (ord[it] != B[i] || !sa[it]) { cout << -1; return 0; }
        B[i] = it;
        --sa[it];
    }

    int ans = 0;
    UnionFind UF(SZ(ord));
    FOR(i,1,N) if (A[i] != B[i]) {
        --sa[B[i]];
        ++ans;
        UF.unionset(A[i],B[i]);
    }

    //cout << ans << endl;
    set<int> comp;
    FOR(i,0,SZ(ord)-1){
        if (UF.p[i] == i && UF.s[i] > 1) comp.insert(i);
    }
    //cout << SZ(comp) << endl;
    int x = UF.findset(A[0]);
    if (comp.count(x)) comp.erase(x);
    cout << ans + SZ(comp);
}


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    vi v(3);
    rep(i, 3) cin >> v[i];
    sort(all(v), greater<ll>());
    cout << v[0]*10+v[1]+v[2] << endl;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int num[105][105];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int h,w;
    scanf("%d%d",&h,&w);
    int n;
    scanf("%d",&n);
    int i;
    int nowx=0,nowy=0;
    int t=1;
    for (i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        int j;
        for (j=0;j<x;j++)
        {
            num[nowx][nowy]=i+1;
            nowy+=t;
            if (nowy==w)
            {
                nowy--;
                nowx++;
                t=-t;
            }
            if (nowy==-1)
            {
                nowy++;
                nowx++;
                t=-t;
            }
        }
    }
    for (i=0;i<h;i++)
    {
        int j;
        for (j=0;j<w;j++)
        {
            printf("%d ",num[i][j]);
        }
        printf("\n");
    }
    return 0;
} 


Measured memory_bytes: 384
#!/usr/bin/env python3

def can_move(t0, x0, y0, t1, x1, y1):
    assert t1 > t0
    dist = abs(x0 - x1) + abs(y0 - y1)
    dt = t1 - t0
    if dist > dt:
        return False
    if (dist + dt) % 2 == 1:
        return False
    return True

n = int(input())
ts = [0]
xs = [0]
ys = [0]
for i in range(n):
    t, x, y = map(int, input().split())
    ts.append(t)
    xs.append(x)
    ys.append(y)

flag = True
for i in range(n):
    if not can_move(ts[i], xs[i], ys[i], ts[i + 1], xs[i + 1], ys[i + 1]):
        flag = False

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


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

int main(){
    int N; cin>>N;
    vector<int> high(N);
    rep(i,N) cin>>high[i];

    vector<int> dp(N+1,2147483647);
    dp[0]=0;

    for(int i=0; i<N-1; i++){
        dp[i+1]=min(dp[i+1], dp[i]+abs(high[i+1]-high[i]));
        dp[i+2]=min(dp[i+2], dp[i]+abs(high[i+2]-high[i]));
    }

    cout << dp[N-1] << endl;
}


Measured memory_bytes: 3980
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=185+10;

int n,m;
char a[N][N]; int s[N][N];
int dp[2][N][N][N];

int same(int lx,int ly,int rx,int ry) {
    int o=s[rx][ry]-s[lx-1][ry]-s[rx][ly-1]+s[lx-1][ly-1];
    return o==(rx-lx+1)*(ry-ly+1)||o==0;
}

int f(int o,int i,int j,int k) {
    int L=i,R=j-1,res=0;
    while (L<=R) {
        int mid=(L+R)>>1;
        res=max(res,min(dp[o][i][mid][k],dp[o][mid+1][j][k]));
        if (dp[o][i][mid][k]<dp[o][mid+1][j][k]) R=mid-1;
        else L=mid+1;
    }
    return res;
}

void solve(int c) {
    for (int i=1;i<=n;++i)
        for (int j=i;j<=n;++j)
            for (int k=1;k<=m;++k) {
                int t=dp[c^1][i][j][k];
                if (t==m) dp[c][i][j][k]=m;
                else dp[c][i][j][k]=max(dp[c^1][i][j][t+1],f(c^1,i,j,k));
            }
}

int main() {
    n=read(),m=read();
    for (int i=1;i<=n;++i) scanf("%s",a[i]+1);
    for (int i=1;i<=n;++i)
        for (int j=1;j<=m;++j)
            s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(a[i][j]=='#');
    for (int i=1;i<=n;++i)
        for (int j=i;j<=n;++j)
            for (int k=1,t;k<=m;k=t) {
                t=k;
                while (t<=m&&same(i,k,j,t)) ++t;
                for (int p=k;p<t;++p) dp[0][i][j][p]=t-1;
                if (k==t) dp[0][i][j][k]=k-1,++t;
            }
    int ans=0;
    for (int i=1;dp[(i&1)^1][1][n][1]<m;++i) solve(i&1),ans=i;
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n){
        int a;
        cin>>a;
        int tmp = 0;
        for(int i=2;i<=sqrt(a);i++){
            if(a%i==0) tmp++;
        }
        if(tmp==0) ans++;
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const llong MOD = 1000000007;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通


int N;
string S;
char SS[100010], SW[100010], WS[100010], WW[100010];
bool FSS, FSW, FWS, FWW;
int main() {
	//input
	cin >> N >> S;
	S.push_back(S[0]);
	S.push_back(S[1]);
	S.push_back(S[2]);

	//Sheep Sheep
	SS[0] = SS[1] = 'S';
	FSS = false;
	for (int i = 2; i < N + 2; i++) {
		if ((SS[i - 1] == 'S') == (S[i - 1] == 'x')) {
			if (SS[i - 2] == 'S') SS[i] = 'W';
			else SS[i] = 'S';
		}

		else {
			if (SS[i - 2] == 'S') SS[i] = 'S';
			else SS[i] = 'W';
		}
	}
	
	if (SS[N] == SS[0] && SS[N + 1] == SS[1]) FSS = true;

	

	

	//Sheep Wolf
	SW[0] = 'S';
	SW[1] = 'W';
	FSW = false;
	for (int i = 2; i < N + 2; i++) {
		if ((SW[i - 1] == 'S') == (S[i - 1] == 'x')) {
			if (SW[i - 2] == 'S') SW[i] = 'W';
			else SW[i] = 'S';
		}

		else {
			if (SW[i - 2] == 'S') SW[i] = 'S';
			else SW[i] = 'W';
		}
	}

	if (SW[N] == SW[0] && SW[N + 1] == SW[1]) FSW = true;





	//Wolf Sheep
	WS[0] = 'W';
	WS[1] = 'S';
	FWS = false;
	for (int i = 2; i < N + 2; i++) {
		if ((WS[i - 1] == 'S') == (S[i - 1] == 'x')) {
			if (WS[i - 2] == 'S') WS[i] = 'W';
			else WS[i] = 'S';
		}

		else {
			if (WS[i - 2] == 'S') WS[i] = 'S';
			else WS[i] = 'W';
		}
	}

	if (WS[N] == WS[0] && WS[N + 1] == WS[1]) FWS = true;



	//Wolf Wolf
	WW[0] = WW[1] = 'W';
	FWW = false;
	for (int i = 2; i < N + 2; i++) {
		if ((WW[i - 1] == 'S') == (S[i - 1] == 'x')) {
			if (WW[i - 2] == 'S') WW[i] = 'W';
			else WW[i] = 'S';
		}

		else {
			if (WW[i - 2] == 'S') WW[i] = 'S';
			else WW[i] = 'W';
		}
	}

	if (WW[N] == WW[0] && WW[N + 1] == WW[1]) FWW = true;

	//出力
	if (FSS) {
		for (int i = 0; i < N; i++) {
			cout << SS[i];
		}
	}
	else if (FSW) {
		for (int i = 0; i < N; i++) {
			cout << SW[i];
		}
	}
	else if (FWS) {
		for (int i = 0; i < N; i++) {
			cout << WS[i];
		}
	}
	else if (FWW) {
		for (int i = 0; i < N; i++) {
			cout << WW[i];
		}
	}
	else cout << -1;
	
	
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define HMAX 1402
#define WMAX 1402
int c[HMAX][WMAX];
int sqmaxmax=0;
int sqmax[HMAX][WMAX];
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;/*
int sqnum(int H,int W,int c[1402][1402],int x,int y){
	if(c[x][y]==1){
		return 0;
	}
	else{
		int sq=1;
		while(1){
			int flag=1;
			rep(i,sq){
				if(c[x-i][y-sq]==1||c[x-sq][y-i]==1){
					flag=0;
					break;
				}
			}
			if(flag) sq++;
			else break;
		}
		return sq;
	}
}*/
int main(){
	int H,W;
	scan(H);scan(W);
	rep(i,H+2){
		c[i][0]=1;
		c[i][W+1]=1;
	}
	rep(i,W+2){
		c[0][i]=1;
		c[H+1][i]=1;
	}
	rep(i,H){
		rep(j,W){
			scan(c[i+1][j+1]);
		}
	}
	for(int i=1;i<H+2;i++){
		for(int j=1;j<W+2;j++){
			if(c[i][j]==1){
				sqmax[i][j]=0;
			}
			else if(i==1||j==1){
				sqmax[i][j]=1;
			}
			else{
				sqmax[i][j]=min(min(sqmax[i-1][j],sqmax[i][j-1]),sqmax[i-1][j-1])+1;
			}
			sqmaxmax=max(sqmaxmax,sqmax[i][j]);
		}
	}
	prin(sqmaxmax*sqmaxmax);
	return 0;
}



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

typedef long long ll;
typedef long double ld;
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

int main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    ll x;
    cin>>x;
    cout<<((x/500)*1000)+(((x%500)/5)*5);
    return 0;
}

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

typedef long long ll;
typedef long double ld;

int niz[3005];
ll dp[3005][3005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> niz[i];
        dp[i][i] = niz[i];
        if(n%2 == 0) dp[i][i] = -dp[i][i];
    }
    for(int len=2; len<=n; len++){
        for(int l=1; l+len-1<=n; l++){
            int r = l+len-1;
            if((n-len)%2 == 0){
                dp[l][r] = max(niz[l] + dp[l+1][r], niz[r] + dp[l][r-1]);
            }
            else{
                dp[l][r] = min(-niz[l] + dp[l+1][r], -niz[r] + dp[l][r-1]);
            }
        }
    }
    cout << dp[1][n];
    return 0;
}


Measured memory_bytes: 70016
#include <cstdio>
#include <string>
#include <map>
#include <iostream>
#define MAX 12
int main()
{
    int N;
    char query[MAX], tmp[MAX];
    std::scanf("%d", &N);
    std::map<std::string, bool> m;
    decltype(m)::iterator it;
    for (int i = 0; i < N; i++) {
        std::scanf("%s %s", query, tmp);
        if (query[0] == 'i') {
            m.insert({tmp, true});
        } else {
            (m.find(tmp) == m.end()) ? std::printf("no\n") : std::printf("yes\n");
        }

    }

    return 0;
}



Measured memory_bytes: 33252
x, y = gets.split.map(&:to_i)
z = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
flag = false
z.each do |g|
  flag = g.include?(x) && g.include?(y)
  break if flag
end
puts flag ? 'Yes' : 'No'

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] X = new int[M];
        for (int i = 0; i < X.length; ++i) {
            X[i] = sc.nextInt();
        }

        System.out.println(solve(N, X));

        sc.close();
    }

    static int solve(int N, int[] X) {
        X = Arrays.stream(X).boxed().sorted().mapToInt(x -> x).toArray();

        int[] X_ = X;
        return IntStream.range(0, X.length - 1).map(i -> X_[i + 1] - X_[i]).sorted().limit(Math.max(0, X.length - N))
                .sum();
    }
}

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

void main_()
{
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> sums;
    vector<int> Ns(N);
    iota(begin(Ns), end(Ns), 1);
    copy_if(
        begin(Ns), end(Ns),
        back_inserter(sums),
        [A, B](int n) {
            int n0 = n % 10;
            int n1 = (n / 10) % 10;
            int n2 = (n / 100) % 10;
            int n3 = (n / 1000) % 10;
            int n4 = (n / 10000) % 10;
            int sum = n0 + n1 + n2 + n3 + n4;
            return (A <= sum && sum <= B);
        });

    auto ans = accumulate(
        begin(sums), end(sums), 0);
    cout << ans << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define pb push_back
#define ins insert
#define sc second
#define fr first
#define endl "\n"
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

int n, a, b, c;
void solve(){
    cin >> n >> a >> b;
    if(a%n==0)c=1;
    else c = (n*((a/n)+1))<=b;
    
    cout<< (c?"OK":"NG")<<endl;
}
int main(){_
    solve();
    /*
    int t; cin >> t;
    while(t--){
        solve();
    }
    */
}

Measured memory_bytes: 3596
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
	string s;
	getline(cin, s);
	rep(i, s.size()) if ('a' <= s[i] && s[i] <= 'z') s[i] += 'A'-'a';
	cout << s << endl;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<double> p(n);
	vector<double> kitai(n),sum(n+1,0);
	rep(i,n){
		cin>>p[i];
		kitai[i]=(1+p[i])/2.0;
		sum[i+1]=sum[i]+kitai[i];
	}
	double ans=0;
	rep(i,n-k+1){
		double now=sum[i+k]-sum[i];
		//cout<<now<<endl;
		chmax(ans,now);
	}
	cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 4992
N = int(input())

S_list = []

for i in range(N):
    S_list.append(input())
    
import collections
c = collections.Counter(S_list)

max_num_of_occur = max(c.values())
most_common_list = []

for k,v in c.items():
    if v==max_num_of_occur:
        most_common_list.append(k)

NO_OUTPUT = [print(x) for x in sorted(most_common_list)]

Measured memory_bytes: 35980
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;
ll n,b[200005],a[200005],ans;
bool check(ll x){
    for(int i=1; i<=n; i++)a[i] = (b[i] <= x);
    ll ind1,ind2;
    ind1 = ind2 = (n + 1) / 2;
    while(ind1 > 1){
        if(a[ind1] == a[ind1 - 1] || a[ind2] == a[ind2 + 1])return a[ind1];
        ind1--;
        ind2++;
    }
    ll sh = a[(n + 1) / 2];
    if((n / 2) % 2 == 1){
        return (1 ^ sh);
    }
    return sh;
}
int main(){
    ios::sync_with_stdio(false);
    cin >> n;
    n *= 2;
    n--;
    for(int i=1; i<=n; i++){
        cin >> b[i];
    }
    ll l =1,r = n,mid;
    
    while(r >= l){
        mid = (l + r) / 2;
        if(check(mid)){
            r = mid - 1;
            ans = mid;
        }
        else {
            l = mid + 1;
        }
    }
    
    cout << ans << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 3328
//Zory-2018
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

namespace mine
{
	typedef long long ll;
	const int INF=0x3f3f3f3f;
	//#define pr pair<double,int>
	#define FR first
	#define SE second
	#define MP make_pair

	const int MAX_N=210;
	struct Nod{int x,y;}p[MAX_N];
	int cross(Nod a,Nod b) {return a.x*b.y-a.y*b.x;}
	const int MOD=998244353;
	bool v[MAX_N][MAX_N];
	int bin[MAX_N];
	void main()
	{
		bin[0]=1;for(int i=1;i<MAX_N;i++) bin[i]=bin[i-1]*2%MOD;

		int n;scanf("%d",&n);
		for(int i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y);

		int ans=bin[n]-1-n;//printf("ans=%d\n",ans);
		for(int a=1;a<=n;a++)
			for(int b=a+1;b<=n;b++)
			{
				int mi,mx;
				if(p[a].x==p[b].x) {if(p[a].y<p[b].y) mi=a,mx=b; else mi=b,mx=a;}
				else
				{
					if(p[a].x<p[b].x) mi=a,mx=b;
					else mi=b,mx=a;
				}

				int tot=2;
				for(int c=1;c<=n;c++) if(c!=a and c!=b)
				{
					if(cross(
						(Nod){p[a].x-p[b].x,p[a].y-p[b].y},
						(Nod){p[a].x-p[c].x,p[a].y-p[c].y})==0)
					{
						if(p[a].x==p[b].x)
						{
							if(p[c].y<p[mi].y) mi=c;
							else if(p[c].y>p[mx].y) mx=c;
						}
						else
						{
							if(p[c].x<p[mi].x) mi=c;
							else if(p[c].x>p[mx].x) mx=c;
						}

						tot++;
					}
				}
				if(v[mi][mx]) continue;
				v[mi][mx]=1;
				ans-=bin[tot]-tot-1;
				ans%=MOD;
				//printf("(%d,%d,%d,%d)=%d\n",mi,mx,a,b,tot);
			}
		printf("%d",(ans+MOD)%MOD);
	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j, w, n, a[31], b[31], num[31], buf;

	for(i=1; i<=30; i++)
		num[i] = i;

	scanf("%d", &w);
	scanf("%d", &n);

	for(i=1; i<=n; i++)
		scanf("%d,%d", &a[i], &b[i]);

	for(i=1; i<=n; i++){
		buf = num[a[i]];
		num[a[i]] = num[b[i]];
		num[b[i]] = buf;
	}

	for(i=1; i<=w; i++)
		printf("%d\n", num[i]);

	return 0;
}

Measured memory_bytes: 596
M = 998244353

n = int(input())
xs = [0] * n
ds = [0] * n
for i in range(n):
    x, d = (int(c) for c in input().split())
    ds[i] = d
    xs[i] = (x,i)

import sys
sys.setrecursionlimit(max(1000,n))

xs.sort()
index = [x[1] for x in xs]
xs = [x[0] for x in xs]
ds = [ds[ind] for ind in index]

def _sub(i):
    # 深さ優先探索しながらi番目以下の組み合わせと、次に調べるべき番号を返す
    if i==n-1:
        return 2, n
    res = 1
    ind = i+1
    while True:
        if (xs[i]+ds[i] <= xs[ind]):
            break
        o, ind = _sub(ind)
        res *= o
        res %= M
        if ind>=n:
            break
    return res+1, ind
out = []
done = 0
while True:
    o, done = _sub(done)
    out.append(o)
    if done>=n:
        break
result = 1
for o in out:
    result *= o
    result %= M
print(result)

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int64_t> ACC(N + 1, 0);
  for (int i = 0; i < N; i++) {
    ACC[i + 1] = ACC[i] + A[i];
  }
  vector<int64_t> B;
  for (int i = 0; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      B.emplace_back(ACC[j] - ACC[i]);
    }
  }
  auto count = [&](int64_t msk) {
    int res = 0;
    for (auto b : B) {
      if ((b & msk) == msk) res++;
    }
    return res;
  };
  int64_t res = 0;
  for (int bit = 60; bit > -1; bit--) {
    if (count(res | (INT64_C(1) << bit)) >= K) res |= (INT64_C(1) << bit);
  }
  cout << res << '\n';
  return 0;
}


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

int main(){
    int x_min(0),x_max(0),y_min(0),y_max(0);
    int x,y; cin >> x >> y;
    int side[35];
    side[0] = 1; side[1] = 1;

    for(int i=2; i<35; i++){
        side[i] = side[i-1] + side[i-2];
    }

    int i(1);
    while(1){
        if(x_min<=x && x<=x_max && y_min<=y && y<=y_max){
            if(i%3==0)
                cout << 3 << endl;
            else
                cout << i%3 << endl;

            break;
        }else{
            switch(i%4){
                case 0:
                    y_min -= side[i];
                    break;

                case 1:
                    x_max += side[i];
                    break;

                case 2:
                    y_max += side[i];
                    break;

                case 3:
                    x_min -= side[i];
                    break;
                
                default:
                    break;
            }
        }
        i++;
    }
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		if(n < 1000) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}
	}
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int X, A, B;

        X = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();

        if (B <= A) {
            out.println("delicious");
        } else if (B > A + X) {
            out.println("dangerous");
        } else {
            out.println("safe");
        }
        
        
        sc.close();
    }
}

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

int main(){
	int v,n, i, j;
	int A[100];

	cin>>n;
	for(int i=0; i<n; i++) cin>>A[i];
	for(int ii=0; ii<n; ii++){
			if(ii>0) cout<<" ";
			cout<<A[ii];
		}
	cout<<"\n";
	for(i=1; i<n; i++){
		
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		for(int ii=0; ii<n; ii++){
			if(ii>0) cout<<" ";
			cout<<A[ii];
		}
		cout<<"\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 3088
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <deque>
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;

int main(void){
  string s;
  cin>>s;
  if(s.substr(0,4)=="YAKI") cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

sum_a1 = [A1[0]]
sum_a2 = [A2[-1]]
for i in range(1, N):
    x1 = sum_a1[i-1] + A1[i]
    sum_a1.append(x1)

    x2 = sum_a2[i-1] + A2[-1 * i - 1]
    sum_a2.append(x2)

# print(sum_a1, sum_a2)

ans = 0
for i in range(N):
    # print(sum_a1[i], sum_a2[N-i-1])
    x = sum_a1[i] + sum_a2[N-i-1]
    ans = max(ans, x)

print(ans)


Measured memory_bytes: 3064
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
x=int(input())
p=100
years=0
while(p<x):
    p+=int(p/100)
    years+=1
print(years)


Measured memory_bytes: 64952
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""

def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

_INPUT = """\
1000 15 80
"""

def main(*, input=input):
    sr = lambda: input()
    ir = lambda: int(sr())
    lr = lambda: list(map(int, sr().split()))

    d,t,s = lr()
    if s*t >= d:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    import io, sys

    # sys.stdin = io.StringIO(_INPUT)

    main()

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

int main(){
    int n,W;
    cin>>n>>W;
    ll value[n],weight[n];
    
    for(int i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }

    ll **dp=new ll*[n+1];
    for(int i=0;i<=n;i++){
        dp[i]=new ll[W+1];
    }
    
    for(int i=0;i<=n;i++)   dp[i][0]=0;
    for(int i=0;i<=W;i++)   dp[0][i]=0;

    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=W;j++){
            
                if(j>=weight[i-1]){
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i-1]] + value[i-1]);
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            
        }
    }
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79488