akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll a, b;
  cin >> a >> b;
  if(a<=12) b/=2;
  if(a<=5) b=0;
  cout << b << newl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N, long long K, std::string S){
    REP(i, N) {
        if (i == K - 1) {
            char c = S[i] + 32;
            cout << c;
        }
        else cout << S[i];
    }
    cout << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    cin >> N;
    long long K;
    cin >> K;
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n;
    int i;
    int judge = 0;
    scanf("%d", &n);
    for(i=0;i<=25;i++){
        if((n-i*4)>=0 && (n-i*4)%7==0){
            judge = 1;
        }
    }
    if(judge==0) printf("No");
    else printf("Yes");

    return 0;
}

Measured memory_bytes: 128
n,x,m = map(int, input().split())
b = x%m
add = 0

# nがm以下なら全部足せば良い
ans = 0
if n <= m:
    for i in range(n):
        ans += b    
        b = pow(b,2,m)
    print(ans)
    exit()

# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
    cnt += 1

# 位数と初期値を出す
s = set()
tmp = 0
for i in range(m):
    if i < cnt:
        add += b
        tmp = b
    else:
        s.add(b)
    b = pow(b, 2, m)

# cnt以降、和*位数+残りの和で計算
rest = (n-cnt)%len(s)
div = (n-cnt)//len(s)

rep = []
for i in range(len(s)):
    tmp = pow(tmp, 2, m)
    rep.append(tmp)

ans = add + sum(rep)*div + sum(rep[:rest])
print(ans)

Measured memory_bytes: 14516
#include <bits/stdc++.h>
#define MAX 10000007
#define INF 1000000000000000000
#define PI acos(-1)
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cout<<x<<endl;
#define endl "\n"
#define MEM(a,x) memset(a,x,sizeof(a))

using namespace std;
typedef long long ll ;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<long long,null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
*/
/*
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b)
{
    return (a.second<b.second);
}
*/
int ara[MAX];
int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.tie(NULL);
    int n;
    cin>>n;

    for(int i=0;i<n;i++)
        cin>>ara[i];

    int ans=__gcd(ara[0],ara[1]);

    for(int i=2;i<n;i++)
        ans=__gcd(ans,ara[i]);

    cout<<ans<<endl;



    return 0;
}


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

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      int count = 0;

      if (a==b&&a==c) {
        System.out.println(1);
        System.exit(0);
      }

      if(a!=b){
        count++;
      }
      if(a!=c){
        count++;
      }
      if (b!=c) {
        count++;
      }
      System.out.println(count);

  }
}


Measured memory_bytes: 21716
s=require('fs').readFileSync('/dev/stdin','utf8').split(' ').map(n=>n|0)
c=0
for(i=0;++i<=s[0];s[1]<=a&&a<=s[2]&&(c+=i))a=(i+'').split('').map(n=>n|0).reduce((a,b)=>a+b)
console.log(c)

Measured memory_bytes: 10856
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+1;

vector<int> v(N, 0);
vector<int> memo(N, -1);

int cost(int pos, int n, int x){
    if (memo[pos]!=-1) return memo[pos];
    else if (pos == n) return 0;
    else {
        int min_cost = INT_MAX;
        int curr_cost = 0;
        for (int k=pos+1; k<=min(n, pos+x); k++){
            curr_cost = abs(v[pos] - v[k]) + cost(k, n, x);
            min_cost = min(curr_cost, min_cost);
        }
        memo[pos] = min_cost;
        return memo[pos];
    }
}

int main(){
    int n, x; cin >> n >> x;
    
    for (int i = 1; i!=n+1; i++) cin >> v[i];
    cout << cost(1, n, x) << endl;

    return 0;
}

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

int main() {
  int a[3][3];
  rep(i,3)rep(j,3) cin >> a[i][j];
  int x[3], y[3];
  x[0] = 0;
  rep(i,3) y[i] = a[0][i] - x[0];
  rep(i,3) x[i] = a[i][0] - y[0];
  bool ok = true;
  rep(i,3)rep(j,3) {
    if (x[i] + y[j] != a[i][j]) ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    char c;
    cin >> c;
    if(isupper(c)) cout << 'A' << endl;
    else cout << 'a' << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3568
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
char map[15][15];
int n,m;
int a[15];bool vis[15],ans=false;
bool v2[15];
void check()
{
	memset(v2,false,sizeof(v2));
	bool op=m&1;
	for(int i=1;i<=m;i++)
		if(!v2[i])
		{
			bool flag=false;
			for(int j=i+1;j<=m;j++)
			{
				if(!v2[j])
				{
					bool ok=true;
					for(int k=1;k<=n;k++) if(map[a[k]][i]!=map[a[n-k+1]][j]) ok=false;
					if(ok) {v2[j]=flag=true;break;}
				}
			}
			if(!flag)
			{
				if(op)
				{
					bool ok=true;
					for(int k=1;k<=n;k++) if(map[a[k]][i]!=map[a[n-k+1]][i]) ok=false;
					if(ok) op=false;
					else return;
				}
				else return;
			}
		}
	ans=true;
}
void dfs(int x,int pos,bool op)
{
	if(ans) return;
	if(x>n) {check();return;}
	if(vis[x]) {dfs(x+1,pos,op);return;}
	for(int i=x+1;i<=n;i++)
	{
		if(vis[i]) continue;
		a[pos]=i;a[n-pos+1]=x;
		vis[i]=true;dfs(x+1,pos+1,op);vis[i]=false;
	}
	if(op)
	{
		a[n/2+1]=x;
		dfs(x+1,pos,false);
	}
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",map[i]+1);
	dfs(1,1,n&1);
	if(ans) printf("YES");
	else printf("NO");
}

Measured memory_bytes: 256
#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
  
int  tr['T'+1];
char f[33554432];
  
int main()
{
    int n, k, c;
  
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}


Measured memory_bytes: 2988
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4.2")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define PB push_back
#define all(x) x.begin(),x.end()
#define vi vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define vb vector<bool>
#define vvi vector<vector<ll> >
#define vvii vector<vii>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define read(x) long long x;cin>>x;
#define FOR(a,b,c,d) for(int a=b;a<=c;a+=d)
#define MP make_pair
#define F first
#define AS assign
#define S second
#define debug(x) cout<<(#x)<<": "<<(x)<<"\n"
#define SZ(x) x.size()
#define mod 1000000007
#define lg2(x) 63-(__builtin_ctzll(x))
#define RZ resize
#define IN insert
#define X real()
#define Y imag()
#define FBO find_by_order
#define OFK order_of_key
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
typedef unsigned long long ull;
typedef long double d64;
typedef complex<d64>P;

vvi G;
vector<vb>vis;

void Hierholzer(int x){

    for(int i=0;i<G[x].size();i++){
            if(!vis[x][i]){
                vis[x][i]=1;
                vis[i][x]=1;
                Hierholzer(G[x][i]);
            }
    }

}


int main(){
read(M);
if(M>=30)cout<<"Yes";
else cout<<"No";

return 0;
}




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

int main() {
    int N, D, X;
    cin >> N >> D >> X;
    vector<int> AA(N);
    for (int i = 0; i < N; i++) {
        cin >> AA.at(i);
    }
    int res = X;
    for (int i = 0; i < N; i++) {
        res += (D - 1) / AA.at(i) + 1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }
    int rev[n];
    for(int i = 0; i < n; i++){
        rev[A[i] - 1] = i+1;
    }
    for(int i = 0; i < n; i++){
        cout << rev[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <unordered_set>

int main() {
  int n;
  std::cin >> n;
  std::string s;
  std::unordered_set<std::string> set(200000);
  for (int i = 0; i < n; ++i) {
    std::cin >> s;
    set.insert(s);
  }
  std::cout << (set.size() == n ? "YES" : "NO") << std::endl;
  
  return 0;
}

Measured memory_bytes: 20096
n = int(input())
p = [int(x) for x in input().split()]
 
count = 0
index = []
 
for i in range(n-1):
  if p[i] < p[i+1]:
    pass
  else:
    count += 1
    index.append(i)

if count == 0:
  print('YES')
elif count != 2:
  print('NO')
else:
  p[index[0]], p[index[1] + 1] = p[index[1] + 1], p[index[0]]
  sorted_p = sorted(p)
  if p == sorted_p:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

int const N = 1300;

int main()
{
	char str[1300];
	while(fgets(str, 1300, stdin))
	{
		for(int i = 0; i < strlen(str); i++)
		{
			if(str[i] >= 'A' && str[i] <= 'Z')
			{
				printf("%c", str[i]+32);
			}
			else if(str[i] >= 'a' && str[i] <= 'z')
			{
				printf("%c", str[i]-32);
			}
			else
			{
				printf("%c", str[i]);
			}

		}
		
	}
	
} 


Measured memory_bytes: 2556
import java.util.*;
import java.lang.*;
import java.util.function.Function;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i=0; i<3;i++) System.out.print(Character.toUpperCase(sc.next().charAt(0)));
        System.out.println();
    }
}


Measured memory_bytes: 21716
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

void reader(int &a) { scanf("%d", &a); }
void reader(double &a) { scanf("%lf", &a); }
void reader(char a[]) { scanf("%s", a); }
void reader(char &a) { scanf(" %c", &a); }
void reader(ll &a) { scanf("%lld", &a); }
void reader(ull &a) { scanf("%llu", &a); }
// void reader(string& a){cin >> a;};
template<class T, class U> void reader(T& t, U& u) { reader(t); reader(u); }
template<class T, class U, class V> void reader(T& t, U& u, V& v) { reader(t); reader(u); reader(v); }

void writer(const int a, char c) { printf("%d", a); putchar(c); }
void writer(const ll a, char c) { printf("%lld", a); putchar(c); }
void writer(const ull a, char c) { printf("%llu", a); putchar(c); }
void writer(const double a, char c) { printf("%.20lf", a); putchar(c); }
void writer(const char a[]) { printf("%s", a); };
void writer(const char a[], char c) { printf("%s", a); putchar(c); };
void writer(const char a, char c) { putchar(a); putchar(c); };
template<class T> void writerLn(T t) { writer(t, '\n'); }
template<class T, class U> void writerLn(T t, U u) { writer(t, ' '); writer(u, '\n'); }
template<class T, class U, class V> void writerLn(T t, U u, V v) { writer(t, ' '); writer(u, ' '); writer(v, '\n'); }
template<class T> void writerArr(T x[], int n) { int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }
template<class T> void writerVec(vector<T> x) { int n = x.size(); int i; if (!n) { putchar('\n'); return; }rep(i, n - 1) writer(x[i], ' '); writer(x[n - 1], '\n'); }

vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); }return v; }
// #define int ll
bool test = 1;
int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };
#define MAX 300000
//.....................
ull mod = (int)1e9 + 7;

ull N;

signed main(void)
{
	int a = 0;
	int b = 0;
	rep(i, 4) {
		int tmp;
		cin >> tmp;
		a += tmp;
	}
	rep(i, 4) {
		int tmp;
		cin >> tmp;
		b += tmp;
	}
	cout << max(a, b) << endl;
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

ll dp[1005][1 << 12];

int main(int argc, char* argv[]) {
  ll n, m;
  cin >> n >> m;

  vector<pair<ll, int>> keys(m);
  vector<int> box_bits(m);
  rep(i, 0, m) {
    int c;
    cin >> keys[i].first >> c;
    vector<ll> tmp(c);
    scan(tmp);
    for (ll k : tmp) {
      keys[i].second |= (1 << (k - 1));
    }
  }

  sort(all(keys));
  Fill(dp, ll(LL_INF));
  dp[0][0] = 0;

  rep(i, 0, m) {
    rep(j, 0, 1 << n) {
      if (dp[i][j] >= LL_INF) continue;

      chmin(dp[i + 1][j], dp[i][j]);
      chmin(dp[i + 1][j | keys[i].second], dp[i][j] + keys[i].first);
    }
  }

  ll ans = dp[m][(1 << n) - 1] >= LL_INF ? -1 : dp[m][(1 << n) - 1];
  put(ans);

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

signed main() {
  int N, X;
  cin >> N >> X;
  
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( i == 0 ){
      if( A.at(i) > X ){
        ans += A.at(i)-X;
        A.at(i) = X;
      }
    }else{
      if( A.at(i-1)+A.at(i) > X ){
        ans += A.at(i)-(X-A.at(i-1));
        A.at(i) -= (A.at(i)-(X-A.at(i-1)));
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1152
n,k=map(int,input().split())
a=n-k+1
b=1
mod=10**9+7
print((a*b)%mod)
for i in range(2,k+1):
  a*=(n-k+2-i)
  a//=i
  b*=(k-i+1)
  b//=(i-1)
  cnt=((a*b)%mod)
  print(cnt)

Measured memory_bytes: 3316
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define MP make_pair
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 6666
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int sx,sy,tx,ty;

int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
 
    for(int i=ty-sy;i;--i)putchar('U');
    for(int i=tx-sx;i;--i)putchar('R');
 
    for(int i=ty-sy;i;--i)putchar('D');
    for(int i=tx-sx;i;--i)putchar('L');
 
    putchar('L');
    for(int i=ty-sy;i;--i)putchar('U');
    putchar('U');
    putchar('R');
    for(int i=tx-sx;i;--i)putchar('R');
    putchar('D');
 
    putchar('R');
    for(int i=ty-sy;i;--i)putchar('D');
    putchar('D');
    putchar('L');
    for(int i=tx-sx;i;--i)putchar('L');
    putchar('U');
    puts("");
   // system("pause");
}

//UURD DLLU UURRDR DDDLLU
//LUURDDRUUULLDLDDDRRU


Measured memory_bytes: 256
using System;

namespace ABC157_B
{
    class Program
    {
        static int Main(string[] args)
        {
            var L1 = Console.ReadLine().Split(' ');
            var L2 = Console.ReadLine().Split(' ');
            var L3 = Console.ReadLine().Split(' ');
            var A = new int[9]
            {
                int.Parse(L1[0]),
                int.Parse(L1[1]),
                int.Parse(L1[2]),
                int.Parse(L2[0]),
                int.Parse(L2[1]),
                int.Parse(L2[2]),
                int.Parse(L3[0]),
                int.Parse(L3[1]),
                int.Parse(L3[2]),
            };
            var B = new bool[9];

            var N = int.Parse(Console.ReadLine());

            for (int i = 0; i < N; i++)
            {
                var I = int.Parse(Console.ReadLine());

                for (int j = 0; j < 9; j++)
                {
                    if (A[j] == I)
                    {
                        B[j] = true;
                        break;
                    }
                }
            }

            if ((B[0] && B[1] && B[2]) ||
                (B[3] && B[4] && B[5]) ||
                (B[6] && B[7] && B[8]) ||
                (B[0] && B[3] && B[6]) ||
                (B[1] && B[4] && B[7]) ||
                (B[2] && B[5] && B[8]) ||
                (B[0] && B[4] && B[8]) ||
                (B[2] && B[4] && B[6]))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            return 0;
        }
    }
}


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

int main(){
    
    int H,W;
    while(1){
        cin >> H >> W;
        if((H == 0 )&&(W == 0)){
          break;
        }

        for(int i=0 ; i < H ; i++){
            for(int j=0 ; j < W ; j++){
              cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return(0);
}


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

int main() {
  string a,b,c;
  cin>>a>>b>>c;
  string s={char(int(a.at(0)-'0')-32+'0'),char(int(b.at(0)-'0')-32+'0'),char(int(c.at(0)-'0')-32+'0')};
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	_, A, B := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	diff := B - A
	if diff == 1 {
		fmt.Println("Borys")
	} else {
		if diff%2 == 0 {
			fmt.Println("Alice")
		} else {
			fmt.Println("Borys")
		}
	}
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}

func (s *FastScanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
from operator import itemgetter

N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
    exit()

# 目的地を小さい順に確認し、目的地間の区間の長さが長い所の両端に駒を置く
# 最小手数は全区間の長さから駒が移動しない区間の長さの和を除いたもの

X.sort()
dist_between_destination = []
for i in range(M-1):
    dist_between_destination.append(abs(X[i]-X[i+1]))

# 大きい方からN-1個の区間はコマで移動しない
dist_between_destination.sort(reverse = True)

print((X[-1] - X[0]) - sum(dist_between_destination[:N-1]))

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

int main() {
    string s;
    cin >> s;
    if (s.length() == 2) cout << s << endl;
    else {
        for (int i = 2; i >= 0; i--) cout << s[i];
        cout << endl;
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> m;
    for(int i = 1;i < 10;++i){
        for(int j = 1;j <10;++j){
            m.push_back(i*j);
        }
    }
    if(count(m.begin(),m.end(),N)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

const int N = 510;
int n, a[N], k, b[N], c[N], d[N];

bool check(int x) { 
	for(int i = 1; i <= n; ++i) b[i] = a[i] % x; 
	sort(b + 1, b + n + 1);
	for(int i = 1; i <= n; ++i) c[i] = c[i - 1] + b[i];
	for(int i = n; i; --i) d[i] = d[i + 1] + (x - b[i]);
	for(int i = 1; i <= n; ++i) {
		if(c[i] <= k && c[i] == d[i + 1]) return 1; 
	}
	return 0;
}

int main() {
	cin >> n >> k;
	int sum = 0;
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]), sum += a[i];
	int Lim = sqrt(sum), ans = 0;
	for(int i = 1; i <= Lim; ++i) {
		if(sum % i == 0) {
			if(check(i)) ans = max(ans, i);
			if(check(sum / i)) ans = max(ans, sum / i);
		}
	}
	cout << ans << endl;
}

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

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

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 200005, mod = 998244353;
std::vector<int> G[maxn];
int sg[3][maxn];
ll f[3][maxn], g[maxn];
ll po[maxn * 3];

inline ll power(ll x, int k) {
	if(k < 0) k += mod - 1;
	ll res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

void FWT (ll *a, int n) {
	for (int m = 1; m < n; m <<= 1)
		for (int i = 0; i < n; i += m << 1)
			for (int k = i; k < i + m; k ++) {
			ll x = a[k], y = a[k + m];
			(a[k] = x + y) %= mod;
			(a[k + m] = x + mod - y) %= mod;
		}
}

void iFWT (ll *a, int n) {
	for (int m = 1; m < n; m <<= 1)
		for (int i = 0; i < n; i += m << 1)
			for (int k = i; k < i + m; k ++) {
			ll x = a[k], y = a[k + m];
			(a[k] = x + y) %= mod;
			(a[k + m] = x + mod - y) %= mod;
			(a[k] *= (mod + 1) >> 1) %= mod;
			(a[k + m] *= (mod + 1) >> 1) %= mod;
		}
}

int main () {
	int n = read, len = 1;
	while (len < n)
		len <<= 1;

	po[0] = 1;
	ll bs = 1000000000000000000ll % mod;
	/* ll bs = 10; */
	for (int i = 1; i <= n * 3; i ++)
		po[i] = po[i - 1] * bs % mod;

	for (int o = 0; o < 3; o ++) {
		int m = read;
		for (int i = 1; i <= n; i ++)
			G[i].clear();
		for (int i = 1; i <= m; i ++) {
			int u = read, v = read;
			if (u < v) G[u].push_back(v);
			if (v < u) G[v].push_back(u);
		}
		for (int i = n; i; i --) {
			if (!G[i].empty()) {
				std::set<int> mex;
				for (int j : G[i])
					mex.insert(sg[o][j]);
				while(mex.count(sg[o][i]))
					++ sg[o][i];
			}
			/* debug("%d\n", sg[o][i]); */
		}
		for (int i = 1; i <= n; i ++)
			(f[o][sg[o][i]] += po[i]) %= mod;
		/* for (int i = 0; i < len; i ++) */
		/* 	debug(" %lld", f[o][i]); */
		/* debug("\n"); */
		FWT(f[o], len);
	}

	for (int i = 0; i < len; i ++)
		g[i] = f[0][i] * f[1][i] % mod * f[2][i] % mod;
	iFWT(g, len);

	ll ans = g[0];
	/* for (int i = 1; i < len; i ++) */
	/* 	ans += g[i]; */
	/* ans %= mod; */

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


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

using namespace std;

int main() {
    long n, m;
    cin >> n >> m;
    vector<long> l(m), r(m);
    for (long i=0; i<m; ++i) {
        cin >> l[i] >> r[i];
    }
    long max_l = 1;
    long min_r = n;
    for (long i=0; i<m; ++i) {
        if (max_l < l[i]) {
            max_l = l[i];
        }
        if (min_r > r[i]) {
            min_r = r[i];
        }
    }
    if (max_l <= min_r) {
        cout << min_r - max_l + 1 << endl;
    } else {
        cout << 0 << endl;
    }
	return 0;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

//euclidの互除法
ll calc_gcd(ll x,ll y){
    if(y==0) return x;
    return calc_gcd(y,x%y);
}
//最小公倍数
ll calc_lcm(ll x,ll y){
    return (x/calc_gcd(y,x%y))*y;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
ll ans;
cin>>ans;
reps(i, n,1){
    ll t;
    cin >> t;
    ans = calc_lcm(ans, t);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(long long x,long long y){
  int a=0,b=0;
  while(x>0){
    x = x/10;
    a = a+1;
  }
  while(y>0){
    y =y/10;
    b = b +1;
  }
  if(a>=b){
    return a;
  }
  else{
    return b;
  }
}

int main() {
  long long N;
  cin>> N;
  int min =15;
  for(long long A= 1; A <= sqrt(N);A++){
    if(N%A ==0){
      if(f(A,N/A) <= min){
        min = f(A,N/A);
      }
    }
  }
  cout<<min<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
val num:Int? = readLine()?.toInt()
val string:String?=readLine()

if(num==null||string==null){
return
}

if(string.length<=num){
println(string)
}else{
val stringV=string.substring(0, num)
println("${stringV}...")
}
}

Measured memory_bytes: 34388
using System;
class Program
{
    static void Main()
    {
        while(true)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            if(a>=b&&a+b!=0)
                Console.WriteLine(b+ " "+a);
            else if(a<=b&&a+b!=0)
                Console.WriteLine(a+" "+b);
            else if(a==0&&b==0)
                break;
        }
    }
}

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

long long a[100007],b[100007];
int main(){
	
	int n;
	
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
	}
	for(int i = 1;i<=n;i++){
		b[i] = b[i-1] + abs(a[i]-a[i-1]);
	}
	b[n+1] = b[n]+abs(a[n]);
	for(int i = 1;i<=n;i++){
		cout << b[n+1]-b[i+1]+b[i-1]+abs(a[i+1]-a[i-1]) << endl;
	}
	
} 

Measured memory_bytes: 2816
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[2] - a[0];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, M, L;
  cin >> N >> M >> L;

  vector<vector<ll>> dist(N, vector<ll>(N, INF));
  for (ll i = 0; i < M; i++)
  {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    dist.at(a).at(b) = c;
    dist.at(b).at(a) = c;
  }

  for (ll i = 0; i < N; i++)
  {
    dist.at(i).at(i) = 0;
  }
  for (ll k = 0; k < N; k++)
  {
    for (ll i = 0; i < N; i++)
    {
      for (ll j = 0; j < N; j++)
      {
        chmin(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }

  vector<vector<ll>> supp(N, vector<ll>(N, INF));
  for (ll i = 0; i < N; i++)
  {
    for (ll j = 0; j < N; j++)
    {
      if (dist.at(i).at(j) <= L)
        supp.at(i).at(j) = 1;
      if (i == j)
        supp.at(i).at(j) = 0;
    }
  }
  for (ll k = 0; k < N; k++)
  {
    for (ll i = 0; i < N; i++)
    {
      for (ll j = 0; j < N; j++)
      {
        chmin(supp.at(i).at(j), supp.at(i).at(k) + supp.at(k).at(j));
      }
    }
  }

  ll Q;
  cin >> Q;
  for (ll i = 0; i < Q; i++)
  {
    ll s, t;
    cin >> s >> t;
    s--, t--;

    ll ans = supp.at(s).at(t);
    cout << ((ans == INF) ? -1 : ans - 1) << endl;
  }
}

Measured memory_bytes: 1920
//b.c B-AcCepted
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int komoji(char c){
    if((c>='a')&&(c<='z')){
        return 1;
    }
    return 0;
}

int oomoji(char c){
    if((c>='A')&&(c<='Z')){
        return 1;
    }
    return 0;
}

int main(void){
    char buf[11];
    bool flag = true;
    scanf("%s",buf);
    bool ff = false;
    int num=-1,count=0;
    int len = strlen(buf);

    if(buf[0]!='A'){
        flag = false;
    }
    
    for(int i=2;i<len-1;++i){
        if(buf[i]=='C'){
            num = i;
            count++;
        }
        if(oomoji(buf[i])&&buf[i]!='C'){
            flag = false;
        }
    }
    if(count!=1){
        flag = false;
    }

    for(int i=1;i<len;++i){
        if(!komoji(buf[i])&&i!=num){
            flag = false;
        }
    }

    if(flag){
        printf("AC\n");
    }else{
        printf("WA\n");
    }

    return 0;
}


Measured memory_bytes: 128
def s()
  gets()
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end

n = i()

c = []
s = []
f = []
(n-1).times{
  temp = li()
  c << temp[0]
  s << temp[1]
  f << temp[2]
}


(n-1).times{|i|
  ride_t = c[i]+s[i]
  (i+1).upto(n-2){|j|
    diff = ride_t-s[j]
    if diff <= 0
      ride_t = s[j]+c[j]
    else
      ride_t = s[j]+(diff.to_f/f[j]).ceil*f[j]+c[j]
    end

  }
  puts ride_t
}
puts 0

Measured memory_bytes: 1788
n=int(input())

a=0
b=0
ab=0
flag=0

for i in range(n):
    line=input()
    if flag!=1 and (line[len(line)-1]!='A' and line[0]=='B') or (line[len(line)-1]=='A' and line[0]!='B'):
        flag=1
    if line[0]=='B':
        b=b+1
    if line[len(line)-1]=='A':
        a=a+1
    for j in range(len(line)-1):
        if line[j]=='A' and line[j+1]=='B':
            ab=ab+1

if flag==0 and a!=0 and b!=0:
    a,b=a-1,b-1

if b>a:
    print(ab+a)
else:
    print(ab+b)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define ketasitei setprecision(15) //15桁表示



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

	ll a, b;
	cin >> a >> b;
	if (a <= b)
	{
		for (int i = 0; i < b; i++)
		{
			cout << a;
		}
		cout << endl;
	}
	else if (b < a)
	{
		for (int i = 0; i < a; i++)
		{
			cout << b;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
def check(A, B, raw):
    now = 0
    for i in raw:
        now += A[i]
        if now > B[i]:
            print('No')
            return
    print('Yes')
    return


N = int(input())
A, B = {}, {}
for i in range(N):
    A[i], B[i] = map(int, input().split())
raw = []
for k, v in sorted(B.items(), key=lambda x: x[1]):
    raw.append(k)

check(A, B, raw)

Measured memory_bytes: 62636
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

ll pow = 1;
rep(i, 1, N+1){
    pow *= i;
    pow %= MOD;
}

cout << pow << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.
// map[]は対数時間．unordered_map[]は一定時間．


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n;
  cin >> n;
  vector<int> price;
  price.push_back(1);
  for(int i = 6; i <= n; i *= 6) price.push_back(i);
  for(int i = 9; i <= n; i *= 9) price.push_back(i);
  vector<int> dp(n + 1, INF);
  dp[0] = 0;
  for(int i = 0; i <= n; ++i){
    for(int v: price){
      if(i + v <= n) dp[i + v] = min(dp[i] + 1, dp[i + v]);
    }
  }
  cout << dp[n] << endl;
}

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

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 ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

int main() {
  string S;
  cin>>S;
  int N = S.size();
  vector<ll> A(N+1,0),B(N+1,0),C(N+1,0),D(N+1,0);
  rep(i,N){
    if(S[i]=='A') A[i+1]++;
    if(S[i]=='B') B[i+1]++;
    if(S[i]=='C') C[i+1]++;
    if(S[i]=='?') D[i+1]++;
  }
  rep(i,N) {
    A[i+1] += A[i];
    B[i+1] += B[i];
    C[i+1] += C[i];
    D[i+1] += D[i];
  }
  ll a = pow(3LL,D[N],mod),b=pow(3LL,D[N]-1,mod),c=pow(3LL,D[N]-2,mod),d=pow(3LL,D[N]-3,mod);
  ll ans = 0;
  rep(i,N){
    ll p = 0;
    if(S[i]=='B') {
      p = (p+((A[i]*(C[N]-C[i+1]))%mod*a)%mod)%mod;
      p = (p+((D[i]*(C[N]-C[i+1]))%mod*b)%mod)%mod;
      p = (p+((A[i]*(D[N]-D[i+1]))%mod*b)%mod)%mod;
      p = (p+((D[i]*(D[N]-D[i+1]))%mod*c)%mod)%mod;
    }
    if(S[i]=='?'){
      p = (p+((A[i]*(C[N]-C[i+1]))%mod*b)%mod)%mod;
      p = (p+((D[i]*(C[N]-C[i+1]))%mod*c)%mod)%mod;
      p = (p+((A[i]*(D[N]-D[i+1]))%mod*c)%mod)%mod;
      p = (p+((D[i]*(D[N]-D[i+1]))%mod*d)%mod)%mod;
    }
    ans = (ans+p)%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6660
#include<iostream> 
#include<vector> 
#include<cmath> 
using namespace std; 
int main()
{ios_base::sync_with_stdio(false); 
cin.tie(0); 
long int n,x,i,k,j,y; 
cin>>n>>k; 
long int dp[n],h[n]; 
for( i=0; i<n;i++) 
 cin>>h[i]; 

 dp[0]=0; 
 dp[1]=abs(h[0]-h[1]); 
 for(i=2;i<n;i++) 
 { y=1000000000; 
   for(j=i-k;j<i;j++) 
    {   if(j<0)
          { j=(-1); 
             continue; }
      x=abs(h[i]-h[j])+dp[j]; 
        if(y>x) 
         y=x; 
    } 
   dp[i]=y; 
 }
cout<<dp[n-1]<<endl; 
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    string a,b,c;
    cin>>n>>a>>b>>c;
    int ans=0;
    rep(i,n){
        if(a[i]==b[i]&&a[i]==c[i])continue;
        if(a[i]==b[i]||a[i]==c[i]||b[i]==c[i])ans++;
        else ans+=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#[allow(non_snake_case)]

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let S = buf.trim().parse::<usize>().unwrap();
    println!("{}:{}:{}", S / 3600, S % 3600 / 60, S % 60);
}


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

int main()
{
	int a,b,c;
	cin >> a;
	if(a%10 == 2 || a%10 == 4 || a%10 == 5 || a%10 == 7 || a%10 == 9){
		cout << "hon" << endl;
	}else if(a%10 == 0 || a%10 == 1 || a%10 == 6 || a%10 == 8){
		cout << "pon" << endl;
	}else cout << "bon" << endl;
	return 0;
}


Measured memory_bytes: 3592
N = int(input())
m = 0
ans = 1
for i in range(1, N + 1):
  n = i
  cnt = 0
  while True:
    if n % 2 != 0:
      break
    else:
      n /= 2
      cnt += 1
  if m < cnt:
    ans = i
    m = cnt
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int n,k,a[N];
map<int,int> mp;
int main()
{
	while(cin>>n>>k)
	{
		mp.clear();
		int d=0,mx=0;
		for(int i=1;i<=n;i++)
			scanf("%d",&a[i]),d=gcd(d,a[i]),mx=max(mx,a[i]);
		if(k%d||k>mx)
			puts("IMPOSSIBLE");
		else
			puts("POSSIBLE");
				
	}
	return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG


int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG
    
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d %d\n", a * b, 2 * (a + b));

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2040
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll h, w;
    cin >> h >> w;
    if(w >= h)cout << "unsafe";
    else cout << "safe";
}

Measured memory_bytes: 3596
#include<iostream>
#define DIM 200005
using namespace std;
int n, i, k, ok;
int a[DIM], b[DIM];
int main(){
    cin>> n >> k;
    for(i = 1; i <= n; i++){
        cin>> a[i];
    }
    for(; k; k--){
        for(i = 1; i <= n; i++){
            b[ max(1, i - a[i]) ]++;
            b[ min(n + 1, i + a[i] + 1) ]--;
        }
        for(i = 1; i <= n; i++){
            b[i] += b[i - 1];
        }
        ok = 0;
        for(i = 1; i <= n; i++){
            a[i] = b[i];
            b[i] = 0;
            if(a[i] != n){
                ok = 1;
            }
        }
        if(ok == 0){
            break;
        }
    }
    for(i = 1; i <= n; i++){
        cout<< a[i] <<" ";
    }
}


Measured memory_bytes: 5152
while(True):  
    a,op,b=input().split()
    if(op=='?'):
        break
    elif(op=='+'):
        print(int(a)+int(b))
    elif(op=='-'):
        print(int(a)-int(b))
    elif(op=='*'):
        print(int(a)*int(b))
    elif(op=='/'):
        print(int(a)//int(b))

        


Measured memory_bytes: 5596
import java.util.Scanner;
 
class Main {
    Scanner sc = new Scanner(System.in);
 
    int[] count = new int[26];
 
    public void run() {
        String s=sc.nextLine().toLowerCase();
        int count=0;
        while(true){
            String str=sc.next();
            if(s.equals(str.toLowerCase()))count++;
            if("END_OF_TEXT".equals(str))break;
        }
        ln(count);
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
 
    public static void pr(Object o) {
        System.out.print(o);
    }
 
    public static void ln(Object o) {
        System.out.println(o);
    }
 
    public static void ln() {
        System.out.println();
    }
}


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

const ll mod = (1e9) + 7;
ll n, k;
ll a[2005];
ll ans;

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

    for (int i = 0; i < n; i++) {
        ll cnt = 0;
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                cnt++;
            }
        }

        ll cnt2 = 0;
        for (int j = 0; j < n; j++) {
            if (a[i] > a[j]) {
                cnt2++;
            }
        }

        ans += (cnt * k) % mod;
        ans += cnt2 * ((k * (k - 1) / 2) % mod) % mod;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256