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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A, long long S)
{
    if (H - S <= 0)
    {
        cout << YES << endl;
    }
    else
    {
        cout << NO << endl;
    }
}

int main()
{
    long long H;
    scanf("%lld", &H);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    long long S = 0;
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
        S += A[i];
    }
    solve(H, N, std::move(A), S);
    return 0;
}


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

const int N = 100010;

struct edge {
    int to, next;
} e[N * 2];

int head[N], ecnt, ind[N];

inline void adde(int from, int to) {
    e[++ecnt] = (edge){ to, head[from] }, head[from] = ecnt;
    e[++ecnt] = (edge){ from, head[to] }, head[to] = ecnt;
    ind[from]++, ind[to]++;
}

int check(int u, int rt, int f) {
    if (u == rt) return 1;
    if (ind[u] == 4) return 0;
    for (int i = head[u]; i; i = e[i].next)
        if (e[i].to != f && check(e[i].to, rt, u)) return 1;
    return 0;
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 1, a, b; i <= m; i++)
        scanf("%d%d", &a, &b), adde(a, b);
    for (int i = 1; i <= n; i++) if (ind[i] & 1) return puts("No"), 0;
    int A = 0, B = 0, ct = 0;
    for (int i = 1; i <= n; i++) {
        if (ind[i] > 4) return puts("Yes"), 0;
        if (ind[i] == 4) ct++, A ? B = i : A = i;
    } 
    if (ct < 2) return puts("No"), 0;
    if (ct > 2) return puts("Yes"), 0;
    int ans = 0;
    for (int i = head[A]; i; i = e[i].next)
        ans += check(e[i].to, A, A);
    for (int i = head[B]; i; i = e[i].next)
        ans += check(e[i].to, B, B);
    puts(ans >= 2 ? "Yes" : "No");
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B,C,D;
  cin >> A>> B >> C >> D;
  if(A+B == C+D) cout << "Balanced" << endl;
  else if(A+B > C+D) cout << "Left" << endl;
  else cout << "Right" << endl;

  return 0;
    

}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();

  	
  	cin>>n>>k;
  	// int a[n+1];
  	// fo(i,n+1) a[i]=k-i;
  	// parray(a,n+1);


 	fo(i,n+1) fo(j,n+1){
 		if( k-j-i>=0 and k-i-j <=n) c++;
 	}

   	cout<<c<<endl;

 	return 0;

   }

Measured memory_bytes: 3652
# ABC143-E

import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,M,L = MI()

inf = 10**12
cost = [[inf]*(N+1) for _ in range(N+1)]  # cost[i][j] = 町iから町jへ移動するのにかかる燃料の総和

# WarshallFloyd法

for i in range(M):
    a,b,c = MI()
    cost[a][b] = c
    cost[b][a] = c

for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            cost[i][j] = min(cost[i][j],cost[i][k]+cost[k][j])

ans = [[inf]*(N+1) for _ in range(N+1)]  # ans[i][j] = 町iから町jへ移動するために必要な燃料補給の回数+1

# WarshallFloyd法、再び

for i in range(N+1):
    for j in range(N+1):
        if cost[i][j] <= L:
            ans[i][j] = 1

for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            ans[i][j] = min(ans[i][j],ans[i][k]+ans[k][j])

Q = I()
for i in range(Q):
    s,t = MI()
    if ans[s][t] == inf:
        print(-1)
        continue
    print(ans[s][t]-1)


Measured memory_bytes: 78636
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<sstream>
#include<climits>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	string a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int m;
	cin>>m;
	string b[m];
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	map<string,int> ac,bc;
	for(int i=0;i<n;i++){
		ac[a[i]]++;
	}
	for(int i=0;i<m;i++){
		bc[b[i]]++;
	}
	int ans=-1000000000;
	for(int i=0;i<n;i++){
		ans=max(ans,ac[a[i]]-bc[a[i]]);
	}
	if(ans<0){
		cout<<"0";
	}
	else{
		cout<<ans;
	}
	return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n,m,q,cap,coe,con,ans[N],cnt,val[N],cur,nowl,nowr,vall,valr; // coefficient, constant
vector<int> tmp;
struct data {
  int t,tp,p,id;
  bool operator < (const data& a) const {
    if (t != a.t) return t < a.t;
    return tp > a.tp;
  }
} dat[N];
void pass(int tms) {
  con -= tms - cur;
  cur = tms;
  if (vall * coe + con <= 0) vall = - con / coe;
  if (valr * coe + con <= 0) valr = - con / coe;
  if (coe > 0) {
    for ( ; val[nowl] * coe + con <= 0 && nowl <= nowr ; ++ nowl)
      vall = - con / coe;
  }
  else {
    for ( ; val[nowr] * coe + con <= 0 && nowr >= nowl ; -- nowr)
      valr = - con / coe;
  }
}
void turnover() {
  coe = -coe;
  con = cap - con;
}
int query(int p) {
  int ret;
  if (p < nowl) ret = vall * coe + con;
  else if (p > nowr) ret = valr * coe + con;
  else ret = val[p] * coe + con;
  if (coe < 0) ret = cap - ret;
  return ret;
}
int main() {
  int x,y;
  scanf("%d",&cap);
  scanf("%d",&n);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%d",&x);
    dat[++cnt] = (data) {x,0,0,0};
  }
  scanf("%d",&q);
  for (int i = 1 ; i <= q ; ++ i) {
    scanf("%d%d",&x,&y);
    tmp.push_back(y);
    dat[++cnt] = (data) {x,1,y,i};
  }
  sort(tmp.begin(),tmp.end());
  tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
  for (int i = 1 ; i <= q ; ++ i)
    dat[i + n].p = lower_bound(tmp.begin(),tmp.end(),dat[i+n].p) - tmp.begin() + 1;
  sort(dat+1,dat+cnt+1);
  for (int i = 1 ; i <= (int)tmp.size() ; ++ i)
    val[i] = tmp[i-1];
  cur = 0;
  nowl = 1, nowr = tmp.size();
  m = tmp.size();
  coe = 1;
  for (int i = 1 ; i <= cnt ; ++ i) {
    pass(dat[i].t);
    if (dat[i].tp == 0) turnover();
    else ans[dat[i].id] = query(dat[i].p);
  }
  for (int i = 1 ; i <= q ; ++ i)
    printf("%d\n",ans[i]);
  return 0;
}


Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,a,i;
  vector<int> g(100000,0);
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a;
    g.at(a)++;
  }
  bool im=false;
  for (i=1-n%2;i<n-1;i+=2) if ((i==0&&g.at(i)!=1)||(i!=0&&g.at(i)!=2)){
    im=true;
    break;
  }
  if (im){
    cout << 0 << endl;
    return 0;
  }
  
  const int mod=1000000007;
  int k=n/2;
  long int ans=1;
  for (i=0;i<k;i++) ans=(ans*2)%mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

int main()
{
	int A, B, C, X;
	int i, j, k,cnt;
	cnt = 0;
		
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &X);

	for (i = 0; i <= A; i++) {
		for (j = 0; j <= B; j++) {
			for (k = 0; k <= C ; k++) {
				int Y;
				Y = 500 * i + 100 * j + 50 * k;
				if (X == Y) {
					//printf("%d%d%d %d", i, j, k, Y);
					cnt++;
				}

			}
		}
	}

	printf("%d", cnt);


}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int b,Max=0,Min=0,sum0=0,sum=0;
			for(int i=0;i<N-1;i++) {
				if(i==0) {
					Min = sc.nextInt();
					Max = sc.nextInt();
					sum0 = Max - Min;
					if(Min > Max)
						Min = Max;
				}else{ // i != 0
					b = sc.nextInt();
					sum = b - Min;
						if(sum > sum0)
							sum0 = sum;
						if(b < Min)
							Min = b;
				}
			
			}
			System.out.println(sum0);
			sc.close();
	}

}


Measured memory_bytes: 98188
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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 T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}
ll H,W;
string S[406];
ll Bc,Wc,chek[405][406];
vector<pair<ll,ll>> V;
ll ans=0;

void bfs(ll i,ll j){
  chek[i][j]=1;
  if(S[i][j]=='.'){
    Wc++;
  }
  else{
    Bc++;
  }
  if(i>0 && S[i-1][j]!=S[i][j] && chek[i-1][j]==0){
    bfs(i-1,j);
  }
  if(j>0 && S[i][j-1]!=S[i][j] && chek[i][j-1]==0){
    bfs(i,j-1);
  }
  if(i<H-1 && S[i+1][j]!=S[i][j] && chek[i+1][j]==0){
    bfs(i+1,j);
  }
  if(j<W-1 && S[i][j+1]!=S[i][j] && chek[i][j+1]==0){
    bfs(i,j+1);
  }
}

int main() {
  cin >> H >> W;
  rep(i,H){
    cin>>S[i];
  }
  rep(i,H){
    rep(j,W){
      if(chek[i][j]==0){
        Bc=0;Wc=0;
        bfs(i,j);
        ans+=Bc*Wc;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 16640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

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

    vector<pair<int, int>> reds(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        reds[i] = {a, b};
    }
    sort(reds.begin(), reds.end());

    vector<pair<int, int>> blues(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        blues[i] = {a, b};
    }
    sort(blues.begin(), blues.end());

    int cnt = 0;
    vector<bool> used_red(N, false);

    for (int bi = 0; bi < N; bi++) {
        pair<int, int> target = {-1, -1};
        int target_ri = -1;

        for (int ri = 0; ri < N; ri++) {
            if (used_red[ri]) {
                continue;
            }
            auto blue = blues[bi];
            auto red = reds[ri];
            if (red.first < blue.first && red.second < blue.second) {
                if (red.second > target.second) {
                    target = red;
                    target_ri = ri;
                }
            }
        }

        if (target_ri != -1) {
            cnt++;
            used_red[target_ri] = true;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
import sys


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


def main():
    X,K,D =map(int,input().split())
    ans =10**19
    if X >= K*D:
        print(X-K*D)
    elif -X>= K*D:
        print(-X - K*D)

    else:
        X =abs(X)
        c =X//D
        if (K-c)%2  ==0:
            print(X-c*D)
        else:
            print(D*(c+1)-X)








if __name__ == "__main__":
    main()


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

int main(){

  long long N, b, i;
  cin>>N;
  map<long long, long long> B;
  
  
  for(i=0; i<N; i++){
    cin>>b;
    B[b]++;
  }
  
  long long mx1=0, mx2=0;
  for(auto p : B){
    if(p.second>=4){
      if(mx1<p.first){
        mx1 = p.first;
        mx2 = mx1;
      }else if(mx2<p.first){
        mx2 = p.first;  
      }
    }else if(p.second>=2){
      if(mx1<p.first){
        mx2 = mx1;
        mx1 = p.first;
      }else if(mx2<p.first){
        mx2 = p.first;
      }
    }
  }
  cout << mx1*mx2 << endl;
  return 0;
}

Measured memory_bytes: 9844
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, K = map(int, readline().split())

list_ = [0] * N
for _ in range(K):
    _ = readline()
    A = list(map(int, readline().split()))
    for a in A:
        list_[a-1] += 1

ans = 0
for okashi in list_:
    if okashi == 0:
        ans += 1

print(ans)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    char X, Y;
    cin >> X >> Y;
    if(X == Y) cout << '=';
    else if(X > Y) cout << '>';
    else cout << '<';
    cout << endl;
    return 0;
}


Measured memory_bytes: 3604
e=1
while e==1:
    n = int ( input() )
    if n==0:
        break
    a = input().split(" ")
    for j in  range(n):
        a[j] = int( a[j])
    a.sort()

    sa=11451419

    for i in range ( n-1 ):
        sa = min (sa ,a[i+1] - a[i])

    print(sa)


Measured memory_bytes: 5620
/*ex5_3
  kt125 */

#include<stdio.h>
#define SIZE 100

int main(void){
    int height, width, //縦、横
        count, //'.'をカウントする変数
        i=0, j=0, k=0, //カウンタ変数
        row_del_num, //消去する行の数
        col_del_num, //消去する列の数
        height_ans, //答えとなる配列の縦の長さ
        width_ans, //答えをなる配列の横の長さ
    	col_del[SIZE], //消去する列の番号を記憶する配列
        row_del[SIZE];  //消去する行の番号を記憶する配列
  
    char board[SIZE][SIZE], //与えられたマス目の配列
         ans_row[SIZE * SIZE], //答えとなるマス目の文字を一列に並べた配列
    	 ans[SIZE][SIZE];  //答えとなる配列
  
    scanf("%d %d", &height, &width);

    for(i=0; i < height;i++){
        for (j=0; j < width; j++){
            scanf(" %c", &board[i][j]);
        }  
    }

    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if(board[i][j]== '.'){
                count++;
            }
        }
        if (count == width){ //i行が全て'.'だった場合
            row_del[k] = i; //配列の最初から順に用いるためにkを使う
            k++;
        }
        count = 0; //各行ごとにリセット
    }  
    row_del_num = k; //消去する行の数

    k = 0; //リセット

    for(i=0; i < width; i++){
        for(j=0; j < height; j++){
            if(board[j][i]== '.'){
                count++;
            }
        }
        if (count == height){ //i列が全て'.'だった場合
            col_del[k] = i;
            k++;
        }
      	count = 0; //各列ごとにリセット
    } 

  	col_del_num = k; //消去する列の数
    
    for(i=0; i < row_del_num; i++){
        for (j=0; j < width; j++){
            board[row_del[i]][j] = 'o'; //消去する行の文字を'o'に置き換える
        }
    }
    for(i=0; i < col_del_num; i++){
        for (j=0; j < height; j++){
            board[j][col_del[i]] = 'o'; //消去する列の文字を'o'に置き換える
        }
    }
  	k = 0; // リセット
  	
    for(i=0; i < height; i++){
        for(j=0; j < width; j++){
            if (board[i][j] != 'o'){ //'o'を飛ばす
                ans_row[k] = board[i][j];
              	k++;
            }
        }
    }

	height_ans = height - row_del_num; //答えとなる配列の縦の長さ
	width_ans = width - col_del_num; //答えとなる配列の横の長さ

	for(i=0; i < height_ans; i++){
        for(j=0; j < width_ans;j++){
            ans[i][j] = ans_row[j + i * (width_ans)]; //一次元の配列をマス目に合うように二次元に直す
        }
    }
  
	for(i=0; i < height_ans;i++){
        for (j=0; j < width_ans; j++){
            printf("%c", ans[i][j]); //マス目をprint
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
   long long a,b,k;
   scanf("%lld %lld %lld",&a,&b,&k);

   if(a>=k){
      a-=k;
   }else if(a+b>=k){
      k-=a;
      a=0;
      b-=k;
   }else{
      a=0;
      b=0;
   }
      printf("%lld %lld",a,b);
   return 0;
   
}


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

int main() {
  int N; cin >> N;
  int A[N]; for (int i = 0; i < N; i++) cin >> A[i];
  long sum = 0, prev_h = 0;
  for (int i = 0; i < N; i++) {
    long stool_h = max(0L, prev_h - A[i]);
    sum += stool_h;
    prev_h = stool_h + A[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

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

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


int main(){
    ll N, M; cin >> N >> M;
    vb path1(N + 1, false); vb path2(N + 1, false);
    REP(i, M){
        ll a, b; cin >> a >> b;
        if(a == 1) path1[b] = true;
        else if(b == N) path2[a] = true;
    }
    
    bool ok = false;
    FOR(i, 2, N + 1){
        if(path1[i] && path2[i]){
            ok = true; break;
        }
    }
    
    cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endstr;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 魔力配列のサイズ */
	private static final int N = 10;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			int[][] c = new int[N][N];
			IntStream.range(0, N).forEach(i -> IntStream.range(0, N).forEach(j -> c[i][j] = scanner.nextInt()));
			int[][] a = new int[h][w];
			IntStream.range(0, h).forEach(i -> IntStream.range(0, w).forEach(j -> a[i][j] = scanner.nextInt()));
			// 魔力の最短ルートの再計算
			warshallFloyd(c, N);
			System.out.println(IntStream.range(0, h)
					.map(i -> IntStream.range(0, w).filter(j -> a[i][j] != -1).map(j -> c[a[i][j]][1]).sum()).sum());
		}
	}

	/**
	 * ノード関の移動コストを計算する
	 * 
	 * @param costs ノード関の移動コストの配列
	 * @param n     ノードの総数
	 */
	private static void warshallFloyd(int[][] costs, int n) {
		IntStream.range(0, n).forEach(k -> IntStream.range(0, n).forEach(j -> IntStream.range(0, n)
				.forEach(i -> costs[i][j] = Math.min(costs[i][j], costs[i][k] + costs[k][j]))));
	}
}


Measured memory_bytes: 47552
//#pragma GCC optimize ("Ofast")
#include"bits/stdc++.h"
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(it,vv) for(auto &it : vv)
#define prep(it,vv) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n; cin >> n;
    map<string, int>mm;
    int xx = 0;
    rep(i, n)
    {
        string s; cin >> s;
        mm[s]++;
        xx = max(mm[s], xx);
    }
    vector<string>vv;
    for (auto it : mm)
    {
        if (it.ss == xx) vv.em(it.ff);
    }
    sort(all(vv));
    for (auto it : vv) cout << it << endll;
}

Measured memory_bytes: 27208
n = int(input())
s1 = input()
s2 = input()
mod = 1000000007

if n == 1 or s1[0] != s1[1]:
    ans = 3
    ind = 1
    mae = 1
else:
    ans = 6
    ind = 2
    mae = 2

while ind < n-1:
    if s1[ind] == s1[ind + 1]:
        if mae == 2:
            ans = (ans * 3) % mod
        else:
            ans = (ans * 2) % mod
        ind += 2
        mae = 2
    else:
        if mae == 2:
            ans = (ans * 1) % mod
        else:
            ans = (ans * 2) % mod
        ind += 1
        mae = 1

if ind == n-1:
    if mae == 2:
        ans = (ans * 1) % mod
    else:
        ans = (ans * 2) % mod

print(ans % mod)


Measured memory_bytes: 3316
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>

using std::cout;
using std::endl;
using std::cin;
using std::vector;
using std::string;

int gcd(int x, int y) {
  return (x % y)? gcd(y, x % y): y;
}

int main(){
  int n;
  cin >> n;
  string tmp;
  vector<string> vec;
  for(int i=0;i<n;i++){
    cin >> tmp;
    vec.push_back(tmp);
  }
  std::sort(vec.begin(), vec.end());
  vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
  cout << vec.size() << endl;
}


Measured memory_bytes: 11664
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *                      # ll = deepcopy(l)
from heapq import *                     # heappush(hp,x)
from string import *                    # alpha = ascii_lowercase
from random import *                    # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *                    # bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin                   # bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize                 # minn = -maxsize
from operator import *                  # d = sorted(d.items(), key=itemgetter(1))
from itertools import *                 # pre = [0] + list(accumulate(l))
from decimal import Decimal             # a = Decimal(a)    # use this for math questions
from collections import Counter         # d = dict(Counter(l))
from collections import defaultdict     # d = defaultdict(list)

'''

'''

def solve(l,d):
    n = len(l)
    ans = 0
    for x,y in l:
        if(sqrt(x**2 + y**2) <= d):
            ans += 1
    return ans
    

N,D = list(map(int, stdin.readline().rstrip().split()))
L = []
for i in range(N):
    l = list(map(int, stdin.readline().rstrip().split()))
    L.append(l)
ans = solve(L,D)
print(ans)



Measured memory_bytes: 110120
n=int(input())
d=list(map(int,input().split()))	
m=int(input())
t=list(map(int,input().split()))	
data={}
for i in range(n):
    if d[i] not in data:
        data[d[i]]=1
    else:
        data[d[i]]+=1
key=0
for i in range(m):
    if t[i] not in data:
        key=1
        break
    else:
        if data[t[i]]>0:
            data[t[i]]-=1
        else:
            key=1
            break
if key==0:
    print("YES")
else:
    print("NO")










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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	vector<vector<int>> A(N,vector<int>(N)),S(N+1,vector<int>(N+1,0));
	REP(i,N){
		REP(j,N){
			A[i][j] = in();
			S[i+1][j+1] = A[i][j];
		}
	}
	REP(i,N){
		for(int j=1;j<N;j++){
			S[i+1][j+1] = A[i][j]+S[i+1][j];
		}
	}
	for(int i=1;i<N+1;i++){
		REP(j,N+1){
			S[i][j] += S[i-1][j];
		}
	}

	int MV=-(1<<30);
	for(int i=0;i<N+1;i++){
		for(int v=i+1;v<N+1;v++){
			for(int j=0;j<N+1;j++){
				for(int u=j+1;u<N+1;u++){
					int sum = S[i][j]+S[v][u]-S[i][u]-S[v][j];
					MV = max(MV,sum);
				}
			}
		}
	}

	out(MV);
	return 0;
}


Measured memory_bytes: 3232
/* 
	今日も一日がんばるぞい
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< '\n'

int main(){
    int n;
    cin >> n;
    int x[n],y[n];
    REP(i,n) cin >> x[i] >> y[i];
    
    double ans = 0;
    vector<int> v(n);
    REP(i,n) v[i] = i;
    int count = 0;
    do{
        double dis = 0;
        for(int i=0;i<n-1;i++){
            double dx = x[v[i]] - x[v[i+1]];
            double dy = y[v[i]] - y[v[i+1]];
            dis += sqrt(dx*dx + dy*dy);
        }
        count++;
        ans += dis;
    }while(next_permutation(v.begin(),v.end()));
    ans /= count;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k=0;
    int a=sc.nextInt();
    int b=sc.nextInt();
    
    if(a%2 != b%2){
      System.out.println("IMPOSSIBLE");
    }else{
      k=(a+b)/2;
      System.out.println(k);
    }
  }
}
                   
    
  

Measured memory_bytes: 23252
from fractions import gcd
import math
a,b,c,d = map(int,input().split())

if c == 1 or d == 1:
    print(0)
elif a == b:
    if a%c == 0 or a%d == 0:
        print(0)
    else:
        print(1)
else:
    an1 = (b//c)
    an2 = ((a-1)//c)
    an3 = (b//d)
    an4 = ((a-1)//d) 
    gcd = round(c * d / gcd(c, d))
    an5 = (b//gcd)
    an6 = ((a-1)//gcd)
    if c == d:
        an = an1-an2
    else:
        an = an1-an2 + an3-an4 -(an5-an6)
    print((b-a+1)-an)
   
        

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int MOD = 1000000007;

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

    ll ans = 0, two = 1;
    for(int i = 0; i < 60; i++){
        ll zero = 0, one = 0;
        for(int j = 0; j < n; j++){
            if(a[j] & (1LL << i)) one++;
            else zero++;
        }
        ll tmp = (zero * one) % MOD * two % MOD;
        ans = (ans + tmp) % MOD;
        two = (two * 2) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int flag=0;
    while(n)
    {
        if(n%10==7)
        {
            flag=1;
            break;
        }
        n/=10;
    }
    if(flag)cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

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

void solve() {
   int n;
   cin>>n;
   int a[3];
   int dp[n+1][3];
   dp[0][0] = 0;
   dp[0][1] = 0;
   dp[0][2] = 0;
   for(int i=1; i<=n; i++) {
        for(int j=0; j<3; j++) {
            cin>>a[j];
            if(j == 0) {
                dp[i][j] = max(dp[i-1][j+1], dp[i-1][j+2])+a[0];
            }
            else if(j == 1) {
                dp[i][j] = max(dp[i-1][j-1], dp[i-1][j+1])+a[1];
            }
            else {
                dp[i][j] = max(dp[i-1][j-1], dp[i-1][j-2])+a[2];
            }
        }
   }
   cout<<max(max(dp[n][0], dp[n][1]), dp[n][2]);


}

 
int main() {
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error", "w", stderr);*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    // int t;
    // cin>>t;
    // while(t--) {
        solve();
    // }
}

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

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

    ll n;
    cin >> n;
    int ans = 0;

    auto get_low = [&](ll cnt){
        // cnt is the number of factors
        ll lo = 0;
        ll hi = cnt+1;
        while( lo < hi ){
            ll mid = (lo) + (hi-lo)/2;
            if( mid * (mid+1) <= 2 * cnt ){
                lo = mid + 1;
            }else{
                hi = mid;
            }
        }
        return lo-1;
    };
    int lim = sqrt(n);
    for(int i=2; i<=lim; ++i){
       if( (n % i) == 0 ){
           int cnt = 0;
           while( (n%i) == 0 ){
               n /= i;
               ++cnt;
           }
           ans += get_low(cnt);
       } 
    }
    if( n != 1 ){
        ans += get_low(1);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    int n;
    cin >> n;
    vector<int> nums = {3, 5, 7};
    rep (i, 8) {
        vector<int> cp = nums;
        for (int e: nums) {
            if (e < pow(10, i)) {
                continue;
            }
            int p = e * 10;
            for (int j = 3; j < 8; j += 2) {
                cp.push_back(p + j);
            }
        }
        nums = cp;
    }
    int ctr = 0;
    for (auto num: nums) {
        if (num > n) {
            continue;
        }
        bool three, five, seven;
        three = five = seven = false;
        while (num > 0) {
            int d = num % 10;
            switch (d) {
                case 3:
                    three = true;
                    break;
                case 5:
                    five = true;
                    break;
                case 7:
                    seven = true;
                    break;
            }
            num /= 10;
        }
        if (three && five && seven) {
            ctr++;
        }
    }
    cout << ctr << endl;
}

Measured memory_bytes: 512
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <math.h> 

using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i, n) for (i = 0; i < n; i++)
#define FOR(i, a, b) for (i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())

double pi = 3.141592653589793;

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

int main()
{

    std::cin.tie(0);

    int a,b,c;
    int tmp,res;
    cin >> a >> b ;



    cout << a*b << endl;

    return 0;

}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class UnionFind {
  vector<int> par, sz;
public:
  UnionFind(int n) : par(n), sz(n, 1) {
    for (int i = 0; i < n; i++)
      par[i] = i;
  }
  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sz[root(x)];
  }
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (sz[x] >= sz[y]) {
      sz[x] += sz[y];
      par[y] = x;
    } else {
      sz[y] += sz[x];
      par[x] = y;
    }
    return true;
  }
};

using P = pair<int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> mp;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    a[x] = y;
    mp[a[x]] = i;
  }
  UnionFind uf(n);
  set<int> st;
  st.insert(a[0]);
  for (int i = 1; i < n; i++) {
    priority_queue<int> que;
    que.push(a[i]);
    st.insert(a[i]);
    for (auto e : st) {
      if (e >= a[i])
        break;
      uf.unite(e, a[i]);
      que.push(e);
    }
    while (que.size() > 1) {
      int num = que.top();
      que.pop();
      st.erase(num);
    }
  }
  vector<int> res(n);
  rep(i, n)
    res[mp[a[i]]] = uf.size(a[i]);
  rep(i, n)
    cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 17216
//2018.10.24

#include <iostream>
using namespace std;

int main() {

    int n;
    cin >> n;
    int i=n;
    while(1){
        if(i/100 == (i%100)/10 && i/100 ==  i%10) {
            break;
        }
        i++;
    }

    cout << i << endl;

}


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

struct asumisu {
	int X, L;
};

int tomatu(const void* x, const void* y) {
	struct asumisu a = *(const struct asumisu*)x, b = *(const struct asumisu*)y;
	int aa = a.X + a.L, bb = b.X + b.L;
	return aa < bb ? -1 : aa > bb;
}

int N;
struct asumisu kugyu[114514];

int main(void) {
	int i;
	int sumipe = INT_MIN;
	int kitaeri = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &kugyu[i].X, &kugyu[i].L) != 2) return 1;
	}
	qsort(kugyu, N, sizeof(*kugyu), tomatu);
	for (i = 0; i < N; i++) {
		int hidari = kugyu[i].X - kugyu[i].L, migi = kugyu[i].X + kugyu[i].L;
		if (sumipe <= hidari) {
			kitaeri++;
			sumipe = migi;
		}
	}
	printf("%d\n", kitaeri);
	return 0;
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  string S, T;
  cin >> S >> T;
  int N = S.size();
  string ans = "No";
  rep(i, N+1){
    if(S == T){
      ans = "Yes";
      break;
    }
    S = S[N-1] + S;
    if(S.substr(0,N) == T){
      ans = "Yes";
      break;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;

class Counter<T> extends TreeMap<T,Long>{
    public Counter(){
        super();
    }
    public Counter(List<T> list){
        super();
        for(T e: list) this.addOne(e);
    }
    public Long count(Object elm){
        return getOrDefault(elm,0L);
    }
    public void add(T elm, long amount){
        if(!this.containsKey(elm)) put(elm, amount);
        else replace(elm, get(elm)+amount);
        if(this.count(elm)==0) this.remove(elm);
    }
    public void addOne(T elm){
        this.add(elm, 1);
    }
    public void removeOne(T elm){
        this.add(elm, -1);
    }
    public void removeAll(T elm){
        this.add(elm, this.count(elm));
    }
    public static<T> Counter<T> merge(Counter<T> a, Counter<T> b){
        Counter<T> c = new Counter<>();
        for(T x: a.keySet()) c.add(x, a.count(x));
        for(T y: b.keySet()) c.add(y, b.count(y));
        return c;
    }
}
class MathLib{
    static long gcd(long a, long b){
        if(a<0) a = -a;
        if(b<0) b = -b;
        if(a>b){
            long t = a;
            a = b;
            b = t;
        }
        while(a>0){
            long r = b%a;
            b = a;
            a = r;            
        }
        return b;
    }
    
    static boolean isPrime(long N){
        if(N%2==0) return false;
        for(long i=3; i*i<=N; i+=2){
            if(N%i==0) return false;
        }
        return true;
    }
    static Counter<Long> factorize(long N){
        Counter<Long> ans = new Counter<>();
        while(N%2==0){
            ans.addOne(2L);
            N /= 2;
        }
        for(long i=3; i*i<=N; i+=2){
            while(N%i==0){
                ans.addOne(i);
                N /= i;
            }
        }
        if(N>1) ans.addOne(N);
        return ans;
    }
    static List<Integer> primeList(int max){
        boolean[] prime = new boolean[max+1];
        Arrays.fill(prime, true); prime[0]=false; prime[1]=false;
        ArrayList<Integer> list = new ArrayList<>();
        for(int n=2; n<=max; n++) if(prime[n]){
            list.add(n);
            if(n*n<=max) for(int m=2*n; m<=max; m+=n) prime[m]=false;
        }
        return list;
    }
}

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        System.out.println(MathLib.factorize(MathLib.gcd(A,B)).keySet().size()+1);
    }
}


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

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

    long long a[n + 1];
    long long b[n];

    for(int i = 0; i < n + 1; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];

    long long ans = 0;
    for(int i = 0; i < n; i++) {
        if(b[i] <= a[i]) ans += b[i];
        else if(b[i] <= a[i] + a[i + 1]) {
            ans += b[i];
            a[i + 1] = a[i + 1] - (b[i] - a[i]);
        } else {
            ans += a[i] + a[i + 1];
            a[i + 1] = 0;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k=1;
      int ans=0;
      for(int i=0;i<n;i++){
        int a = sc.nextInt();
        if(a==k){
          k++;
        }else{
          ans++;
        }
      }
      if(k==1){
        ans=-1;
      }
      System.out.println(ans);
    }
}

Measured memory_bytes: 59124
# C

import copy
n = int(input())
x = list(map(int, input().split()))
if n == 2:
    print(x[1])
    print(x[0])
else:
    temp = copy.copy(x)
    temp.sort()

    m = temp[int(n/2)-1]

    for i in range(n):
        if x[i] <= m:
            print(temp[int(n/2)])
        else:
            print(m)

Measured memory_bytes: 26528
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// 挿入ソート
func main() {

	// var num int
	// // fmt.Scanは自動で空白区切で読み込む
	// fmt.Scan(&num)
	// nums := make([]int, num)
	// for i := range nums {
	// 	fmt.Scan(&nums[i])
	// }
	scanner := bufio.NewScanner(os.Stdin)
	var num int
	scanner.Scan()
	num, _ = strconv.Atoi(scanner.Text())
	nums := make([]int, num)
	for i := range nums {
		scanner.Scan()
		nums[i], _ = strconv.Atoi(scanner.Text())
	}

	maxDiff := 1 - 10*10*10*10*10*10*10*10*10 - 1
	min := nums[0]

	for i := 1; i < num; i++ {
		diff := nums[i] - min
		if maxDiff < diff {
			maxDiff = diff
		}
		if nums[i] < min {
			min = nums[i]
		}
	}

	fmt.Println(maxDiff)
}



Measured memory_bytes: 5396
C = [list(map(int,input().split())) for _ in range(3)]

b = [0]*3
for i in range(3):
  b[i] = C[0][i]-0
a = [0]*3
for i in range(3):
  a[i] = C[i][0] - b[0]
ans = "Yes"
for i in range(3):
  for j in range(3):
    if(C[i][j] != a[i] + b[j]):
      ans = "No"
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
const int INF = 1e9;

int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    sort(all(h));
    int d = INF;
    rep(i,n-k+1){
        d = min(d, h[i+k-1]-h[i]);
    }
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 640
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int r, g, b, n; cin >> r >> g >> b >> n;

	LL ans = 0;
	for (int i = 0; i < n+1; i++) {
		for (int j = 0; j < n+1; j++) {
			LL k = n-r * i - j * g;


			if (k < 0)continue;

			if (k%b!=0)continue;

			ans++;
		}
	}

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

Measured memory_bytes: 256
import sys
     
def main():
    sinputl = sys.stdin.readline

    num_card, num_gate = [int(x) for x in sinputl().split()]
    input = [[int(x) for x in sinputl().split()] for _ in range(num_gate)]
   
    under_limit = [x[0] for x in input]
    over_limit = [x[1] for x in input]
     
    print(max(min(over_limit) - max(under_limit) + 1, 0))
     
     
if __name__ == "__main__":
    main()

Measured memory_bytes: 22848