akhauriyash/Code-Regression huggingface dataset:
int N,M,X[1<<17];
int cnt[1<<17],mcnt[1<<17],p[1<<17];
main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++)
	{
		scanf("%d",X+i);
		cnt[X[i]]++;
	}
	int ans=0;
	for(int i=1;i<1<<17;i++)
	{
		ans+=cnt[i]/2;
		mcnt[i%M]+=cnt[i]%2;
		p[i%M]+=cnt[i]/2;
	}
	for(int i=0;i<=M/2;i++)
	{
		if(i==(M-i)%M)
		{
			ans+=mcnt[i]/2;
			continue;
		}
		int t=fmin(mcnt[i],mcnt[M-i]);
		ans+=t;
		mcnt[i]-=t;
		mcnt[M-i]-=t;
		ans+=fmin(p[M-i],mcnt[i]/2);
		ans+=fmin(p[i],mcnt[M-i]/2);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1792
n,k = gets.strip.split.map(&:to_i)
  a = gets.strip.split.map(&:to_i)
  
  t = []
  f = Array.new(n)
  ti = 0
  ts,te = 0,0
  n.times do |i|
    t.append (a[ti] - 1)
    if f[ti]
      ts = f[ti]
      te = i
      break
    else
      f[ti] = i
    end
    ti = a[ti] - 1
  end
  if k < te
    p t[k-1]+1
  else
    p t[(k-1-ts)%(te-ts) + ts]+1
  end


Measured memory_bytes: 31664
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;

  ll ans = 1e18;
  if((a + b) < 2*c){
    // 別々に買う
    ans = a * x + b * y;
    cout<<ans<<endl;
    return 0;
  }
  else{
    // min(x,y)*2 - max(x,y)*2のどれかをc買う
    for(ll i = min(x,y) * 2; i <= max(x,y) * 2; i++){
      ll tmp = 0;
      tmp += i * c;
      tmp += max( (x - (i / 2 ) ), (ll)0) * a;
      tmp += max( (y - (i / 2 ) ), (ll)0) * b;
      // cout<<i<<" "<<tmp<<endl;
      ans = min(ans , tmp);
    }
    cout<<ans<<endl;
    return 0;
  }
}


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

using namespace std;

long long int a[100009] , dp[100009] , k;

long long int jump(long long int n)
{   
    if(dp[n]>=0) return dp[n];

    if(n==1) dp[n]=0;

    else if(n==2) dp[n]=abs(a[2]-a[1]);

    else
    {
        long long int x = INT_MAX , i;
        for( i = 1 ; i <= k; i++)
        {
            if(n-i>0) x = min(jump(n-i)+abs(a[n-i]-a[n]),x);
        }

        dp[n]=x;
    }

    return dp[n];
}

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

    cout<<jump(n)<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b) { return a>b?a:b;}
ll min(ll a,ll b) { return a<b?a:b;}

void solve()
{
    
}
int main() {
   
    int n;
    cin>>n;
    map<string,int> m;
    string s;
    fi(i,0,n)
    {
      cin>>s;
      m[s]++;
    }
    cout<<"AC x "<<m["AC"];nl;
    cout<<"WA x "<<m["WA"];nl;
    cout<<"TLE x "<<m["TLE"];nl;
    cout<<"RE x "<<m["RE"];nl;

    
    return 0;
}


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

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 1;
    int count = 0;
    while(ans < B) {
        ans--;
        ans += A;
        count++;
    }
    cout << count << endl;
    return 0;
}

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

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

  int s = 1, dist_s = 0;
  for(int i=2;i<=n;i++){
    cout << "? " << 1 << " " << i << endl;
    int dist; cin >> dist;
    if(dist_s < dist) dist_s = dist, s = i;
  }

  vector<int> p(n+1,s);
  for(int i=1;i<=n;i++){
    if(i==s) continue;
    cout << "? " << s << " " << i << endl;
    int dist; cin >> dist;
    p[dist+1] = i;
  }

  if(p[1] > p[n]) reverse(p.begin()+1, p.end());
  cout << "!";
  for(int i=1;i<=n;i++) cout << " " << p[i];
  cout << endl;

  return 0;
}



Measured memory_bytes: 3692
import java.time.Instant;
import java.util.*;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int T = sc.nextInt();


		System.out.println(T/A * B);
	}
}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    vector<int> v(3, 0);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    if (v[0] != v[1]) cout << v[0] << endl;
    if (v[1] != v[2]) cout << v[2] << endl;
}




Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <cstdarg>
typedef long long ll_t;


void debug(const char *fmt, ...) {
    va_list ap;
    va_start(ap, fmt);
    vfprintf(stderr, fmt, ap);
    va_end(ap);
}

int N;
int A;
int x[50];
ll_t dp[51][51][2501];

int main() {
    scanf("%d%d", &N, &A);
    for (int i = 0; i < N; i++)
        scanf("%d", &x[i]);
    memset(dp, 0, sizeof dp);
    for (int i = 0; i <= N; i++)
        dp[i][0][0] = 1;
    for (int n = 1; n <= N; n++) 
    for (int k = 1; k <= n; k++) 
    for (int s = 1; s <= k * 50; s++) {
        dp[n][k][s] = dp[n-1][k][s];
        if (s >= x[n-1])
            dp[n][k][s] += dp[n-1][k-1][s-x[n-1]];
        //debug("%d %d %d: %lld\n", n, k, s, dp[n][k][s]);
    }
    ll_t r = 0;
    for (int k = 1; k <= N; k++) {
        r += dp[N][k][k*A];
        //debug("%d: %lld\n", k, dp[N][k][k*A]);
    }
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 50944
#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 rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int>v(4);
  rep(i,0,n){
    string s;
    cin >> s;
    if(s=="AC")v[0]++;
    if(s=="WA")v[1]++;
    if(s=="TLE")v[2]++;
    if(s=="RE")v[3]++;
  }
  cout << "AC" << " " << "x" << " " << v[0] << endl;
  cout << "WA" << " " << "x" << " " << v[1] << endl;
  cout << "TLE" << " " << "x" << " " << v[2] << endl;
  cout << "RE" << " " << "x" << " " << v[3] << endl;
  return 0;
}

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

using ll = long long;

ll f(ll a, ll b) {
    if (a > b) swap(a, b);

    if (a == 0) return 0;
    ll res = 2 * (b / a) * a + f(a, b % a);
    if ((b - a) % a == 0) res -= a;
    return res;
}

int main() {
    ll N, X;
    cin >> N >> X;

    cout << N + f(N - X, X) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	err := Main(os.Stdin, os.Stdout)
	if err != nil {
		panic(err)
	}
}

func Main(r io.Reader, w io.Writer) error {
	scanner := bufio.NewScanner(r)
	scanner.Scan()
	num := scanner.Text()
	n, err := strconv.Atoi(num)
	if err != nil {
		return err
	}

	counter := make(map[string]int, n)

	for scanner.Scan() {
		s := strings.TrimSpace(scanner.Text())
		if s == "" {
			continue
		}
		counter[s]++
	}
	if err := scanner.Err(); err != nil {
		return err
	}

	fmt.Fprintln(w, len(counter))
	return nil
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){

  
  ll N;
  cin>>N;
  bool flag=false;
  if(N%10==7){
    flag=true;
  }
if(N/100==7){
  flag=true;
}
if((N-(N/100)*100-(N%10))/10==7){
flag=true;
}

  if(flag){
cout<<"Yes"<<endl;
  }
else{
cout<<"No"<<endl;
}
}



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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n;
    ll ans = 0;
    cin >> n;
    FOR(i,1,n+1){
        ans += i;
    }
    cout << ans << endl;
    return 0;
}



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

left = A[0]
left_count = 0
right = A[N - 1]
right_count = 0
for i in range(N - 2):
    if left <= right:
        left_count += 1
        left += A[left_count]
    else:
        right_count += 1
        right += A[N - right_count - 1]

print(abs(left- right))

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int n;
	cin >> n;
	int a[25] = {};
	int b[25] = {};
	int c[25] = {};

	int sum = 0;
	rep(i,n) {
		cin >> a[i];
	}

	rep(i,n) {
		cin >> b[i];
		sum += b[i];
	}

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

	rep(i,n-1) {
		if (a[i] +1 == a[i+1]) {
			sum += c[a[i]-1];
		}
	}

	cout << sum << endl;
}



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

using namespace std;

const int N = 1e5 + 10;

int n, m, a[N];
vector<int> ans;

int main() {
  scanf("%d %d", &n, &m);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &a[i]);
    cnt += (a[i] & 1);
  }
  if (cnt > 2) {
    puts("Impossible");
    return 0;
  }
  for (int i = 2; i < m; i++) {
    if (a[i] & 1) {
      if (a[1] & 1) {
        swap(a[m], a[i]);
      } else {
        swap(a[1], a[i]);
      }
    }
  }
  if (m == 1) {
    if (a[1] > 1) {
      ans.push_back(a[1] - 1);
    }
    ans.push_back(1);
  } else {
    ans.push_back(a[1] + 1);
    for (int i = 2; i < m; i++) {
      ans.push_back(a[i]);
    }
    if (a[m] > 1) {
      ans.push_back(a[m] - 1);
    }
  }
  for (int i = 1; i <= m; i++) {
    printf("%d ", a[i]);
  }
  puts("");
  printf("%d\n", ans.size());
  for (auto a : ans) {
    printf("%d ", a);
  }
  return 0;
}

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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)

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

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

void solve(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    int ma = A[0];
    int ans = 0;
    rep(i,N){
        if(A[i] < ma){
            ans += ma- A[i];
        }else{
            ma = A[i];
        }
    }
    cout << ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
//    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 4832
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, (int)s.sz){
        if(s[i] == '1')cnt++;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int tmp = abs(a - b), tmpp = abs(b - c);
	if (abs(c - a) <= d || (tmp <= d && tmpp <= d)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

const int N = 17;
ll graph[N][N];
ll dp[(1 << N)];
ll cost[(1 << N)];

ll count_cost(ll m)
{
    ll ans = 0;

    for(int i = 0; i < N; i++)
        if(((m >> i) | 1) == (m >> i))
            for(int j =  i + 1; j < N; j++)
                if(((m >> j) | 1) == (m >> j))
                    ans += graph[i][j];
    return ans;
}
int main()
{
    turbo

    int n; cin >> n;

    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
        {
            int x; cin >> x;
            graph[i][j] = x;
        }
    for(int i = 0; i < (1 << n); i++)
        cost[i] = count_cost(i);
    
    for(int i = 0; i < (1 << n); i++)
        for(int j = i; j >= 0; j = (j - 1) & i)
        {
            dp[i] = max(dp[i], cost[j] + dp[i ^ j]); 
            if(j == 0) break;
        }

    cout << dp[(1 << n) - 1];
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a = 0,b = 0;
  for(int i = 0;i<s.size();i++){
    if(s.at(i) == '0'){
      a++;
    }
    else{
      b++;
    }
  }
  if(a>b){
    cout << 2*b << endl;
  }
  else{
    cout << 2*a << endl;
  }
  return 0;
}

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

const int N = 1e5 + 10;
char s[N];
int n;

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int ans = 0x7f7f7f7f;
    for(int i = 1; i < n; i++) {
        if(s[i] != s[i + 1]){
            ans = min(ans, max(i, n - i));
        }
    }
    printf("%d\n", ans == 0x7f7f7f7f ? n : ans);
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
array = list(map(int, input().strip().split(' ')))
array.sort()
array2 = []
for i in range(M-1):
  array2.append(array[i+1] - array[i])
array2.sort()
array2.reverse()
del array2[0:N-1]
sum = 0
for i in range(M-N):
  sum = sum + array2[i]
print(sum)

Measured memory_bytes: 13960
def common():
  X = raw_input()
  Y = raw_input()
  a = len(X)
  b = len(Y)
  k1 = [0 for i in range(b+1)]
 
  for i in range(a):
     k2 = k1 + []
     for j in range(b):
       if X[i] == Y[j]:
          k1[j+1] = k2[j] + 1
       elif k1[j+1] < k1[j]:
          k1[j+1] = k1[j]
 
  return k1[-1]
 
n = input()
for l in range(n):
  print common()

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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct data_t{
	string s;
	int p;
	int k;
	data_t(string str, int pt, int kk){
		s = str;
		p = pt;
		k = kk;
	}
	bool operator<(const data_t &another) const{
		if(s != another.s)
			return s < another.s;
		else
			return p > another.p;
	}
};

int main(void)
{
	int n;
	vector<data_t> d;
	cin>>n;
	rep(i,n){
		string st;int pt;
		cin>>st>>pt;
		d.push_back(data_t(st, pt, i + 1));
	}
	sort(all(d));
	rep(i,n)cout << d[i].k << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
unsigned long mix(unsigned long a, unsigned long b, unsigned long c){
    a=a-b;  a=a-c;  a=a^(c >> 13);
    b=b-c;  b=b-a;  b=b^(a << 8);
    c=c-a;  c=c-b;  c=c^(b >> 13);
    a=a-b;  a=a-c;  a=a^(c >> 12);
    b=b-c;  b=b-a;  b=b^(a << 16);
    c=c-a;  c=c-b;  c=c^(b >> 5);
    a=a-b;  a=a-c;  a=a^(c >> 3);
    b=b-c;  b=b-a;  b=b^(a << 10);
    c=c-a;  c=c-b;  c=c^(b >> 15);
    return c;
}
unsigned long seed = mix(clock(), time(NULL), 22869420);
int n;
ll cst[26], sat[366][26], last[26], tmp[26];
ll tester(vector<int>v){
	ll res = 0ll;
	memset(last, 0ll, sizeof(last));
	for(int nw, i=0; i<n; i++){
		nw = v[i];
		res += sat[i][nw-1];
		last[nw-1] = i+1;
		for(int j=0; j<26; j++)
			res -= cst[j]*(i+1-last[j]);
	}
	return res;
}
int rand(int x){return rand()%x+1;}
vector<int>gen(int hm, int x){
	vector<int>res;
	for(int cr=rand()%x+1, times=0; times<hm; cr=rand(x)%x+1, times++)
		res.push_back(cr);
	return res;
}
int randlf(int l, int r){return rand()%(r-l+1)+l;}
vector<int>lgg={1, 2, 4, 8, 16, 32, 64, 96};
vector<int>best;
int main(){
	srand(seed);
	scanf("%d", &n);
	memset(last, 0ll, sizeof(last));
	for(int i=0; i<26; i++) scanf("%lld", &cst[i]);
	for(int i=0; i<n; i++) for(int j=0; j<26; j++)
		scanf("%lld", &sat[i][j]);
	ll res = 0ll;
	vector<int>base;
	for(int nw, i=0; i<n; i++){
		memset(tmp, 0ll, sizeof(tmp));
		for(nw=0; nw<26; nw++){
			tmp[nw] += sat[i][nw];
			for(int j=0; j<26; j++) if(j != nw)
				tmp[nw] -= cst[j] * (i+1-last[j]);
		}
		ll get = -inf; int id = -1;
		for(nw=0; nw<26; nw++) 
			if(get < tmp[nw]){
				get = tmp[nw]; id = nw;
			}else if(get == tmp[nw] && cst[nw] > cst[id]){
				get = tmp[nw]; id = nw;
			}
		base.push_back(id+1); 
		last[id] = i+1; res += tmp[nw];
	}
	best=base;
	for(int times=0; times<300; times++){
		for(int k=7; k>0; k--){
			vector<int>changeid, changeval;
			vector<int>nw = best;
			for(int tt=0; tt<5*(11-k); tt++){
				int cv = randlf(lgg[k-1], lgg[k]);
				changeid = gen(cv, 365);
				changeval = gen(cv, 26);
				vector<int>cur = nw;
				for(int i=0; i<cv; i++)
					cur[changeid[i]-1] = changeval[i];
				if(tester(best) < tester(cur))
					best = cur;
				else{
					cur = best;
					for(int i=0; i<cv; i++)
						cur[changeid[i]-1] = changeval[i];
					if(tester(best) < tester(cur))
						best = cur;
				}
			}
		}
	}
	for(int i=0; i<n; i++) printf("%d\n", best[i]);
	return 0;
}

Measured memory_bytes: 3952
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <string>
#include <math.h>
#include<set>
#include<stdio.h>
#include <bitset>
#define ii int64_t
#define PI 3.14
#define lli long long int
#define li long int
#define mod 1000000007
#define f(x,n) for(int64_t x=0;x<n;++x)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// while(scanf("%d",&n)!=EOF)
using namespace std;



int main()
{
    fio
    ii n,i,j;
    cin>>n;
    ii h[n+3],dp[n+3];
    for(i=1;i<n+1;i++)
        cin>>h[i];
    dp[1]=dp[0]=0;
    dp[2]=dp[1]+abs(h[2]-h[1]);
    for(i=3;i<=n;i++)
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    
    cout<<dp[n];


}


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

const double PI = 3.14159265358979323846;

int main() {
  int r;
  cin >> r;
  double ans = (double)2.0 * (double)r * PI;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3804
#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<string>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 a,b,c,d,z=0,x=0,y=0;
cin>>a>>b>>c>>d;
if (d!=0){
x = min (a,d);
d-=x;}
//cout<<x<<" "<<d;
if (d!=0){
y = min (b,d);
d-=y;}
//cout<<y<<d;
if (d!=0){
z = min (c,d);
d-=z;}
cout<<x-z;}





Measured memory_bytes: 3532
#include<stdio.h>

int main(void)
{
	long n,m,i;
	long sum=0;
	scanf("%ld %ld",&n,&m);

	long a[m];
	for(i=0;i<m;i++){
		scanf("%ld",&a[i]);
		sum=sum+a[i];
	}

	if(sum>n){
		puts("-1");
	}
	else{
		printf("%ld\n",n-sum);
	}

	return 0;
}


Measured memory_bytes: 1764
import sys


def input():
    return sys.stdin.readline().strip()


def solve():
    N, Q = map(int, input().split())
    g = [set() for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        g[a].add(b)
        g[b].add(a)
    counter = [0] * N
    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        counter[p] += x

    stack = [0]
    visited = [False] * N
    visited[0] = True
    while stack:
        v = stack.pop()
        for nv in g[v]:
            if visited[nv]:
                continue
            stack.append(nv)
            visited[nv] = True
            counter[nv] += counter[v]
    return counter


print(" ".join(map(str, solve())))


Measured memory_bytes: 76056
#include<bits/stdc++.h>
    using namespace std;
    #define rep(i,b) for(i=0;i<b;++i)
    #define repp(i,a,b) for(i=a;i<b;++i)
    #define per(i,n) for(i=n-1;i>=0;i--)
    #define endl "\n"
    #define pb push_back
    typedef long long int lli;
    const lli mod=1000000007;
    typedef vector<lli> vi;
    typedef pair<lli,lli> pi;
    #define mp make_pair
    #define pb push_back
    int main(){
       //ios_base::sync_with_stdio(false);
       //cin.tie(NULL);
        lli n,t,i,k,j,f,g,m;
        string s;
        vi v;
        map<lli,lli> mm;
        map<lli,lli> :: iterator it;
        cin>>n;
        if(n==1){
            cout<<"Hello World"<<endl;
        }
        else{
            cin>>k>>j;
            cout<<k+j<<endl;
        }
        return 0;
    }



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
static const int MAX_N = 10000;
 
class DisjointSet{
    public:
        vector<int> rank, p;
 
        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i = 0;i < size;i++) makeSet(i);
        }
 
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }
 
        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x, int y){
            link(findSet(x), findSet(y));
        }
 
        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x] == rank[y]){
                    rank[y]++;
                }
            }
        }
 
        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};
 
class Edge{
public:
    int source, target; double cost;
    Edge(int source = 0, int target = 0, double cost = 0.0):
    source(source), target(target), cost(cost){}
    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
};
 
double kruskal(int N, vector<Edge> edges){
    double totalCost = 0.0;
    sort(edges.begin(), edges.end());
 
    DisjointSet dset = DisjointSet(N + 1);
 
    for(int i = 0; i < N; i++) dset.makeSet(i);
 
    int source, target;
    for(int i = 0; i < edges.size(); i++){
        Edge e = edges[i];
        if(!dset.same(e.source, e.target)){
 
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}
 
 
int main(){
    int N, M;
    int source, target; double cost;
    double x[MAX_N], y[MAX_N];
    
    scanf("%d %d", &N, &M);
    for(int i = 0; i < N; i++) scanf("%lf %lf", &x[i], &y[i]);
    vector<Edge> edges;
    double sum = 0.0;
    for(int i = 0; i < M; i++){
        scanf("%d %d", &source, &target);
        source--; target--;
        cost = sqrt(pow(x[source] - x[target], 2.0) + pow(y[source] - y[target], 2.0));
        edges.push_back(Edge(source, target, -cost));
        sum += cost;
    }
    printf("%.10lf\n", sum + kruskal(N, edges));
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;
	long N; cin >> N;
	string S; cin >> S;
	long mycount[500009]; //i番目をリーダーにした時の向きを変える人の数。
	mycount[1] = 0;
	for (int i = 2; i <= N; i++) if (S[i - 1] == 'E') mycount[1]++;
	for (int i = 2; i <= N; i++) {
		mycount[i] = mycount[i - 1];
		if (S[i - 2] == 'W') mycount[i]++;
		if (S[i - 1] == 'E') mycount[i]--;

	}

	sort(mycount + 1, mycount + N + 1);
	res = mycount[1];

	cout << res << endl;
}

Measured memory_bytes: 4484
import heapq

N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)

for _ in range(M):
    max_price = -heapq.heappop(A)
    heapq.heappush(A, -(max_price // 2))

ans = 0
for a in A:
    ans += -a
print(ans)


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

const int maxn = 100050;
const int INF = 0x3f3f3f3f;
int a[maxn];
int b[maxn];
int c[maxn];

int dp[maxn][4];
int ddp[maxn];

int main()
{
	int n;
	cin>>n;
	for(int i = 1;i<=n;++i)
	    cin>>a[i]>>b[i]>>c[i];
	
	dp[0][1] = 0,dp[0][2] = 0,dp[0][3] = 0;  
	dp[1][1] = a[1],dp[1][2] = b[1],dp[1][3] = c[1];
	int m = max(dp[1][1],dp[1][2]);
	ddp[1] = max(m,dp[1][3]);
	
	for(int i = 2;i<=n;++i){
		dp[i][1] = max(dp[i-1][2]+a[i],dp[i-1][3]+a[i]);
		dp[i][2] = max(dp[i-1][1]+b[i],dp[i-1][3]+b[i]);
		dp[i][3] = max(dp[i-1][1]+c[i],dp[i-1][2]+c[i]);
		m = max(dp[i][1],dp[i][2]);
		ddp[i] = max(m,dp[i][3]);		
	}
	cout<<ddp[n]<<endl;
	return 0;
} 

Measured memory_bytes: 6696
#include <stdio.h>

int main(void)
{
	double a;
	double tmp;
	double sum;
	int i;
	
	while (scanf("%lf", &a) != EOF){
		sum = a;
		tmp = a;
		for (i = 1; i < 10; i++){
			if (i % 2 == 0){
				tmp /= 3;
				sum += tmp;
			}
			else {
				tmp *= 2;
				sum += tmp;
			}
		}
		printf("%.8lf\n", sum);
	}
	
	return (0);
}

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

using namespace std;
using ll = long long;


int main()
{
	int n, m;
	cin >> n >> m;
	vector<pair<int,int>> a(n); for(int i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end());
	ll sum = 0;

	for(int i = 0;m; i++) {
		sum += (ll)a[i].first * min(a[i].second, m);
		m = max(m - a[i].second, 0);
	}
	cout << sum << endl;
}


Measured memory_bytes: 1024
import numpy as np

def check(a,b,c):
  return a==b==c==0


t=[list(map(int,list(input().split(" ")))) for i in range(3)]
n = int(input())
a = [int(input()) for _ in range(n)]

for i in a:
  for x in range(3):
    for y in range(3):
      if t[x][y] == i :
        t[x][y] = 0

ans = check(t[0][0],t[0][1],t[0][2]) or \
check(t[1][0],t[1][1],t[1][2]) or \
check(t[2][0],t[2][1],t[2][2]) or \
check(t[0][0],t[1][0],t[2][0]) or \
check(t[0][1],t[1][1],t[2][1]) or \
check(t[0][2],t[1][2],t[2][2]) or \
check(t[0][0],t[1][1],t[2][2]) or \
check(t[0][2],t[1][1],t[2][0]) 

print(["No","Yes"][ans])

Measured memory_bytes: 12484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	ll a[x], b[y], c[z], ab[x * y];
	for (int i = 0; i < x; cin >> a[i++]);
	for (int i = 0; i < y; cin >> b[i++]);
	for (int i = 0; i < z; cin >> c[i++]);

	for (int i = 0; i < x; i++)
		for (int j = 0; j < y; j++)
			ab[i * y + j] = a[i] + b[j];
	sort(ab, ab + x * y, greater<ll>());

	vector<ll> ans;
	for (int i = 0; i < min(k, x * y); i++)
		for (int j = 0; j < z; j++)
			ans.pb(ab[i] + c[j]);

	sort(ans.rbegin(), ans.rend());
	for (int i = 0; i < k; i++)
		cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 42980
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

template< typename T >
struct Dinic
{
  struct edge
  {
    int to;
    T cap;
    int rev;
  };

  const T INF;
  vector< vector< edge > > graph;
  vector< T > min_cost;
  vector< int > iter;

  Dinic(int n) : INF(numeric_limits< T >::max())
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, T cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  T dfs(int idx, const int t, T flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      T f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll v,e;
    cin>>v>>e;
    Dinic<int> dinic(v);
    FOR(i,0,e){
      ll src,to,cap;
      cin>>src>>to>>cap;
      dinic.add_edge(src,to,cap);
    }
    cout<<dinic.max_flow(0,v-1)<<endl;
}



Measured memory_bytes: 3228
n,m = gets.split.map(&:to_i)
ary = []
rank = []
m.times do |i|
  ary[i] = gets.split.map(&:to_i)
end

(1..n).each do |i|
  rank[i] = []
end
m.times do |i|
  p,y = ary[i]
  rank[p].push([y,i]) 
end

(1..n).each do |p|
  next if rank[p].nil?
  rank[p].sort!
end

(1..n).each do |p|
  next if rank[p].nil?
  (rank[p].size).times do |r|
    ary[rank[p][r][1]][2] = r+1
  end
end

m.times do |i|
  puts ary[i][0].to_s.rjust(6,"0") + ary[i][2].to_s.rjust(6,"0")
end



Measured memory_bytes: 28464
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test lli t;cin>>t;while(t--)
#define vll vector<lli>
#define mll map<lli,lli>
#define vvll vector<vector<lli>>
#define vpll vector<pair<lli,lli>>
#define vvpll vector<vector<pair<lli,lli>>>
#define mpll map<pair<lli,lli>,lli>
#define pll pair<lli,lli>
#define sll stack<lli>
#define qll queqe<lli>
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define mod 1000000007
#define ma 1000000000000000000
#define mi -1000000000000000000
int main()
{
 
  fastio
  int r,g,b,k;
  cin>>r>>g>>b;
  cin>>k;
  while(g<=r&&k>0)
  {
    g=g*2;
    k--;
  }
  while(b<=g&&k>0)
  {
    b=b*2;
    k--;
  }
  if(b>g&&g>r)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> d;
    for(int i = 1; i < 101; i++)
    {
        if(a % i == 0 && b % i == 0)
        {
            d.push_back(i);
        }
    }
    cout << d[d.size()-k] << endl;
}




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	if(S.size()==3) reverse(ALL(S));
	cout<<S<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);
        
        int max = array[n-1];
        int min = array[0];
        
        int[][] data = new int[n][2];
        for (int i = 1; i < n; i++) {
            data[i][0] = array[i] - array[i-1];
            data[i][1] = i;
        }
        Arrays.sort(data, (a, b) -> Integer.compare(b[0], a[0]));    // foo[][0]で
        
        int ans = max - min;
        for (int i = 0; i < Math.min(k-1, n); i++) {
            ans -= data[i][0];
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 51980
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long; using ull = unsigned long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using pii = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>;
template<typename T, typename U> static void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void chmax(T &x, U y) { if (x < y) x = y; }

signed main() {
    int k;
    string s;
    cin>>k>>s;
    if(s.size() <= k) {
        cout<<s;
    } else {
        rep(i,k)cout<<s[i];
        cout<<"...";
    }
    return 0;
}

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

int sygma(int n){
	if(n == 1) return 1;
	
	return n + sygma(n - 1);
}

int main(){
	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", 1 + sygma(n));
	}
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long
using namespace std;
int i,j,k;
int x,y;
int p[100005];
int l,r;
int M,N;
int a[100010];
int b[100010];
int c[100010];
int cnt[100010];
signed main()
{
  ios_base::sync_with_stdio(0);
  cin>>M>>N;
  for(i=1;i<=N;i++)
    cin>>p[i];
  for(i=1;i<M;i++)
  {
      cin>>a[i]>>b[i]>>c[i];
  }
  for(i=1;i<N;i++)
  {
      if(p[i]<p[i+1])
          for(j=p[i];j<p[i+1];j++)
            cnt[j]++;
      else
        for(j=p[i]-1;j>=p[i+1];j--)
          cnt[j]++;
  }
  int kq=0;
  for(i=1;i<M;i++)
  {
      kq+=min(a[i]*cnt[i],c[i]+b[i]*cnt[i]);
  }
  cout<<kq<<endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){

  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;






  

  return 0;
}

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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }



  int main(){
      int N, H, W;
      cin >> N >> H >> W;
      int ans = (N - H + 1) * (N - W + 1);
      print(ans);
  }

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, m;
    cin >> n >> m;
    vector<P> v(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        v[i] = {a, b};
    }
    sort(ALL(v));

    priority_queue<int> pq;

    int j = 0;
    int ans = 0;
    rep(i, m){
        while(j < n && v[j].first <= i + 1){
            pq.push(v[j++].second);
        }

        if(not pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2936
r = int(input())
tp = tuple(map(int,input().split()))
tq = tuple(map(int,input().split()))

import itertools

p, q = 0, 0 
for i, ti in enumerate(itertools.permutations(range(1,r+1))):
    if tp == ti:
        p = i        
    if tq == ti:
        q = i
    if p * q > 0:
        break

print(abs(p-q))

Measured memory_bytes: 38896
n,k,q = map(int, input().split())

anslist=[0]*(n+1)
for i in range(q):
  a=int(input())
  anslist[a]=anslist[a]+1

  
for i in range(1,n+1):
  if anslist[i]>q-k:
    print("Yes")
  else:
    print("No")
    

Measured memory_bytes: 50904
#include "iostream"
using namespace std;
int main() {
	int a, b, c, ans =0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		int temp = c % i;
		if (temp == 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#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++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
N, T = map(int, input().split(' '))
time = list(map(int, input().split(' ')))
Sumtime = 0
prev = 0
for i in time:
    if i == 0:
        continue
    elif i - prev >= T:
        Sumtime += T
    else:
        Sumtime += i - prev
    prev = i
print(Sumtime + T)

Measured memory_bytes: 26836
/* kadai 3_2
   nabe9393 */

#include<stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  if (N % 10 == 3){
    printf("bon\n");
  }
  else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
    printf("pon\n");
  }
  else{
    printf("hon\n");
  }
return 0;
}

Measured memory_bytes: 1620
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll fact(int n){
	ll ret=1;
	rep(i,n)ret*=(i+1);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl x(n),y(n);
	rep(i,n)cin>>x[i]>>y[i];
	double sum=0;
	rep(i,n){
		range(j,i+1,n){
			double tmp=hypot((x[i]-x[j]),(y[i]-y[j]));
			sum+=tmp*fact(n-1);
		}
	}
	fcout(8)<<2*sum/fact(n)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    rep(i, a + 1) {
        rep(j, b + 1) {
            rep(k, c + 1) {
                if(500 * i + 100 * j + k * 50 == x) ans++;
            }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256