akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var s = LnStr();
        var t = LnStr();

        var dp = new int[s.Length + 1][]; for (int i = 0; i < dp.Length; i++) { dp[i] = new int[t.Length + 1]; }

        dp[0][0] = 0;//自明だけども

        for (int i = 0; i < s.Length; i++)
        {
            for (int n = 0; n < t.Length; n++)
            {
                if (s[i] == t[n]) { dp[i + 1][n + 1] = Max(dp[i + 1][n + 1], dp[i][n] + 1); }
                dp[i + 1][n + 1] = Max(dp[i + 1][n + 1], dp[i][n + 1]);
                dp[i + 1][n + 1] = Max(dp[i + 1][n + 1], dp[i + 1][n]);
            }
        }
        var result = "";
        int i_ = s.Length;
        int t_ = t.Length;
        while (i_ > 0 && t_ > 0)
        {
            if (dp[i_][t_] == dp[i_ - 1][t_])//dp[i-1]からdp[i]が変わってない。つまり、ここじゃない
            {
                i_--;
            }
            else if (dp[i_][t_] == dp[i_][t_ - 1])//dpのt-1から変更がない、つまりここじゃない
            {
                t_--;
            }
            else//dp[i-1][t-1]からdp[i][t]が変わってない場合は上の場合わけで弾かれてる。つまり変わっている場合、ここや
            {
                i_--; t_--;
                result += s[i_];
            }
        }
        var rev = result.Reverse();
        result = "";
        foreach (var str in rev)
        {
            result += str;
        }
        Console.WriteLine(result);
    }
   


public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
}



Measured memory_bytes: 54988
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, K = [int(sys.stdin.readline()) for _ in range(2)]
X = np.array(list(map(int, sys.stdin.readline().split())))

print(np.minimum(X, abs(X - K)).sum() * 2)


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e13;
int main() {
    ll n, i, j;
    cin >> n;
    ll p[4];
    ll t[4];
    ll dp[5][450];
    for(i = 0; i < 4; i++) {
        for(j = 0; j <= 449; j++) {
            dp[i][j] = INF;
        }
    }
    for(i = 0; i < 4; i++) {
        cin >> p[i];
    }
    for(i = 0; i < 4; i++) {
        cin >> t[i];
    }
    dp[0][0] = 0;
    for(i = 0; i < 4; i++) {
        for(j = 0; j < 450; j++) {
            if(j - t[i] >= 0)
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - t[i]] + p[i]);
            else
                dp[i + 1][j] = dp[i][j];
        }
    }
    ll ret = 1e13;
    for(i = n; i < 450; i++) {
        ret = min(ret, dp[4][i]);
    }
    cout << ret << endl;
    return 0;
}


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

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

    int A,B,C;
    cin>>A>>B>>C;
    if(max(A,B)-C>=0 && min(A,B)-C<=0){
        cout<<"Yes"<<endl;
    }else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=3;
int a[M];
int main() {
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[2]-a[1]==a[3]-a[2])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let d: usize = iter.next().unwrap().parse().unwrap();
    
    let x: Vec<Vec<i32>> = (0..n).map(|_| read(d, &mut iter)).collect();

    fn read(d: usize, iter: &mut std::str::SplitWhitespace) -> Vec<i32> {
        return (0..d).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    }

    let mut ans = 0 ;

    fn is_square(x: i32) -> bool {
        for i in 0..300 {
            if i * i == x {
                return true;
            }
        }
        return false;
    }

    for i in 0..n{
        for j in 0..i {
            let mut d2 = 0 ;
            for k in 0..d {
                d2 += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            if is_square(d2) {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <climits>

using namespace std;

int N;
string S;
int preW[200005];
int preB[200005];
int ans=INT_MAX;

int main()
{
	cin >> N >> S;
	for (int i=1; i<=N; i++)
	{
		preW[i]=preW[i-1]+(S[i-1]=='.'?1:0);
		preB[i]=preB[i-1]+(S[i-1]=='#'?1:0);
	}
	for (int i=0; i<=N; i++) ans=min(ans,preB[i]+preW[N]-preW[i]);
	cout << ans;
	return 0;
}

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  vP as(n);
  rep(i, n) {
    ll a;
    cin >> a;
    as[i] = P(a, i);
  }
  sort(as.rbegin(), as.rend());

  vvll dp(n + 1, vll(n + 1, 0));
  rep(i, n) {
    ll a, p;
    tie(a, p) = as[i];
    rep(l, i + 1) {
      chmax(dp[i + 1][l + 1], dp[i][l] + a*(p - l));
      chmax(dp[i + 1][l], dp[i][l] + a*(n - 1 - i + l - p));
    }
  }
  ll ans = 0;
  rep(l, n + 1) chmax(ans, dp[n][l]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 34620
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
/* DSU 
int find_set(int v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}
void make_set(int v) {
    parent[v] = v;
    rank[v] = 0;
}
void union_sets(int a, int b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rank[a] < rank[b])
            swap(a, b);
        parent[b] = a;
        if (rank[a] == rank[b])
            rank[a]++;
    }
}
*/ 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
 
using namespace std;

int main()
{
	fast;
	ll n; cin>>n; ll arr[n]; for(ll i = 0; i < n; i++) cin>>arr[i];
	unordered_map<ll,ll>mp; ll others = 0;
	for(ll i = 0; i < n; i++)
	{
		if(arr[i] >= 1 && arr[i] <= 399)
			mp[0]++;
		else if(arr[i] >= 400 && arr[i] <= 799)
			mp[1]++;
		else if(arr[i] >= 800 && arr[i] <= 1199)
			mp[2]++;
		else if(arr[i] >= 1200 && arr[i] <= 1599)
			mp[3]++;
		else if(arr[i] >= 1600 && arr[i] <= 1999)
			mp[4]++;
		else if(arr[i] >= 2000 && arr[i] <= 2399)
			mp[5]++;
		else if(arr[i] >= 2400 && arr[i] <= 2799)
			mp[6]++;
		else if(arr[i] >= 2800 && arr[i] <= 3199)
			mp[7]++;
		else if(arr[i] >= 3200)
		{
			others++;
		}
	}
	if(mp.size() == 0)
	{
		cout << 1 << " " << others << endl;
	}
	else if(others == 0)
	{
		cout << mp.size() << " " << mp.size() << endl;
	}
	else
		cout << mp.size() << " " << others + mp.size() << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n; 
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int ans = 0;
    rep(i,n){
        if(p[i] == i+1){
            ans++;
            if(i == n-1) swap(p[i], p[i-1]);
            else swap(p[i], p[i+1]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define INF 1<<30
#define mp make_pair

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> v[h];
	rep(i, h) {
		rep(j, w) {
			string s;
			cin >> s;

			v[i].push_back(s);
		}
	}

	rep(i, h) {
		rep(j, w) {
			if(v[i][j] == "snuke") {
				cout << char('A' + j) << i + 1 << endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 764
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int nTests = Integer.parseInt(br.readLine());
    for (int t=0; t<nTests; t++) {
      String[] s = br.readLine().split(" ");
      long a = Long.parseLong(s[0]);
      long b = Long.parseLong(s[1]);
      long c = Long.parseLong(s[2]);
      long d = Long.parseLong(s[3]);
      if (a<b) {
        sb.append("No\n");
      } else {
        if (d<b) {
          sb.append("No\n");
        } else {
          d = d%b;
          if (d==0) {
            if (a%b>c) {
              sb.append("No\n");
            } else {
              sb.append("Yes\n");
            }
          } else {
            if (c+1>b-1) {
              sb.append("Yes\n");
            } else {
              d += b;
              long div = gcd(b,d);
              long badLo = (c+1);
              long badHi = b-1;
              if (badHi-badLo+1>=div) {
                sb.append("No\n");
              } else {
                long mBadLo = badLo%div;
                long mBadHi = badHi%div;
                if (mBadLo>mBadHi) {
                  mBadHi += div;
                }
                long mA = a%div;
                if (mA>=mBadLo && mA<=mBadHi) {
                  sb.append("No\n");
                } else {
                  sb.append("Yes\n");
                }
              }
            }
          }
        }
      }
    }
    System.out.print(sb);
  }
  static long gcd(long a, long b) {
    return (b==0 ? a : gcd(b, a%b));
  }
}


Measured memory_bytes: 21076
def solve():
    N = int(input())
    X = [int(i) for i in input().split()]
    from decimal import Decimal, ROUND_HALF_UP
    target = int(Decimal(sum(X)/float(N)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
    ans = 0
    for x in X:
        ans += (x-target)**2
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

struct Dice {
    ll a[6];
    void swap4(ll i1,ll i2,ll i3,ll i4){
        ll tmp=a[i1];
        a[i1]=a[i2];
        a[i2]=a[i3];
        a[i3]=a[i4];
        a[i4]=tmp;
    }
    void rotateE(){
        swap4(2,0,3,5);
    }
    void rotateN(){
        swap4(4,0,1,5);
    }
    void rotateS(){
        swap4(1,0,4,5);
    }
    void rotateW(){
        swap4(3,0,2,5);
    }
};

void solve(){
    Dice d;
    rep(i,6)cin>>d.a[i];
    ll n;cin>>n;
    rep(i,n){
        ll u,f;cin>>u>>f;
        if(d.a[3]==f)d.rotateE();
        if(d.a[2]==f)d.rotateW();
        while(d.a[1]!=f)d.rotateN();
        while(d.a[0]!=u)d.rotateE();
        cout<<d.a[2]<<endl;
    }
}

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



Measured memory_bytes: 3164
// https://img.atcoder.jp/abc104/editorial.pdf
// https://atcoder.jp/contests/abc104/submissions/2955456

#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    const int64 MOD = 1000000007;
    string s; cin >> s;
    int N = s.size();
    
    vector<vector<int64>> dp(N+1, vector<int64>(4LL));
    
    for(int i=N; i>=0; --i){
        for(int j=3; j>=0; --j){
            if(i==N){
                dp[i][j] = (j<3 ? 0LL:1LL);
            }else{
                dp[i][j] = dp[i+1][j] * (s[i]=='?' ? 3LL:1LL);
                if(j<3 && (s[i]=='?' || s[i]=="ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
    
    return 0;
}

Measured memory_bytes: 7376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll func(ll n){
  if(n==1){
    return 1;
  }else{
    return (n*func(n-1))%1000000007;
  }
}

int main(){
  ll n,m;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0<<endl;
    return 0;
  }else if(n==m){
    cout<<(2*func(n)*func(n))%1000000007<<endl;
  }else{
    cout<<(func(max(n,m))*func(min(n,m)))%1000000007<<endl;
  }

    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,x[100010],tot,md,tmp,idx,cnt,tmpcnt,temp,diff;
bool ok;
int main()
{
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&x[i]);
		tot+=x[i];
	}
	md = (n*(n+1))/2;
	if(tot%md) printf("NO\n");
	else
	{	
		ok = 1;
		cnt = 1;
		tmp = tot/md;
		for(long long i=0;i<n;i++)
		{
			diff = x[(i+1)%n]-x[i]-tmp;
			if(diff>0 ||abs(diff)%n) 
			{
				ok = 0;
				break;
			}
		}
		printf("%s\n",ok?"YES":"NO");	
	}
	return 0;
}

Measured memory_bytes: 1024
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let x = read1::<usize>();

    let t_2 = x / 11;
    let t_rest = x % 11;
    if t_rest == 0 {
        println!("{}", t_2 * 2);
    } else if t_rest <= 6 {
        println!("{}", t_2 * 2 + 1);
    } else {
        println!("{}", t_2 * 2 + 2);
    }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

int N;

int main() {
    cin >> N;
    ll ans = 0;
    REP (i, N) {
        int l, r; cin >> l >> r;
        ans += (r - l + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int H, W;
  cin>>H>>W;
  vector<string> S(H);
  for(int i=0;i<H;++i) cin>>S[i];
  bool can = true;
  for(int i=0;i<H;++i) {
    for(int j=0;j<W;++j) {
      if(S[i][j]=='#') {
        if(!((i>0 && S[i-1][j]=='#') || (j>0 && S[i][j-1]=='#') || (i<H-1 && S[i+1][j]=='#') || (j<W-1 && S[i][j+1]=='#'))) can = false;
      }
    }
  }
  if(can) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
int isStable(char in[36][3] ,char out[36][3]);
int N;
int main(void){
  int i, j,cnt = 0, minj;
  char CardB[36][3],Check[36][3],CardS[36][3],temp[36];
 
  scanf("%d",&N);


   
  for(i = 0;i < N;i++){
    scanf("%s",&CardB[i]);
    strcpy(Check[i],CardB[i]);
    strcpy(CardS[i],CardB[i]);
  }



  for(i = 0; i < N; i++ ) {
    for(j= N-1; j>i; j--) {
      if(CardB[j][1] < CardB[j-1][1]) {
         strcpy(temp,CardB[j]);
         strcpy(CardB[j],CardB[j-1]);
         strcpy(CardB[j-1],temp);
         
      }

    }
  }
  for(i=0;i<N-1;i++) 
    printf("%s ",CardB[i]);
    printf("%s\n",CardB[i]);
 

  if(isStable(Check,CardB)==1) {
  printf("Stable\n");
}
  else {
    printf("Not stable\n");
  }



for(i = 0; i < N; i++ ) {
    minj = i;
    for(j= i; j < N; j++)  {
      if(CardS[j][1] < CardS[minj][1]) {
         minj = j;
      }
    }
      if(CardS[minj][1] < CardS[i][1]) {
         strcpy(temp,CardS[i]);
         strcpy(CardS[i],CardS[minj]);
         strcpy(CardS[minj],temp);
      }
  }
  

for(i=0;i<N-1;i++) 
    printf("%s ",CardS[i]);
    printf("%s\n",CardS[i]);
  


  if(isStable(Check,CardS)==1) {
  printf("Stable\n");
}
  else {
    printf("Not stable\n");
  }
  return 0;
}

 int isStable(char Check[36][3] , char Solve[36][3]) {
    int i,j,k,l;

    for(i=0;i<N;i++){
      for(j=i+1;j<N;j++){
        for(k=0;k<N;k++){
          for(l=k+1;l<N;l++){
              if((Check[i][1]==Check[j][1])&&(strcmp(Check[i],Solve[l])==0)&&(strcmp(Check[j],Solve[k])==0)) {
                return 0;
              }
          }
        }
      }
    }

  return 1;
}


Measured memory_bytes: 2052
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    vector <string> C(H);

    for (int i = 0; i < H; i++){
        cin >> C[i];
    }

    for (int i = 0; i < H; i++){
        for (int j = 0; j < 2; j++){
            cout << C[i] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
//500 円玉を AA 枚、100 円玉を BB 枚、50 円玉を CC 枚持っています。これらの硬貨の中から何枚かを選び、合計金額をちょうど XX 円にする方法は何通りあるでしょうか？

#include <iostream>
using namespace std;

int main(){
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int res = 0;

    for (int a = 0; a <= A; ++a) {
        for (int b = 0; b <= B; ++b) {
            for (int c = 0; c <= C; ++c) {
                int total = 500*a + 100*b + 50*c; // 合計金額
                if (total == X) ++res; // 合計金額が X に一致したら答えをインクリメント
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N%10 == 3){
  cout << "bon"<< endl;
  }
  else if(N%10==0|| N%10==1||N%10==6||N%10==8){
    cout<<"pon"<<endl;
  }
  else{
  cout<<"hon"<<endl;
  }
  return 0; 
}

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

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

  if (b == 'A')
    puts("T");
  if (b == 'T')
    puts("A");
  if (b == 'C')
    puts("G");
  if (b == 'G')
    puts("C");
}

Measured memory_bytes: 256
N = int(input())
if N <= 599:
    print(8)
elif N <= 799:
    print(7)
elif N <= 999:
    print(6)
elif N <= 1199:
    print(5)
elif N <= 1399:
    print(4)
elif N <= 1599:
    print(3)
elif N <= 1799:
    print(2)
elif N <= 1999:
    print(1)
else:
    None

Measured memory_bytes: 9172
n = gets.to_i
a = gets.split.map(&:to_i)
min = 10000000
max = -10000000
sum = 0
n.times do|i|
  x = a[i]
  if x < min
    min = x
  end
  if x > max
    max = x
  end
sum += x
end
printf("%d %d %d\n", min, max, sum)



Measured memory_bytes: 9196
def gcd(a, b):
	if a < b:
		a,b = b,a
	while b:
		a, b = b, a % b
	return a
def lcm(a, b): 
	return (a*b)//gcd(a,b)

a,b,c,d = map(int,input().split())
a3 = b // c - (a-1) // c
b3 = b // d - (a-1) // d
if c < d:
	c,d = d,c
width = b - a + 1
c3 = b//lcm(c,d) - (a-1)//lcm(c,d)
print(int(width - a3 - b3 + c3))


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
for(;;){
int n,m;
string s1[1000],s2[1000];
string ans="";
string s;
cin >> n;
if(n==0)return 0;
for(int i=0;i<n;i++){
cin >> s1[i] >> s2[i];
}
cin >> m;
for(int i=0;i<m;i++){
cin >> s;
bool f=true;
for(int j=0;j<n;j++){
if(s==s1[j]){
ans+=s2[j];
f=false;
}
}
if(f)ans+=s;
}
cout << ans << "\n";
}
return 0;
}

Measured memory_bytes: 1352
n,k = map(int,input().split())
ans = 0
for i in range(k,n+2):
    max_1 = ((n+(n-i+1))*i)//2
    min_1 = ((i-1)*i)//2
    ans +=max_1 - min_1 +1
    ans %=10**9+7
print(ans)

Measured memory_bytes: 9184
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	s1 := scanText()
	s2 := scanText()

	ans := 3
	p := 0

	pre := true
	f := false

	for p<n {
		var now bool
		if s1[p]==s2[p] {
			now = true
			p++
		} else {
			now = false
			p+=2
		}

		if !f {
			f = true
			if !now {
				ans*=2
			}
			pre = now
			continue
		}

		if pre {
			ans = ans*2%mod
		} else {
			if !now {
				ans = ans*3%mod
			}
		}
		pre = now
	}

	fmt.Println(ans)

}

const mod = 1000000007


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a <= c && c <= b){
            System.out.print("Yes");
        }else {
            System.out.print("No");
        }
    }
}

Measured memory_bytes: 21332
/*
गिरते हैं शहसवार ही मैदान-ए-जंग में ।
वो तिफ़्ल क्या गिरे जो घुटनों के बल चले ।।
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)   sort(v.rbegin(),v.rend())
#define R(v)    reverse(v.begin(),v.end())
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define T       int tc;cin>>tc;while(tc--)
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)      for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)      for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define sz(v)       (int)(v.size())
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define N 400005


void Weapons19(){
    int n;cin>>n;
    set<string>s;
    for(int i=0;i<n;i++){
        string p;cin>>p;s.insert(p);
    }
    cout<<sz(s);














}

int32_t main(){

    /*
    त्यक्तवाधर्मं च लोभं च
    मोहंचो द्यमास्थिता।
    युद्ध्यध्वमनहंकारा
    यतो धर्मस्ततो जयः।।
    */

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);



    Weapons19();
    
}


Measured memory_bytes: 19128
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
	ll x,k,d;
	cin >> x >> k >> d;
	ll a = abs(x)/d;
	ll ans;
	if(a == k) ans = abs(x) - d*a;
	else if(a < k){
		k -= a;
		if(k & 1) ans = d*(a+1) - abs(x);
		else ans = abs(x) - d*a;
	}
	else ans = abs(x) - d*k;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> q(102, 0);
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    q[p] = 1;
  }

  for (int i = 0; i < 51; i++) {
    int idx_lo = X - i;
    if (q[idx_lo] == 0) {
      cout << idx_lo << endl;
      break;
    }
    int idx_hi = X + i;
    if (q[idx_hi] == 0) {
      cout << idx_hi << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int H, W;

int Check(const vector<string>& grid) {
  vector<vector<int>> counts(H+1, vector<int>(W+1));
  for (int h = 0; h < H; ++h) {
    int start = -1;
    for (int w = 0, end = grid[0].size(); w < end; ++w) {
      if (grid[h][w] == '#') {
        if (start != -1) {
          for (int i = start; i < w; ++i) {
            counts[h][i] = w - start;
          }
        }
        start = -1;
        continue;
      }
      if (start == -1) start = w;
    }
  }
  int res = 0;
  for (int w = 0; w < W; ++w) {
    int start = -1;
    for (int h = 0, end = grid.size(); h < end; ++h) {
      if (grid[h][w] == '#') {
        if (start != -1) {
          for (int i = start; i < h; ++i) {
            counts[i][w] += h - start - 1;
            res = max(res, counts[i][w]);
          }
        }
        start = -1;
        continue;
      }
      if (start == -1) start = h;
    }
  }
  return res;
}

int main() {
  cin >> H >> W;
  vector<string> grid(H+1);
  for (int h = 0; h < H; ++h) {
    string s;
    cin >> s;
    grid[h] = s + '#';
  }
  grid[H] = string(W+1, '#');
  cout << Check(grid) << endl;
  
  return 0;
}


Measured memory_bytes: 27000
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
  x, y = map(int, input().split())
  a.append(x)
  b.append(y)

dp = list([9e9] * (h + 1) for i in range(n + 1))
dp[0][0] = 0

for i in range(n):
  for j in range(h + 1):
    dp[i + 1][j] = min(dp[i+1][j], dp[i][j])
    dp[i+1][min(j+a[i], h)] = min(dp[i+1][min(j+a[i], h)], dp[i+1][j] + b[i])

print(dp[n][h])



Measured memory_bytes: 286856
#include<bits/stdc++.h>
using namespace std;
const int N=3000010;
int a[N],b[N],pre1[N],tagL[N],tagR[N],mn1[N],pre2[N],mn2[N],n,L;
typedef long long ll;
ll ans;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>L;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i){
		cin>>b[i];ans+=b[i]/(2*L)*2;
		b[i]%=2*L;
		if(!b[i])ans-=2,b[i]=2*L;
		if(b[i]<=2*(L-a[i]))tagR[i]=1;
		if(b[i]<=2*a[i])tagL[i]=1;
		if(!tagL[i]&&!tagR[i])ans++;
	}
	for(int i=1;i<=n;++i){
		pre1[i]=pre1[i-1]+tagL[i]-tagR[i];if(tagL[i]&&tagR[i])pre1[i]++;
		mn1[i]=min(mn1[i-1],pre1[i]);
	}
	mn2[n+1]=1;
	for(int i=n;i;--i){
		pre2[i]=pre2[i+1]+tagL[i]-tagR[i];if(tagL[i]&&tagR[i])pre2[i]--;
		mn2[i]=min(0,pre2[i]-pre2[i+1]+mn2[i+1]);
	}
	int ret=INT_MAX;
	for(int i=0;i<=n;++i){
		int d=1-min(mn1[i],pre1[i]+mn2[i+1]),s=pre1[i]+pre2[i+1]+d;
		ret=min(ret,d+s);
	}
	ans+=ret+n;
	cout<<ans*L<<'\n';
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


string numToChar(int num){
    if(num == 0) return "A";
    else if(num == 1) return "B";
    else return "C";
}

int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];

    vector<char> ans;
    long long S = accumulate(num.begin(), num.end(), (long long) 0);
    if(S == 0){
        cout << "No" << endl;
        return 0;
    }
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0){
            cout << "No" << endl;
            return 0;
        }
        if(S == 1){
            // 0の方に足す
            int small = (num[c1] > num[c2])? c2: c1;
            int large = (num[c1] > num[c2])? c1: c2;
            ans.push_back(char(small+'A'));
            ++num[small];
            --num[large];
        }else{
            if(num[c1] == 0){
                ans.push_back(s[i][0]);
                ++num[c1];
                --num[c2];
                continue;
            }
            if(num[c2] == 0){
                ans.push_back(s[i][1]);
                --num[c1];
                ++num[c2];
                continue;
            }
            if(i+1 < N and num[c1] == 1 and num[c3] == 0 and (s[i+1] == numToChar(c1)+numToChar(c3) or s[i+1] == numToChar(c3)+numToChar(c1))){
                ans.push_back(s[i][0]);
                ++num[c1];
                --num[c2];
                continue;
            }
            if(i+1 < N and num[c2] == 1 and num[c3] == 0 and (s[i+1] == numToChar(c2)+numToChar(c3) or s[i+1] == numToChar(c3)+numToChar(c2))){
                ans.push_back(s[i][1]);
                --num[c1];
                ++num[c2];
                continue;
            }
            ans.push_back(s[i][0]);
            ++num[c1];
            --num[c2];
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

Measured memory_bytes: 5508
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll; 
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
ll checkDivisible (ll n)
{
  ll cnt=0;
  while(n>0)
  {
    cnt++;
    n/=2;
  }
  cnt--;
  return cnt;
}
int main()
{
  ll n,num,max_num,cnt=0,max_cnt=0;
  cin>>n;
  if(n==1)
  {
    cout<<1;
    return 0;
  }
  REP(i,2,n)
  {
    if(i%2==0)
    {
      cnt=checkDivisible(i);
      if(cnt>max_cnt)
      {
        max_num=i;
        max_cnt=max(max_cnt,cnt);
      }
   }    
  }
  cout<<max_num;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int h = in.nextInt(), w = in.nextInt();
			char[][] s = new char[h][w];
			boolean[] hh = new boolean[h];
			boolean[] ww = new boolean[w];

			for (int i = 0; i < h; i++) {
				String str = in.nextString();
				for (int j = 0; j < w; j++) {
					char c = str.charAt(j);
					s[i][j] = c;
					if (c == '#') {
						hh[i] = true;
						ww[j] = true;
					}
				}
			}

			for (int i = 0; i < h; i++) {
				if (!hh[i]) continue;
				for (int j = 0; j < w; j++) {
					if (!ww[j]) continue;
					out.print(s[i][j]);
				}
				out.print("\n");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 23636
s = gets.chomp


ans1 = s[0...((s.length - 1) / 2)]
ans2 = s[0...((s.length - 1) / 2)].reverse

ans3 = s[((s.length + 3) / 2) - 1...s.length]
ans4 = s[((s.length + 3) / 2) - 1...s.length].reverse

puts s == s.reverse && ans1 == ans2 && ans3 == ans4 ? "Yes" : "No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

ll v[maxn+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n, k; cin >> n >> k;
  int i, j, z;
  for (i = 0; i < n; i++) cin >> v[i];
  sort(v,v+n);
  ll s = 0;
  for (i = 0; i < n-k; i++) s += v[i];
  cout << s;
  return 0;
}


Measured memory_bytes: 1792
def main():
    N = int(input())
    V = [int(v) for v in input().split()]
    V = sorted(V)
    val = (V[1]+V[0])/2.0
    for i in range(2, N):
        val = (val + V[i])/2.0
    print(val)
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import math

def main():
    a, b, x = map(int, input().split())
    
    if x > a ** 2 * b / 2:
        print(math.degrees(math.atan(2 * (a ** 2 * b - x) / a ** 3)))
    else:
        print(math.degrees(math.atan(a * b ** 2 / (2 * x))))


if __name__ == '__main__':
    main()


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

int main(){
    string n;
    cin >> n;
    ll s = 0;
    rep(i, n.size()){
        char a = n[i];
        s += a - '0';
    }
    if(s%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3752
//ehhhhh...... i hate you......

/* optimizations and other useless stuff*/
#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define INF 1e14
#define ull unsigned long long int
using namespace std;
/* TYPE DEFINITIONS */
typedef     long long int   ll;
typedef     vector<ll>      vi;
typedef     pair<ll,ll>     pi;


/* Basic  Math!!! */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
ll ncr(int n, int k)  
{  
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 

/* MACROS */
#define  all(A)         (A).begin() , (A).end()
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)  
void solve()
{
    ull n,s=0;
    cin>>n;
    --n;
    cout<<n*(n+1)/2;
}

int main()
{
    FastIO;
    ll c=0;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;
int main(void){

    int dice[6];
    cin >> dice[0] >> dice[1] >> dice[2] >> dice[3] >> dice[4] >> dice[5];
    
    string order;
    cin >> order;

    int dice_aft[6];
    for(int i=0;i<order.size();i++){
        if(order[i]=='N'){
            dice_aft[0]=dice[1];
            dice_aft[1]=dice[5];
            dice_aft[2]=dice[2];
            dice_aft[3]=dice[3];
            dice_aft[4]=dice[0];
            dice_aft[5]=dice[4];
        }else if(order[i]=='S'){
            dice_aft[0]=dice[4];
            dice_aft[1]=dice[0];
            dice_aft[2]=dice[2];
            dice_aft[3]=dice[3];
            dice_aft[4]=dice[5];
            dice_aft[5]=dice[1];
        }else if(order[i]=='W'){
            dice_aft[0]=dice[2];
            dice_aft[1]=dice[1];
            dice_aft[2]=dice[5];
            dice_aft[3]=dice[0];
            dice_aft[4]=dice[4];
            dice_aft[5]=dice[3];
        }else{
            dice_aft[0]=dice[3];
            dice_aft[1]=dice[1];
            dice_aft[2]=dice[0];
            dice_aft[3]=dice[5];
            dice_aft[4]=dice[4];
            dice_aft[5]=dice[2];
        }
        for(int j=0;j<6;j++) dice[j]=dice_aft[j];
    }
    cout << dice[0] <<endl;

}



Measured memory_bytes: 3144
#include <cstring>
#include <cstdio>
#include <queue>
#define rg register
#define mk(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=100010;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}


int n,dis[maxn];
pii x;
deque<pii> q;
inline int nxt(int x){return x==n-1?0:x+1;}
int main()
{
	scanf("%d", &n);
	memset(dis,0x3f,sizeof(dis));
	q.push_back(mk(1,1));
	while(1)
	{
		x=q.front();q.pop_front();
		if(!getmin(dis[x.first],x.second)) continue;
		if(x.first==0) break;
		q.push_back(mk(nxt(x.first),x.second+1));
		q.push_front(mk(x.first*10%n,x.second));
	}
	printf("%d\n",dis[0]);
	return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  string S; cin>>S;
  map<pair<string,string>,int> M;
  rep(i,0,(1ll<<N)){
    bitset<18> B(i);
    string T,U;
    rep(j,0,N){
      if(B.test(j)) T+=S[j];
      else U+=S[j];
    }
    M[mp(T,U)]++;
  }
  int ans=0;
  rep(i,0,(1ll<<N)){
    bitset<18> B(i);
    string T,U;
    rep(j,0,N){
      if(B.test(j)) T+=S[j+N];
      else U+=S[j+N];
    }
    reverse(ALL(T));
    reverse(ALL(U));
    ans+=M[mp(T,U)];
  }
  cout<<ans<<endl;
  }




Measured memory_bytes: 87040
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<int> a{1, 2, 3, 4, 5, 6, 7, 8, 9};
    vector<int> v(9);
    for (auto &&i : v) scanf("%d", &i);
    int ans = 0;
    do {
        int ok = 1;
        for (int i = 0; i < 9; ++i) if(v[i] != -1 && a[i] != v[i]) ok = 0;
        if(ok && a[0]+a[2]+a[5]+(a[1]+a[4])*10 + a[3]*100 == a[6]*100 + a[7]*10 + a[8]) ans++;
    }while(next_permutation(a.begin(),a.end()));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	i64 r, D, x; scanf("%lld%lld%lld", &r, &D, &x);
	
	for(int i = 0; i < 10; i++) {
		x = r * x - D;
		printf("%lld\n", x);
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

type P struct {
	X int
	Y int
}

type Queue struct {
	p []*P
}

func (q *Queue) push(p *P) {
	q.p = append(q.p, p)
}

func (q *Queue) pop() {
	q.p = q.p[1:]
}

func (q *Queue) front() *P {
	return q.p[0]
}

func (q *Queue) size() int {
	return len(q.p)
}

var (
	H  int
	W  int
	sy int
	sx int
	gy int
	gx int
)

// 地形データ
var field []string

// 訪問状態
var visted [][]bool

// 各点までの最短距離のスライス
var d [][]int

func main() {
	fmt.Scan(&H, &W)
	sx, sy = 0, 0
	gx, gy = H-1, W-1
	field = make([]string, H)
	visted = make([][]bool, H)
	d = make([][]int, H)

	for i := 0; i < H; i++ {
		// 地形データ初期化
		fmt.Scan(&field[i])

		// 訪問状態を初期化
		visted[i] = make([]bool, W)

		// 各点までの最短距離のスライス初期化
		d[i] = make([]int, W)
	}

	black := 0
	for h := 0; h < H; h++ {
		for w := 0; w < W; w++ {
			if string(field[h][w]) == "#" {
				black++
			}
		}
	}

	res := bfs()
	if visted[gx][gy] {
		ans := H*W - (res + 1 + black)
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}

}

func bfs() int {
	// 初期位置をキューにpush
	q := Queue{}
	q.push(&P{X: sx, Y: sy})
	// 初期位置のコストを0
	d[sx][sy] = 0
	visted[sx][sy] = true

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

	for q.size() > 0 {
		// キューの先頭を取り出す
		p := q.front()
		// fmt.Println(p)
		q.pop()

		// 取り出してきた状態がゴールなら探索を終了
		if p.X == gx && p.Y == gy {
			break
		}

		// 移動4方向をループ
		for i := 0; i < 4; i++ {
			nx := p.X + dx[i]
			ny := p.Y + dy[i]

			if 0 <= nx && nx < H && 0 <= ny && ny < W && string(field[nx][ny]) != "#" && !visted[nx][ny] {
				q.push(&P{X: nx, Y: ny})
				d[nx][ny] = d[p.X][p.Y] + 1
				visted[nx][ny] = true

			}
		}

	}

	return d[gx][gy]
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(ii, aa, bb) for (int ii = aa; ii >= bb; ii--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vector<int> A(n), dp(n, intMax);
    rep(i, 0, n)
    {
        cin >> A[i];
    }
    dp[0] = 0;
    rep(i, 1, min(k + 1, n))
    {
        dp[i] = abs(A[0] - A[i]);
    }
    rep(i,k+1,n)
    {
        int counter = 0;
        for (int j = i - 1; j >= 0 && counter < k ; counter++ , j--)
        {
            dp[i] = min(dp[i], dp[j] + abs(A[i] - A[j]));
        }
    }
    cout << dp[n - 1];
}

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

using namespace std;
const int MAXN = 1e5 + 5;
typedef long long ll;
int we[MAXN] , val[MAXN];
ll mem[105][MAXN];
ll n,wmax;
ll ans = 0;
ll solve(int i, ll v)
{
if(v < 0) return 1e18;
if(v == 0) return 0;
if(i == n) return 1e18;
ll &ret = mem[i][v];
if(ret != -1) return ret;
ret =  min(solve(i + 1 , v) , solve(i + 1 , v - val[i]) + we[i]);

return ret;

    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   cin >> n >> wmax;
   for(int i = 0 ; i < n ; i++) cin >> we[i] >> val[i];
  memset(mem,-1,sizeof(mem));
   
  for(int i = 1 ; i <= 1e5 ; ++i)
  {
      if(solve(0,(ll)i) <= wmax) ans = i;
  }
  cout << ans;
   
   
  
    return 0;
}

Measured memory_bytes: 82304