akhauriyash/Code-Regression huggingface dataset:
use std::io::{self, BufWriter, Write};

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty), +) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
                assert!(_it.next().is_none());
        }
    };
}

fn top_buttom(size: usize) -> String {
    "#".repeat(size) + "\n"
}

fn middle(size: usize) -> String {
    "#".to_owned() + &".".repeat(size - 2) + "#\n"
}

fn main() {
    let out = io::stdout();
    let mut out = BufWriter::new(out.lock());
    loop {
        from_line!(h: usize, w: usize);
        if h == 0 && w == 0 {
            break;
        }
        let top = top_buttom(w);
        out.write_all(&top.as_bytes()).unwrap();
        for _x in 0..h - 2 {
            let middle = middle(w);
            out.write_all(&middle.as_bytes()).unwrap();
        }
        let buttom = top_buttom(w);
        out.write_all(&buttom.as_bytes()).unwrap();
        out.write_all(b"\n").unwrap();
    }
}



Measured memory_bytes: 5032
#include<iostream>
using namespace std;
int main(){
    int n,c=0,ans=0;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<n-1;i++){
        if(h[i]>=h[i+1])c++;
        else ans=max(ans,c),c=0;
    }
    cout<<max(ans,c)<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 100
int main()
{
	int n,b;
	scanf("%d",&n);
	int a[N];
	for(int c=0;c<n;c++)
	{
		scanf("%d",a+c);	
	}
	int numble=0,judge=1;
	while(judge)
	{
		judge=0;
		for(int i=0;i<n-1;i++)
		{
			if(a[i]>a[i+1])
			{
				b=a[i];
				a[i]=a[i+1];
				a[i+1]=b;
				numble++;
				judge=1;
			}
		}
	}
	for(int j=0;j<n;j++)
	{
		printf("%d",a[j]);
		if(j!=n-1)
		{
			printf(" ");
		}

	}
	printf("\n");
	printf("%d",numble);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2704
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1, i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
string s;int w;
void input(){
    cin>>s>>w;
}
void src(){
    for(int i=0;i<s.length();i+=w){
        cout<<s[i];
    }
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
N = int(input())
A, B, C = [0]*N, [0] * N, [0] * N
bsum = 0
for i in range(N):
    A[i], B[i] = map(int, input().split())
    C[i] = A[i] + B[i]
    bsum += B[i]

C = sorted(C, reverse=True)
ans = -bsum
for i in range(len(C)):
    if(i % 2 == 0):
        ans += C[i]
    else:
        continue
print(ans)


Measured memory_bytes: 16176
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

typedef  long long ll;

#define rep(i,a,n) for(ll (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(ll (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007


using namespace std;

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}


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

void yb(){
    cout << "YES" << endl;
}

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

void nb(){
    cout << "NO" << endl;
}

int dig(int d){
    int ans = 1;
    if(d == 0) return ans;
    while(d != 0){
        d--;
        ans*=100;
    }
    return ans;
}

ll divisors(ll n) {
    vector<ll> res;

    for(ll i = 1; i*i <= n; ++i) {
        if(n % i != 0) continue;
        res.push_back(i-1);
        if(n/i == i) continue;
        res.push_back((n/i)-1);
    }

    ll ans = 0;

    rep(i,0,res.size()){
        if(res[i] != 0)
        if(n/res[i] == n%res[i]) ans += res[i];
    } 
    return ans;
}


void solve(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for(int i = a;i <=b;i++) {
    if(i%10 == i/10000%10 && i/10%10 == i/1000%10){ans++;}
  }
  cout << ans << endl;

}

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


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  const N = Number.parseInt(inputStr[0]);
  inputStr = input[1].split(" ");
  const S = inputStr[0];
  //引数Sを重み付けして配列ANSに格納する
  var ans = [];
  var tmp = 1;
  for(var i=1 ; i<N ; i++){
    //console.log("loop内出力",S.substr(i,1));
    if( S.substr(i-1,1) !== S.substr(i,1) ){
      ans.push(tmp);
      tmp = 1;
    } else {
      tmp++;
    }
  }
  ans.push(tmp);
  //結果出力
  console.log(ans.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

l = [2,1]
i = 2
while True:
    l.append(l[i-1] + l[i-2])
    if i == n:
        print(l[i])
        exit()
    elif n == 0:
        print(2)
        exit()
    elif n == 1:
        print(1)
        exit()
    else:
        i += 1

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n";
#pragma GCC optimize "trapv"
using namespace std;
typedef long long int ll;
int mx =1e6+100;
int mod = 1e9+7;

  
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int n= (int )s1.size();
    int m = (int)s2.size();
    //
    int ans=INT_MAX;
    for(int i=0;i<=n-m;i++)
    {
        int v=i,ct=0;
       // cout<<"i:"<<i<<endl;
        for(int j=0;j<m;j++)
        {
            if(s1[v]!=s2[j]){
                ct++;
            }
            v++;
        }
      //  cout<<i<<" "<<ct<<endl;
        ans = min(ans,ct);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    string s;
    cin >> s;

    int l = 0;
    int cnt = 0;
    for (auto i = 0; i < s.length(); ++i)
    {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
        {
            cnt++;
        }
        else
        {
            l = max(l, cnt);
            cnt = 0;
        }
    }
    if (cnt)
        l = max(l, cnt);
    Cout(l);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
    long long int a,b,c,d,ans1,ans2,ans3,ans4;
    int i = 0;
    scanf("%lld %lld %lld %lld", &a,&b,&c,&d);
    ans1 = a * c;
    ans2 = b * d;
    ans3 = a * d;
    ans4 = b * c;
    if(ans1 >= ans2 && ans1 >= ans3 && ans1 >= ans4){
        printf("%lld\n", ans1);
    }else if(ans2 >= ans1 && ans2 >= ans3 && ans2 >= ans4){
        printf("%lld\n", ans2);
    }else if(ans3 >= ans2 && ans3 >= ans1 && ans3 >= ans4){
        printf("%lld\n", ans3);
    }else if(ans4 >= ans2 && ans4 >= ans3 && ans4 >= ans1){
        printf("%lld\n", ans4);
    }
    return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<iostream>
using namespace std;
int k;
int mp[1005];
int main()
{
	scanf("%d",&k);
	if(k==1)
	{
		printf("1\n");
		printf("1\n");
		return 0;
	}
	int n=((k-1)/4+1)*2;
	for(int i=0;i<n;++i)
	{
		mp[i]=i+1;
		mp[i+n]=(i+n<k?i+n:i)+1; 
	}
	printf("%d\n",n);
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			if(j) printf(" ");
			printf("%d",mp[(i&1)?n+(i+j)%n:(i+j)%n]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int placesum = 0;
    int t = N,c = 0;
    for(int i = 0;i < 9;i++){
        if(t > 0){
        c += t % 10;
        t  = t / 10;
        }
    }
    if(N % c == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
	return firstElof.second > secondElof.second;
}

int gkmax(vector<pair<int, int>> cnt1, vector<pair<int, int>> cnt2) {

	int max = 0;
	int cnt1Max = cnt1[0].second;
	for (int i = 0; i < cnt1.size() && cnt1[i].second == cnt1Max; i++) {
		if (cnt1[i].first == cnt2[0].first) {
			if (max < cnt1[i].second + cnt2[1].second) {
				max = cnt1[i].second + cnt2[1].second;
			}
		}
		else {
			if (max < cnt1[i].second + cnt2[0].second) {
				max = cnt1[i].second + cnt2[0].second;
			}
		}
	}
	return max;
}

int main(void)
{
	int n;
	map<int,int> gusuc;
	map<int, int> kisuc;
	vector<pair<int, int>> gusucsorted;
	vector<pair<int, int>> kisucsorted;
	cin >> n;

	vector<int> v(n);

	for (int i = 0; i < v.size(); i++) {
		cin >> v[i];
		if (i % 2 == 1) {
			gusuc[v[i]]++;
		}
		else {
			kisuc[v[i]]++;
		}
	}

	for (auto itr = gusuc.begin(); itr != gusuc.end(); ++itr) {
		gusucsorted.push_back(*itr);
	}
	for (auto itr = kisuc.begin(); itr != kisuc.end(); ++itr) {
		kisucsorted.push_back(*itr);
	}

	sort(gusucsorted.begin(),gusucsorted.end(),pairCompare);
	sort(kisucsorted.begin(), kisucsorted.end(), pairCompare);



	if (n == kisuc[v[0]] + gusuc[v[0]]) {
		cout << n / 2 << endl;
	}
	else {
		cout << n - max(gkmax(gusucsorted, kisucsorted), gkmax(kisucsorted, gusucsorted)) << endl;
	}

	return 0;
}



Measured memory_bytes: 7800
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  double w,h,x,y;cin>>w>>h>>x>>y;
  cout<< fixed<< setprecision(6)<<w*h/2<<" ";
  if(w/2==x&&h/2==y)
    cout<<1;
  else
    cout<<0;
}


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

const int N = 10000;

class DisjointSet {
  int p[N], rank[N];

public:
  DisjointSet(int n) {
    for (int i = 0; i < n; i++) make_set(i);
  };

  void make_set(int x) {
    rank[x] = 0;
    p[x] = x;
  }

  int findSet(int x) {
    if (x != p[x]) p[x] = findSet(p[x]);
    return p[x];
  }

  void unite(int x, int y) {
    int root_x, root_y;
    root_x = findSet(x);
    root_y = findSet(y);

    if (rank[root_x] > rank[root_y]) {
      p[root_y] = root_x;
    } else if (rank[root_x] < rank[root_y]) {
      p[root_x] = root_y;
    } else {
      p[root_y] = root_x;
      root_x++;
    }
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }
};



int main() {
  int i, n, q, com, x, y;

  cin >> n >> q;

  DisjointSet dj(n);

  for (i = 0; i < q; i++) {
    cin >> com >> x >> y;
    if (com) cout << dj.same(x, y) << endl;
    else dj.unite(x, y);
  }

  return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <algorithm>
int main(){
  int p, q, r;
  std::cin >> p >> q >> r;
  std::vector<int> hours;
  hours.push_back(p + q);
  hours.push_back(p + r);
  hours.push_back(q + r);
  std::sort(hours.begin(), hours.end() );
  std::cout << hours[0];
}

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

int N;
bool flag = false;

int main()
{
    scanf("%d",&N);
    int T = 0,X = 0,Y = 0;
    for(int i = 0; i < N; i++)
    {
        int t,x,y;
        scanf("%d%d%d",&t,&x,&y);
        int dis = abs(x - X) + abs(y - Y);
        if(t - T < dis || ((t - T) % 2 != dis % 2))flag = true;
        T = t;
        X = x;
        Y = y;
    }
    if(flag)printf("No\n");
    else printf("Yes\n");
    return 0;
}


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

int main() {
  ll h;
  cin >> h;
  ll sum =0;
  ll H=h;
  while(H){
    H/=2;
    sum++;
  }
  ll ans=pow(2,sum)-1;
  cout << ans<<endl;
}

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

int main(){
  int n;
  long long tot = 0;
  long long card_types = 0;
  map<long long, long long> m;
  cin >> n;
  for (int i=0;i<n;i++) {
    long long tmp_a;
    cin >> tmp_a;
    if (m.find(tmp_a) == m.end()) {
      m[tmp_a] = 0;
      card_types++;
    } else {
      tot++;
    }
    m[tmp_a]++;
  }
  cout << card_types - (tot % 2) << endl;
  return(0);
}


Measured memory_bytes: 6528
L,R=map(int,input().split())
Lk=int((L-L%2019)/2019)
Rk=int((R-R%2019)/2019)
list1=[]
if Lk==Rk:
    Lr=L%2019
    Rr=R%2019
    for i in range(Lr,Rr):
        for j in range(i+1,Rr+1):
            list1.append((i*j)%2019)
    print(min(list1))    
else:
    print(0)

Measured memory_bytes: 75416
s=int(input())
h=0
while True:
    if s>=500:
        a=s//500
        h +=1000*a
        s=s%500
        
    elif s>=5:
        a=s//5
        h +=5*a
        s=s%5
    else:
        break
    
print(str(h))

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
double dp[100][100],g[100][100];
int main(){
  int n, m;
  while(cin >> n >> m , n){
    for(int i = 0 ; i < n ; i++ ) for(int j = 0 ; j < n ; j++ ) cin >> g[i][j];
 
    fill_n( dp[0], n, 1.0);
    fill_n( dp[1], 9900, 0.0);
    for(int i = 1 ; i < m ; i++ ){ //回数
      for(int prev = 0 ; prev < n ; prev++ ){ // prev
        for(int now = 0 ; now < n ; now++ ){ // now
          dp[i][now] = max( dp[i][now], dp[i - 1][prev] * g[prev][now]);
        }
      }
    }
    cout << fixed << setprecision(2) << *max_element( dp[m - 1], dp[m - 1] + n ) << endl;
  }
}

Measured memory_bytes: 1444
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
const int N = 3e5+5;
const int INF = 0x3f3f3f3f;

char seq[N];
int prefix[N];
int suffix[N];
int main() {
    int n;
    while(~scanf("%d %s", &n, seq+1)) {
        prefix[0] = 0;
        for(int i = 1; i <= n; ++i) {
            prefix[i] = prefix[i-1] + (seq[i] == 'W');
        }
        suffix[n + 1] = 0;
        for(int i = n; i >= 1; --i) {
            suffix[i] = suffix[i+1] + (seq[i] == 'E');
        //    printf("%d\n", suffix[i]);
        }
        int ans = INF;
        for(int i = 1; i <= n; ++i) {
            ans = min(ans, prefix[i-1] + suffix[i+1]);
        }  
        printf("%d\n", ans);
    }   
    return 0;
}

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

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

    vector<int> A(n);
    vector<int> kek(n);
    for (int i = 0; i < n; ++i)
        cin >> A[i];
    kek[0] = 0;
    kek[1] = abs(A[0] - A[1]);

    int sum = 0; int tmp;
    for (int i = 2; i < n; ++i)
        kek[i] = min(kek[i - 1] + abs(A[i] - A[i - 1]),
                     kek[i - 2] + abs(A[i] - A[i - 2]));

    cout << kek.back() << endl;
}


Measured memory_bytes: 4060
n = int(input())
s = ''
while n:
  x = (n + 40000000000) % 4
  if x == 0:
    s = '00' + s
  if x == 1:
    s = '01' + s
    n -= 1
  if x == 2:
    s = '10' + s
    n += 2
  if x == 3:
    s = '11' + s
    n += 1
  n //= 4
s = s.lstrip('0')
if not s:
  s = '0'
print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

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

typedef pair<string, int> P;
int main() {
    int n, q;
    int tt = 0;
    cin >> n >> q;
    queue<P> que;
    REP(i,n) {
        string name;
        int time;
        cin >> name >> time;
        que.push(make_pair(name, time));
    }
    
    while(!que.empty()) {
        P top = que.front();
        if (top.second <= q) {
            tt += top.second;
            cout << top.first << " " << tt << endl;
            que.pop();
        }else {
            tt += q;
            que.push(make_pair(top.first, top.second - q));
            que.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e8+7;

ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

const int N = 2020;
ll f[N];
ll C(ll n, ll r){
    ll ret = f[n];
    (ret*=mod_inv(f[r]))%=mod;
    (ret*=mod_inv(f[n-r]))%=mod;
    return ret;
}

int main(){
    f[0]=1;
    for(ll i=1; i<N; ++i) f[i]=(f[i-1]*i)%mod;

    int r,c,a1,a2,b1,b2;
    cin >>r >>c >>a1 >>a2 >>b1 >>b2;

    int mul = 1;
    int X = abs(a1-b1);
    if(X == r-X) mul *= 2;
    X = min(X,r-X);

    int Y = abs(a2-b2);
    if(Y == c-Y) mul *= 2;
    Y = min(Y,c-Y);

    cout << (C(X+Y,X)*mul)%mod << endl;
    return 0;
}



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

vector<int> e[100000];

bool d[100000],used[100000];

int dfs(int p,int pr){
  if(used[p]){
    return p;

  }
  used[p]=1;
   for(int i=0;i<e[p].size();i++){
    int np=e[p][i];
    if(np==pr)continue;
    int res=dfs(np,p);
    if(res!=-1){
      if(res>=0)d[p]=1;
      if(res==p)return -2;
      return res;
    }
  }
  return -1;
}

signed main(){
  int n;
  cin>>n;
  int u,v;
  for(int i=0;i<n;i++){
    cin>>u>>v;
    u--,v--;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(0,-1);
  int q,a,b;
  cin>>q;
  while(q--){
    cin>>a>>b;
    a--,b--;
    cout<<((d[a]&&d[b])?2:1)<<endl;
  }
  return 0;
}



Measured memory_bytes: 13500
using System;

    class Program
    {
        static void Main(string[] args)
        {
            string[] st = Console.ReadLine().Split(' ');
            int n = int.Parse(st[0]);
            int k = int.Parse(st[1]);

            double prob = 0;
            int m = 1;
            while (m < k && m <= n)
            {
                int i = m;
                int count = 0;
                while (i < k)
                {
                    i *= 2;
                    ++count;
                }
                prob += 1.0 / Math.Pow(2, count);
                ++m;
            }
            for (int i = m; i <= n; i++)
            {
                prob += 1;
            }

            prob /= n;

            Console.WriteLine(prob);
        }
    }

Measured memory_bytes: 11092
#include<iostream>
#include<numeric>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){ 
	int a,b,c; cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int x;
    cin>>x;
    cout<<(30<=x?"Yes":"No")<<endl;
}

Measured memory_bytes: 3636
n,m = map(int,input().split())


l = [0] * m
r = [0] * m

for i in range(m):
    l[i], r[i] = map(int, input().split())
    
    
l_max = 0
r_min = 1000000000000     
for i in range(m):
    a = max(l[i],r[i])
    b = min(l[i],r[i])
    if a<r_min:
        r_min = a
    if b>l_max:
        l_max = b

print(max(r_min-l_max+1,0))         

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

using namespace std;
using ll=long long;

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

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


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N;
vpint adj[2001];
int d[2001][2001],color[2001][2001];
int dnum[2001][2001]={};
void dijkstra(int st){
	priority_queue<pint> PQ;//辺の長さのオーバーフローに注意！
	rep(i,N){
		d[st][i]=INF;
		color[st][i]=0;
	}
	d[st][st]=0;
	color[st][st]=1;
	PQ.push(mp(0,st));
	while(!PQ.empty()){
		pint f=PQ.top();
		PQ.pop();
		int u=f.second;
		color[st][u]=2;
		if(d[st][u]< -f.first) continue;
		rep(j,adj[u].size()){
			int v=adj[u][j].first;
			if(color[st][v]==2) continue;
			if(d[st][v]>d[st][u]+adj[u][j].second){
				d[st][v]=d[st][u]+adj[u][j].second;
				PQ.push(mp(-d[st][v],v));
				color[st][v]=1;
			}
		}
	}
}
int main(){
	int K;
	scan(N>>K);
	rep(i,N-1){
		int a,b;
		scan(a>>b);
		a--; b--;
		adj[a].push_back({b,1});
		adj[b].push_back({a,1});
	}
	rep(i,N) dijkstra(i);
	if(K%2){
		int ans=INF;
		rep(i,N){
			rep(j,adj[i].size()){
				int overnum=0;
				int v=adj[i][j].first;
				rep(k,N){
					if(min(d[i][k],d[v][k])>(K-1)/2){
						overnum++;
					}
				}
				ans=min(ans,overnum);
			}
		}
		prin(ans);
	}
	else{
		int ans=INF;
		rep(i,N){
			int overnum=0;
			rep(k,N) if(d[i][k]>K/2) overnum++;
			ans=min(ans,overnum);
		}
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int a,b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	char s[3], count=0;
	
	scanf("%s", s);
	
	if(s[0] == 'o') count++; 
	if(s[1] == 'o') count++; 
	if(s[2] == 'o') count++; 
	
	printf("%d\n", 700+100*count);
	return 0;
}

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

public class Main {
    static int count = 1;

    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        int x1 = scanner.nextInt();
        print(x1);
        int x2 = scanner.nextInt();
        print(x2);
        int x3 = scanner.nextInt();
        print(x3);
        int x4 = scanner.nextInt();
        print(x4);
        int x5 = scanner.nextInt();
        print(x5);
    }

    private static void print(int number) {
        if(number == 0) {
            System.out.println(count);
            System.exit(0);
        }
        count++;
    }

}

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: 32372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    int flag = 0;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) flag = 1;
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int min = n + 1;
		int ans = 0;

		for (int i = 0; i < n; i++) {
			int next = scan.nextInt();
			if (min > next) {
				min = next;
				ans++;
			}
		}
		System.out.println(ans);

		scan.close();
	}
}


Measured memory_bytes: 62860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

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

    int ans = 0;
    for (int i = 1; i < 35; i++) {
        for (int j = 2; j < 10; j++) {
            int a = 1;
            for (int k = 0; k < j; k++) {
                a *= i;
            }
            if (a <= x) ans = max(ans, a);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
  {
  ios_base::sync_with_stdio(0); 
  LL a;
  cin >> a;
  int b1, b2;
  char ch;
  cin >> b1 >> ch >> b2;

  LL b = b1 * 100 + b2;

  cout << a * b / 100 << endl;
  }


Measured memory_bytes: 3648
MOD = 10 ** 9 + 7
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

sm = [[0] * (M + 1) for _ in range(N + 1)]
for i in range(N + 1):
    sm[i][0] = 1
for j in range(M + 1):
    sm[0][j] = 1

for i in range(1, N + 1):
    for j in range(1, M + 1):
        tmp = sm[i - 1][j - 1] if S[i - 1] == T[j - 1] else 0
        sm[i][j] = (sm[i - 1][j] + sm[i][j - 1] - sm[i - 1][j - 1] + tmp) % MOD

print(sm[N][M])


Measured memory_bytes: 72668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.next();
		int con = 0;

		for (int i = 0; i < line.length(); i++) {
			con +=Character.getNumericValue(line.charAt(i));

		}

		if (con %9==0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}


	}

}

Measured memory_bytes: 39772
import sys 
from collections import Counter
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
l = read().decode().split()
c = Counter(l)
 
max = c.most_common()[0][1]
ans = [i[0] for i in c.items() if i[1] >= max]
 
print('\n'.join(sorted(ans)))

Measured memory_bytes: 50232
#include <cstdio>
#include <algorithm>
using namespace std;

int n;
int l[255];

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

	n += n;

	for (int i = 0; i < n; i++) scanf("%d", &l[i]);

	sort(l, l + n);

	int res = 0;

	for (int i = 0; i < n; i += 2) res += l[i];

	printf("%d\n", res);

	return 0;
}

Measured memory_bytes: 128
s = input()
if s == "SUN":
    print(7)
elif s == "SAT":
    print(1)
elif s == "FRI":
    print(2)
elif s == "THU":
    print(3)
elif s == "WED":
    print(4)
elif s == "TUE":
    print(5)
elif s == "MON":
    print(6)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={0,31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int n,m;
int a[200005];
int cnt[200005];
inline void init() {
	for(int i=1;i<=n;i++) {
		a[i]=i;
		cnt[i]=1;
	}
}
inline int get(int x) {
	if(a[x]==x) 
		return x;
	return a[x]=get(a[x]);
}
int main(){
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	init();
	for(int i=1;i<=m;i++) {
		int u,v;
		cin>>u>>v;
		u=get(u);
		v=get(v);
		if(u!=v) {
			a[v]=u;
			cnt[u]+=cnt[v];
		}
	}
	int res=0;
	for(int i=1;i<=n;i++) {
		if(a[i]==i) {
			res=max(res,cnt[i]);
		}
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 5184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String b = in.next();
            char c = b.charAt(0);
            System.out.println(c == 'A' ? 'T' : c == 'T' ? 'A' : c == 'C' ? 'G' : 'C');
        }
    }
}


Measured memory_bytes: 26812
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
sum_A = np.sum(A)
cumsum_A = np.cumsum(A)

ans = float('inf')
for i in range(N - 1):
    ans = min(ans, abs(sum_A - 2 * cumsum_A[i]))
print(ans)

Measured memory_bytes: 32732
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

struct vec
{
    double x, y;
    vec (const double& x0 = 0, const double& y0 = 0) : x(x0), y(y0) {}
    vec operator + (const vec& t) const {return vec(x+t.x, y+t.y);}
    vec operator - (const vec& t) const {return vec(x-t.x, y-t.y);}
    vec operator * (const double& t) const {return vec(x*t, y*t);}
    vec operator / (const double& t) const {return vec(x/t, y/t);}
    const double len2 () const {return x*x + y*y;}
    const double len () const {return sqrt(len2());}
    vec norm() const {return *this/len();}
    vec rotate_90_c () {return vec(y, -x);}
};

double dot(const vec& a, const vec& b) {return a.x*b.x + a.y*b.y;}
double crs(const vec& a, const vec& b) {return a.x*b.y - a.y*b.x;}

vec lin_lin_int(const vec& p0, const vec& v0, const vec& p1, const vec& v1)
{
    double t = crs(p1-p0, v1) / crs(v0, v1);
    return p0 + v0 * t;
}

vec circle(const vec& a, const vec& b, const vec& c)
{
    return lin_lin_int((a+b)/2, (b-a).rotate_90_c(), (a+c)/2, (c-a).rotate_90_c());
}

int n;
vec pot[100005];

int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++) scanf("%lf%lf", &pot[i].x, &pot[i].y);
    random_shuffle(pot+1, pot+n+1);
    vec o;
    double r2 = 0;
    for(int i=1; i<=n; i++)
    {
        if((pot[i]-o).len2() > r2)
        {
            o = pot[i], r2 = 0;
            for(int j=1; j<i; j++)
            {
                if((pot[j]-o).len2() > r2)
                {
                    o = (pot[i]+pot[j])/2, r2 = (pot[j]-o).len2();
                    for(int k=1; k<j; k++)
                    {
                        if((pot[k]-o).len2() > r2)
                        {
                            o = circle(pot[i], pot[j], pot[k]), r2 = (pot[k]-o).len2();
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n", sqrt(r2));
    return 0;
}

Measured memory_bytes: 1920
def dp_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    dp=[[float("inf") for _ in range(2)] for _ in range(l+2)]
    dp[0][0]=0
    for i in range(l+1):
        for j in range(2):
            num=int(rev[i])
            num+=j
            if num<10:
                dp[i+1][0]=min(dp[i+1][0],dp[i][j]+num)
            if num>0:
                dp[i+1][1]=min(dp[i+1][1],dp[i][j]+(10-num))

    import numpy as np
    dp=np.array(dp)
    return(dp[l+1])

def y_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    seq_flag=False
    ans=0
    next_bit=0
    kuri_cal=0
    for i in range(l-1):
        num=int(rev[i])+next_bit
        next_num=int(rev[i+1])
        if not seq_flag:
            if (num<5) or (num==5 and next_num<5):
                ans+=num
                next_bit=0
                kuri_cal=0
                continue
            seq_s=i
            seq_flag=True
            kuri_cal=10-num
            next_bit+=1
            continue
        #print(kuri_cal)
        if num<5:
            ans+=(kuri_cal+num)
            kuri_cal=0
            next_bit=0
            seq_flag=False
        elif num>5:
            kuri_cal+=10-num
        else:
            if next_num<5:
                ans+=(kuri_cal+num)
                next_bit=0
                kuri_cal=0
                seq_flag=False
            else:
                kuri_cal+=10-num
    last=int(tmp[0])+next_bit
    ans+=kuri_cal+min(last,11-last)
    return ans

n=input()
ans=y_solver(n)
print(ans)

Measured memory_bytes: 5620
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n;cin>>n;
  int seq[200004];
  int check[200004];
  for(int i=0;i<n;i++)cin>>seq[i];
  for(int i=0;i<n;i++)check[i]=0;
  for(int i=0;i<n;i++)check[ seq[i] ] = check[ seq[i]-1 ]+1;
  int ans = 0;
  for(int i=0;i<=n;i++) ans = max(ans, check[i]);
  cout<<(n-ans)<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const double PI = 3.1415926535;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n; cin >> n;
    vector<int> num(n);
    REP(i, n) cin >> num[i];
    whole(sort, num, greater<>());


    int ans = INF;
    REP(i, 101){
        int tmp = 0;
        REP(j, n){
            tmp += (num[j] - i) * (num[j] - i);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    int a, b;
    cin >> a >> b;
    vector<vector<int>> vv;
    vector<int> v = {1,3,5,7,8,10,12};
    vector<int> v1 = {4,6,9,11};
    vector<int> v2 = {2};
    vv.push_back(v);
    vv.push_back(v1);
    vv.push_back(v2);
    for (int i = 0; i < 3; i++) {
        if (find(bn(vv[i]), a) != vv[i].end() && find(bn(vv[i]), b) != vv[i].end()) {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No\n";

}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9+7;
#define REP(i,j,n) for(int i=j;i<n;i++)
#define rep(i,n) REP(i,0,n)


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    rep(i,3)
    {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define M ((ll)1e12)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
typedef long long ll;
using namespace std;


void solve()
{
   int m1,d1,m2,d2;
   cin>>m1>>d1>>m2>>d2;
   int ar[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
   if(d1==ar[m1])
   cout<<1<<endl;
   else
   cout<<0<<endl;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=3*100000;
int n ,a[N],b[N],c[N],d[N],tot=0,tot2=0;
bool tag=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(tag==0)
		{
			tot++;b[tot]=a[i];tag=1;
		}
		else
		{
			tot2++;c[tot2]=a[i];tag=0;
		}
	}
	int tot3=0;
	for(int i=tot2;i>=1;i--)
	{
		d[++tot3]=c[i];
	}
	if(tag==0)
	{
		for(int i=1;i<=tot3;i++) printf("%d ",d[i]);
		for(int i=1;i<=tot;i++) printf("%d ",b[i]);
	}
	else
	{
		for(int i=tot;i>=1;i--) printf("%d ",b[i]);
		for(int i=1;i<=tot2;i++) printf("%d ",c[i]);
	}
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define Mod 998244353
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll k;
    string s;
    cin>>k>>s;
    if(s.length()>k){
    	for(ll i=0;i<k;i++)
    	cout<<s[i];
    	cout<<"...";
	}
	else
	cout<<s;
}

Measured memory_bytes: 3652
def read_inputs
  exam_results = []
  while true do
    exam_result = gets.split(" ").map(&:to_i)
    case exam_result
      when [-1, -1, -1] then break
      else exam_results << exam_result
    end
  end
  exam_results
end

def score(m, f, r)
  return "F" if m == -1 || f == -1
  total = m + f
  return "A" if total >= 80
  return "B" if total >= 65
  return "C" if total >= 50 || r >= 50
  return "D" if total >= 30
  "F"
end

exam_results = read_inputs
puts exam_results.map {|r| score(*r)}.join("\n")

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0, coin = 0;
  while (coin < c) {
    count++;
    coin += a;
    if (count % 7 == 0) coin += b;
  }
  cout << count << endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int64_t> v(N);
	int64_t s = 0, cnt = 0, m = INT_MAX;

	for (int64_t i = 0; i < N; i++) {
		int64_t n;
		cin >> n;
		v[i] = n;
		if (n < 0) {
			cnt++;
			n *= -1;
		}
		m = min(m, n);
		s += n;
	}

	if (cnt % 2 == 0) cout << s << endl;
	else cout << s - m * 2 << endl;
}

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

const int MAXN = 100000;
long long a[MAXN + 1], b[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    	cin >> a[i] >> b[i];
    long long ans = 0;
    for(int i = n - 1; i >= 0; i--) {
    	a[i] += ans;
    	if(a[i] % b[i])
    		ans += b[i] - a[i] % b[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        long[][] dp = new long[N+1][W+1];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        for (int i = 1; i <= N ; i++) {//item
            for (int j = 1; j <=W ; j++) {
                if(j-w[i-1]>=0)
                    dp[i][j] = Math.max(dp[i-1][j],dp[i-1][j-w[i-1]] +v[i-1]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }

        System.out.println(dp[N][W]);

    }

}


Measured memory_bytes: 125012
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    string ans = "APPROVED";
    rep(i,n) {
        if (a[i]%2==0) {
            if (a[i]%3!=0 && a[i]%5!=0) ans = "DENIED";
        }
    }
    cout << ans << endl;
    return 0;
}





























Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,K;
    cin>>N>>K;
    cout<<N-K+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n,k;
    cin >> n >> k;
    int d=0;
    while(n>0){
        n/=k;
        ++d;
    }
    cout << d << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int people = 0;
  for(int i=0; i<N; i++){
    int A, B;
    cin >> A >> B;
    people += B-A+1;
  }
  
  cout << people << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}
const int N=2e5+50;
int n,m,q[N],h,t,deg[N][2];
char s[N];
vector<int> g[N];

bool chk(int v){return deg[v][1]&&deg[v][0]; }
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n),read(m); 
	scanf("%s",s+1);
	rep(i,1,m){
		int u,v;
		read(u),read(v);
		g[u].pb(v),g[v].pb(u);
		deg[v][s[u]-'A']++;
		deg[u][s[v]-'A']++;
	}
	rep(i,1,n)Pr("%d,%d\n",deg[i][0],deg[i][1]);
	rep(i,1,n)if(!chk(i))q[t++]=i;
	Pr("t=%d\n",t);
	while(h<t){
		int v=q[h++];
		Pr("v=%d\n",v);
		for(int d:g[v]){
			bool o=chk(d);
			--deg[d][s[v]-'A'];
			if(o&&!chk(d))q[t++]=d;
		}
	}
	puts(t==n?"No":"Yes");
	return 0; 
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define 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>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    vector<int>vec = {a,b,c};
    sort(vec.begin(), vec.end());

    cout << vec[1] - vec[0] + vec[2] - vec[1] << endl;
}

Measured memory_bytes: 256