akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3580
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    string s, c = "hi";
    cin >> s;
    bool ch = true;
    lli i = 0;
    if(s.size()%2!=0){
        ch = false;
    }
    while(i<s.size()-1){
        string p = s.substr(i, 2);
        if(p!=c){
            ch = false;
            break;
        }
        i += 2;

    }
    YN(ch);
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
 
int main() 
{
    FAST;
    ll n,m;
    cin>>n>>m;
    if(n%2==1)
        for(int i=1,j=n,k=0;i<j && k<m;i++,j--,k++)
            cout<<i<<' '<<j<<'\n';
    else
    {
        int k=0;
        for(int i=1,j=n/2;i<j && k<m;i++,j--,k++)
            cout<<i<<' '<<j<<'\n';
        for(int i=(n/2)+2,j=n;i<j && k<m;i++,j--,k++)
            cout<<i<<' '<<j<<'\n';
    }
    subt;
    return 0;
}

Measured memory_bytes: 3792
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>
#include<math.h>

int main(void){
	char s[2000]={0};
	int w,i;

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

	for(i=0;s[i]!=0;i+=w){
		putchar(s[i]);
	}
	putchar('\n');
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		ll n;
		cin>>n;
		if(n==0) break;
		set<P> emp;
		set<pair<P,ll>> plt;
		map<ll,vector<P>> buf;
		emp.insert(P(0,INF+1));
		REP(roop,n) {
			char c;
			cin>>c;
			if(c=='W') {
				ll idt,sec;
				cin>>idt>>sec;
				buf[idt]=vector<P>();
				while(sec>0) {
					P p=*(emp.begin());
					emp.erase(emp.begin());
					if(p.second-p.first+1>sec) {
						buf[idt].pb(P(p.first,p.first+sec-1));
						plt.insert(pair<P,ll>(P(p.first,p.first+sec-1),idt));
						emp.insert(P(p.first+sec,p.second));
						sec=0;
					} else {
						buf[idt].pb(p);
						plt.insert(pair<P,ll>(p,idt));
						sec-=(p.second-p.first+1);
					}
				}
			}
			if(c=='D') {
				ll dlt;
				cin>>dlt;
				vector<P> vec=buf[dlt];
				REP(i,(ll)vec.size()) {
					emp.insert(vec[i]);
					plt.erase(pair<P,ll>(vec[i],dlt));
				}
				buf.erase(dlt);
			}
			if(c=='R') {
				ll ref;
				cin>>ref;
				if(plt.empty()) {
					cout<<-1<<endl;
					continue;
				}
				auto ite=upper_bound(ALL(plt),pair<P,ll>(P(ref,INF*INF),INF*INF));
				if(ite==plt.begin()) {
					cout<<-1<<endl;
					continue;
				}
				ite--;
				if((*ite).first.first<=ref&&(*ite).first.second>=ref) cout<<(*ite).second<<endl;
				else cout<<-1<<endl;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3812
#include<stdio.h>
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	int h[n];
	int flag[n];
	for(int i=1;i<=n;i++){
	scanf("%d",&h[i]);
	flag[i]=1;
	}
	for(int i=1;i<=m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(h[a]>=h[b]){
			flag[b]=0;
		}
		if(h[a]<=h[b])
		flag[a]=0;
	}
	int count=0;
	for(int i=1;i<=n;i++){
		if(flag[i]==1)
		count++;
	}
	printf("%d",count);
}


Measured memory_bytes: 2448
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  double x[3], y[3];
  for (int i = 0; i < 3; i++) {
      cin >> x[i] >> y[i];
  }
  double a = sqrt((x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]));
  double b = sqrt((x[0] - x[2]) * (x[0] - x[2]) + (y[0] - y[2]) * (y[0] - y[2]));
  double c = sqrt((x[1] - x[2]) * (x[1] - x[2]) + (y[1] - y[2]) * (y[1] - y[2]));
  double s = (a + b + c) / 2;
  double S = sqrt(s * (s - a) * (s - b) * (s - c));
  double r = 2 * S / (a + b + c);
  double m = max({a, b, c});
  double ans = m * r / (m + 2 * r);
  cout << setprecision(15) << ans << endl;
}

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

int main(){
    int N, x;

    for(int j=0;j < 5;j++){
      cin>>N;
      if(N == 0) break;
      
      for(int i=0;i < 9;i++){
        cin>>x;
        N -= x;
      }
      cout<<N<<endl;
    }
    return 0;
}



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

const int N=105;

int n,m,f[N][N];
char ma[N][N];

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",ma[i]+1);
	if (ma[1][1]=='#') f[1][1]=1;
	for (int i=2;i<=n;i++)
	{
		if (ma[i][1]=='.'||ma[i][1]==ma[i-1][1]) f[i][1]=f[i-1][1];
		else f[i][1]=f[i-1][1]+1;
	}
	for (int i=2;i<=m;i++)
		if (ma[1][i]=='.'||ma[1][i]==ma[1][i-1]) f[1][i]=f[1][i-1];
		else f[1][i]=f[1][i-1]+1;
	for (int i=2;i<=n;i++)
		for (int j=2;j<=m;j++)
		{
			if (ma[i][j]=='.'||ma[i][j]==ma[i][j-1]) f[i][j]=f[i][j-1];
			else f[i][j]=f[i][j-1]+1;
			if (ma[i][j]=='.'||ma[i][j]==ma[i-1][j]) f[i][j]=std::min(f[i][j],f[i-1][j]);
			else f[i][j]=std::min(f[i][j],f[i-1][j]+1);
		}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 256
def T(N,A):
    t = 1
    for i in range(N):
        if A[i]%2 == 1:
            t = 0
    return t

def W(b):
    return b/2

N = int(input())
A = list(map(int,input().split()))
count = 0
t = T(N,A)
while t == 1:
    A = list(map(W,A))
    count += 1
    t = T(N,A)
print(count)



Measured memory_bytes: 9140
#include<cstdio>
using namespace std;
int main(){
	int a,b,c,d,e;
	scanf("%d",&a);
	for(b=1;b<=a;b++){
		scanf("%d%d%d",&c,&d,&e);
		if(c%2^(d+e)%2||c<d+e){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int K,A,B;
    cin >> K >> A >> B;
    int count=0;
    for(int x=A;x<=B;x++){
        if(x%K==0){
            count++;
        }
    }
    if(count!=0){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
}

Measured memory_bytes: 3596
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=300005;
int cnt[M],tmp,abr_cnt[M];
int fx[M];
int pcnt[M],pabr_cnt[M];
int ses[M];
 main()

{
    fast
    int n;
    cin>>n;
    f(i,1,n)
    {
        cin>>tmp;
        cnt[tmp]++;
    }
    f(i,1,n)
    {
        abr_cnt[cnt[i]]++;
    }
    int sum=0;
    f(i,1,n)
    {
        sum+=(abr_cnt[i]*i);
        pcnt[i]=sum;
    }
    sum=0;
    f(i,1,n)
    {
        sum+=abr_cnt[i];
        pabr_cnt[i]=sum;
    }
    f(x,1,n)
    {
       int lft=pcnt[x];
       int rgt=(pabr_cnt[n]-pabr_cnt[x])*x;
       fx[x]=(lft+rgt)/x;
       ses[fx[x]]=max(ses[fx[x]],x);
    }
    rf(i,n,1)
    {
        ses[i]=max(ses[i],ses[i+1]);
    }
    f(i,1,n)
    {
        cout<<ses[i]<<" ";
    }
    cout<<endl;
    return 0;

}





































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

a = [0] * 100
b = [0] * 100
ans = 0

for i in range(100):
    a[i] = 2 * i + 1

for i in range(100):
    for j in range(2, 200):
        if a[i] % j == 0:
            b[i] += 1

for k in range(100):
    if b[k] == 7 and a[k] <= n:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int n,flg,t[26][26];
string str[500];
void check(int x,int y){
  //cout<<str[x]<<' '<<str[y]<<endl;
  int v = str[x].size();
  int w = str[y].size();
  for(int i=0;i<min(v,w);i++){
    if(str[x][i]==str[y][i])continue;
    if(t[str[x][i]-'a'][str[y][i]-'a']==-1)flg=0;
    t[str[x][i]-'a'][str[y][i]-'a']=1;
    t[str[y][i]-'a'][str[x][i]-'a']=-1;
    return;
  }
  if(w<v)flg=0;
}
int main(){
  while(cin>>n&&n){
 
    for(int i=0;i<26;i++)
      for(int j=0;j<26;j++)
    t[i][j]=0;
 
    flg=1;
    cin>>str[0];
    for(int i=1;i<n;i++){
      cin>>str[i];
      for(int j=i-1;j>=0;j--)check(j,i);
    }
    cout<<(flg?"yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include<iostream>
#include<stdio.h>


int main()
{
	int sum = 0, num = 0, c = 0;
	int a, b;
	while( scanf( "%d,%d", &a, &b ) != EOF ){
	 	sum += a * b;
		num += b;
		c++;
	}
	
	printf( "%d\n", sum );

	printf( "%.0f\n", num / (double)c + 0.5 );

 	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using P = pair<ll, ll>;
 
#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (ll i = (b)-1; i >= (a); --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__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);
 
template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	each(x, vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	rep(i, vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& vec) {
	rep(i, vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, h, w; cin >> n >> h >> w;
	ll sum = 0;
	vector<ll> x(n); cin >> x;
	for (ll i = 0; i < n; i += 2) {
		ll x1 = min(x[i], w - x[i+1]);
		ll x2 = max(x[i] + w, 2 * w - x[i+1]);
		sum += (x2 - x1) * h;
	}
	ll ans = h * n * w - sum;
	cout << ans << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define N 25
using namespace std;
int n,a[N],l[N],r[N];
bool used[N];

void dfs(int x,int z){
  if(z==0)cout<<' '<<x;
  if(l[x]!=-1)dfs(l[x],z);
  if(z==1)cout<<' '<<x;
  if(r[x]!=-1)dfs(r[x],z);
  if(z==2)cout<<' '<<x;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cin>>l[a[i]]>>r[a[i]];
    if(l[a[i]]!=-1)used[l[a[i]]]=true;
    if(r[a[i]]!=-1)used[r[a[i]]]=true;
  }
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Preorder"<<endl,dfs(i,0),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Inorder"<<endl,dfs(i,1),cout<<endl;
  for(int i=0;i<n;i++)
    if(!used[i])cout<<"Postorder"<<endl,dfs(i,2),cout<<endl;
  return 0;
}



Measured memory_bytes: 3104
gets
xs = gets.split(' ').map(&:to_i)

def flip_sign(v)
  v > 0 ? -1 : 1
end

def sign(v)
  v > 0 ? 1 : -1
end

first = xs.first == 0 ? [1, 1] : [xs.first, 0]

a = xs[1..-1].inject(first){|r,v|
  sum = r.first
  count = r.last
  s = sign(sum)
  sum += v
  fs = sign(sum)
  if s == fs
    count += sum.abs + 1
    sum = flip_sign(s)
  end
  [sum, count]
}.last

first = xs.first == 0 ? [-1, 1] : [flip_sign(xs.first),xs.first.abs + 1]

b = xs[1..-1].inject(first){|r,v|
  sum = r.first
  count = r.last
  s = sign(sum)
  sum += v
  fs = sign(sum)
  if s == fs
    count += sum.abs + 1
    sum = flip_sign(s)
  end
  [sum, count]
}.last
puts [a,b].min


Measured memory_bytes: 11148
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            String S = in.next();
            int number = 0;
            for (int i = 0; i < S.length(); i++) {
                char c = S.charAt(i);
                if (c == '+') {
                    number++;
                } else {
                    number--;
                }
            }
            System.out.println(number);
        }
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<string,bool> m;
    while(n--)
    {
        string s;
        cin>>s;
        m[s]=true;
    }
    cout<<m.size();
    return 0;
}


Measured memory_bytes: 19160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
#define pw(x) (1LL<<(x))
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to kth largest, order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define NEWL EVAL({cout << '\n';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 1e5 + 10;
const int MAX = 1e9 + 10;

int n;
struct Num {
    int val, pos;
};
vector<Num> nums;

LL ans[N];

int main() {
    cin >> n;
    FOR(i, 1, n+1) {
        int a; cin >> a;
        nums.push_back({a, i});
    }
    nums.push_back({0, -1});
    sort(nums.begin(), nums.end(),
        [&](const Num& n1, const Num& n2){
            return n1.val > n2.val;
        });
    set<int> S;
    for(int i = 0; i < (int)nums.size(); ) {
        int j = i-1;
        while(j+1 < (int)nums.size() && nums[i].val == nums[j+1].val) {
            S.insert(nums[j+1].pos);
            j++;
        }
        int nex = j+1;
        int nex_val = nums[nex].val;
        ans[*S.begin()] += (LL)S.size() * (nums[i].val - nex_val);
        if(nex_val == 0) break;
        i = nex;
    }
    FOR(i, 1, n+1) cout << ans[i] << '\n';
}






























Measured memory_bytes: 7412
x = int(input())
cardinal = 2
exponential = 2
pows = set([1])
def makePows(cardinal, exponential, maxNum):
    resultPow = pow(cardinal, exponential)
    if resultPow > maxNum:
        return

    makePows(cardinal+1, exponential, maxNum)
    makePows(cardinal, exponential+1, maxNum)

    pows.add(resultPow)

makePows(cardinal, exponential, 1000)

for i in sorted(pows):
    if x < i:
        break
    maxPow = i

print(maxPow)

Measured memory_bytes: 3064
N=int(input())
B=[int(i) for i in input().split()]
DP=[10**9 for i in range(N)]
for t in range(N-1):
    if DP[t]>B[t]:
        DP[t]=B[t]
    if DP[t+1]>B[t]:
        DP[t+1]=B[t]
print(sum(DP))

Measured memory_bytes: 3064
read;tr \  \\n|nl|awk 1,\$1%=2|sort|uniq -c|sort -nr|awk 's+=$1{$2?a?b<$1&&b=$1:(a=$1)>c=$3:d?e<$1&&e=$1:(d=$1)>f=$3}END{print s-(c~f?a+e<b+d?b+d:a+e:a+d)}'

Measured memory_bytes: 11764
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

// 子どもを表す構造体
struct infant{
  int position; // 位置
  int64_t lively;   // 活発度
  
  // 活発度が同じ場合、位置で判断する
  bool operator<( const infant &right ) const{
    return lively == right.lively ? position < right.position : lively < right.lively;
  }
  
};

int main(){
  
  int N = 0;
  std::cin >> N;
  
  std::vector< infant > vec_infants( N );
  for( int cnt = 0; cnt < N; cnt++ ){
    vec_infants.at( cnt ).position = cnt + 1;
    std::cin >> vec_infants.at( cnt ).lively;
  }
  
  // 活発度を基準に降順ソート
  sort( vec_infants.begin(), vec_infants.end() );
  reverse( vec_infants.begin(), vec_infants.end() ); 
  
  // dp[x][y]
  // x:左端に寄せた数 y:右端に寄せた数
  // x+y = N
  std::vector< std::vector< int64_t > > dp( N + 1, std::vector< int64_t >( N + 1, 0 ) );
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < N - i; j++ ){
      // 左端に寄せたとき
      int left_renge = std::abs( ( i + 1 ) - vec_infants.at( i + j ).position );
      if( dp.at( i + 1 ).at( j ) < dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * left_renge ){
        dp.at( i + 1 ).at( j ) = dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * left_renge;
      }
      // 右端に寄せたとき
      int right_renge = std::abs( ( N - j ) - vec_infants.at( i + j ).position );
      if( dp.at( i ).at( j + 1 ) < dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * right_renge ){
        dp.at( i ).at( j + 1 ) = dp.at( i ).at( j ) + vec_infants.at( i + j ).lively * right_renge;
      }
      
    }
  }
  
  int64_t answer = 0;
  for(int i = 0; i <= N ;i++){
    for(int j = 0; j <= N; j++){
      //std::cout << "dp[" << i << "][" << j << "]" << dp.at(i).at(j) << std::endl;
      answer = std::max( dp.at( i ).at( j ), answer );
    }
  }
  
  std::cout << answer << std::endl;
  
  return 0;
}

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

const int MAX = 100000;

int main(){
  int n, m, bmin = 10e5, ans = 1;
  int a[1000001] = {0};

  
  cin >> n >> m;

  int work, awork;
  for(int i=0; i<m; ++i){
    cin >> work;
    cin >> awork;

    if(a[work] != 0){
      if(awork < a[work]) a[work] = awork;
    }else{
      a[work] = awork;
    }
    
    bmin = min(work, bmin);
  }


  work = bmin + 1;
  bmin = a[bmin];
  for(int i=work; i<100001; ++i){
    if(a[i] != 0){
      if(i >= bmin){
	++ans;
	bmin = a[i];
	continue;
      }
      bmin = min(bmin, a[i]);
    }
  }


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


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
struct Node;
vector<Node> V;
struct Node {
  int idx;
  set<int> nbr;
  bool vst = false;
  vector<int> dfs(int det) {
    vst = true;
    if(det == idx) {
      vector<int> ret = {idx};
      return ret;
    }
    for(int x : nbr) {
      if(!V[x].vst) {
        vector<int> ret = V[x].dfs(det);
        if(ret.size()>0) {
          ret.push_back(idx);
          return ret;
        }
      }
    }
    vector<int> emp;
    return emp;
  };
};
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  REP(i, N) {
    V.emplace_back();
    V[i].idx = i;
  }
  vector<int> A(M);
  vector<int> B(M);
  REP(i, M) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    V[A[i]].nbr.insert(B[i]);
  }
  int min = 1e9;
  vector<int> ans;
  REP(i, M) {
    V[A[i]].nbr.erase(B[i]);
    vector<int> ret = V[B[i]].dfs(A[i]);
    V[A[i]].nbr.insert(B[i]);
    REP(j, N) V[j].vst = false;
    if(ret.size() > 0 && ret.size() < min) {
      min = ret.size();
      ans = ret;
    }
  }
  if(min == 1e9) {
    cout << -1 << "\n";
  } else {
    cout << min << "\n";
    REP(i, ans.size()) cout << (ans[i]+1) << "\n";
  }

}

Measured memory_bytes: 512
from collections import deque

n = int(input())
AL = [None for _ in range(n + 1)]
for i in range(1, n + 1):
    ukv = [int(x) for x in input().split()]
    AL[ukv[0]] = ukv[2:]

que = deque([1])
visited = [False] + [True] + [False] * (n - 1)
dist = [-1] + [0] + [-1] * (n - 1)
while que:
    u = que.popleft()
    for v in AL[u]:
        if visited[v]: continue
        dist[v] = dist[u] + 1
        visited[v] = True
        que.append(v)

for i in range(1, n + 1):
    print(i, dist[i])


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

int main(){
  int a[10],u,count=0;
  while(cin >> u ){
    if(u!=0){
      a[count]=u;
      count++;
    }
    else {
      cout << a[count-1]<<endl;
      count--;
    }
  }
}



Measured memory_bytes: 3092
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(m):
    b1.append(b1[-1]+b[i])
ans=0
j=m
for i in range(n+1):
    if a1[i]>k:
        break
    while b1[j]>k-a1[i]:
        j-=1
    ans=max(ans,i+j)
print ans

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

int main()
{
  static char s[100010];
  scanf("%s",s);
  int n=strlen(s),N;
  scanf("%d",&N);
  vector<int> L(N),R(N);
  for(int i=0;i<N;i++){
    scanf("%d%d",&(L[i]),&(R[i]));
  }
  static int P[100010];
  for(int i=0;i<n/2;i++){
    P[i]=(s[i]+26-s[n-i-1])%26;
    //printf("%d %d\n",i,P[i]);
  }
  vector<vector<int> > e(n/2+1);
  for(int i=0;i<N;i++){
    L[i]--;
    if(L[i]>n/2)L[i]=n-L[i];
    if(R[i]>n/2)R[i]=n-R[i];
    e[L[i]].push_back(R[i]);
    e[R[i]].push_back(L[i]);
    //printf("%d %d\n",L[i],R[i]);
  }
  bool F=0;
  for(int i=0;i<=n/2;i++){
    if(2*i+1!=n&&(i<n/2?P[i]:0)!=(i>0?P[i-1]:0)&&e[i].size()==0){
      F=1;
      break;
    }
  }
  vector<int> V(n/2+1,0);
  for(int i=0;i<=n/2;i++){
    if(V[i])continue;
    V[i]=1;
    int T=0;
    queue<int> Q;
    Q.push(i);
    V[i]=1;
    bool FF=0;
    while(!Q.empty()){
      int j=Q.front();
      Q.pop();
      T+=(j<n/2?P[j]:0)+26-(j>0?P[j-1]:0);
      if(2*i+1==n)FF=1;
      for(int x=0;x<e[j].size();x++){
	int k=e[j][x];
	if(!V[k]){
	  V[k]=1;
	  Q.push(k);
	}
      }
    }
    //printf("%d %d\n",i,T);
    if(!FF&&T%26!=0){
      F=1;
      break;
    }
  }
  puts(F?"NO":"YES");
  return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std ;
template< class T > inl T read() {
	T x = 0 ; int f = 1 ; char k = getchar() ;
	for( ; k > '9' || k < '0'; k = getchar() ) if( k == '-' ) f = -1 ;
	for( ; k >= '0' && k <= '9'; k = getchar() ) x = x * 10 + k - '0' ;
	return x * f ;
}
template< class T > inl T read( T &x ) { return x = read<T>() ; }
int _num, _buf[20];
template< class T > il print( T x ) {
   	if( x == 0 ) return putchar( '0' ) ,void() ;
	if( x < 0 ) putchar( '-' ), x = -x ;
	while( x ) _buf[++_num] = x % 10, x /= 10 ;
	while( _num ) putchar( _buf[_num--] + '0' ) ;
}
ll mul( ll a, ll b, ll mod ) { long double c = 1. ; return ( a * b - (ll)( c * a * b / mod ) * mod ) % mod ; }
it qpow( int x, int m, int mod ) {
	int res = 1, bas = x ;
	while(m) {
		if( m & 1 ) res = ( 1ll * res * bas ) % mod ;
		bas = ( 1ll * bas * bas ) % mod, m >>= 1 ;
	}
	return res ;
}
const int N = 2e5 + 5, mod = 1e9 + 7 ;
it add( int x, int y ) {
	return x + y >= mod ? x + y - mod : x + y ;
}
it mul( int x, int y ) {
	return 1ll * x * y % mod ;
}
il inc( int &x, int y ) {
	x = add( x, y ) ;
}
int n, ans, num[2], f[N], pw[N];
ll A[N], B[N];
map< pair< ll, ll >, int > cnt;
int main() {
//	freopen( ".in", "r", stdin ) ;
//	freopen( ".out", "w", stdout ) ;
	n = read<int>(), pw[0] = 1 ;
	for( ri i = 1; i <= n; ++i ) {
		A[i] = read<ll>(), B[i] = read<ll>() ;
		pw[i] = mul( pw[i - 1], 2 ) ;
	}
	for( ri i = 1; i <= n; ++i ) {
		ans += A[i] == 0 && B[i] == 0 ;
		num[0] += A[i] == 0 && B[i] != 0 ;
		num[1] += A[i] != 0 && B[i] == 0 ;
	}
	int res = add( pw[num[0]], pw[num[1]] ) ;
	inc( res, mod - 1 ) ;
	for( ri i = 1; i <= n; ++i ) {
		if( !A[i] || !B[i] ) continue ;
		ll d = __gcd( A[i], B[i] ) ;
		pair< ll, ll > tmp = { -B[i] / d, A[i] / d } ;
		if( tmp.second < 0 )
			tmp.first = -tmp.first, tmp.second = -tmp.second ;
		cnt[tmp] += 1 ;
	}
	for( ri i = 1; i <= n; ++i ) {
		if( !A[i] || !B[i] ) continue ;
		ll d = __gcd( A[i], B[i] ) ;
		pair< ll, ll > tmp = { -B[i] / d, A[i] / d } ;
		if( tmp.second < 0 )
			tmp.first = -tmp.first, tmp.second = -tmp.second ;
		int x = cnt[tmp] ;
		cnt[tmp] = 0 ;
		tmp = { A[i] / d, B[i] / d } ;
		if( tmp.second < 0 )
			tmp.first = -tmp.first, tmp.second = -tmp.second ;
		int y = cnt[tmp] ;
		cnt[tmp] = 0 ;
		int upd = add( pw[x], pw[y] ) ;
		inc( upd, mod - 1 ) ;
		res = mul( res, upd ) ;
	}
	inc( ans, res ), inc( ans, mod - 1 ) ;
	print( ans ), puts( "" ) ;
	cerr << 1. * clock() / CLOCKS_PER_SEC << "\n" ;
	return 0;
}

Measured memory_bytes: 32576
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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 main(){
  cout << fixed << setprecision(15);

  string s, t; cin >> s >> t;
  int i, j; cin >> i >> j;
  string r; cin >> r;

  ll ans = 0;
  //string ans = "No";

  if (r == s) i--;
  else j--;
  
  //cout << ans << endl;
  cout << i << " " << j << endl;

  return 0;
}
//

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i+=)
typedef int long long ll;
int main(){
    int n;
    cin>>n;
    if(n%2){
        cout<<(n/2)*(n/2+1)<<endl;
    }else{
        cout<<(n/2)*(n/2)<<endl;
    }
    
    
    
    
    
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {

    val n = Integer.parseInt(readNext())

    val a = readNext().split(" ").map { Integer.parseInt(it) }
    var list = mutableListOf<Int>()
    var result = 0
    var tmp = 0
    for (i in 0..n - 1) {
        list.add(0)
    }
    var pre = 0;
    for (i in 0..a.size - 1) {
        val n = a[i]
        val s = list[i]
        val t = list[i + 1]
        if(i == 0) {
            list[i] = n
            if (i == a.size - 1) {
                list[i + 1] = n
            }
            pre = n
            continue
        }
        var tmp = Math.max(Math.abs(n), Math.abs(s))
        if (pre >= tmp) {
            list[i] = tmp
        } else {
            list[i] = pre
        }
        pre = n
        if (i == a.size - 1) {
            list[i + 1] = Math.max(Math.abs(n), Math.abs(t))
        }
    }
    println(list.sum())
}
fun readNext(): String {
    return readLine()!!
}

Measured memory_bytes: 37916
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
const int64_t INF=9999999999999999;
char K[100];
char G[100];
int main() {
  int a,b;
 cin>>a>>b;
 for(int i=0;i<b;i++){
   K[i]='0'+a;
 }
 string A=K;
 for(int i=0;i<a;i++){
   G[i]='0'+b;
 }
 string B=G;
 
 if(A>B){cout<<B<<endl;}
 else{cout<<A<<endl;}
 return 0;}

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

const ll mod = 998244353;

int main() {
    
    int N, K;
    cin >> N >> K;
    int L[K], R[K];

    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }
    


    ll d[N]{};
    ll c[N + 1]{};
    d[0] = 1;
    c[1] = 1;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < K; j++) {
            int l = max(0, i - R[j]);
            int r = max(0, i - L[j] + 1);
            d[i] += (c[r] - c[l] + mod) % mod;
            d[i] %= mod;
        }
        c[i + 1] = d[i] + c[i];
        c[i + 1] %= mod; 
    }
    cout << d[N - 1] << "\n";
    return 0;
}

Measured memory_bytes: 6736
from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

count = 0
for i in range(m):
    edges = [[]*n for _ in range(n)]
    for j in range(m):
        if j == i:
            continue
        edges[ab[j][0]-1].append(ab[j][1]-1)
        edges[ab[j][1]-1].append(ab[j][0]-1)
    #print(edges)
    d = deque([0])
    visited = [0]*n
    visited[0] = 1
    while d:
        p = d.pop()
        for child in edges[p]:
            if visited[child] == 1:
                continue
            visited[child] = 1
            d.append(child)
    if sum(visited) != n:
        count += 1
print(count)



Measured memory_bytes: 74540
def f(a):
    if a < 0:
        return 0
    if a % 2:
        return (a // 2 + 1) % 2
    return a // 2 % 2 + a

def main():
    a, b = map(int, input().split())
    print(f(a - 1) ^ f(b))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

//#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int main(){
	int n,k,x,y;
	int ans;
	cin >> n >> k >> x >> y;
	
	ans = min(n, k) * x + max(n - k, 0) * y;
	
	cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/numeric>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)
#define ll long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0);

const int MAXN = 3003;
int n, T;
pair<int, int> arr[MAXN];
int memo[MAXN][MAXN];

int solve(int idx, int t) {
//    cout << idx << ' ' << t  << endl;
    if (idx == n || t >= T)
        return 0;
    int &ret = memo[idx][t];
    if (~ret)
        return ret;
    ret = solve(idx + 1, t);
    ret = max(ret, solve(idx + 1, t + arr[idx].first) + arr[idx].second);
    return ret;
}

int fact(int n) {
    int ret = 1;
    for (int i = 2; i <= n; ++i)
        ret *= i;
    return ret;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("friday.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout
            << fixed;

    int n;
    cin >> n;
    vector<pair<int, int>> points(n);
    for (int i = 0; i < n; ++i)
        cin >> points[i].first >> points[i].second;

    vector<int> perm(n);
    for (int i = 0; i < n; ++i)
        perm[i] = i;

    long double ans = 0;
    do {
        for (int i = 1; i < n; ++i) {
            ans += sqrt((points[perm[i]].first - points[perm[i - 1]].first) * (points[perm[i]].first - points[perm[i - 1]].first) + (points[perm[i]].second - points[perm[i - 1]].second) * (points[perm[i]].second - points[perm[i - 1]].second));
        }
    } while(next_permutation(perm.begin(), perm.end()));


    cout << ans / fact(n) << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    char b, ans;
    cin >> b;

    switch (b) {
        case 'A':
            ans = 'T';
            break;
        case 'C':
            ans = 'G';
            break;
        case 'G':
            ans = 'C';
            break;
        case 'T':
            ans = 'A';
            break;
    }

    printf("%c\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
  long double a, b, x;
  cin >> a >> b >> x;
  if(a*a*b/2 < x)cout << setprecision(10) << atan(2*(a*a*b-x)/(a*a*a))*180/3.141592653589793 << endl;
  else cout << setprecision(10) << atan(a*b*b/(2*x))*180/3.141592653589793 << endl;

  return 0;
}


Measured memory_bytes: 256
from bisect import bisect

n = 1000000
sn = int(n**0.5)+1

num = [False, False] + [True]*(n-1)
for i in xrange(2, int(n**0.5)+1):
  if num[i]:
    for j in xrange(i**2, n, i):
      num[j] = False
prime = [i for i in xrange(2, n) if num[i]]

while True:
  try:
    print bisect(prime, input())
  except:
    break

Measured memory_bytes: 19940
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];
double dist(ll i, ll j)
{
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return pow(dx*dx+dy*dy,0.5);
}

int main()
{
    double sum=0.0;
    ll n,i,j,cc=0;
    cin>>n;
    (n%2==0) ? j=n/2 : j=n/2+1;
    cout<<fixed<<setprecision(10)<<j*1.0/n*1.0<<endl;
}


Measured memory_bytes: 4992
// https://atcoder.jp/contests/abc170/tasks/abc170_d

use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a_s: [usize; n],
    }
    a_s.sort_unstable();
    let a_max = *a_s.last().unwrap();
    let mut dp = vec![0; a_max + 1];
    for &a in &a_s {
        if dp[a] >= 2 {
            continue;
        }
        for j in 1..=a_max {
            let p = j * a;
            if p > a_max {
                break;
            } else {
                dp[p] += 1;
            }
        }
    }
    println!("{}", a_s.iter().filter(|&&x| dp[x] == 1).count());
}


Measured memory_bytes: 8808
<?php
while(fscanf(STDIN,"%d %d %d",$score_m,$score_f,$score_r)){
    if($score_m===-1 and $score_f===-1 and $score_r===-1) break;
    $score_mf = $score_m + $score_f;
    if($score_m===-1 or $score_f===-1){
        echo "F",PHP_EOL;
    }elseif($score_mf >= 80){
        echo "A",PHP_EOL;
    }elseif($score_mf >=65 ) {
        echo "B",PHP_EOL;
    }elseif($score_mf >= 50 or ($score_mf>=30 and $score_r>=50) ){
        echo "C",PHP_EOL;
    }elseif($score_mf >= 30){
        echo "D",PHP_EOL;
    }else{
        echo "F",PHP_EOL;
    }
}

Measured memory_bytes: 15228
R,C,K=map(int,input().split())
rcv=[list(map(int,input().split())) for _ in range(K)]
mat=[[0]*C for _ in range(R)]
for r,c,v in rcv:
  mat[r-1][c-1]=v
dp=[0]*C
for i in range(R):
  ndp=[0]*C
  wdp=[0]*4
  for j in range(C):
    wdp[0]=max(wdp[0],dp[j])
    if mat[i][j]>0:
      v=mat[i][j]
      wdp[3]=max(wdp[3],wdp[2]+v)
      wdp[2]=max(wdp[2],wdp[1]+v)
      wdp[1]=max(wdp[1],wdp[0]+v)
    ndp[j]=max(wdp)
  dp=ndp.copy()
print(max(wdp))

Measured memory_bytes: 188056
N = int(input())
A = list(map(int, input().split()))

dic = {}
for i in range(N):
    dic[i] = A[i]
dic_swap = {v: k for k, v in dic.items()}
dic_swap_sorted = sorted(dic_swap.items())

order = []
for tap in dic_swap_sorted:
    order.append(tap[1] + 1)

print(*order)


Measured memory_bytes: 38876
def ten_to_n(X, n):
    i = int(X / n)
    s = str(X % n)
    if (i):
        return ten_to_n(i, n) + s
    return s

def solve():
    N, M = map(int, input().split())
    n = ten_to_n(N, M)
    return len(n)
 
print(solve())


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int32_t main()
{
    IOS
    int a;
    string s;
    cin>>a>>s;
    if (a>=3200) cout<<s<<endl;
    else cout<<"red"<<endl;
}



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

#define nl                 "\n"
#define ll                 long long
#define pb                 push_back
#define pf                 push_front
#define np                 next_permutation
#define pp                 prev_permutation
#define sqr(x)             ((x)*(x))
#define pi                 acos(-1)
#define setprecision(x)    fixed<<setprecision((int)(x))
#define mem1(x)            memset(x,0,sizeof(x))
#define mem2(x)            memset(x,-1,sizeof(x))
#define all(x)             (x).begin(),(x).end()
#define sort1(x)           sort(all(x))
#define csort(x,c)         sort(all(x),c)
#define rsort(x)           sort(x.rbegin(),x.rend())
#define rep(i,n,m)         for(int i=(int)(n); i<(int)(m); i++)

//typedef map<int,int> mapii;
//typedef map<string,int> mapsi;
//typedef map<int,string> mapis;
//typedef vector<int> vi;
//typedef vector<vectori> v2d;
//typedef vector<long long> vll;


using namespace std;
void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)
        cin>>a[i];
    int i=0,j=n-1,sum1=0,sum2=0;
    while(i<=j)
    {
        if(sum1<=sum2)
        {
            sum1+=a[i];
            i++;
        }
        else
        {
            sum2+=a[j];
            j--;
        }
    }
    cout<<abs(sum1-sum2)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int t; cin>>t; while(t--){solve();}
    solve();
    return 0;
}


Measured memory_bytes: 3460
n,m=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))

sx=0
sy=0
mod=10**9+7

for i in range(n-1):
  sx=(sx+(i+1)*(n-i-1)*(x[i+1]-x[i]))%mod

for i in range(m-1):
  sy=(sy+(i+1)*(m-i-1)*(y[i+1]-y[i]))%mod

print((sx*sy)%mod)

Measured memory_bytes: 24352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		
		int n,p[];
		
		while(true){
			n=sc.nextInt();
			if(n==0) break;
			p=new int[n];
			for(int i=0;i<n;i++){
				p[i]=sc.nextInt();
			}
			int count=0;

			if(n==1){
				System.out.println(p[0]);
			}
			else{
				for(int i=0;i<n-1;i++){
					//System.out.println(i+"!"+p[i]);
					if(p[i+1]-p[i]==1){
						count++;
					}
					else{
						if(count==0){
							System.out.print(p[i]);
						}
						else{
							System.out.print(p[i-count]+"-"+p[i]);
						}
						count=0;
						System.out.print(" ");
					}
					if(i==(n-2)){
						if(count==0){
							System.out.print(p[i+1]);
						}
						else{
							System.out.print(p[i-count+1]+"-"+p[i+1]);
						}
						count=0;
					}	
				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 24920
#include <iostream>
using namespace std;
int main () {
    int a,b;
    cin >> a >> b;
    if (a % b == 0) {
        cout << a / b;
    }
    else if (b > a) {
        cout << 1;
    }
    else if (a % b != 0) {
        cout << a / b + 1;
    }
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.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 FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int l,r,d;
    R(l,r,d);
    int an=0;
    FOR(i,l,r)
    {
        an+=(i%d==0);
    }
    W(an);
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


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

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

int main(){
	long long N;
	cin >> N;
	long long ans=N;
	
	map<long long,long long> prime;
	long long p=2;
	N*=2;
	while(N>=p*p){
		while(N%p==0){
			prime[p]++;
			N/=p;
		}
		p++;
	}
	if(N>1)prime[N]++;
	
	vector<long long> P;
	for(auto a:prime){
		long long x=1;
		for(auto i=0;i<a.second;i++)x*=a.first;
		P.push_back(x);
	}
	
	long long M=(1LL<<P.size());
	for(long long bit=0;bit<M;bit++){
		vector<bool> use(P.size());
		for(int i=0;i<P.size();i++)use[i]=(bit&(1LL<<i));
		
		long long X=1,Y=1;
		for(int i=0;i<P.size();i++){
			if(use[i])X*=P[i];
			else Y*=P[i];
		}
		
		long long A,B;
		extGCD(X,-Y,A,B);
		if(A==0 || B==0)continue;
		ans=min(ans,A*X);
		//printf("%lld %lld %lld %lld\n",X,Y,A,B);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668