akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long       ll;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define fore(i, b, e)      for(int i = b; i < e; i++)
#define forr(i, b, e)      for(int i = b; i < e; i++)
#define forg(i, b, e, m)  for(int i = b; i < e; i+=m)
#define F first
#define S second
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef pair<int, ii>  iii;
typedef vector<int>     vi;

typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const double EPS = 1e-9;
#define tam 1234567

int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    ll x=(n/(a+b));
    cout<<a*x+min(n%(a+b),a)<<endl;
}
// PLUS ULTRA!

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define pll pair<ll,ll>
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"
const ll mod=1e9+7;
inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        return p1.first<p2.first;
    }
};

int main(){
	ll n;cin>>n;
	vl a(n);
	f(n)cin>>a[i];
	ll ans=1000;
	for(ll i=1;i<n;i++){
		if(a[i]>a[i-1]){
			ans+=(a[i]-a[i-1])*(ans/a[i-1]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    vi v(5,0); vi p;
    int u[]={0,6000,4000,3000,2000};
    rep(i,4){int hoge,tyome;cin>>hoge>>tyome;v[hoge]=tyome;p.push_back(hoge);}
    rep(i,p.size())cout<<v[p[i]]*u[p[i]]<<endl;
}

Measured memory_bytes: 3116
import java.util.Scanner;

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();

        String com;
        if (a<b && b<c) {
            com = "Yes";
        } else {
            com = "No";
        }

        System.out.println(com);
    }

}


Measured memory_bytes: 26308
import Data.List
import qualified Data.Vector as V
import Data.Bits

cover n keys =
    case coverMemo n keys V.! 0 of
      Nothing -> -1
      Just x -> x

coverMemo :: Int -> [[Int]] -> V.Vector (Maybe Integer)
coverMemo n [] = V.snoc (V.fromList [Nothing | i <- [0..2^n-2]]) (Just 0)
coverMemo n ([a,b]:cs:rest) =
    let memo = coverMemo n rest in
    let mask = listToInt cs in
    V.fromList [maybeMin (memo V.! i) (maybePlus (fromIntegral a) (memo V.! (mask .|. i)))
               | i <- [0..2^n-1]]

listToInt :: [Int] -> Int
listToInt = foldl (\a -> \x -> a+2^(x-1)) 0

maybeMin :: Maybe Integer -> Maybe Integer -> Maybe Integer
maybeMin Nothing Nothing = Nothing
maybeMin Nothing y = y
maybeMin x Nothing = x
maybeMin (Just x) (Just y) = Just (min x y)

maybePlus :: Integer -> Maybe Integer -> Maybe Integer
maybePlus _ Nothing = Nothing
maybePlus a (Just x) = Just (a+x)

main = do
  n:m:_ <- map read . words <$> getLine :: IO [Int]
  abc <- map (map read . words) <$> lines <$> getContents :: IO [[Int]]
  putStrLn $ show $ cover n abc


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

int main(){
    int gohyaku, hyaku, goju;
    int cost;
    int sum;
    int ans = 0;

    cin >> gohyaku >> hyaku >> goju >> cost;

    for(int i=0; i<=gohyaku; i++){
        for(int j=0; j<=hyaku; j++){
            for(int k=0; k<=goju; k++){
                
                sum = 500*i + 100*j + 50*k;
                if(sum == cost) ans++;

            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
int f[1000];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>f[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++){
            int flag=0;
        for(int j=1;j<i;j++){
            if(f[i]<f[j]){
                flag=1;
                break;
            }
        }
        if(!flag){
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args) throws IOException
	{
		Scanner c = new Scanner(System.in);
		String str = c.next();
		boolean[] arr = new boolean[200];
		for(int i=0; i<str.length(); i++) arr[str.charAt(i)] = true;
		for(int i=97; i<97+26; i++)
		{
			if(!arr[i])
			{
				System.out.println((char) i);
				return;
			}
		}
		System.out.println("None");
	}
}


Measured memory_bytes: 24088
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> SPi(N);
  string S;
  int P;
  for (int i = 0; i < N; i++) {
    cin >> S >> P;
    SPi[i] = make_tuple(S, -P, i+1);
  }
  sort(ALL(SPi));
  for (int i = 0; i < N; i++) {
    cout << get<2>(SPi[i]) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue<LL>
#define PQS priority_queue<LL, vector<LL>, greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
//#define MOD 1000000007
#define MOD 998244353
#define ERR 0.00000000000001
#define NUM 200010

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}

struct UF{
private:
  VL par;
public:
  UF(LL n){par.resize(n,-1);}
  LL root(LL x){if(par[x]<0)return x;else return par[x]=root(par[x]);}
  LL size(LL x){return -par[root(x)];}
  bool same(LL x,LL y){return root(x)==root(y);}
  void unite(LL x,LL y){x=root(x);y=root(y);if(x!=y){if(size(x)<size(y))swap(x,y);par[x]+=par[y];par[y]=x;}}
};
typedef struct{LL s,e,c,n;}Edge;
bool cmpc(Edge a,Edge b){return a.c<b.c;}
struct Kruscal{
private:UF *uf;VE<Edge> ed;
public:
  VE<Edge> edge;
  Kruscal(LL N){uf=new UF(N);}
  void add(LL s,LL e,LL c,LL n=0){Edge f;f.s=s,f.e=e,f.c=c,f.n=n;ed.PB(f);}
  void run(){sort(ALL(ed),cmpc);for(Edge a:ed){if(uf->same(a.s,a.e))continue;else{edge.PB(a);uf->unite(a.s,a.e);}}}
};

typedef struct{LL x,y,n;}Node;
bool cmpx(Node a,Node b){return a.x<b.x;}
bool cmpy(Node a,Node b){return a.y<b.y;}

int main(){
  LL i,N,ans=0;
  cin>>N;
  VE<Node> v(N);
  Kruscal k(2*N-2);
  rep(i,N){
    cin>>v[i].x>>v[i].y;
    v[i].n=i;
  }
  sort(ALL(v),cmpx);
  rep(i,N-1)k.add(v[i].n,v[i+1].n,v[i+1].x-v[i].x);
  sort(ALL(v),cmpy);
  rep(i,N-1)k.add(v[i].n,v[i+1].n,v[i+1].y-v[i].y);
  k.run();
  for(Edge a:k.edge)ans+=a.c;
  cout<<ans<<endl;
}


Measured memory_bytes: 19816
#include<iostream>
using namespace std;
int main(){
  int n,i,ans,count;cin >> n;ans = count = 0;
  int a[n];
  for(i=0;i<n;i++) cin >> a[i];
  for(i=1;i<n;i++){
    if (a[i] <= a[i-1]) count += 1;
    else count = 0;
    if (ans < count) ans = count;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const int mn=2e5+10;
pll p[mn];
vector<int> g[mn];
int main(){
    int n,k,i,j;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)for(j=n;j>i;j--)g[i].push_back(j);
    for(i=1;i<n;i++){
        while(k&&g[i].size()>1){
            k--;
            g[i].pop_back();
        }
    }
    int m=0;
    for(i=1;i<=n;i++)m+=g[i].size();
    if(k)printf("-1");
    else{
        printf("%d\n",m);
        for(i=1;i<=m;i++){
            for(int x:g[i])printf("%d %d\n",i,x);
        }
    }
}

Measured memory_bytes: 6400
import sys
from io import StringIO
import unittest

def resolve():
    S = input()
    T = input()

    S = list(S[::-1])
    T = list(T[::-1])

    flag = 0
    for i in range(0, len(S) - len(T) + 1):
        # Tが当てはまるかどうかの判定
        cnt = 0
        for j in range(len(T)):
            if S[i + j] == T[j] or S[i + j] == '?':
                cnt += 1

        if cnt == len(T):
            for j in range(len(T)):
                S[i + j] = T[j]
            flag = 1
            break

    if flag == 0:
        print('UNRESTORABLE')
        exit(0)

    for i in range(len(S)):
        if S[i] == '?':
            S[i] = 'a'

    S.reverse()
    print(''.join(S))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """?tc????
coder"""
        output = """atcoder"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """??p??d??
abc"""
        output = """UNRESTORABLE"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

Measured memory_bytes: 49648
#include <bits/stdc++.h>
#define ll      long long int
#define INF2    ((ll)1e18)
#define pii     pair<ll,ll>
#define x       first
#define y       second
#define vi      vector<ll>
#define pb      push_back
#define sz(a)   (ll)((a).size())
#define all(x)  (x).begin(), (x).end()
#define FIO     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define W(x)    cout<<#x<<": "<<x<<"\n";
#define SzOf(x) sizeof((x))/1048576;
using namespace std;
template<typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p){os<<"("<<p.x<<","<<p.y<<") "; return os;}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){for(auto i: v) os<<i<<" "; return os;}

const ll mxN = 1e5;
const ll mod = 1e9+7;

int main(){
    FIO;
	//freopen("input.txt", "r", stdin);
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll i=0;
    while(a>0&&c>0){
        if(i%2==0) c-=b;
        else a-=d;
        i++;
    }
    if(a<=0) cout<<"No";
    else cout<<"Yes";
}




Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in, n) for(int i=0; i<n; i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(int i=0; i<(n); i++)

vector<int> digit(int n){
    vector<int> ans;
    while(1 == 1){
        ans.push_back(n % 10);
        n/=10;
        if(n==0) break;
    }
    return ans;
}


int main(){
    int a, b; cin>> a >> b;
    int cnt=0;
    vector<int> keta;
    for(int i=a; i<=b; i++){
        keta=digit(i);
        if(keta[0] == keta[4] && keta[1] == keta[3]) cnt++;
    }
    cout << cnt <<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
 
int main(void)
{
    int flag = 0;
    float max, min;
    float hill;
 
    while (scanf("%f", &hill) != EOF){
        if (flag == 0){
            max = min = hill;
            flag++;
        }
         
        if (max < hill){
            max = hill;
        }
        else if (min > hill){
            min = hill;
        }
    }
 
    printf("%f\n", max - min);
 
    return (0);
}

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

using namespace std;

#define SZ(a) int((a).size())
#define mp make_pair
#define pb push_back
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define lrt rt<<1
#define rrt rt<<1|1
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const LL mod=1e9+7;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-6;
inline void read(LL& x){int f=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(f=-1,x=0):(x=c-'0');while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=f;}
inline void read(int& x){LL t;read(t);x=t;}

int g[15][15];

void floyd(int n){
    for(int k=0;k<=n;k++){
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
            }
        }
    }
}

int main(){//ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;read(n);read(m);
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            read(g[i][j]);
        }
    }
    floyd(9);
    int mi=1e9;
    for(int i=0;i<=9;i++) mi=min(mi,g[i][1]);
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int t;read(t);
            if(t==-1) ans+=mi;
            else ans+=g[t][1];
        }
    }
    printf("%d\n",ans);
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    writeln((lread() + 1) / 2);
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


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

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

Measured memory_bytes: 3080
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

int d1[205][205], d2[205][205];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  while(true) {
    int n, m;
    cin >> n >> m;
    if(!n) break;
    REP(i, n) REP(j, n) {
      d1[i][j] = i==j?0:INF;
      d2[i][j] = i==j?0:INF;
    }
    REP(i, m) {
      int x, y, c;
      char t;
      cin >> x >> y >> c >> t;
      x--, y--;
      if(t == 'L') {
        chmin(d1[x][y], c);
        chmin(d1[y][x], c);
      } else {
        chmin(d2[x][y], c);
        chmin(d2[y][x], c);
      }
    }

    REP(k, n) REP(i, n) REP(j, n) {
      chmin(d1[i][j], d1[i][k] + d1[k][j]);
      chmin(d2[i][j], d2[i][k] + d2[k][j]);
    }

    int r;
    cin >> r;
    VI cur(n, INF), nxt(n, INF);
    int now;
    cin >> now; now--;
    REP(i, n) cur[i] = i==now?0:INF;
    REP(i, r-1) {
      int g;
      cin >> g; g--;

      REP(j, n) {
        // (now, j) からスタートする
        REP(k, n) {
          // (g, k) を目的とする
          // 陸でnow->j 船でj->k 陸でk->g
          int tmp = d1[now][j] + d2[j][k] + d1[k][g];
          // 陸だけで移動
          if(j == k) chmin(tmp, d1[now][g]);
          chmin(nxt[k], cur[j] + tmp);
        }
      }
      // cout << nxt << endl;

      cur = nxt;
      nxt.assign(n, INF);
      now = g;
    }

    int ret = INF;
    REP(i, n) chmin(ret, cur[i]);
    cout << ret << endl;
  }

  return 0;
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }

void test_case() {
    string d;
    cin >> d;
    int rem = 0;
    for(char c : d) {
        rem += (c - '0');
        rem %= 9;
    }
    cout << (rem == 0 ? "Yes" : "No") << endl;
}

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

    int T = 1;
    while(T--) {
        test_case();
    }

    return 0;
}


Measured memory_bytes: 3784
#include<stdio.h>
int main(void)
{
	int N, K,co;
	scanf("%d%d", &N, &K);
	if (N % 2 == 0) {
		co = N / 2;
	}else{
		co = (N + 1) / 2;
	}
	if (co >= K) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3>=22)
    cout << "bust" << endl;
    else if(a1+a2+a3<=21)
    cout << "win" << endl;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  bool dp[100001] = {0};
  for(int i(1);i<=K;i++){
    for(int j(0);j<N;j++){
      if(i - A[j] >= 0){
        dp[i] |= !dp[i-A[j]];
      }
    }
  }
  if(dp[K]){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
N = int(input())
alist = list(map(int, input().split()))
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

balls_multiple = [0] * N
ans = []
for num in range(N-1, -1, -1):
    if balls_multiple[num] % 2 != alist[num]:
        ans.append(num+1)
        for div in make_divisors(num+1):
            balls_multiple[div-1] += 1
if ans:
    print(len(ans))
    print(*sorted(ans))
else:
    print(0)


Measured memory_bytes: 70236
//abc169

#include <bits/stdc++.h>
#include <string>
using namespace std;

int main() {

  int a,b,c,k;
  int ans = 0;
  cin >> a >> b >> c >> k;

  if(a > k){
    ans = k;
  }else if(k <= a + b){
    ans = a;
  }else{
    ans = a - (k - (a + b));
  }

  cout << ans << endl;

}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,m;
  cin>>n>>m;

  cout<<(n*(n-1)/2)+(m*(m-1)/2)<<newl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll n; cin>>n;
	ll ans=0;
	ll cnt=0;
	vl v(n);
	rep(i,0,n){
		ll a; cin>>a;
		if(0>a)cnt++;
		v[i]=abs(a);
		ans+=v[i];
	}
	if(cnt%2==1){
		sort(all(v));
		ans-=2*v[0];
	}
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 4016
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
typedef long long ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const int MAX=310;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int a,b;
int main(){
	cin>>a>>b;
	a--;
	b--;
	char s[100][100];
	REP(i,50)
		REP(j,100)
			s[i][j]='#';
	cout<<"100 100"<<endl;
	for(int i=50;i<100;i++)
		REP(j,100)
			s[i][j]='.';
	int x=0,y=0;
	REP(i,a){
		s[x][y]='.';
		if(y==98){
			x+=2;
			y=0;
		}else{
			y+=2;
		}
	}
	x=99,y=99;
	REP(i,b){
		s[x][y]='#';
		if(y==1){
			x-=2;
			y=99;
		}else{
			y-=2;
		}
	}
	REP(i,100){
		REP(j,100){
			cout<<s[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
string s;

signed main(void) {
    cin>>N>>s;
    int r=0, b=0;
    rep(i, s.size()) {
        if (s[i]=='R') r++;
        else b++;
    }
    if (r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 105

struct Edge{

	int from,to,dist;
};

int N,M;
int min_dist[SIZE][SIZE];
Edge edge[1005];

int main(){

	scanf("%d %d",&N,&M);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(k == i){

				min_dist[i][k] = 0;
			}else{

				min_dist[i][k] = BIG_NUM;
			}
		}
	}

	for(int i = 0; i < M; i++){

		scanf("%d %d %d",&edge[i].from,&edge[i].to,&edge[i].dist);
		edge[i].from--;
		edge[i].to--;

		min_dist[edge[i].from][edge[i].to] = min(min_dist[edge[i].from][edge[i].to],edge[i].dist);
		min_dist[edge[i].to][edge[i].from] = min(min_dist[edge[i].to][edge[i].from],edge[i].dist);
	}

	for(int mid = 0; mid < N; mid++){
		for(int start = 0; start < N; start++){
			if(min_dist[start][mid] == BIG_NUM)continue;
			for(int goal = 0; goal < N; goal++){
				if(min_dist[mid][goal] == BIG_NUM)continue;

				min_dist[start][goal] = min(min_dist[start][goal],min_dist[start][mid]+min_dist[mid][goal]);
			}
		}
	}

	int ans = 0;
	for(int i = 0; i < M; i++){
		bool FLG = false;

		for(int a = 0; a < N; a++){
			for(int b = 0; b < N; b++){
				if(b == a)continue;

				if(min_dist[a][b] == min_dist[a][edge[i].from]+edge[i].dist+min_dist[edge[i].to][b] ||
						min_dist[a][b] == min_dist[a][edge[i].to]+edge[i].dist+min_dist[edge[i].from][b]){
					FLG = true;
					break;
				}
			}
			if(FLG)break;
		}

		if(!FLG){

			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int number; 
    int number1[10000] = {0};
    int min, max; 
    long int sum;
    int i;

    scanf("%d", &number);
    for (i = 0; i < number; i++){
        scanf("%d", &number1[i]);
    }
    
    min = number1[0];
    max = number1[0];
    sum = 0;

    for (i = 0; i < number; i++) {
        if (min > number1[i]) {
            min = number1[i];
        }
        if (max < number1[i]) {
            max = number1[i];
        }
        sum += number1[i];
    }

    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

Measured memory_bytes: 648
#include<stdio.h>
#include <stdlib.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a*b>c){
	printf("%d",c);
	}else{
	printf("%d",a*b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;

int temp;

int func(int a){
    if(a%2 == 0){
        temp++;
        func(a/2);
    }
    return temp;
}

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    int ans = 0;
    REP(i, N){
        temp = 0;
        ans += func(a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<set>
#include<vector>
#include <algorithm>
using namespace std;
int main(){
  vector<int> v;
  int n,i,k;
  cin >>n;
  for (i=0;i<n;i++){
    cin>>k;
    v.push_back(k);
  }
  sort(v.begin(),v.end());
  cout << v[n-1]-v[0] << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	cout << max(a+b, max(a-b, a*b)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fast()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main()
{
    fast();
    int n,a[200005],b[1000005],j,i,ans=0;
    cin>>n;
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    for(i=0;i<=a[n-1];i++)
        b[i]=1;
    for(i=0;i<n;i++)
        if(b[a[i]])
           for(j=a[i]*2;j<=a[n-1];j+=a[i])
           b[j]=0;
    for(i=0;i<n-1;i++)
        if(a[i]==a[i+1])
        b[a[i]]=0;
    for(i=0;i<n;i++)
        if(b[a[i]])
        ++ans;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8284
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

int main(){
    string str[10] = {"0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"};
    while(1){
        int n;
        scanf("%d",&n);
        if(n==-1)break;
        string cur = "0000000";
        for(int i=0;i<n;i++){
            int next;
            scanf("%d",&next);
            string ans = "0000000";
            for(int i=0;i<8;i++){
                if(cur[i]!=str[next][i]){
                    ans[i] = '1';
                }
            }
            cout << ans << endl;
            cur = str[next];
        }
    }

    return 0;
}

Measured memory_bytes: 1220
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

long long GCD(long long a, long long b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0)
            continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1)
        res.push_back({N, 1});
    return res;
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll gcd = GCD(A, B);
    vector<pair<ll, ll>> pri = prime_factorize(gcd);
    ll ans = pri.size() + 1;
    cout << ans << endl;
}

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

using namespace std;

bool can(int N, int K, const vector<int>& A, int x)
{
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		cnt += (A[i] + x - 1) / x - 1;
	}

	return cnt <= K;
}

int solve(int N, int K, const vector<int>& A)
{
	int l = 0;
	int u = 1000 * 1000 * 1000 + 10;
	while (l + 1 < u) {
		int m = l + (u - l) / 2;
		if (can(N, K, A, m)) {
			u = m;
		}
		else {
			l = m;
		}
	}
	return u;
}

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}

	cout << solve(N, K, A) << endl;
}


Measured memory_bytes: 3984
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut que = VecDeque::<(usize, usize)>::new();
    let mut visit = vec![false; n];
    let mut dists = vec![usize::max_value(); n];
    que.push_back((1, 1));
    let mut ans = 0;
    while let Some((cost, v)) = que.pop_front() {
        if v == 0 {
            ans = cost;
            break;
        }
        visit[v] = true;
        for &(ncost, nv) in [(cost + 1, (v + 1) % n), (cost, v * 10 % n)].iter() {
            if visit[nv] || dists[nv] <= ncost {
                continue;
            }
            dists[nv] = ncost;
            if cost == ncost {
                que.push_front((ncost, nv));
            } else {
                que.push_back((ncost, nv));
            }
        }
    }
    println!("{}", ans);
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n; cin >> n;
	int res = INT_MAX;
	REPU(a, 1, n) {
		int b = n - a;
		if (b < a) break;
		int ans = 0;
		int x = a;
		while (x > 0) {
			ans += x % 10, x /= 10;
		}
		x = b;
		while (x > 0) {
			ans += x % 10, x /= 10;
		}
		amin(res, ans);
	}
	cout << res << endl;

	return 0;
}


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

using namespace std;

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

    for (int o : a)
    {
        cout << o << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>

struct Comparator {
	bool operator()(const std::pair<long long int, long long int>& a, const std::pair<long long int, long long int>& b) const {
		return a.second > b.second;
	}
};
long long int by_two(const long long int n, const long long int a, const long long int d) {
	return n == 1 ? d : by_two(n >> 1, a, d) + a + (n & 1) * d;
}
int main() {
	std::cin.tie(nullptr); std::cin.sync_with_stdio(false);
	int test_case; std::cin >> test_case;
	for (auto t = 0; t < test_case; ++t) {
		long long int n, a, b, c, d; std::cin >> n >> a >> b >> c >> d;
		std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int>>, Comparator> queue;
		const long long int max = by_two(n, a, d);
		std::vector<long long int> costs{ a, b, c };
		std::vector<int> multipier{ 2, 3, 5 };
		queue.emplace(n, 0);
		std::unordered_map<long long int, long long int> min_cost; min_cost[n] = 0;
		min_cost[0] = max;
		while (!queue.empty()) {
			const auto top = queue.top(); queue.pop();
			//std::cout << top.first << ", " << top.second << '\n';
			if (top.first == 0) break;
			if (min_cost[top.first] != top.second) continue;
			if (top.second / d + top.first <= min_cost[0] / d + 1) {
				if (min_cost[0] > top.first * d + top.second) {
					min_cost[0] = top.first * d + top.second;
					queue.emplace(0, top.first * d + top.second);
				}
			}
			for (auto i = 0; i < costs.size(); ++i) {
				const auto m = multipier[i];
				const auto cost = costs[i];
				for (const auto next : { top.first / m, top.first / m + 1 }) {
					const auto diff = d * std::abs(top.first - next * m) + top.second;
					if (cost + diff < min_cost[0] && (min_cost.find(next) == min_cost.end() || min_cost.find(next)->second > cost + diff)) {
						min_cost[next] = cost + diff;
						queue.emplace(next, cost + diff);
					}
				}
			}
		}
		std::cout << min_cost[0] << '\n';
	}
}


Measured memory_bytes: 4220
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n, x, y;
	cin >> n >> x >> y;
	x = x - 1;
	y = y - 1;
	vector<vector<int>>s(2003);
	for (int i = 1; i < n; i++) {
		s[i].push_back(i - 1);
		s[i - 1].push_back(i);
	}
	s[x].push_back(y);
	s[y].push_back(x);
	int ans[2030] = {};
	for (int i = 0; i < n; i++) {
		queue<int>q;
		q.push(i);
		int seen[2030] = {};
		int kyori[2030] = {};
		seen[i] = 1;
		while (q.size()) {
			int np = q.front();
			q.pop();
			for (auto iter : s[np]) {
				if (seen[iter] == 0) {
					seen[iter] = 1;
					q.push(iter);
					kyori[iter] = kyori[np] + 1;
					ans[kyori[iter]]++;
				}
			}
		}
	}
	for (int i = 1; i < n; i++) {
		cout << ans[i]/2 << endl;
	}
 }


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int x[100000], dx[100000], sw[100000], tmp[100000];

int main(void) {
    int i, j, l, n, m;
    long long k;
    scanf("%d",&n);
    REP (i,n) scanf("%d",&x[i]);
    REP (i,n-1) dx[i] = x[i+1] - x[i];
    scanf("%d%lld",&m,&k);
    REP (i,n-1) sw[i] = i;
    REP (i,m) {
        int a;
        scanf("%d",&a); a--;
        swap(sw[a-1],sw[a]);
    }
    while (k > 0) {
        if (k % 2) {
            REP (i,n-1) tmp[i] = dx[i];
            REP (i,n-1) dx[i] = tmp[sw[i]];
        }
        REP (i,n-1) tmp[i] = sw[i];
        REP (i,n-1) sw[i] = tmp[tmp[i]];
        k /= 2;
    }
    long long sum = x[0];
    printf("%lld\n",sum);
    REP (i,n-1) {
        sum += dx[i];
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional> //operator[]
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep(i,n) for(int i=n-1;i>0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
#define P pair<int,int>
#define Pll pair<ll,ll>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main(){
    ll x; cin >> x;
    ll res=100;
    int ans=0;
    while(res<x){
        ans++;
        res*=1.01;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
 
int main()
{
    int n,x;
    cin>>n>>x;
 
    if(x==1||x==2*n-1)
    {
        cout<<"No";
        return 0;
    }
 
    cout<<"Yes\n";
    for(int i=1;i<=2*n-1;i++)
    {
        int a=i+(x-n)+2*n-1;
        a=a%(2*n-1);
        if(a==0)
            a=2*n-1;
        cout<<a<<"\n";
    }
    return 0;
}

Measured memory_bytes: 1536
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int h=tx-sx;
    int v=ty-sy;
    forn(i,h)cout<<"R";
    forn(i,v)cout<<"U";
    forn(i,h)cout<<"L";
    forn(i,v)cout<<"D";
    cout<<"D";
    forn(i,h+1)cout<<"R";
    forn(i,v+1)cout<<"U";
    cout<<"LU";
    forn(i,h+1)cout<<"L";
    forn(i,v+1)cout<<"D";
    cout<<"R"<<endl;
    return 0;
}

Measured memory_bytes: 256
lec=0
loz=0
while line = STDIN.gets
  a, b, c = line.chomp.split(',').map { |item| item.to_i }
  if a*a+b*b == c*c then
    lec += 1
  elsif a == b then
    loz += 1
  end   
end

puts lec
puts loz

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    int ans = MOD;
    for (int i = 0; i + k - 1 < n; i++){
        int t = min(abs(x[i]), abs(x[i + k - 1])) + x[i + k - 1] - x[i];
        ans = min(ans, t);
    }

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

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

N=int(input())
As=list(map(int, input().split()))

inds=sorted(range(len(As)), key=lambda k: As[k])[::-1]
#ds=[[0 for j in range(N+1-i)] for i in range(N+1)]

ds=[0]
for xy in range(1,N+1):
    i=inds[xy-1] #←
    a=As[i] #←この２行でメモリアクセス省略しないとTLEになる
    nds=[0]*(xy+1)
    nds[-1]=ds[-1]+a*(i-(xy-1))
    nds[0]=ds[0]+a*(N-xy-i)

    for x in range(1,xy):
        y=xy-x
        c1=ds[x-1]+a*abs(i-(x-1))
        c2=ds[x]+a*abs(N-y-i)
        nds[x]=max(c1,c2)
    ds=nds.copy()
    #print(ds)


print(max(ds))
#print(ds)
#print(inds)




Measured memory_bytes: 74432
($h,$w,$d)=glob<>;
for$x(1..$h){$==0;$p[$_]=[$x,++$=]for glob<>}
$s[$_+$d]=$s[$_]+abs($p[$_+$d][0]-$p[$_][0])+abs$p[$_+$d][1]-$p[$_][1]for 1..9e4;
<>;
/ /,print$s[$']-$s[$`],$/for<>

Measured memory_bytes: 50688
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;

public class Main {
  /**
   * main method.
   */
  public static void main(String[] args) throws IOException {
    InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
    BufferedReader in = new BufferedReader(reader);
    
    //グリッド
    int[][] grid = new int[3][3];
    for (int i = 0; i < 3; i++) {
    	String line = in.readLine();
    	for (int j = 0; j < 3; j++) {
    		String[] line_char = line.split(" ");
    		grid[i][j] = Integer.parseInt(line_char[j]);	
        }
    }
    
    //正しい場合はtrue
    boolean trueFlag = true;
    
    for (int i = 1; i < 3; i++) {
    	for (int j = 0; j < 2; j++) {
    		if (grid[i][j] - grid[i-1][j] != grid[i][j+1] - grid[i-1][j+1]) {
    			trueFlag = false;
    		}
        }
    }
    
    if (trueFlag) {
    	System.out.println("Yes");
    } else {
    	System.out.println("No");
    }
    
  }
}

Measured memory_bytes: 23124