akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"YES\n":"NO\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = false;
  if(a == 5 && b == 5 && c == 7) flag = true;
  if(a == 7 && b == 5 && c == 5) flag = true;
  if(a == 5 && b == 7 && c == 5) flag = true;
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/


int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	n = a% b;
	s = "NO";
	REP(i,b)
	{
		if(n==c) {
			s = "YES";
		}
		n += a;
		n %= b;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
while true
  a, op, b = gets.chomp.split
  a = a.to_i
  b = b.to_i

  if op == '+'
    puts a + b
  elsif op == '-'
    puts a - b
  elsif op == '*'
    puts a * b
  elsif op == '/'
    puts a / b
  else
    break
  end
end




Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
using namespace std;

int n, k, a[200001], ans;

bool ok(int x){
    int tk = k;
    for(int i=0; i<n; i++){
        tk -= (a[i]-1)/x;
        if(tk<0) return false;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("A.txt", "r", stdin);
    #endif
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> a[i];
        ans = max(ans, a[i]);
    }
    int lb = 1, rb = ans;
    while(lb<rb){
        int mid = (lb+rb)/2;
        if(ok(mid)){
            ans = mid;
            rb = mid;
        }
        else lb = mid+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4336
#include<iostream>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    using namespace std;
    #define INF 10000000;
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)

    int main(){
     int n,sum = 0;
     cin >> n;
     vector<int> a(n);
     vector<int> b(n-1);

     rep(i,n-1){
       cin >> b[i];
     }

     a[0] = b[0];
     for(int i=1;i<n-1;i++){
       a[i] = min(b[i-1],b[i]);
       //cout << i << ";" << a[i] <<endl;
     }
     a[n-1] = b[n-2];

    rep(i,n){
      sum += a[i];
    }
    cout << sum <<endl;
    }
    

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000

typedef struct{
  char n[10];
  int q;
}Data;


int main(){
  int n,q,i,j,head=0,tail,sum=0;
  Data data[N];

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

  for(i=0;i<n;i++){
    scanf("%s%d",&data[i].n,&data[i].q);
  }

  head=0;
  tail=n;
  while(1){
    data[head].q-=q;
    sum+=q;
    if(data[head].q<=0){
      printf("%s %d\n",data[head].n,data[head].q+sum);
      sum+=data[head].q;
    }
    else {
      data[tail]=data[head];
      tail++;
    }
    head++;
    if(head==tail)break;
    if(head>=N)head=0;
    if(tail>=N)tail=0;
  }
  return 0;
}

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

int d;
vector<int> c(26);
vector<vector<int>> s;

int scoring(const vector<int>& t) {
    int v = 0;
    vector<int> last(26, -1);
    rep(i, d) {
        v += s[i][t[i]];
        last[t[i]] = i;
        rep(j, 26) {
            v -= c[j] * (i - last[j]);
        }
    }
    return v;
}

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

    cin >> d;
    rep(i, 26) cin >> c[i];
    s.resize(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];

    vector<int> t(d);
    rep(i, d) cin >> t[i], t[i]--;

    int m;
    cin >> m;
    vector<int> d(m), q(m);
    rep(i, m) cin >> d[i] >> q[i], d[i]--, q[i]--;
    
    rep(i, m) {
        t[d[i]] = q[i];
        cout << scoring(t) << endl;
    }
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> time(2);
    for (int i=0;i<2;++i){
        int H,W; cin >> H >> W;
        time[i]=H*60+W;
    }
    int K; cin >> K;
    cout << time[1]-time[0]-K << '\n';
}

Measured memory_bytes: 3648
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }




int main() {
	
	ll N;
	cin >> N;
	vll C(N - 1), S(N - 1), F(N - 1);
	rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	rep(loop, N) {
		ll tm = 0;
		fori(i, loop, N - 1) {
			ll tmp = S[i];
			rep(j, INF) {
				if (tm <= tmp) break;
				else tmp += F[i];
			}
			tm = tmp + C[i];
		}
		cout << tm << endl;
	}
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let  s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: [i32; 3]
    }
    let mut b = vec![
        (a[0] - a[1]).abs(),
        (a[1] - a[2]).abs(),
        (a[2] - a[0]).abs(),
    ];
    b.sort();
    println!("{}", b[0] + b[1]);
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	vector<ll> v;
	ll ans = 0;

	cin >> n;

	REP(i, n) {
		ll p;
		cin >> p;
		v.push_back(p);
	}

	if (v[0] == 1) {
		swap(v[0], v[1]);
		ans++;
	}

	FOR(i, 1, n) {
		if (i == n - 1) {
			if (v[i] == n) {
				swap(v[i], v[i - 1]);
				ans++;
			}
		}

		if (v[i] != i + 1) {
			continue;
		}
		else if (v[i + 1] != i + 1) {
			swap(v[i], v[i + 1]);
				ans++;
		}
		else {
			swap(v[i], v[i - 1]);
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int n;cin>>n;
    int m = n;
    int s=0;
    while(m){
        s += m % 10;
        m /= 10;
    }
	cout << ((n % s ==0) ? "Yes": "No") << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#define N 1000
using namespace std;
int tree[N][N];
int lowbit(int x) {
    return x&(-x);
}

void add(int x,int y){
    for(int i = x;i<N;i+=lowbit(i)){
        for(int j = y;j<N;j+=lowbit(j)){
            tree[i][j]++;
        }
    }
}

int query(int x,int y){
    int ans = 0;
    for(int i = x;i>0;i-=lowbit(i)){
        for(int j = y;j>0;j-=lowbit(j)){
            ans+=tree[i][j];
        }
    }
    return ans;
}


int main(){
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    for(int i=0;i<q;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        int ans = query(y,y)-query(x-1,y)-query(y,x-1)+query(x-1,x-1);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream> 
#include <algorithm>
#include <bits/stdc++.h>
 
using namespace std; 
typedef long long ll;
 
#define umap unordered_map
#define f first
#define s second
 
#define for0(i, a, b) for (int i = (a); i < (b); i++)
#define for1(i, a) for (int i = 0; i < (a); i++)
#define ford(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define fored(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define rep(i,a,b) for (int i = a; i < b; i++)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sstr substr
typedef vector<int> vi;
typedef vector<string> vis;
typedef unordered_map<string, int> umap; 

 
int main()
{   
    ll stone ;
    cin >> stone;
    ll jump;
    cin >> jump;
    ll dp[stone];
    for0(i, 0, stone){
        dp[i] = 9999999999;
    }
    dp[0] = 0 ;
    ll stonearr[stone];
    ll temp;
    for0(i,0, stone){
        cin >> temp;
        stonearr[i] = temp;
    }
    
    for0 (i , 0 , stone){
        for0(j,i+1, i+jump + 1){
            if ( j >= stone){
                break;
            }
            dp[j] = min(dp[j], abs(stonearr[i] - stonearr[j]) + dp[i]);
        }
    }
    
    cout<<dp[stone - 1]<<endl;
    
    // trav(i ,dp){
    //     cout<<i<<" ";
    // }
    
    return 0;
}

Measured memory_bytes: 1792
def solve():
    N, M = map(int, input().split())
    students = []
    points = []
    
    for _ in range(N):
        a, b = map(int, input().split())
        students.append([a, b])
        
    for _ in range(M):
        c, d = map(int, input().split())
        points.append([c, d])
    
    for [a, b] in students:
        md = []
        for [c, d] in points:
            md.append(abs(a-c) + abs(b-d))
        md_min = min(md)
        md_min_idx = md.index(md_min)
        print(md_min_idx + 1)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] o = sc.next().toCharArray();
        char[] e = sc.next().toCharArray();

        sc.close();

        for (int i = 0; i < o.length; i++) {
            System.out.print(o[i]);
            if (i == e.length) {
                return;
            }
            System.out.print(e[i]);
        }

    }
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  ll L, R;
  cin >> L >> R;
  ll ans = INF;
  for (ll i = L; i <= L + 2019 && i < R; i++) {
    for (ll j = i + 1; j <= L + 2019 && j <= R; j++) {
      ans = min(ans, (i * j) % 2019LL);
    }
  }
  // for (ll i = L; i < R; i++) {
  //   for (ll j = i + 1; j <= R; j++) {
  //     ans = min(ans, (i * j) % 2019LL);
  //     if (ans == 0) break;
  //   }
  //   if (ans == 0) break;
  // }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
	int n,k;
	cin>>n;
	cin>>k;
	int h[n+1];
	for(int i=1;i<=n;i++)
	{cin>>h[i];

	}
  a[1]=0;
  a[2]=abs(h[2]-h[1]);

  for (int i = 3; i <=n; ++i)
  {int x=10000000000;
  	for(int j=max(i-k,1);j<=i-1;j++)
  	{x=min(a[j]+abs(h[j]-h[i]),x);

  	}
  	a[i]=x;
  }
  cout<<a[n]<<endl;

}

Measured memory_bytes: 4324
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ALibra {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c, d;
	    in >> a >> b >> c >> d;
	    int left = a+b;
	    int right = c+d;
	    if(left < right) out << "Right" << endl;
	    else if(left == right) out << "Balanced" << endl;
	    else out << "Left" << endl;
	}
};


int main() {
	ALibra solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, H, W;
  cin >> N >> H >> W;
  ll ans = 0, a, b;
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    if (H <= a && W <= b) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
   int N;
   cin>>N;
   int t[110000];
   int x[110000];
   int y[110000];
   for(int i=0;i<N;i++){
     cin>>t[i+1]>>x[i+1]>>y[i+1];
   }
   for(int i=0;i<N;i++){
     int dt=t[i+1]-t[i];
     int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
     if(dt<dist){cout<<"No"<<endl;return 0;}
     if(dt%2!=dist%2){cout<<"No"<<endl;return 0;}
   }
   cout<<"Yes"<<endl;
return 0;}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const int mod = 1e9+7;

int main(){
  map<char, int> mp;
  string w;
  cin >> w;
  rep(i,w.size()){
    mp[w[i]]++;
  }
  int ans = true;
  for(char i = 'a'; i <= 'z'; i++){
    if(mp[i] % 2 != 0) ans = false;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  int ans = inf;
  for(int i = 1; i*i <= N; i++) {
    if(N%i != 0) continue;
    int j = N/i;
    chmin(ans, (max(to_string(i).size(), to_string(j).size())));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
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();
      if(a<b&&b<c){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
  }
}


Measured memory_bytes: 26332
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
struct Edge{
	int v,c,cost,nxt;
}e[50010];int tot=1;
int first[4010];
void build(int u,int v,int c,int cost)
{
	e[++tot]=(Edge){v,c,cost,first[u]};
	first[u]=tot;
	return ;
}
void adde(int u,int v,int c,int cost)
{
	build(u,v,c,cost);
	build(v,u,0,-cost);
	return ;
}
const long long INF=1e18;
int S,T;
long long dis[4010];
int pren[4010],pree[4010];
bool book[4010];
bool spfa()
{
	queue<int>q;
	for(int i=S;i<=T;i++)
		dis[i]=-INF;
	dis[S]=0;
	q.push(S);
	book[S]=true;
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		book[u]=false;
		for(int i=first[u];i;i=e[i].nxt)
			if(e[i].c&&dis[u]+e[i].cost>dis[e[i].v])
			{
				dis[e[i].v]=dis[u]+e[i].cost;
				pren[e[i].v]=u;pree[e[i].v]=i;
				if(!book[e[i].v])
				{
					q.push(e[i].v);
					book[e[i].v]=true;
				}
			}
	}
	return dis[T]>-INF;
}
long long solve()
{
	long long ans=0;
	while(spfa())
	{
		int mn=1e9;
		for(int i=T;i!=S;i=pren[i])
		{
			int ee=pree[i];
			mn=min(mn,e[ee].c);
		}
		ans+=dis[T]*mn;
		for(int i=T;i!=S;i=pren[i])
		{
			int ee=pree[i];
			e[ee].c-=mn;
			e[ee^1].c+=mn;
		}
	}
	return ans;
}
int main()
{
	int n;scanf("%d",&n);
	S=0;T=n*2+5;
	for(int i=1;i<=n;i++)
	{
		int x,y,c;
		scanf("%d %d %d",&x,&y,&c);
		adde(S,i,c,0);
		adde(i,n*2+1,1e9,x+y);
		adde(i,n*2+2,1e9,x-y);
		adde(i,n*2+3,1e9,-x+y);
		adde(i,n*2+4,1e9,-x-y);
	}
	for(int i=1;i<=n;i++)
	{
		int x,y,c;
		scanf("%d %d %d",&x,&y,&c);
		adde(i+n,T,c,0);
		adde(n*2+1,i+n,1e9,-x-y);
		adde(n*2+2,i+n,1e9,-x+y);
		adde(n*2+3,i+n,1e9,x-y);
		adde(n*2+4,i+n,1e9,x+y);
	}
	printf("%lld\n",solve());
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

        for(int i = 1;i <= n;i++){
            a[sc.nextInt()-1] = i;
        }
        for(int i = 0;i < n;i++){
            System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 68424
n,W=map(int,input().split())
w=[]
v=[]
for i in range(n):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
dp=[[float('inf')]*(100001) for i in range(n+1)]
dp[0][0]=0
for i in range(1,n+1):
  for j in range(100001):
    if j-v[i-1]>=0:
      dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1])
    else:
      dp[i][j]=dp[i-1][j]
  
ans=100000
while dp[n][ans]>W:
  ans-=1
print(ans)

Measured memory_bytes: 249732
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s; cin>>s;
    int cnt =0;
for(int i=0;i<s.size();i++){
    if(s[i]=='x') cnt++;
    }
    if(cnt>=8) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
List = [int(input()) for _ in range(M)]

P = 10**9+7

dp = [1]*(N+1)

for a in List:
    dp[a]=0

for i in range(1, N+1):
    if (i>=2)&(dp[i]!=0):
        dp[i] = (dp[i-1]+dp[i-2])%P
        
print(dp[N])

Measured memory_bytes: 7824
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll cash = 1000;
  ll stock = 0;

  for (int i = 0; i < n - 1; i++) {
    if (cash > 0) {
      if (a[i] < a[i+1]) {
        stock += cash / a[i];
        cash %= a[i];
      }
    }
    if (stock > 0) {
      if (a[i] > a[i+1]) {
        cash += stock * a[i];
        stock = 0;
      }
    }
  }

  if (stock > 0) cash += stock * a[n-1];

  cout << cash << endl;

  return 0;
}


Measured memory_bytes: 3572
# Problem A - Poisonous Cookies

# input process
A, B, C = map(int, input().split())

# initialization
c_count = 0

# count process
nokori = C - (A + B)
if nokori>0:
    c_count = (A + B) + 1
else:
    c_count = C

# output process
print(c_count + B)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var K = ReadInt();
            var X = ReadInt();
            var Y = ReadInt();
            var sum = 0;
            for (int i = 0; i < Min(N, K); i++)
                sum += X;

            if (N - K > 0) sum += (N - K) * Y;
            Println(sum);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static void YESOrNO(bool e) => Println(e ? "YES" : "NO");

        static void YesOrNo(bool e) => Println(e ? "Yes" : "No");

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());
        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}



Measured memory_bytes: 13140
#include<stdio.h>

int main(){
	int N;
	scanf("%d\n",&N);
	double ans=0.0;
	for(int i=0;i<N;i++){
		double x;
		char u[4];
		scanf("%lf%s",&x,u);
		if(u[0]=='J')ans+=x;
		else ans+=x*380000.0;
	}
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 128
def call(n):
    s = ""
    for i in range(1,n+1):
        if i%3 == 0:
            s += " {0}".format(i)
        else:
            x = i
            while x > 0:
               if x%10 == 3:
                   s += " {0}".format(i)
                   break
               x = x // 10
    print(s)

m = int(input())
call(m)

Measured memory_bytes: 7716
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : map(int, stdin.readline().split())

def main():
  n = ni()

  odd = 1 if n%2 == 1 else 0
  for i in range(1, n+1):
    if i%2 == 0:
      odd += 1
  print(odd/n)

main()

Measured memory_bytes: 3060
A,V= map(int,input().split())
B,W= map(int,input().split())
T = int(input())

if A == B:
    print('YES')
    exit()

if V <= W:
    print('NO')
    exit()

L = abs(A-B)
rV = V - W

if L <= rV*T:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 61668
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int h=scanner.nextInt();
		int w=scanner.nextInt();
		int[][] a=new int[h][w];
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				a[i][j]=scanner.nextInt();
			}
		}
		int cnt=0;
		StringBuilder sb=new StringBuilder();
		boolean b=false;
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				int y=(i%2==0)?j:w-1-j;
				if(b) {
					a[i][y]++;
					b=false;
					sb.append((i+1)+" "+(y+1)+"\n");
					cnt++;
				}
				if(a[i][y]%2==0||i==h-1&&j==w-1)continue;
				b=true;
				sb.append((i+1)+" "+(y+1)+" ");
			}
		}
		System.out.println(cnt+"\n"+sb);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 54524
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int a = in.nextInt();
		int b = in.nextInt();
		int t = in.nextInt();
		System.out.println(solve(a, b, t));
		in.close();
	}

	private static int solve(int a, int b, int t) {
		return (t / a) * b;
	}
}


Measured memory_bytes: 23380
n=int(input())
c=input()

head=0
end=n-1

ans=0
ret=False
while head<end:
    while c[head]!="W":
        head+=1
        if head==end:
            ret=True
            break
    
    if ret==True:
        break
    
    while c[end]!="R":
        end-=1
        if head==end:
            ret=True
            break
    
    if ret==True:
        break
    
    ans+=1
    head+=1
    end-=1

print(ans)

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin >> n;
    int arr[n];
    for(int i = 0; i < n - 1; ++i){
        cin >> arr[i];
    }
    int ans = 0;
    for(int i = 0; i < n - 2; ++i){
        ans += min(arr[i], arr[i + 1]);
    }
    ans += arr[0] + arr[n - 2];
    cout << ans;
}

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

int main()
{
  string S;

  cin >> S;

  if (S.at(2) == S.at(3) && S.at(4) == S.at(5))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

int mypow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	int six, nine;
	vector<int> dp(N + 1, INF);
	dp[0] = 0;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= 6; j++) {
			six = mypow(6, j), nine = mypow(9, j);
			if (i >= six) dp[i] = min(dp[i], dp[i - six] + 1);
			if (i >= nine) dp[i] = min(dp[i], dp[i - nine] + 1);
		}
	}

	cout << dp[N] << "\n";

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<string,int> cnt;
  rep(i,n) {
    string s;
    cin >> s;
    cnt[s]++;
  }
  for (string s : {"AC", "WA", "TLE", "RE"}) {
    cout << s << " x " << cnt[s] << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
N, Ma, Mb = map(int, input().split())
a = [0]*N
b = [0]*N
c = [0]*N
INF = 10000


for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())

#dp[i][j][k]...i番目までの品物で, タイプAの物質をjグラム, タイプBの物質をkグラム調達するのに必要な費用の最小値

dp = [[[INF]*400 for _ in range(400)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(400):
        for k in range(400):
            if j < a[i-1] or k < b[i-1]:
                dp[i][j][k] = dp[i-1][j][k]
            else:
                dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1])

ans = INF

for i in range(1, N+1):
    for j in range(1, 400):
        for k in range(1, 400):
            if j*Mb == k*Ma:
                ans = min(ans, dp[i][j][k])
if ans == INF:
    print(-1)
else:
    print(ans)




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

n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    t1, t2 = input().split()
    p.append(int(t1)-1)
    s.append(t2)

# 問題iがACしているかどうかを覚えておく配列
ac = [0 for _ in range(n)]
# 問題iがWAしている回数
pena = [0 for _ in range(n)]

# ac[], pena[]を作る。
for i in range(m):
    if ac[p[i]] == 0:
        if s[i] == 'AC':
            ac[p[i]] = 1 
        else:
            pena[p[i]] += 1

AC=0
PENA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        PENA += pena[i]

print("%d %d" % (AC,PENA))


Measured memory_bytes: 15320
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int l,k;
  string s,t;
  cin>>s>>t;
  l=s.length();
  k=t.length();
  if(l==k-1)
  {
    if(s==t.substr(0,l))
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  else
    cout<<"No"<<endl;
}
  

Measured memory_bytes: 3620
N,Y=map(int, input().split())
flag=True
for x in range(N+1):
    for y in range(N+1-x):
        z=N-x-y
        if(10000*x+5000*y+1000*z==Y):
            print(x,y,z)
            flag=False
            break
    else:
        continue
    break
if(flag):
    print(-1,-1,-1)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N=1e5+9;
ll n,dp[N][3],a[N],b[N],c[N];
int main(){
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    dp[0][0]=a[0];dp[0][1]=b[0];dp[0][2]=c[0];
    for(ll i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<"\n";
    return 0; 
}

Measured memory_bytes: 4992
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        x: u64,
    }

    let ans = if x % 11 == 0 {
        (x / 11) * 2
    } else if x % 11 < 7 {
        (x / 11) * 2 + 1
    } else {
        (x / 11) * 2 + 2
    };

    println!("{}", ans);
}


Measured memory_bytes: 2088
//Bismillahir Rahmanir Raheem
//#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define FF first
#define SS second
#define mxN (int) 2e5 + 2

vector<string> sol;
string ans;
int n;
void Print()
{
    for(auto x : sol)
        cout << x << endl;
}
void solve(int pos, int mx)
{
    if(pos == n) {
        sol.pb(ans);
        return;
    }
    for(int i = 0; i <= pos && i <= mx + 1; i++)
    {
        ans += ('a' + i);
        solve(pos + 1, max(mx, i));
        ans.pop_back();
    }
}

int main()
{
    cin >> n;
    solve(0, 0);
    Print();
}



Measured memory_bytes: 9588
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
if N==2:
    print(1,2)
    exit()
es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

depth = [-1]*N
depth[0] = 0
def dfs(v,p=-1):
    for to in es[v]:
        if to==p: continue
        depth[to] = depth[v] + 1
        dfs(to,v)
dfs(0)

g1 = []
g2 = []
for i,d in enumerate(depth):
    if d%2:
        g2.append(i)
    else:
        g1.append(i)
if len(g1) < len(g2):
    g1,g2 = g2,g1

ans = [None] * N
if len(g2) <= N//3:
    for n in range(1,N+1):
        if n%3==0:
            if g2:
                i = g2.pop()
            else:
                i = g1.pop()
        else:
            i = g1.pop()
        ans[i] = n
else:
    for n in range(1,N+1,3):
        i = g1.pop()
        ans[i] = n
    for n in range(2,N+1,3):
        i = g2.pop()
        ans[i] = n
    for n in range(3,N+1,3):
        if g1:
            i = g1.pop()
        else:
            i = g2.pop()
        ans[i] = n
print(*ans)

Measured memory_bytes: 226152
#include <bits/stdc++.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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

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


    
}

/*
*/



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
VI e[SIZE];
bool u[SIZE];
void print_array(vector<int>&arr){
    REP(i,SZ(arr)){
        if(i)printf(" ");
        printf("%d",arr[i]);
    }
    puts("");
}
int main(){
    DRII(N,M);
    REP(i,M){
        DRII(x,y);
        e[x].PB(y);
        e[y].PB(x);
    }
    int st=1;
    while(!SZ(e[st]))st++;
    VI an;
    an.PB(st);
    u[st]=1;
    bool sus=1;
    while(sus){
        sus=0;
        REP(i,SZ(e[an.back()])){
            int y=e[an.back()][i];
            if(!u[y]){
                sus=1;
                an.PB(y);
                u[y]=1;
                break;
            }
        }
    }
    reverse(ALL(an));
    sus=1;
    while(sus){
        sus=0;
        REP(i,SZ(e[an.back()])){
            int y=e[an.back()][i];
            if(!u[y]){
                sus=1;
                an.PB(y);
                u[y]=1;
                break;
            }
        }
    }
    printf("%d\n",SZ(an));
    print_array(an);
    return 0;
}


Measured memory_bytes: 28024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    cout << (n * (n + 1)) / 2 << endl;
}


Measured memory_bytes: 888
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
s = 0
for i in 0...n do
  s += b[a[i] - 1]
  if i > 0 && (a[i - 1] + 1) == a[i]
    s += c[a[i - 1] - 1]
  end
end
puts s


Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int ct=0;
		//1
		int rt=pow(n,0.5);
		if(rt*rt==n) ct++;
		//2
		for(int i=1;i<=rt+1;i++){
			for(int j=i;j<=rt+1;j++){
				if(i*i+j*j==n) ct++;
			}
		}
		//3
		for(int i=1;i<=rt+1;i++){
			for(int j=i;j<=rt+1;j++){
				for(int k=j;k<=rt+1;k++){
					if(i*i+j*j+k*k==n) ct++;
				}
			}
		}
		//4
		for(int i=1;i<=rt+1;i++){
			for(int j=i;j<=rt+1;j++){
				for(int k=j;k<=rt+1;k++){
					for(int l=k;l<=rt+1;l++){
						if(i*i+j*j+k*k+l*l==n) ct++;
					}
				}
			}
		}
		cout<<ct<<endl;
	}
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    ll ans = 0;
    for(auto it1 = l.begin(); it1 != l.end(); it1++) {
        for(auto it2 = it1; it2 != l.end(); it2++) {
            if (it1 == it2) continue;
            auto it3 = it2; it3++;
            for(auto it4 = upper_bound(it3, l.end(), *it2 - *it1); it4 != l.end(); it4++) {
                if (*it4 >= (*it1 + *it2)) break;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    d = 0;
    for (a; a <= b; a++){
        if(c % a == 0){
            d++;
        }
    }
    printf("%d\n", d);
}


Measured memory_bytes: 2760