akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    set<int> dic;
    bool check = true;

    for(int i=0; i<N; i++){
        cin>>a[i];
        dic.insert(a[i]);
    }

    /*
    多くても三種類しかないことを考える
    */

    int s = (int)dic.size();

    if(s > 3) check = false;

    else{

        /*種類が一つだけの時、すべてゼロじゃないとだめ*/
        if(s == 1){
            for(int i=0; i<N; i++){
                if(a[i] != 0) check = false;
            }
        }

        /*種類が二種類の時、N/3枚が0、2N/3枚が同じ数
        種類が三種類の時、三つの種類がそれぞれN/3枚必要
        */

        if(s == 2 || s == 3){
            map<int,int> mp;

            if(N%3 != 0) check = false;
            
            for(int i=0; i<N; i++){
                mp[a[i]]++;
            }

            if(s == 2){
                for(auto a : mp){ 
                    if(a.first == 0){
                        if(a.second != N/3) check = false;
                    }

                    else{
                        if(a.second != 2*N/3) check = false;
                    }
                }
                
            }

            if(s == 3){
                vector<int> tmp;

                for(auto a : mp){
                    if(a.first == 0) check = false;
                    if(a.second != N/3) check = false;
                    tmp.push_back(a.first);
                }

                int sum = 0;

                for(int i=0; i<3; i++){
                    sum ^= tmp[i];
                }

                if(sum != 0) check = false;
            }
        }
    }

    cout<<(check ? "Yes" : "No")<<endl;

    return 0;
}

Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;

D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
P circum_center(const P &a, const P &b, const P &c){
    P bc = c - b, ca = a - c, ab = b - a;
    return (a + b - (inprd(bc, ca) / outprd(ab, bc)) * ab * P(0,1)) / 2.0;
}
D sign(D d){ return (d<0)?-1:d>0?1:0; }

int main(void){
    CIN_NO_SYNC;
    int r, d; char c;
    P deg(0,1);
    P pts(0,0);
    while(cin >> r >> c >> d){
        pts += deg * P(r, 0);
        deg *= polar(1.0, M_PI*-d/180);
    }
    printf("%d\n%d\n", (int)pts.X, (int)pts.Y);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n+1);
    vector<long long> num(n,0);
    for(int i=0;i<n;i++) {
        cin >> a[i].first;
        a[i].second=i;
    }
    a[n]={0,-1};
    sort(a.begin(),a.end(),[](auto &l,auto &r){
        if(l.first != r.first) return l.first>r.first;
        else return l.second>r.second;
    });
    priority_queue<int,vector<int>,greater<int>> que;
    for(int i=0;i<n+1;i++){
        if(i>0 && a[i].first<a[i-1].first){
            num[que.top()] += (a[i-1].first-a[i].first) * que.size();
        }
        que.push(a[i].second);
    }
    for(int i=0;i<n;i++) cout << num[i] << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  IN(S);
  
  if(S=="hi"){
    OUT("Yes");
  }else if(S=="hihi"){
    OUT("Yes");
  }else if(S=="hihihi"){
    OUT("Yes");
  }else if(S=="hihihihi"){
    OUT("Yes");
  }else if(S=="hihihihihi"){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,n;
  int x[10001],y[10001];
   
  cin>>w>>h>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  int ans=0;
  int nowx=x[0],nowy=y[0];
  int i=1;
  while(i<n){
    while(nowx<x[i] && nowy<y[i]){
      nowx++;nowy++;
      ans++;
    }
    while(nowx>x[i] && nowy>y[i]){
      nowx--;nowy--;
      ans++;
    }
     
    ans+=abs(nowx-x[i])+abs(nowy-y[i]);
    nowx=x[i];
    nowy=y[i];
    i++;
  }
  cout<<ans<<endl;
  return 0;
}
       

Measured memory_bytes: 1176
N=parse(Int,readline())
H=map(x->parse(Int,x),split(readline()))
ans=0
p=N
for i=N:-1:1
	if i<N&&H[i]<H[i+1]
		ans=max(ans,p-i-1)
		p=i
	end
end
println(max(ans,p-1))


Measured memory_bytes: 169200
s = gets.chomp
pr = 2019

ans = 0

map = Hash.new(0)
map[0] = 1
s.reverse!
ketam = 1
prevm = 0
s.size.times{|i|
  t = (ketam * s[i].to_i + prevm) % pr
  ans += map[t]
  map[t] += 1
  ketam = ketam*10%pr
  prevm = t
}

p ans


Measured memory_bytes: 14776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.Int();
            int K = in.Int();
            long[] a = in.Long(N);

            long ans = 1L << 60;
            int m = 1 << N;
            for (int p = 0; p < m; p++) {
                long temp = 0;
                long max = 0;
                int cnt = 0;
                for (int i = 0; i < N; i++) {
                    long len = a[i];
                    if (((p >> i) & 1) == 1) {
                        if (len < max + 1) {
                            temp += max + 1 - len;
                            len = max + 1;
                        }
                    }
                    if (max < len) {
                        max = len;
                        cnt++;
                    }
                }
                if (cnt >= K) {
                    ans = Math.min(ans, temp);
                }
            }
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public long Long() {
            return Long.parseLong(next());
        }

        public long[] Long(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long();
            }
            return a;
        }

    }
}



Measured memory_bytes: 21588
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

grid = [[-1]*W for _ in range(H)]
order = [-1]*(H*W)
k = 0
for i in range(H):
    if i%2 == 0:
        l = range(W)
    else:
        l = range(W-1,-1,-1)
    for j in l:
        order[k] = (i,j)
        k += 1

acc = 0
for k in range(N):
    for i,j in order[acc:acc+A[k]]:
        grid[i][j] = k+1
    acc += A[k]

for line in grid:
    print(" ".join([str(s) for s in line]))

Measured memory_bytes: 4212
#include<iostream>
using namespace std;
int P[101][101];
char map[101][101];
int h, w;
int main(){
  cin>>h>>w;
  for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++){
      P[i][j]=-1;
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin>>map[i][j];
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(map[i][j]=='c')
	P[i][j]=0;
      else if(P[i][j-1]!=-1)
	P[i][j]=P[i][j-1]+1;
      if(j!=w)
	cout<<P[i][j]<<' ';
      else
	cout<<P[i][j];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<ctype.h>
int main() {
	int i, n, k;
	char s[51];
	scanf("%d %d", &n, &k);
	scanf("%s",s);
	s[k-1]=tolower(s[k-1]);
	printf("%s\n", s);
	return 0;
		
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LOCAL 0
#define lli long long int
const lli mod=1e9+7;
const lli pINF=LLONG_MAX;
const lli nINF=-LLONG_MAX;
void fast() {std::ios::sync_with_stdio(false);cin.tie(NULL);}
lli power(lli a,lli b){lli ans=1;while(b!=0){ if(b%2==1){ans*=a;}b/=2;a*=a;} return ans;}
lli invmod(lli a) {return pow(a,mod-2);}
#define vi vector<int>
#define vlli vector<lli>
#define pb push_back
#define mp make_pair
#define F first
#define S second
const int INT=1000000000;
const int INF=0x3f3f3f3f;
#define Pa pair<int,int>
#define si(n) scanf("%d",&n)
#define sli(n) scanf("%lld",&n)
#define printi(n) printf("%d\n",n)
#define ld long double
#define printli(n) printf("%lld\n",n)
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i=0;i<n;i++)
void print(int a[],int n){for(int i=0;i<n;i++) cout<<a[i]<<" ";}
int e[300005],w[300005];

int main() 
{
    int n;
    si(n);
    
    string s;
    cin>>s;
    
    for(int i=0;i<n;i++){
        if(s[i]=='E'){
            if(i==0) e[i]++;
            else {e[i]=e[i-1]+1;w[i]=w[i-1];}
        }
        else{
            if(i==0) w[i]++;
            else {w[i]=w[i-1]+1;e[i]=e[i-1];}
        }
    }
    
    int fans=INT_MAX;
    int ans;
    for(int i=0;i<n;i++){
        if(i==0) ans=e[n-1]-e[i];
        else if(i==n-1) ans=w[i-1];
        else ans=w[i-1]+e[n-1]-e[i];
        //cout<<ans<<endl;
        fans=min(fans,ans);
    }
    
    cout<<fans<<endl;
	return 0;
}

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

int main(){
  int r,c,a[101][101]={};

  cin>>r>>c;
  for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
      cin>>a[i][j];
      a[i][c]+=a[i][j];
      a[r][j]+=a[i][j];
      a[r][c]+=a[i][j];
    }
  }
  for(int i=0;i<r+1;i++){
    for(int j=0;j<c+1;j++){
      if(j==c) cout<<a[i][j];
      else cout<<a[i][j]<<" ";
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3088
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    

 

int32_t main() {
    IOS;
	int n,W,val,wt;
	vector<int> v,w;
	cin>>n>>W;
	int i;
	for(i=0;i<n;i++)
	{
		cin>>wt>>val;
		v.push_back(val);
		w.push_back(wt);
	}
   int j,V=0;
  int res=-1;
  for(i=0;i<n;i++)
    V+=v[i];
  
  int dp[n+1][V+1];
  
  for(i=0;i<=n;i++)
  {
    for(j=0;j<=V;j++)
    {
     if(j==0)
        dp[i][j]=0;
     else if(i==0)
       dp[i][j]=INT_MAX;
     else if(v[i-1]<=j)
        dp[i][j]=min(w[i-1]+dp[i-1][j-v[i-1]],dp[i-1][j]);
     else
        dp[i][j]=dp[i-1][j];
    }
  }
  for(i=0;i<=V;i++)
  {
    if(dp[n][i]<=W)
      res=max(res,i);
      
  }
  cout<<res<<endl;
	return 0;
}






Measured memory_bytes: 79232
N, M, X, Y = map(int,input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]


ans = "War"
for i in range(X + 1, Y + 1):
  if max(x) < i <= min(y):
    ans = "No War"
    break
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int X = int.Parse(str.Split(' ')[0]);

            int A = int.Parse(str.Split(' ')[1]);

            if (X < A)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(10);
            }     
        }
    }
}


Measured memory_bytes: 27560
#include<iostream>
#include<algorithm>
#include<string>
//#include<Hatsune_Miku>
using namespace std;
int n;
int main()
{
	std::ios::sync_with_stdio(false);
cin>>n;
if(n%10==n/100)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main()

{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    
    int n,x,i;
    cin>>n>>x;
    int d[n+1],l[n];
    for(i=0;i<n;i++){
    	cin>>l[i];
    }
    d[0]=0;
    int cnt=1;
    for(i=1;i<=n;i++){
    	d[i]=d[i-1]+l[i-1];
    	if(d[i]<=x)cnt++;

    }
    cout<<cnt;
   
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
   
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N = int.Parse(str[0]);
            int Y = int.Parse(str[1]);


            for(int a = 0; a <= N; a++)
            {
                int s = Y - a * 10000;
                if (s < 0) continue;
                for(int b = 0; b <= N - a; b++)
                {
                    int t = s - 5000 * b;
                    int c = N - a - b;
                    if (t < 0 || t % 1000 != 0 || t / 1000 != c) continue;                   
                    else
                    {                       
                        Console.WriteLine($"{a} {b} {c}");
                        return;
                    }                               
                    
                }


            }

            Console.WriteLine("-1 -1 -1");

        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

bool ch (int ar[], int br[], int n) {
	for (int i = 0; i < n; i++) {
		if (ar[i] != br[i]) {
			return 0;
		}
	}
	return 1;
}
	
int main () {
	int n;
	cin >> n;
	int a[n], b[n];	
	for (int i = 0; i < n; i++) {	
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {	
		cin >> b[i];
	}
	int aa[n];
	iota (aa, aa + n, 1);
	int i1 = 0, i2 = 0, ii = 0;
	do {
		if (ch (a, aa, n)) {
			i1 = ii;
		}
		if (ch (b, aa, n)) {
			i2 = ii;
		}
		ii++;
	} while (next_permutation (aa, aa + n));
	cout << abs (i1 - i2) << "\n";
}
		
	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
#define rrep(i,n) for(int i = n-1; i >= 0 ; i--)
typedef long long ll;
constexpr auto INFI = 2147483647;
const ll INFL = 9223372036854775807;

int main(){
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
  return 0;
}

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

long long DP[3001][3001][2]; // (pocz, kon), czyja tura


int main(){
    ios_base::sync_with_stdio(0);
    int N;
    cin >> N;
    vector <long long> V;
    for (int i = 0; i < N; i++){
        long long x;
        cin >> x;
        V.push_back(x);
    }   

    for (int pocz = 0; pocz < N; pocz++){
        DP[pocz][pocz][0] = -V[pocz];
        DP[pocz][pocz][1] = V[pocz];
    }

    for (int dlug = 2; dlug <= N; dlug++){
        for (int pocz = 0; pocz <= N - dlug; pocz++){
            int kon = pocz + dlug - 1;
            DP[pocz][kon][0] = min(DP[pocz][kon-1][1] - V[kon], DP[pocz+1][kon][1] - V[pocz]);
            DP[pocz][kon][1] = max(DP[pocz][kon-1][0] + V[kon], DP[pocz+1][kon][0] + V[pocz]);     
        }
    }
    cout << DP[0][N-1][1];




     
}

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

int main(){
  string S, T;
  cin >> S >> T;
  T.pop_back();
  if(T == S) cout << "Yes" << endl;
  else cout << "No" << endl;
    

}


Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>

int main()
{
	int	n;
	char	w[100][11];
	int	i, j;

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

	for (i = 0; i < n-1; ++i) {
		if (w[i][strlen(w[i])-1] != w[i+1][0]) {
			printf("No\n");
				return 0;
		}
	}
	for (i = 0; i < n-1; ++i) {
		for (j = i+1; j < n; ++j) {
			if (strcmp(w[i], w[j]) == 0) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}


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


int partition(int A[], int p, int r)
{
  int x = A[r];
  int i = p-1; // -1 ?

  for(int j = p; j < r; j++)
  {
    if(A[j] <= x)
    {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i+1;
}


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

  int A[100000];
  for(int i = 0; i < n; i++) cin >> A[i];

  int q = partition(A, 0, n-1);

  for(int i = 0; i < n; i++)
  {
      if(i) cout << " ";
      if(i == q) cout << "[" << A[i] << "]";
      else cout << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3388
h,w=map(int,input().split())

def sds(h,w):
    sdmin=h*w
    for hi in range(1,h):
        s1=hi*w
        s2=(h-hi)*(w//2)
        s3=(h-hi)*(w-w//2)
        sd=max(s1,s2,s3)-min(s1,s2,s3)
        sdmin=min(sdmin,sd)
    
        h2=(h-hi)//2
        s2=h2*w
        s3=(h-hi-h2)*w
        sd=max(s1,s2,s3)-min(s1,s2,s3)
        sdmin=min(sdmin,sd)

    return sdmin

print(min(sds(h,w),sds(w,h)))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
int main(){
    int a[10010] , b[10010] ;
    int n ;
    cin >> n ;
    for( int i = 1 ; i <= n ; i++ )
        scanf( "%d" , &a[i] ) ;
    for( int i = 1 ; i <= n ; i++ )
        scanf( "%d" , &b[i] ) ;
    long long suma , sumb ;
    suma = sumb = 0 ;
    for( int i = 1 ; i <= n ; i++ ){
        if ( b[i] > a[i] ) suma += ( b[i] - a[i] ) / 2 ;
        if ( a[i] > b[i] ) sumb += a[i] - b[i] ;
    }
    if ( sumb <= suma ) cout << "Yes" << endl ;
    else cout << "No" << endl ;
    return 0 ;
}

Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n,m;
int ws(int x)
{
	return (x/100>=1)+(x/10>=1)+1;
}
void wqpfs()
{
	int lj=((n*(pow(10,(ws(m)))))+m);
	bool flag=0;
	for(register int i=4;i<=317;i++)
	{
		if((pow(i,2))>=lj)
		{
			if(!(lj-(pow(i,2))))
			{
				flag=1;
			}
			break;
		}
	}
	printf(((!(flag-1))?("Yes"):("No")));
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	wqpfs();
	putchar(10);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
	int d;
	int i;
	double S;
	
	while(scanf("%d",&d) != EOF){
		S = 0;
		for(i = 0;i*d < 600;i++)S += i*d*i*d*d;
		printf("%.0lf\n",S);
	}
	
	return 0;
}

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

#define int long long

signed main() {
	ios::sync_with_stdio(false);

	struct list {
		int num;
		int pos;

		bool operator<(const list& another) const {
			return pos < another.pos;
		}
	};

	int n;
	cin >> n;

	vector<list> a(n);

	for (int i = 0; i < a.size(); i++) {
		a[i].num = i + 1;
	}

	for (int i = 0; i < a.size(); i++) {
		cin >> a[i].pos;
	}

	sort(a.begin(), a.end());

	for (int i = 0; i < a.size(); i++) {
		cout << a[i].num << " ";
	}

	return 0;
}

Measured memory_bytes: 2432
def f(num):
  if num % 2 == 0:
    return int(num / 2)
  else:
    return num * 3 + 1

s = int(input())
a = [s]
ans = 0
for i in range(1, 1000000):
  ai = f(a[i - 1])
  if a.count(ai) == 1:
    ans = i + 1
    break
  a.append(ai)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
	int main(){
	int sum1=0,sum2=0;int a;
	for(int i=0;i<4;i++){
	cin>>a;
	sum1+=a;
}
for(int i=0;i<4;i++){
	cin>>a;
	sum2+=a;
}
	if(sum1>sum2)cout<<sum1<<endl;
	else if(sum1<sum2)cout<<sum2<<endl;
	else cout<<sum1<<endl;

return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<ctime>
#include<map>
#include<vector>
#include<list>
using namespace std;

#define ll long long
#define uint unsigned int
#define alloc(n,type) (type*)calloc(n,sizeof(type))
#define MODULE 1
#define RAND(min,max) (rand()%(max-min+1)+min)
#define repeat(i,condition) for(int i = 0; condition; i++)
#define LOG(log) cout<<#log<<" : "<<log<<'\n'
#define DEBUG() {cout<<"DEBUG "<<num_debug<<'\n'; num_debug++;}
int num_debug = 0;
bool* IsPrime;
vector<int> Prime;

int compare_int(const void* a, const void* b);
class Math {
public:
	template<typename T> static T Fac(int n) {
		T ans = 1;
		for (int i = 2; i <= n; i++) {
			ans *= i;
		}
		return ans;
	}
public :
	template<typename T> static T P(int n, int r) {
		T ans = 1;
		for (int i = 0; i < r; i++) {
			ans *= n - i;
		}
		return ans;
	}
public:
	template<typename T>static T C(int n, int r) {
		T nmr = 1;
		T dnm = 1;
		if (n - r < r)
			r = n - r;
		for (int i = 0; i < r; i++) {
			nmr *= n - i;
			dnm *= r - i;
		}
		return nmr / dnm;
	}
};
class Module_int {
public:
	static const int mod = MODULE;

public:
	static int add(int a, int b) {
		int ans = a + b;
		if (ans < 0)
			ans += mod;
		ans %= mod;
		return ans;
	}
public:
	static int mult(int a, int b) {
		return (a * b) % mod;
	}

public:
	static int Pow(int a, int b) {
		int base = a % mod;
		if (mod / 2 < abs(base))
			if (base < 0) {
				base += mod;  //negative
			}
			else {
				base -= mod;  //positive
			}

		return pow(base, b);
	}
};


int main(void) {
	srand((unsigned)time(NULL));

	int N;
	int* A;

	cin >> N;
	A = alloc(N, int);
	repeat(i, i < N) {
		//DEBUG()
		scanf("%d", &A[i]);
	}
	//DEBUG();

	qsort(A, N, sizeof(int), compare_int);
	int p;
	unsigned ll comform;
	int flag = 2;
	comform = A[0];
	p = A[1];
	int count = 1;
	//DEBUG();
	for (int i = 2; i < N; i++) {
		flag--;
		comform += p;
		if (flag == 0) {
			flag = 2;
			count++;
			p = A[count];
		}
	}

	//DEBUG();
	cout << comform;

	free(A);
	return 0;
}


int compare_int(const void* a, const void* b) {
	return -*(int*)a + *(int*)b;
}
void PrimeEnable(int n) {
	//initialize IsPrime
	IsPrime = (bool*)calloc(n + 1, sizeof(bool));
	for (int i = 0; i <= n; i++)
		IsPrime[i] = true;

	//IsPrime 
	IsPrime[0] = IsPrime[1] = false;
	for (int i = 2; i * i <= n; i++) {
		if (IsPrime[i])
			for (int j = i; i * j <= n; j++) {
				IsPrime[i * j] = false;
			}
	}

	//push back to Prime
	for (int i = 0; i <= n; i++) {
		if (IsPrime[i])
			Prime.push_back(i);
	}
}


Measured memory_bytes: 4992
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 998244353;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 305
// vector < vector < int >  > v(MAXN);
// vector < vector < int >  > vnew(MAXN);
// int visit[MAXN];

int mat[MAXN][MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
long long int preval[16];
void pre(){
  preval[0] = 1;
  preval[1] = 10;
  for(int i = 2;i<=15;i++){
    long long int val = (long long int)pow(10,i-1) - 1 + preval[i-1] + 10;
    preval[i] = val;
  }

  // for(int i = 0;i<=14;i++) cout<<preval[i]<<' ';
}

void solve(){
  int n,W;
  cin>>n>>W;

  long long int v[n];
  long long int w[n];

  for(int i = 0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  long long int dp[W+1];
  long long int taken[W+1][n];
  memset(taken,0,sizeof(taken));
  memset(dp,0,sizeof(dp));

  for(int i = 1;i<=W;i++){
    int index = -1;
    for(int j = 0;j<n;j++){
      if(i - w[j] < 0) continue;
      else{
        // cout<<"I "<<i<<' '<<j<<' '<<taken[i-w[j]][j]<<endl;
        if((dp[i] < dp[i-w[j]] + v[j]) && (taken[i-w[j]][j] == 0)){
          index = j;
          dp[i] = dp[i-w[j]] + v[j];
        }
      }
    }
    if(index != -1){
      for(int j = 0;j<n;j++){
        taken[i][j] = taken[i-w[index]][j];
      }
      taken[i][index] = 1;
    }
    // cout<<i<<' '<<index<<endl;
  }

  long long int ans = 0;
  // for(int i = 1;i<=W;i++){
  //   for(int j = 0;j<n;j++){
  //     cout<<taken[i][j]<<' ';
  //   }
  //   cout<<endl;
  // }

  for(int i = 1;i<=W;i++){
    // cout<<dp[i]<<' ';
    ans = max(ans,dp[i]);
  }
    // cout<<endl;

  cout<<ans;

}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 82948
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X){
    if (500 * K >= X) print(YES);
    else print(NO);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 256
implicit none
integer :: i,n,ans
character(100000) :: s
character(1) :: t

read *,s
n = len_trim(s)

t = s(1:1)
ans = 0
do i = 2, n
   if (s(i:i) /= t) then
      ans = ans + 1
      t = s(i:i)
   endif
enddo

print '(i0)',ans
end

Measured memory_bytes: 700
n = int(input())
# a,b = map(int,input().split())
# A = list(map(int,input().split()))
# An = [list(map(int,input().split())) for i in range(n)]
a = n//500
b = (n-a*500)//5
ans = int(a*1000 + b*5)
print(ans)

Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum1=0
sum2=0
for num in range(N):
  if num % 2 == 0:
    sum1 += A[num]
  else:
    sum2 += A[num]
print(sum1 - sum2)

Measured memory_bytes: 9180
n, k = map(int, input().split())
okasi = [0]*(n+1)
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        okasi[a[i]] += 1

count = 0
for i in range(1, n+1):
    if okasi[i] == 0:
        count += 1

print(count)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    int fd = 0;
    bool ans = true;
    for(char c = 'a'; c <= 'z'; c++){
        fd = 0;
        REP(j, s.size()) if(c == s[j]) fd++;
        if(fd >= 2) ans = false;
    }
    cout << (ans ? "yes" : "no") << endl;
}

Measured memory_bytes: 256
import  numpy as np
N, W, *L = map(int, open(0).read().split())
M = 3*(N-1)+1
dp = np.zeros((M,N+1),np.int64)
for w,v in zip(*[iter(L)]*2):
  w -= L[0]
  dp[w:,1:] = np.maximum(dp[w:,1:], dp[:M-w,:N]+v)

ans = 0
for i in range(N+1):
  m = i*L[0]
  if m>W:
    continue
  m = min(W-m,M-1)
  ans = max(ans, dp[m,i])
print(ans)

Measured memory_bytes: 15276
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
struct UnionFind{
    vector<int>par,sz;
    UnionFind(int n): par(n),sz(n,1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int i){
        if(i == par[i])return i;
        else return par[i] = find(par[i]);
    }
    void unite(int i,int j){
        i = find(i);
        j = find(j);
        if(i==j)return;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        par[j] = i;
    }
    int size(int i){
        return sz[find(i)];
    }
};
int main(){
    int n, k;
    cin >> n >> k;
    int a[3];
    rep(i,3)cin >> a[i];
    UnionFind uf(n);
    string t;
    cin >> t;
    rep(i,n){
        if(i - k >= 0 and t[i]==t[i-k]){
            uf.unite(i, i-k);
        }
    }
    int ans = 0;
    rep(i,n){
        if(uf.find(i)==i){
            if(t[i]=='p')t[i]++;
            ans += (uf.size(i)+1)/2*a[(t[i]+2)%3];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
a, b, c, d = map(int, input().split())
i, j = c, d
def gcd(i, j):
    return i if j == 0 else gcd(j, i%j)
lcm = int(c//gcd(c, d)*d)

def cont(x):
    cnt1 = x//c 
    cnt2 = x//d
    ans = x - cnt1 - cnt2 + x//lcm
    return int(ans)

print(cont(b) - cont(a-1))

Measured memory_bytes: 3060
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//出力
	console.log('%s%s',tmp[1],tmp[0]);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABCtest
{
    delegate void Signal();
    class Program
    {
        static void Main(string[] args)
        {
            int A, B ,Ans;         
            string[] value = Console.ReadLine().Split(' ');

            if (value.Length == 1) return;
            
            if (!int.TryParse(value[0], out A) || !int.TryParse(value[1], out B)) return;
            if (A < 1 || (B > 9)) return;

            Ans = A + B;
            if(Ans >= 10) Console.WriteLine("error");
            else  Console.WriteLine(Ans);

            Console.ReadLine();


        }
    }
}


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

int main(){
	int k,n=0;
	string S;
	cin >> S;
	k=(int)S.size();
	int roop;
	for(roop=0;roop<k;roop++){
		if(S[roop]=='o')
			n+=1;
	}
	if((15-k+n)>7){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}

int main(){

    int n,W;
    cin >> n >> W;
    int v[n],w[n];

    REP(i,n){
        cin >> w[i] >> v[i];
    }

    vector<vector<ll>> dp(n+1,vector<ll>(W+1,0));

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

    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 83212
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto S = cast(char[])readln.chomp;
  auto N = readln.chomp.to!long;

  void solve() {
    bool inverted = false;
    char[200000] head;
    char[200000] tail;
    long num_head;
    long num_tail;

    foreach(_; 0..N) {
      auto query = readln.split;
      if (query[0] == "2") {
        if ((inverted && query[1] == "2") || !inverted && query[1] == "1") {
          tail[num_tail] = query[2][0];
          num_tail++;
        }
        if ((inverted && query[1] == "1") || !inverted && query[1] == "2") {
          head[num_head] = query[2][0];
          num_head++;
        }
        continue;
      }
      inverted ^= true;
    }
    if (inverted) {
      auto reversed_head = head[0..num_head];
      reversed_head.reverse();
      S.reverse();
      writeln( reversed_head ~ S ~ tail[0..num_tail]);
    } else {
      auto reversed_tail = tail[0..num_tail];
      reversed_tail.reverse();
      writeln(reversed_tail ~ S ~ head[0..num_head]);
    }
  }

  solve();
}


Measured memory_bytes: 2456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with-stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum<<"\n";
}



Measured memory_bytes: 3584
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Measured memory_bytes: 3188
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    int K=38;
    int N=K*(K-1)+1;
    cout << N << ' ' << K << '\n';//N=K(K-1)+1&&K-1=pで成立してくれる
    vvl x(K,vl(K-1));
    rep(i,K){
        rep(j,K-1){
            x[i][j]=(K-1)*i+j+2;
        }
    }
    rep(i,K){
        cout << 1 << ' ';
        rep(j,K-1){
            cout << x[i][j] << ( j==K-2 ? '\n' : ' ');
        }
    }
    rep(i,N-K){
        cout << i/(K-1)+2 << ' ';
        rep(j,K-1){
            cout << x[j+1][((i/(K-1)*j)%(K-1)+(i%(K-1)))%(K-1)] << ( j==K-2 ? '\n' : ' ');
        }
    }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int n;
  cin>>n;
  
  if(n>=400&&n<=599)
    cout<<8<<endl;
  else if(n>=600&&n<=799)
    cout<<7<<endl;
  else if(n>=800&&n<=999)
    cout<<6<<endl;
  else if(n>=1000&&n<=1199)
    cout<<5<<endl;
  else if(n>=1200&&n<=1399)
    cout<<4<<endl;
  else if(n>=1400&&n<=1599)
    cout<<3<<endl;
  else if(n>=1600&&n<=1799)
    cout<<2<<endl;
  else if(n>=1800&&n<=1999)
    cout<<1<<endl;
  }

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,m;
    cin>>n>>m;
    if(m%2)
    {
        repA(i,1,m/2)
        {
            cout<<i<<" "<<m-i+1<<'\n';
        }
        repA(i,1,(m/2)+1)
        {
            cout<<m+i<<" "<<2*m+2-i<<'\n';
        }
    }
    else
    {
        repA(i,1,m/2)
        {
            cout<<i<<" "<<m-i+1<<'\n';
        }
        repA(i,1,m/2)
        {
            cout<<m+i<<" "<<2*m+2-i<<'\n';
        }
    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3624
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
//#define int long long
const int N = 1e6 + 10;
const int INF = 1e9 + 10;

int main() {
  vector<int> v, vv;
  for(int i = 1; i * (i + 1) * (i + 2) / 6 < N; ++i) v.push_back(i * (i + 1) * (i + 2) / 6);
  REP(i, v.size()) if(v[i] % 2) vv.push_back(v[i]);
  vector<int> dp(N, INF), dp_odd(N, INF);
  dp[0] = dp_odd[0] = 0;
  REP(i, v.size()) for(int j = v[i]; j < N; ++j) dp[j] = min(dp[j], dp[j - v[i]] + 1);
  REP(i, vv.size()) for(int j = vv[i]; j < N; ++j) dp_odd[j] = min(dp_odd[j], dp_odd[j - vv[i]] + 1);
  int n;
  while(cin >>n && n) cout <<dp[n] <<" " <<dp_odd[n] <<endl;
  return 0;
}

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

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

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

    string s;
    cin >> s;
    if (s.back () == 's')
        s += "es";
    else
        s += "s";
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
using ll = long long;

// p < r < A.size()
// after this operation: p,...,q-1, q, q+1, ..., r
// A[p],...,A[q-1] <= A[q]
// A[q] < A[q+1], ..., A[r]
// returns q
ll Partition(vector<ll> &A, ll p, ll r) {
	ll x = A[r];// pivot 
	ll i = p-1;
	for (ll j=p; j<r; ++j) {
		if (A[j] <= x) {
			i++;
			ll t = A[j];
			A[j] = A[i];
			A[i] = t;
		}
	}
	A[r] = A[i+1];
	A[i+1] = x; 
	return i+1;
}

int main() {
	ll n;
	cin >> n;
	vector<ll> A(n,0);
	for(ll i=0;i<n;++i) scanf("%lld", &A[i]);

	ll q = Partition(A, 0, A.size()-1);
	for(ll i=0;i<n;++i) {
	 if(i != 0) cout << " ";
	 if(i == q) {
		 cout << "[" << A[i] << "]";
		 continue;
	 } 
	 cout  << A[i];
	}
	cout << endl;
	return 0;
}




Measured memory_bytes: 3504
def c_SpecialTrains(N, STATION):
    ans = []
    for i in range(N):
        t = 0  # 駅iからNまでにかかる時間
        for j in range(i, N - 1):
            c, s, f = STATION[j]
            if t < s:
                t = s  # まだ運行していないので、運行するまで待つ必要がある
            elif t % f == 0:
                # tがfで割り切れるなら、すぐに鉄道に乗ればよい
                # sはfで割り切れることが保証されているので、この条件式でよい
                pass
            else:
                t += f - (t % f)  # この分だけ駅で待つ必要がある
            t += c  # 次の駅までかかる時間
        ans.append(t)
    return '\n'.join(map(str, ans))
 
N = int(input())
STATION = [[int(i) for i in input().split()] for j in range(N-1)]
print(c_SpecialTrains(N, STATION))

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        var n = int.Parse(Console.ReadLine());

        string[] tmp = new string[n];
        for (int i = 0; i < n; i++)
        {
            tmp[i] = Console.ReadLine();
        }

        long ans = 0;
        Dictionary<string, long> strHash = new Dictionary<string, long>();
        for (int i = 0; i < n; i++)
        {
            string s = tmp[i];
            tmp[i] = "";
            char[] sort = new char[10];
            for (int j = 0; j < 10; j++)
            {
                sort[j] = s[j];
            }
            Array.Sort(sort);
            tmp[i] = new string(sort);

            if (!strHash.ContainsKey(tmp[i]))
            {
                strHash.Add(tmp[i], 0);
            }
            else
            {
                strHash[tmp[i]]++;
            }

            ans += strHash[tmp[i]];
        }

        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 36564