akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
class Simple
{
    string s;
    void Solve() {
        s = io.String;
        //cal
        var indexedS = s.Select((c, i) => new { c, i });
        var aIdx     = indexedS.First(v => v.c == 'A').i;
        var zIdx     = indexedS.Last (v => v.c == 'Z').i;
        var ans      = zIdx - aIdx + 1;
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
        AutoFlush = false
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next() {
        if (_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == "")
            st = ReadLine();
        if (st != null)
            _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        else
            st = "";
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}


Measured memory_bytes: 16732
#include<stdio.h>
#include<stdlib.h>
#include <string.h>

int main(void)
{
	int n, i, k = 0;
	int v[50] = {0};
	int c[50]= {0};
	int b[50]= {0};

	scanf("%d", &n);

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

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

	//printf("%d", v[0]);

	/*for(i = 0; i < n; i++){
		printf("%d", v[i]);
	}
	printf("\n");
	
	for(i = 0; i < n; i++){
		printf("%d", c[i]);
	}
	printf("\n");*/

	for(i = 0; i < n; i++){
		b[i] = v[i]- c[i];
		if(b[i] > 0){
			k+=b[i];
		}
	}

	printf("%d", k);

	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <cctype>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main()
{
    string S;
    cin >> S;
    string res = "AC";
    if (S[0] != 'A')
    {
        res = "WA";
    }
    int c = 0;
    int N = S.size();
    rep(i, 1, N)
    {
        if (!islower(S[i]))
        {
  
            if (S[i] != 'C' || i < 2 || i > N - 2)
            {
                res = "WA";
            }
            else
            {
                c++;
            }
        }
    }
    if (c != 1)
    {
        res = "WA";
       
    }
     cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define endl '\n'
//pair<int, int> *p=new pair<int, int>[n];
//std::vector<pair<int,int>> vp;
//v.push_back(make_pair(x,y))
//pair<int, int> p[1000001];
//string *s=new string [n];
//int freq[e];
//freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi, yi, q;
vector<ll>v;
set<int>s;
map<string, ll >mp;
bool PE ( int x )
{
    for ( int i = 2; i * i <= x; i++ )
        if ( x % i == 0 )
            return false;
    return true;
}
bool PR ( string s )
{
    int n = s.length();
    for ( int i = 0; i < n / 2; i++ )
        if ( s[i] != s[n - i - 1] )
            return false;
    return true;
}

int main ( void )
{ 
    SpeeD
    ll n;
    cin>>n;
    c=0;
    while (n % 2 == 0)
    {
            n/=2;
            c++;
        
    }
    //cout<<c;
   
    ll dif = (-1 + sqrt(1 + 8*c)) / 2 ;
    
   
   for (ll i = 2 ; i * i <= n;i++){
   c1=0;
    while (n%i == 0){
    c1++, n/=i;
    }

        dif += (-1 + sqrt(1 + 8*c1)) / 2 ;}
       // cout<<n;
    if (n>2)
    dif++;
    
    
cout<<dif;
     
    
   
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
const int N=110;
string str[N];
bool cmp(string a,string b)
{
    bool h=a.size()<b.size();
    int minn=min(a.size(),b.size());
    for(int i=0;i<minn;i++){
        if(a[i]!=b[i])return a[i]<b[i];
    }
    return h;
}
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)cin>>str[i];
    sort(str+1,str+n+1,cmp);
    string ans;
    for(int i=1;i<=n;i++)ans+=str[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int h, a;
  std::cin >> h >> a;

  std::cout << std::ceil(h/1.0/a) << std::endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    long long int n;
    cin>>n;
    long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    long long int sum[n];
    sum[0] = a[0];
    for(long long int i=1;i<n;i++)
    {
        sum[i] = a[i]+sum[i-1];
    }
    int ans =1;
    for(long long int i=n-2;i>=0;i--)
    {   
        if(i==0)
        {
            if((2*a[i])>=a[i+1])
            {
                ans++;
                break;
            }
            else
                break;
        }
        if(2*(a[i]+sum[i-1])>=a[i+1])
            ans++;
        else
            break;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())




// ループ系
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)

// #define fou(i,a,n) for(int i=a;i<n;i++)
#define elif(c) else if(c)


// 出力系
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}

const ll MAX=1000000007,MAXL=1LL<<61,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};

typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;





void Main() {
    int n;
    cin >> n;
    VI a(n);
    rep(i,n) R a[i];

    // pr(n);
    // PR(a, a.size());

    sort(all(a), greater<int>());
    // PR(a, a.size());


    int Alice=0, Bob=0;

    rep(i, n){
        if (i%2 == 0){
            Alice += a[i];
        }else{
            Bob += a[i];
        };
    }

    pr(Alice-Bob);

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

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

int main() {
    ll n, m;
    cin >> n >> m;
    priority_queue<Pl, vector<Pl>, greater<Pl>> q;
    rep(i,n) {
        ll a, b;
        cin >> a >> b;
        q.emplace(a,b);
    }
    ll ans = 0, cnt = 0;
    while (cnt < m) {
        auto p = q.top();
        q.pop();
        ans += p.first*min(m-cnt,p.second);
        cnt += min(m,p.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5300
#include <stdio.h>

int euclid(int a, int b);

int main(void) {
  int a, b;
  while(scanf("%d %d", &a, &b) != EOF) {
    printf("%d\n", euclid(a, b));
  }
}

int euclid(int a, int b) {
  if(b<=0)
    return a;

  return euclid(b, a%b);
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = n / 3;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
A,B,K = map(int,input().split())
list = []
for i in range(max([A,B])+1):
    if i != 0 and A % i == 0 and B % i == 0:
        list.append(i)

list.sort(reverse = True)
if len(list) == 1:
    print(list[0])
else:
    print(list[K-1])

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

if (A + B) % 2 == 0:
    print((B - A)//2)
else:
    if (N - B) > (A - 1):
        print((B - A)//2 + A)
    else:
        print((B - 1 - A)//2 + N - B + 1)


Measured memory_bytes: 2940
def g;gets.split.map &:to_i;end
while(n,m=g)[0]>0
d=(0..n).map{[]}
m.times{s,t=g;d[s]+=[t];d[t]+=[s]}
l=[0]+g
r=[0]+(1..n).map{g[1..-1].sort}
h={l<<1=>[0,0]}
q=l[1]<1?[]:[l<<0]
(*t,a,c=q.shift
c+=1
(d[a].map{|i|t[i]>0&&[t.dup,i,"Move to room #{i}."]}+
r[a].map{|i|u=t.dup;v=u[i]^=1;a!=i &&[u,a,"Switch o#{v>0??n:"ff"} room #{i}."]})
.map{|v,i,s|v&&(!h[v<<i]||h[v][1]>c)&&(h[v]=[s,c,t+[a]];q<<(v+[c]))})while q[0]
puts (a=h[[0]*n+[1,n]])?(a,b,c=a
["You can go home in #{b} steps."]+(s=[a]
(a,b,c=h[c];s=[a]+s)while b>1
s)
):h.all?{|k,v|k[n+1]<n}?"Help me!":"You can not switch off all lights."
end

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

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 51;

int N;
int src[MAXN];
int targ[MAXN];

bool dp[MAXN][MAXN];
bool tmp[MAXN][MAXN];

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

    cin >> N;
    for(int a = 0; a < N; a++){
        cin >> src[a];
        dp[a][src[a]] = true;
    }
    for(int a = 0; a < N; a++){
        cin >> targ[a];
    }
    
    ll ans = 0;

    for(int a = 50; a >= 1; a--){
        memcpy(tmp, dp, sizeof dp);

        //try this many times
        for(int b = 0; b <= a; b++){
            for(int c = 1; c < a; c++){
                for(int d = 0; d < N; d++){
                    for(int e = 0; e <= 50; e++){
                        if(tmp[d][e]){
                            tmp[d][e % c] = true;
                        }
                    }
                }
            }
        }

        bool good = true;
        for(int b = 0; b < N; b++){
            if(!tmp[b][targ[b]]){
                good = false;
                break;
            }
        }
        if(!good){
            //we must use this
            ans += (1ll << (ll)a);
            for(int b = 0; b < N; b++){
                for(int c = 0; c <= 50; c++){
                    if(dp[b][c]){
                        dp[b][c % a] = true;
                    }
                }
            }
        }
    }
    for(int a = 0; a < N; a++){
        if(!dp[a][targ[a]]){
            cout << -1;
            return 0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {

    double l, r;
    long long num[4][2] = {};
    while (scanf("%lf%lf",&l, &r) != EOF) {
        if (l >= 1.1) {
            num[0][0]++;
        } else if (l >= 0.6) {
            num[1][0]++;
        } else if (l >= 0.2) {
            num[2][0]++;
        } else {
            num[3][0]++;
        }
        if (r >= 1.1) {
            num[0][1]++;
        } else if (r >= 0.6) {
            num[1][1]++;
        } else if (r >= 0.2) {
            num[2][1]++;
        } else {
            num[3][1]++;
        }
    }

    printf("%lld %lld\n", num[0][0], num[0][1]);
    printf("%lld %lld\n", num[1][0], num[1][1]);
    printf("%lld %lld\n", num[2][0], num[2][1]);
    printf("%lld %lld\n", num[3][0], num[3][1]);

}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  vector<int> num(3);
  rep(i, 3) cin >> num.at(i);
  for(int i = 1; i < 3; i++) {
    int tmp = 0;
    tmp = num.at(0);
    num.at(0) = num.at(i);
    num.at(i) = tmp;
  }
  rep(i, 3) cout << num.at(i) << " ";
  cout << endl;
  return 0;
}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    ll k,a,b; cin >> k >> a >> b;
    bool flag = false;
    rep2(i,a,b+1){
        if(i%k==0) flag = true;
    }
    if(flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
ll longinf=1ll<<60;
int inf=1<<29;

string s;
 
int main(){
    cin>>s;
    bool f=true;
    int cnt=0;
    if(s[0]!='A') f=false;
    if(s[1]=='C') f=false;
  if(s[s.size()-1]=='C') f=false;
    REP(i,1,s.size()){
        char b='A';
      if(s[i]=='C') cnt++;
        rep0(j,26){
            if(s[i]!='C'&&s[i]==b) f=false;
            b++;
        }
    }
    if(cnt==1&&f) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
    ll a,b;
    cin>>a>>b;
    ll ans = a*b;
    cout<<ans<<endl;
}

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

using namespace std;

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

int main(){
    int i,N;
    //入力
    cin>>N;
    //処理
    long x=0;
    if(N/100000>0)x=100000-10000+1000-100+10-1;
    else if(N/10000>0)x=N-10000+1000-100+10;
    else if(N/1000>0)x=1000-100+10-1;
    else if(N/100>0)x=N-100+10;
    else if(N/10>0)x=9;
    else x=N;
    //出力
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A,V,B,W,T;
  cin >> A >> V >> B >> W >> T;
  if(V <= W){
    cout << "NO" << endl;
    return 0;
  }
  long long shoki_vec = abs(A-B);
  long long move_vec = abs(V-W);
  if(shoki_vec <= move_vec * T) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <queue>

int main()
{
    int N, x;
    std::cin >> N >> x;

    if(x==1 || x==2*N-1){
        std::cout << "No" << std::endl; return 0;
    }
    printf("Yes\n");
    if(N==2){
        std::cout << "1 2 3" << std::endl; return 0;
    }

    if(x==2*N-2){
        for(int i=1; i<=N-2; i++) printf("%d\n", i);
        printf("%d\n%d\n%d\n%d\n", x-1, x, x+1, x-2);
        for(int i=x-3; i>N-2; i--) printf("%d\n", i);
    }
    else{
        for(int i=1; i<=N-3; i++){
            if(i>=x-1) printf("%d\n", i+4);
            else printf("%d\n", i);
        }
        printf("%d\n%d\n%d\n%d\n", x+2, x-1, x, x+1);
        for(int i=N-2; i<=2*N-5; i++){
            if(i>=x-1) printf("%d\n", i+4);
            else printf("%d\n", i);
        }
    }
}

Measured memory_bytes: 1536
/* Author: Rennan Rocha
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define PB push_back
#define MP make_pair

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define MOD 1000000007

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//*find_by_order(); order_of_key();

int n, m;
ll dp[1010][1010];
bool grid[1010][1010];

ll add(ll a, ll b) {
    return ((a % MOD) + (b % MOD)) % MOD;
}

ll solve(int i, int j) {
    if(i == n-1 && j == m-1) return 1;
    if(i >= n || j >= m || !grid[i][j]) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    return dp[i][j] = add(solve(i+1, j), solve(i, j+1));
}

int main() {
    ios_base::sync_with_stdio(false);
    memset(dp, -1, sizeof dp);

    cin >> n >> m;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            char c;
            cin >> c;
            if(c == '.') grid[i][j] = true;
        }
    }
    cout << solve(0,0) << "\n";
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    P a[N];
    rep(i, N){
        int s;
        cin >> s;
        a[i].first = s;
        a[i].second = i + 1;
    }
    sort(a, a + N);
    rep(i, N)cout << a[i].second << " ";
    cout << endl;
}


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

int main(void) {
    string str;
    char letter;
    
    getline(cin, str);
    
    for(int i = 0; i < str.length(); ++i) {
        letter = str[i];
        if(islower(letter))   str[i] = toupper(letter);
        else if(isupper(letter))   str[i] = tolower(letter);
    }
    
    cout << str << endl;
    
    return 0;
}



Measured memory_bytes: 3196
s=input()
t=input()
ans=[]
for i in range(0,len(s)-len(t)+1):
  m=[]
  flag=True
  for p in range(i):
    if s[p]=='?':
      m.append('a')
    else:
      m.append(s[p])
  for q in range(i,len(t)+i):
    if s[q]=='?' or s[q]==t[q-i]:
      m.append(t[q-i])
    else:
      flag=False
      break
  for r in range(len(t)+i,len(s)):
    if flag==False:
      break
    if s[r]=='?':
      m.append('a')
    else:
      m.append(s[r])
  if flag:
    ans.append("".join(m))
ans.sort()
if len(ans)>0:
  print(ans[0])
else:
  print('UNRESTORABLE')

Measured memory_bytes: 3064
#include<stdio.h>
main()
{
    int A, B;
    scanf("%d %d", &A, &B);


    if(A==1 && B==2)
    {
        printf("3");
    }
    if(A==2 && B==3)
    {
        printf("1");
    }
    if(A==3 && B==1)
    {
        printf("2");
    }if(A==2 && B==1)
    {
        printf("3");
    }
    if(A==3 && B==2)
    {
        printf("1");
    }if(A==1 && B==3)
    {
        printf("2");
    }
}


Measured memory_bytes: 128
N = int(input())


allsum = (N * (N + 1))/2
fizzsum = (((N//3) * ((N//3) + 1))/2)*3
buzzsum = (((N//5) * ((N//5) + 1))/2)*5
fbsum = (((N//15) * ((N//15) + 1))/2)*15

print(int(allsum-fizzsum - buzzsum + fbsum))

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

typedef long long ll;
typedef long double ld;

map <pair <string, string>, ll> br;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin()+n, s.end());
    for(int i=0; i<(1<<n); i++){
        string a = "";
        string b = "";
        for(int j=0; j<n; j++){
            if((1<<j) & i) a += s[j];
            else b += s[j];
        }
        br[{a,b}]++;
    }
    ll res = 0;
    for(int i=0; i<(1<<n); i++){
        string a = "";
        string b = "";
        for(int j=n; j<2*n; j++){
            if((1<<(j-n)) & i) a += s[j];
            else b += s[j];
        }
        res += br[{a,b}];
    }
    cout << res;
    return 0;
}


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


int main() {
  ll n;
  cin >> n;
  ll a[n];
  rep(i, n) cin >> a[i];
  
  int m = 100010;
  
  
  ll check[m];
  rep(i, m) {
    check[i] = 0;
  }

  rep(i, n){
     check[a[i]] ++;
   }
   
  ll ans = 0;

  rep(i, m-2){
    ll sum = 0;
    sum = check[i] + check[i+1] + check[i+2];

    if (sum > ans) ans = sum;
  }
  cout << ans << endl;
}

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

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int out = 100 * x + 10 * y + z;
	if (out % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
	return (0);
}

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

int main () {
    long long l, r;
    std::cin >> l >> r;
    int L = l % 2019;
    int R = r % 2019;
    if (R < L)
    {
        std::swap(L, R);
    }
    std::vector<int> ans;
    for (int i = L; i <= R; i++)
    {
        for(int j = i + 1; j <= R; j++) {
            ans.push_back((i * j) % 2019);
        }
    }
    if(r - l >= 2019) {
        ans.push_back(0);
    }
    ans.push_back(2018);

    std::cout << *std::min_element(ans.begin(), ans.end()) << "\n";
}

Measured memory_bytes: 10348
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val nums = mutableMapOf<Int, Int>()
    val comb = mutableMapOf<Int, Long>()

    aa.forEachIndexed { idx, a ->
        val tmp = nums[a] ?: 0
        if (tmp == 0) {
            nums[a] = 1
            comb[a] = 0
            return@forEachIndexed
        }

        if (tmp == 1) {
            nums[a] = 2
            comb[a] = 1
            return@forEachIndexed
        }

        comb[a] = comb[a]!! + nums[a]!!
        nums[a] = nums[a]!! + 1
    }

    var combSum = 0L
    comb.entries.forEach {
        combSum += it.value
    }

    aa.forEach {
        println(combSum - (nums[it]!!-1))
    }
}

Measured memory_bytes: 107452
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int n;
    int i;

    cin >> n;
    for(i = 1; i <= n; i ++)
        if((int)(i * 1.08) == n)
        {
            cout << i << endl;

            return 0;
        }
    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import defaultdict


n,m = map(int, input().split())
h = np.array(list(map(int, input().split())))

road = defaultdict(list)

for i in range(m):
    a, b = map(int, input().split())
    road[a].append(b)
    road[b].append(a)


answer = 0
for j in range(n):
    if len(road[j+1]) == 0:
        answer += 1
        continue
    neighbors = h[np.array(road[j+1])-1]
    if (len(neighbors) == 0) or (h[j] > neighbors.max()):
        answer += 1
print(answer)
        


Measured memory_bytes: 52692
#include<cstdio>
#include<algorithm>
using namespace std;
bool vis[100005];
struct EDGE{int to,next,id;}edge[400005];
int len,n,m,l,r,anslen,dis[100005],c[100005],ans[200005],head[100005];
void add(int x,int y,int id){
	++len;
	edge[len].to=y;
	edge[len].next=head[x];
	edge[len].id=id;
	head[x]=len;
}
int dfs(int u){
	int now=c[u];
	vis[u]=1;
	for (register int i=head[u];i;i=edge[i].next){
		int v=edge[i].to;
		if (!vis[v]){
			if (dfs(v)){
				ans[edge[i].id]=1;
				now^=1;
			}
		}
	}
	return now;
}
struct NODE{
	int a,b;
}ar[100005];
int main(){
	scanf ("%d%d",&n,&m);
	for (register int i=1;i<=n;++i){
		scanf ("%d%d",&ar[i].a,&ar[i].b);
		dis[i]=ar[i].a;
	}
	sort (dis+1,dis+1+n);
	for (register int i=1;i<=n;++i){
		ar[i].a=lower_bound(dis+1,dis+1+n,ar[i].a)-dis;
		c[ar[i].a]=ar[i].b;
	}
	for (register int i=1;i<=m;++i){
		scanf ("%d%d",&l,&r);
		int pl=lower_bound(dis+1,dis+1+n,l)-dis,pr=upper_bound(dis+1,dis+1+n,r)-dis-1;
		add(pl,pr+1,i);add(pr+1,pl,i);
	}
	for (register int i=n+1;i>=1;--i) c[i]=c[i-1]^c[i];
	for (register int i=1;i<=n+1;++i){
		if (!vis[i]){
			if (dfs(i)){
				printf ("-1\n");return 0;
			}
		}
	}
	for (register int i=1;i<=m;++i){
		if (ans[i]) ++anslen;
	}
	printf ("%d\n",anslen);
	for (register int i=1;i<=m;++i){
		if (ans[i]) printf ("%d ",i);
	}
	printf ("\n");
	return 0;
}

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

// MOD p でいくつクラス
#define MOD 1000000007 // 10^9 + 7
class mll {
	unsigned long long val = 0;
public:
	mll(long long y = 0) : val(((y % MOD) + MOD) % MOD) {}
	mll operator + (const mll& y) { return mll(*this) += y; }
	mll& operator += (const mll& y) {
		val = (val + y.val) % MOD;
		return *this;
	}
	mll operator - (const mll& y) { return mll(*this) -= y; }
	mll& operator -= (const mll& y) {
		val = (val - y.val + MOD) % MOD;
		return *this;
	}
	mll operator * (const mll& y) { return mll(*this) *= y; }
	mll& operator *= (const mll& y) {
		val = (val * y.val) % MOD;
		return *this;
	}
	mll operator / (const mll& y) { return mll(*this) /= y; }
	mll& operator /= (const mll& y) {
		long long a = y.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		mll c = val * u; // この計算でoverflowしないか？
		val = c.val;
		return *this;
	}
	bool operator >= (const mll& y) {
		return this->val >= y.val;
	}
	mll pow(long long t) const {
		if (!t) return 1;
		mll a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	unsigned long long getVal() {
		return val;
	}
	friend ostream& operator <<(ostream& os, mll& y) {
		os << y.val;
		return os;
	}
};
#undef MOD


int main() {
	int N;
	cin >> N;
	mll A = 0;
	mll A2 = 0;
	for(int i = 0; i < N; i++){
		ll a = 0;
		cin >> a;
		A += a;
		mll Ai = a;
		Ai *= a;
		A2 += Ai;
	}

	mll c = A * A - A2;
	c /= 2;

	cout << c.getVal() << endl;
	return(0);
}


Measured memory_bytes: 3592
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

S = SI().strip()

months = ['01','02','03','04','05','06','07','08','09','10','11','12']

YYMM, MMYY = False, False
if S[:2] in months:
    MMYY = True

if S[2:] in months:
    YYMM = True

if MMYY and YYMM: print('AMBIGUOUS')
elif MMYY and not YYMM: print('MMYY')
elif not MMYY and YYMM: print('YYMM')
else: print('NA')


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
class Main {
    static class Triplet implements Comparable<Triplet> {
        int weight;
        int strength;
        long value;
        Triplet(int weight, int strength, long value) {
            this.weight = weight;
            this.strength = strength;
            this.value = value;
        }
        public int compareTo(Triplet other) {
            return this.weight+this.strength-other.weight-other.strength;
        }
    }
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] weights = new int[n];
        int[] strengths = new int[n];
        long[] values = new long[n];
        Triplet[] triplets = new Triplet[n];
        int maxWeight = 0;
        for(int i = 0; i<n; i++) {
            weights[i] = sc.nextInt();
            strengths[i] = sc.nextInt();
            values[i] = sc.nextLong();
            triplets[i] = new Triplet(weights[i], strengths[i], values[i]);
            maxWeight = Math.max(maxWeight, weights[i]);
        }
        Arrays.sort(triplets);
        long[] dp = new long[n*maxWeight+1];
        for(int i = 0; i<n; i++) {
            for(int j = triplets[i].strength; j>=0; j--) {
                int newWeight = j+triplets[i].weight;
                if(newWeight<dp.length)
                    dp[newWeight] = Math.max(dp[newWeight], dp[j]+triplets[i].value);
            }
        }
        long max = 0;
        for(long i: dp)
            max = Math.max(max, i);
        System.out.println(max);
    }
}

Measured memory_bytes: 106568
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 998244353; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class SegmentTree(object):
	def __init__(self, N):
		self.N0 = 2 ** (N - 1).bit_length()
		self.data = [0] * (2 * self.N0)

	def update(self, k, x):
		k += self.N0 - 1
		self.data[k] = x
		while k > 0:
			k = (k - 1) // 2
			self.data[k] = self.data[2 * k + 1] + self.data[2 * k + 2]

	def query(self, l, r):
		L = l + self.N0; R = r + self.N0 + 1
		m = 0
		while L < R:
			if R & 1:
				R -= 1
				m += self.data[R - 1]
			if L & 1:
				m += self.data[L - 1]
				L += 1
			L >>= 1; R >>= 1

		return m

#処理内容
def main():
	N = int(input())
	XY = [None] * N
	X = [None] * N
	Y = [None] * N
	for i in range(N):
		x, y = getlist()
		XY[i] = [x, y]
		X[i] = x; Y[i] = y

	#座圧
	X.sort(); Y.sort()
	Dx = defaultdict(int)
	Dy = defaultdict(int)
	for i in range(N):
		Dx[X[i]] = i
		Dy[Y[i]] = i

	for i in range(N):
		XY[i] = Dx[XY[i][0]], Dy[XY[i][1]]

	XY.sort(key=lambda x: x[0])
	YY = [XY[i][1] for i in range(N)]
	# print(YY)
	# print(XY)
	
	Segleft = SegmentTree(N)
	Segright = SegmentTree(N)

	#関係なく決まっている値
	ans = pow(2, N - 1, con) * N
	ans %= con

	yLU = [0] * N
	yLD = [0] * N
	yRU = [0] * N
	yRD = [0] * N

	#左初期化
	Segleft.update(YY[0], 1)

	for i in range(1, N - 1):
		y = YY[i]
		yLD[i] = Segleft.query(0, y)
		yLU[i] = Segleft.query(y, N - 1)
		Segleft.update(y, 1)

	#右初期化
	Segright.update(YY[N - 1], 1)

	for i in range(N - 2, 0, -1):
		y = YY[i]
		yRD[i] = Segright.query(0, y)
		yRU[i] = Segright.query(y, N - 1)
		Segright.update(y, 1)

	# print(yLD)
	# print(yLU)
	# print(yRD)
	# print(yRU)

	for i in range(1, N - 1):
		lu = yLU[i]; ru = yRU[i]
		ld = yLD[i]; rd = yRD[i]
		a = pow(2, lu, con)
		b = pow(2, ru, con)
		c = pow(2, ld, con)
		d = pow(2, rd, con)
		if rd != 0 and lu != 0:
			ans += (d - 1) * (a - 1) * b * c
		if ld != 0 and ru != 0:
			ans += (c - 1) * (b - 1) * a * d
		#包除
		if rd != 0 and lu != 0 and ld != 0 and ru != 0:
			ans -= (a - 1) * (b - 1) * (c - 1) * (d - 1)
		ans %= con

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 119336
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n;cin>>n;
    int before;
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if(i==0) {
            before = a;
        } else {
            if(before > a) sum += (before - a);
            else before = a;
        }
    }
    cout << sum;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

map<pair<int, int>, int> mp;

int pow(int n, int m)
{
  if (m == 1) {
    return n;
  }
  if (m == 0) {
    return 1;
  }
  if (m % 2 == 1) {
    return n * pow(n, m - 1);
  }
  if (m % 2 == 0) {
    int a = pow(n, m / 2);
    return a * a;
  }
}

int comb(int n, int m, int k) {
  if (n == 1) {
    if (1 <= k && k <= m) {
      return 1;
    } else {
      return 0;
    }
  }
  int sum = 0;
  if (mp.find(make_pair(n, k)) != mp.end()) {
    return mp[make_pair(n, k)];
  } else {
    for (int i = 1; i <= m; i++) {
      if (i >= k) {break;}
      sum += comb(n - 1, m, k - i);
    }
  }
  mp[make_pair(n, k)] = sum;
  return sum;
}

int main()
{
  int n, m, k;
  while (scanf("%d %d %d ", &n, &m, &k) == 3) {
    if (n == 0 && m == 0 && k == 0) {
      break;
    }
    mp.clear();
    int E = 0;
    for (int i = n; i <= k; i++) {      
      E += comb(n, m, i);
      //printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
    }
    for (int i = k + 1; i <= m * n; i++) {
      E += comb(n, m, i) * (i - k);
      //printf("%d %d %d = %d\n", n, m, i, comb(n, m, i));
    }
    printf("%.9lf\n", (double)E / pow(m, n));
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    if(n>1&&b>=a||n==1&&a==b)
        cout<<(n-2)*(b-a)+1<<endl;
    else
        cout<<0<<endl;
    return 0;
} 

Measured memory_bytes: 256
from collections import Counter
Next = [i*10 % 2019 for i in range(2019)]
S = input()
L = list(reversed(S))
Amaris = []#「右から」x桁まで見た場合の余り
amari = 0
kurai = 1
for l in L:
    amari += kurai*int(l)
    amari %= 2019 
    kurai *= 10
    kurai %= 2019
    Amaris.append(amari)
C = Counter(Amaris)
ans = 0 
for d in C.values():
    ans += d*(d-1)//2
print(ans + C[0])

Measured memory_bytes: 84996
#include<stdio.h>

int main(){
  int i, j, v, k, n, u, x, min;
  int p[100], d[100], M[100][100];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = 1000000;
    }
  }
  for(i=0; i<n; i++){
    scanf("%d %d",&u, &k);
    for(j=0; j<k; j++){
      scanf("%d %d",&v, &x);
      M[u][v] = x;
    }
  }
  for(i=0; i<n; i++){
    d[i] = 1000000;
    p[i] = 0;
  }
  d[0] = 0;
  p[0] = 2;
  while(1){
    min = 1000000;
    u = -1;
    for(i=0; i<n; i++){
      if(min > d[i] && p[i] != 1){
	u = i;
	min = d[i];
      }
    }
    if(u==-1){
      break;
    }
    p[u] = 1;
    for(i=0; i<n; i++){
      if(p[i] != 1 && M[u][i] != 1000000){
	if(d[i] > d[u] + M[u][i]){
	  d[i] = d[u] + M[u][i];
	  p[i] = 2;
	}
      }
    }
  }
  for(i=0; i<n; i++){
    if(d[i] == 1000000){
      printf("%d -1\n",i);
    }
    else{
      printf("%d %d\n",i, d[i]);
    }
  }
  return 0;
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<ll> x = {a, b};
    vector<ll> y = {c, d};
    if(a <= 0 && 0 <= b) {
        x.emplace_back(0);
    }
    if(c <= 0 && 0 <= d) {
        y.emplace_back(0);
    }
    ll ans = -LLINF;
    for(auto i : x) {
        for(auto j : y) {
            chmax(ans, i * j);
        }
    }
    cout << ans << endl;
}

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

int main() {
  int X,A,B;
  cin >> X >> A >> B;
  
  if(A-B>=0){
    cout << "delicious" << endl;
  }else{
    if(X>=B-A){
      cout << "safe" << endl;
    }else{
      cout << "dangerous" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int M_N = 300000;

vector<LL> fact;
vector<LL> inver(M_N+1);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=M_N;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[M_N]=fpow(fact[M_N],mod-2);
    for(int i=M_N-1;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 
LL hcombi(int n,int r){
    return combi(n+r-1,r); 
}

vector<LL> divi(LL K){
    vector<LL> v;
    for(LL i=1;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        v.pb(K/i);
    }
    sort(ALL(v));
    v.erase(unique(ALL(v)),v.end());
    return v;
}

vector<LL> pdivi(LL K){
    vector<LL> v;
    for(LL i=2;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        while(K%i==0){
            K/=i;
        }
    }
    if(K!=1) v.pb(K);
    return v;
}



int main(){
    set_combi();
    LL n,m,k;cin >> n >> m >> k;
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        LL p = n - (i + 1);
        if(p <= k){
            ans = (ans + combi(n-1, i) * fpow(m-1,i) %mod * m %mod)%mod;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9620
#-*-coding:utf-8-*-

def main():
    sx, sy, tx, ty = map(int, input().split())

    diff = [tx - sx, ty - sy]
    for i in range(diff[1]):
        print('U', end='')
    for i in range(diff[0]):
        print('R', end='')
    for i in range(diff[1]):
        print('D', end='')
    for i in range(diff[0]):
        print('L', end='')
    
    print('L', end='')

    for i in range(diff[1] + 1):
        print('U', end='')
    for i in range(diff[0] + 1):
        print('R', end='')
    
    print('D', end='')

    print('R', end='')

    for i in range(diff[1] + 1):
        print('D', end='')
    for i in range(diff[0] + 1):
        print('L', end='')

    print('U', end='')
    print('')

if __name__ == '__main__':
    main()

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

const int N = 200000;
const int mod = 1000*1000*1000+7;

int n;
int m;
int x[N + 1];
int last[N + 1];
int res[N + 1];

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n; i++) scanf ("%d", &x[i]);
	for (int i = 0; i <= N; i++) last[i] = n;
	res[n] = 1;
	for (int i = n - 1; i >= 0; i--) {
		res[i] = (res[i + 1] + int (last[x[i]] < n && last[x[i]] > i + 1) * res[last[x[i]]]) % mod;
		last[x[i]] = i;
	}
	printf ("%d\n", res[0]);
	return 0;
}

Measured memory_bytes: 2560
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n===0)break;
   var ary=arr.shift().split(" ").map(Number);
   var obj={};
   ary.forEach(function(v){obj[v]=0;});
   ary.forEach(function(v){obj[v]++;});
   var ans="NO COLOR";
   var half=n/2;
   for(var k in obj){
      if(obj[k]>half)ans=k;
   }
   console.log(ans);
}

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

int main(void) {
  int x; 
  cin >> x;
  if(x >= 1200)
  cout << "ARC" << endl;
  else 
  cout << "ABC" << endl;
}

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

int main() {
    int n, x; cin >> n >> x;
    if (n == 2) {
        if (x == 2) cout << "Yes\n1\n2\n3\n";
        else cout << "No\n";
    } else if (x == 1 || x == 2*n-1)
        cout << "No\n";
    else {
        vector<int> ans(2*n-1);
        ans[n-1] = x;
        ans[n-2] = x-1;
        ans[n] = x+1;
        if (x >= 3) ans[n+1] = x-2;
        if (x < 2*n-2) ans[n-3] = x+2;
        for (int i = 1, j = 0; i <= 2*n-1; i++)
            if (abs(i - x) > 2) {
                while (ans[j] > 0) j++;
                ans[j] = i;
            }
        cout << "Yes\n";
        for (int a : ans) cout << a << endl;
    }
}


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



int main() 
{
  ll X; cin>>X;
  ll T;
  rep(i,100000)
  {
    if(i*(i+1)/2>=X)
    {
      T=i;
      break;
    }
  }
  cout<<T<<endl;
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "#.#" ].parse.expand.solve == 1 );
	assert( [ "5", "#.##." ].parse.expand.solve == 2 );
	assert( [ "9", "........." ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto gs = s.group.array;
	if( gs.length == 1 ) return 0L;
	
	// 入力を整形
	if( gs[ 0     ][ 0 ] == '.' ) gs  = gs[ 1 .. $ ];
	if( gs[ $ - 1 ][ 0 ] == '.' ) gs ~= [ Tuple!( dchar, uint )( '#', 0 ), Tuple!( dchar, uint )( '.', 0 ) ];
	else                          gs ~= [ Tuple!( dchar, uint )( '.', 0 ), Tuple!( dchar, uint )( '#', 0 ), Tuple!( dchar, uint )( '.', 0 ) ];
	
	// i番目の黒を境界にした場合を計算（i-1番目までの黒を白にして、i+1番目以降の白を黒にする）
	auto wt = reduce!( ( a, b ) => b[ 0 ] == '.' ? a + b[ 1 ] : a )( 0L, gs );
	auto ans = long.max;
	auto b = 0L;
	auto w = 0L;
	for( auto i = 0L; i < gs.length; i += 2 )
	{
		ans = min( ans, b + ( wt - w ) );
		
		b += gs[ i ][ 1 ];
		w += gs[ i + 1 ][ 1 ];
	}
	
	return ans;
}


Measured memory_bytes: 6524
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<unordered_map>
#include<iomanip>
#include<sstream>

using namespace std;

#define P 1009

struct Node{
  int s;
  int num;
  bool operator==(const Node &left) const {return this->s == left.s;}
};

struct Graph{
  int num;
  Graph(){
    num = 0;
  }
  queue< Node > free;
  unordered_map<int, int> inpath;
  unordered_map<int, vector<Node> > outpath;
};

int main(){
  int n; cin >> n;
  Graph G;
  vector< Node > last(n, {-1, -1});
  for(int i = 0; i < n ; i++){
    for(int j = 0; j < n-1; j++){
      int t; cin >> t; t--;
      int a = min(i,t);
      int b = max(i,t);
      int s = a * P + b;
      if(a == i){
        G.inpath[(Node){s, 0}.s] = 0;
      }
      if(last[i].s != -1){
        G.outpath[last[i].s].push_back((Node){s, 0});
        G.inpath[(Node){s, 0}.s]++;
      }
      if(i == b && G.inpath[(Node){s, 0}.s] == 0) G.free.push((Node){s, 0});
      last[i] = (Node){s, 0};
    }
  }
  int ans = 0;
  while(!G.free.empty()){
    Node now = G.free.front();
    G.free.pop();
    G.num++;
    ans = now.num;
    for(auto to : G.outpath[now.s]){
      G.inpath[to.s]--;
      if(G.inpath[to.s] == 0){
        to.num = max(to.num, now.num + 1);
        G.free.push(to);
      }
    }
  }
  if(G.num != n*(n-1)/2){
    cout << -1 << endl;
  }
  else{
    cout << ans+1 << endl;
  }
}


Measured memory_bytes: 63080
import sys
MOD = 10**9 + 7


def sum_from_to(fr, to):
    return (to - fr + 1) * (fr + to) // 2 % MOD


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    ans = 0
    for i in range(k, n + 2):
        ans += sum_from_to(n - i + 1, n) - sum_from_to(0, i - 1) + 1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8984