akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
using namespace std;
#define ll long long
#define INF 1000000007

signed main(){
    int x;
    cin>>x;
    int i=1;
    int count=0;
    while(1){
        count+=i;
        i++;
        if(count>=x)break;
    }
    cout<<i-1<<endl;
    return 0;
}





Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Random;
import java.io.PrintWriter;

public class Main{
    public static Random rand = new Random();
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        int D = Integer.parseInt(sc.next());
        int[] C = new int[26];
        int[] L = new int[26];
        for (int i = 0; i < 26; i++){
            C[i] = Integer.parseInt(sc.next());
            L[i] = 0;
        }
        int[][] S = new int[D][26];
        for (int i = 0; i < D; i++){
            for (int j = 0; j < 26; j++){
                S[i][j] = Integer.parseInt(sc.next());
            }
        }
        int[] Ans = new int[D];
        for (int i = 0; i < D; i++){
            Ans[i] = (i % 26) + 1;
        }
        int maxPoint = calcPoint(Ans, S, C, L, D);
        
        //int roop = 0;
        while (System.currentTimeMillis() - start < 1850){
            maxPoint = change(Ans, S, C, L, D, maxPoint);
            //roop += 1;
        }

        for (int i = 0; i < D; i++){
            out.print(Ans[i]);
            out.print("\n");
        }
        //out.println(roop);
        //out.println(maxPoint);
        //template
        sc.close();
        out.flush();
    }

    public static int calcPoint(int[] Ans, int[][] S, int[] C, int[] L, int D){
        int point = 0;
        for (int i = 0; i < 26; i++){
            L[i] = 0;
        }
        for (int i = 0; i < D; i++){
            point += S[i][Ans[i] - 1];
            L[Ans[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++){
                point -= C[j] * (i + 1 - L[j]);
            }
        }
        return point;
    }

    public static int change(int[] Ans, int[][] S, int[] C, int[] L, int D, int maxPoint){
        int ci = rand.nextInt(D);
        int before = Ans[ci];
        Ans[ci] = rand.nextInt(26) + 1;
        int newPoint = calcPoint(Ans, S, C, L, D);
        if (newPoint < maxPoint){
            Ans[ci] = before;
            return maxPoint;
        }
        else{
            return newPoint;
        }
    }
}

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

    int combi(int n,int k){
        if(n==k || k == 0) return 1;
        else {
            return combi(n-1,k-1) + combi(n-1,k);
        }
    }
     
    int main() {
        int N,M;
        cin >> N >> M;
        // NC2 + MC2
        int answer;
        if(N==1 && M==1){
            cout << 0 << endl;
            return 0;
        }else if(N<=1){
            answer = combi(M,2);
        }else if(M<=1){
            answer = combi(N,2);
        }else answer = combi(N,2) + combi(M,2);
        cout << answer << endl;
        return 0;
    }

Measured memory_bytes: 256
N=int(input())
c=1,6,9,36,81,216,729,1296,6561,7776,46656,59049

DP = [N for i in range(N + 1)]
DP[0] = 0
for cost in c:
    for i in range(cost, N + 1):
        DP[i] = min(DP[i], DP[i - cost] + 1)
print(DP[N])

Measured memory_bytes: 7064
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    s=1
    while s*2<=n:
        s*=2
    print(s)
main()

Measured memory_bytes: 3188
N, K = map(int, input().split())

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

a = Base_10_to_n(N, K)
print(len(a))

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

using namespace std;

int main() {
    int ok=1;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i+=2){
        if(s[i]=='L') ok=0;
    }
    for(int i=1;i<s.length();i+=2){
        if(s[i]=='R') ok=0;
    }
    if(ok==1)   cout<<"Yes";
    else        cout<<"No";
    return 0;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main() {
    int x,y; cin >> x >> y;
    if(x%y==0) cout<<-1<<endl;
    else{
      for(int i=1;i<100;i++){
        if(x*i%y!=0){
          cout<<x*i<<endl;
          break;
        }
      }
    }
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if((a == b && b != c) || (b == c && c != a) || (c == a && a != b) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a+3);

    cout << a[0] + a[1] << endl;
}


Measured memory_bytes: 256
sx, sy, tx, ty = [int(x) for x in input().split()]

r = []
# 1
r.append("U" * (ty - sy))
r.append("R" * (tx - sx))
# 2
r.append("D" * (ty - sy))
r.append("L" * (tx - sx))
# 3
r.append("L")
r.append("U" * (ty - sy + 1))
r.append("R" * (tx - sx + 1))
r.append("D")
# 4
r.append("R")
r.append("D" * (ty - sy + 1))
r.append("L" * (tx - sx + 1))
r.append("U")

print("".join(r))

Measured memory_bytes: 3064
N = int(input())
r0 = int(input())
r1 = int(input())

res = r1 - r0
r_min = r0 if r0 < r1 else r1

for i in range(2, N):
    r = int(input())

    if res < r - r_min:
        res = r - r_min
    elif r < r_min:
        r_min = r

print(res)



Measured memory_bytes: 5612
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
// all_of

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int A, B, C, D, E, F;
bool DP[3001];
int main() {
	cin >> A >> B >> C >> D >> E >> F;
	
	DP[0] = true;
	REP(k, C, 3001) {
		DP[k] |= DP[k - C];
	}
	REP(k, D, 3001) {
		DP[k] |= DP[k - D];
	}

	double dmax = 0;
	PP val{ 100 * A, 0 };
	REP(i, 0, 31) {
		REP(j, 0, 31) {
			if (i == 0 && j == 0) continue;
			int w = i * A + j * B;
			int lim = w * E;
			if (lim > 3000) continue;
			int smax = 0;
			REP(k, 0, min(lim, F - 100 * w) + 1) {
				if (DP[k]) smax = k;
			}
			int sw = smax + 100 * w;
			if (sw <= F && 1.0 * smax / w > dmax) {
				dmax = 1.0 * smax / w;
				val = PP(sw, smax);
			}
		}
	}
	cout << val << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
	int N;
 	scanf("%d",&N);
  
  	int a ;
    int b = N/1000;
  
  	if(b*1000 < N){
  		b++;
  		a = b*1000 - N;
	}else
		a = N - b*1000 ;
  
  
  	printf("%d\n",a);
  
 	return 0;
}

Measured memory_bytes: 1684
fun main(args: Array<String>) {
    val N = nextInt()
    val (S, T) = listOfString()
    var ans = ""
    for (n in 0 until N) {
        ans += S[n]
        ans += T[n]
    }
    println(ans)
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    bool ans = true;
    rep(i,n/2){
        if(s[i] != s[n-i-1]) ans = false;
    }
    rep(i, (n-1)/4 ){
        if(s[i] != s[(n-1)/2-i-1]) ans = false;
    }
    rep(i,(n-1)/4){
        if(s[(n+3)/2 + i -1] != s[n-i-1]) ans = false;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	double n,m,s;
	while(cin>>n>>m>>s,n){
		int ans=0;
		for(int i=1;i<1000;i++){
			for(int j=1;j<1000;j++){
				int p1=i*(n+100)/100;
				int p2=j*(n+100)/100;
				if(p1+p2==s){
					int p1=i*(m+100)/100;
					int p2=j*(m+100)/100;
					ans=max(ans,p1+p2);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<int> A(N,0);
    bool f=true;
    for(int i=0;i<N-1;i++){
        if(S[i]=='A' && S[i+1]=='C'){
            i++;
            A[i]=1;
        }
    }
    //累積和
    for(int i=1;i<N;i++){
        A[i] += A[i-1];
    }
    
    for(int i=0;i<Q;i++){
        int l,r;
        cin >> l >> r;
        cout << A[r-1] - A[l-1] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define PI 3.141592653589

int main(void)
{
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double x = 1.0*m/60*360, y = 1.0*(h*60+m)/720*360;
    double deg = fabs(x-y);
    deg = min(deg,360-deg);
    double ans = a*a+b*b-2*a*b*cos(deg/180*PI);
    ans = sqrt(ans);
    printf("%.10lf",ans);
    return 0;
}

Measured memory_bytes: 4072
N = int(input())
strengths = map(int, input().split())
sorted_strengths = sorted(strengths, reverse=True)
# print(sorted_strengths)
team_strength_sum = 0
for i in range(3*N):
    if ((i+1)%2 == 0) & ((i+1)//2 <= N):
        team_strength_sum += sorted_strengths[i]
print(team_strength_sum)

Measured memory_bytes: 37084
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,ddx,ddy;
ll x[100005],y[100005];
char s[300004];


int main(){
	cin>>a>>b>>c>>d;
	if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d){
		p("Yes");
	}else{
		p("No");
	}
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	cout<<(n/2)*(n-n/2)<<endl;
}

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

int main(){
  int a,b,c;
  int x,y;
  cin >> a >> b >> c >> x >> y;
  if(c*2<a+b){
    cout << ((((x<y)?2*c*x+b*(y-x):2*c*y+a*(x-y)))<((x<y)?2*c*y:2*c*x)?((x<y)?2*c*x+b*(y-x):2*c*y+a*(x-y)):((x<y)?2*c*y:2*c*x)) << endl;
  }else{
    cout << a*x+b*y << endl;
  }
  return 0;
}


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

int main() {
  
  int N;
  int A;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
  int s;
  int t;
  cin >> s >> t;
  A += t - s + 1;
  }
  cout << A << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
int a[100005], b[100005], n;
LL c[100005];
int main() {
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%d%d", &a[i], &b[i]);
	}
	per(i, n, 1) {
		c[i] = (b[i] - a[i] % b[i]) % b[i];
		LL k = max(c[i + 1] - c[i], 0ll);
		k = k / b[i] + (k % b[i] > 0);
		c[i] = c[i] + b[i] * k;
	}
	cout << c[1] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
ll dp[101][4][4][4];
int main(){
    ll n,ans=0,z=pow(10,9)+7;
    cin >> n;
    if(n==3){
        cout << 61 << endl;
        return 0;
    }
    
    //A C G T
    //0 1 2 3

    for(ll h=4;h < n+1;h++)
    {
        for(ll i=0;i < 4;i++)
        {
            for(ll j=0;j < 4;j++)
            {
                for(ll k=0;k < 4;k++)
                {
                    for(ll l=0;l < 4;l++)
                    {
                    if(l==1 && k==2 && j==0){                       
                        continue;
                    }
                    else if(l==1 && j==2 && k==0){
                        continue;
                    }
                    else if(l==1 && j==2 && i==0){
                       continue;
                    }
                    else if(l==1 && k==2 && i==0){
                       continue;
                    }
                    else if(l==2 && k==1 && j==0){
                       continue;
                    }
                    else if(i==0 && j==2 && k==1){
                       continue;
                    }
                    else if(i==2 && j==0 && k==1){
                       continue;
                    }
                    else if(i==0 && j==1 && k==2){
                       continue;
                    }else{
                        if(h==4){
                            dp[h][j][k][l] += 1;
                        }else{
                            dp[h][j][k][l] += dp[h-1][i][j][k];
                            dp[h][j][k][l] %= z;
                        }  
                    }
                    
                    }
                }
            }
        }
    }
   
        for(ll j=0;j < 4;j++)
            {
                for(ll k=0;k < 4;k++)
                {
                    for(ll l=0;l < 4;l++)
                    {
                        ans += dp[n][j][k][l];
                        ans %= z;
                    }
                }
            }
        
    cout << ans << endl;
}
/*
ＤＰ変数もう一つ減らせた（最後の3文字をもって、一つ増やすことを考えればよい
プログラムの中で使う変数で書き換えて考える
（数字で置き換えるとき、最初から数字で考えた方が分かりやすい）
意味が違うものは区別して変数をつける（h→lengthとか）

生配列はグローバルに置くと０で初期化される*/

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

using namespace std;

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

int intpow(int x, int n){
    int t = 1;
    rep(i, n) t *= x;
    return t;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    // 桁の先頭がi+1, 桁の最後がj+1の個数
    int a[9][9];
    rep(i, 9)rep(j, 9) a[i][j] = 0;

    for (int i = 1; i <= n; i++){
        int keta = 0;
        int num = i;
        while(num > 0){
            num /= 10;
            keta++;
        }
        int f = (i / intpow(10, keta - 1)) - 1;
        int e = (i % 10) - 1;
        if (e < 0) continue;
        
        a[f][e]++;
    }

    rep(i, 9)rep(j, 9) ans += a[i][j] * a[j][i];
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
 const long long mod=1e9+7;

 int main(){
 int N,M;
 cin>>N>>M;

 vector<int>oks(N+1,true);
 for(int i=0;i<M;++i){
 int a;cin>>a;
 oks[a]=false;
 }

 vector<long long int>dp(N+1);
 dp[0]=1;
 for(int now=0;now<N;++now){
 for(int next=now+1;next<=min(N,now+2);++next){
 if(oks[next]){
 dp[next]+=dp[now];
 dp[next]%=mod;
 }
}
 }

 cout<<dp[N]<<endl;
 return 0;
 }

Measured memory_bytes: 1408
#Cはソート済み
def getNumCoin(C,n):
    T=[float('inf') for i in range(n+1)]
    T[0]=0
    m=len(C)
    
    for i in range(m):
        for j in range(C[i],n+1):
            T[j]=min(T[j], T[j-C[i]]+1)
    return T[n]
  
N=int(input())
nine=[0,1,9,9**2,9**3,9**4,9**5]
six=[6,6**2,6**3,6**4,6**5,6**6]
L=sorted(nine+six)
print(getNumCoin(L,N))

Measured memory_bytes: 49792
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

typedef ll Weight;
struct Edge {
    ll src, dst;
    Weight weight;
    Edge(ll src, ll dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void Dijkstra(const Graph &g, int s,
              vector<Weight> &dist, vll &prev) {
    int n = (int)g.size();
    dist.assign(n, INF); dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
        Edge e = Q.top(); Q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        for(Edge f: g[e.dst]) {
            if (dist[f.dst] > e.weight+f.weight) {
                dist[f.dst] = e.weight+f.weight;
                Q.push(Edge(f.src, f.dst, e.weight+f.weight));
            }
        }
    }
}

int main() {
  int N,M;
  cin >> N >>M;
  vll src,dst;
  vector<set<ll> > color(N+1);
  vector<Weight> weight;
  vll compress;
  repeat(i,M){
    ll p,q,c;
    cin >> p >> q >> c;
    color[p].insert(c);
    color[q].insert(c);
    ll P = c*(N+1)+p,Q = c*(N+1)+q;
    src.push_back(P);
    dst.push_back(Q);
    weight.push_back(0);
    src.push_back(Q);
    dst.push_back(P);
    weight.push_back(0);
    compress.push_back(P);
    compress.push_back(Q);
  }
  repeat(i,N){
    ll s = i+1;
    compress.push_back(s);
    for(auto c:color[i+1]){
      ll t=c*(N+1)+i+1;
      src.push_back(s);
      dst.push_back(t);
      weight.push_back(1);
      src.push_back(t);
      dst.push_back(s);
      weight.push_back(0);
      compress.push_back(t);
    }
  }
  sort(compress.begin(),compress.end());
  compress.erase(unique(compress.begin(),compress.end()),compress.end());
  map<ll,int> idx;
  repeat(i,compress.size()){
    idx[compress[i]] = i;
  }
  Graph g(compress.size());
  repeat(i,src.size()){
    int s = idx[src[i]];
    int t = idx[dst[i]];
    Weight w = weight[i];
    g[s].push_back(Edge(s,t,w));
  }
  vector<Weight> dist;
  vll prev;
  Dijkstra(g,idx[1],dist,prev);
  cout << (dist[idx[N]]!=INF? dist[idx[N]]:-1) << endl;
  return 0;
}


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

int main(){
    string s;
    cin>>s;
    int a,b;
    while(s!="-"){
        cin>>a;
        for(int i=0;i<a;i++){
            cin>>b;
            s=s.substr(b,s.size()-b)+s.substr(0,b);
        }
        cout<<s<<endl;
        cin>>s;
    }
    
}


Measured memory_bytes: 3140
#include <iostream>
#include <vector>
#include <memory.h>
#include <algorithm>
#include <queue>
using namespace std;

const int INF = 1 << 25;
int direction[1000010][4];
int memo[1010][1010][4];
vector<int> direct[4];
char field[1010][1010];
string command;

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

typedef pair<int, int> P;
typedef pair<P, int> state;  // position, direcion
typedef pair<int, state> data;


int main(){
  int H, W, N;
  int sy, sx;
  int gy, gx;
  while(cin >> H >> W >> N && (H || W || N)){
    int dir = 0;
    cin >> command;
    
    
    for(int i = 0; i < 1000010; i++){
      for(int j = 0; j < 4; j++){
	direction[i][j] = INF;
      }
    }
    for(int i = 0; i < 1010; i++){
      for(int j = 0; j < 1010; j++){
	field[i][j] = '#';
	for(int k = 0; k < 4; k++){
	  memo[i][j][k] = INF;
	}
      }
    }

    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
	cin >> field[i+1][j+1];
	if(field[i+1][j+1] == 'S'){
	  sy = i + 1;
	  sx = j + 1;
	  field[i+1][j+1] = '.';
	}
	if(field[i+1][j+1] == 'G'){
	  gy = i + 1;
	  gx = j + 1;
	  field[i+1][j+1] = '.';
	}
      }
    }
    
    for(int i = 0; i < 4; i++) direct[i].clear();
    for(int i = 0; i < N; i++){
      direct[dir].push_back(i);
      if(command[i] == 'R') dir = (dir + 1) %4 ;
      else dir = (dir + 3) % 4;
    }
    direct[dir].push_back(N);
    
    for(int i = 0; i <= N; i++){
      for(int j = 0; j < 4; j++){
	vector<int>::iterator iter
	  = upper_bound(direct[j].begin(), direct[j].end(), i);
	if(iter != direct[j].end()) direction[i][j] = *iter;
      }
    }
    
    memo[sy][sx][0] = 0;
    priority_queue<data, vector<data>, greater<data> > que;
 
    bool flag=false;
    que.push(data(0, state(P(sy, sx), 0)));
    while(!que.empty()){
      data d = que.top();
      int cost = d.first;
      state s = d.second;
      int y = s.first.first;
      int x = s.first.second;
      int dir = s.second;
      que.pop();
      
      if(s.first.first == gy && s.first.second==gx){
	flag = true;
	break;
      }
      if(cost > memo[y][x][dir]) continue;

      
      
      for(int i=0;i<4;i++){
	int nextturn = direction[cost][i];
	int y2 = y + dy[i];
	int x2 = x + dx[i];
	if(field[y2][x2] == '#') continue;
	if(memo[y2][x2][i] > nextturn){
	  memo[y2][x2][i] = nextturn;
	  que.push(data(nextturn, state(P(y2, x2), i)));
	}
	
      }
      int y2 = y + dy[dir];
      int x2 = x + dx[dir];
      if(field[y2][x2] != '#' && memo[y2][x2][dir] > cost){
	memo[y2][x2][dir] = cost;
	que.push(data(cost, state(P(y2, x2), dir)));
      }
    }
    if(flag){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

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

int n, m, l;
long long a[101][101], b[101][101], c[101][101];

int main(){

  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      for(int k = 0; k < m; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << c[i][j];
      if(j != l-1) cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	/**
	 * 入力された数のうち素数の数がいくつかを出力する
	 * 
	 * @param args
	 *            入力数、素数判定する数字
	 */
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();

		long check;
		int count = 0;// 素数の数
		// 入力された数の素数を判定する
		for (int i = 0; i < num; i++) {
			check = scan.nextLong();
			if (PrimeNumber_Checker(check)) {
				count++;
			}
		}
		System.out.println(count);
	}

	/**
	 * 素数であるかどうかを判定数
	 * 
	 * @param check_num
	 *            判定する数字
	 * @return 判定結果(true:素数)
	 */
	public static boolean PrimeNumber_Checker(long check_num) {
		if (check_num < 2) {// 1は素数ではない
			return false;
		}
		if (check_num == 2) {// ２は素数
			return true;
		}
		if (check_num % 2 == 0) {// 偶数は素数でない
			return false;
		}

		double sqrtNum = Math.sqrt(check_num);
		for (int k = 3; k <= sqrtNum; k = k + 2) {
			if (check_num % k == 0) {
				return false;
			}
		}
		return true;

	}
}



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

#define fi first
#define se second

const int N = 100100;
const int mod = 998244353;

using namespace std;

int n, a[N];

int main()
{
    ios_base::sync_with_stdio(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    reverse(a + 1, a + n + 1);

    int l = 1;
    while(l + 1 <= n && a[l + 1] >= l + 1) l += 1;

    int r = 0;
    while(l + r <= n && a[l + r] >= l) r += 1;

    l = a[l] - l + 1;
    cout << (r % 2 == 0 || l % 2 == 0 ? "First" : "Second") << "\n";
}



Measured memory_bytes: 640
const main = input => input.split('\n').slice(1).filter(x => x).map(line => line.split('').map(x => x === '#' ? 1 : 0)).map((vs, i, matrix) => vs.map((v, j) => v ? '#' : [i - 1, i, i + 1].filter(x => matrix[x]).map(x => [j - 1, j, j + 1].filter(y => matrix[x][y]).length).reduce((a, b) => a + b)).join('')).join('\n');

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 10444
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val array = IntArray(n){sc.nextInt()}
    var cnt = 0
    (1 until n).forEach { i ->
        (n - 1 downTo i).forEach { j ->
            if (array[j] < array[j - 1]) {
                array.swap(j, j - 1)
                cnt++
            }
        }
    }
    println(array.joinToString(" "))
    println(cnt)
}

fun IntArray.swap(index1: Int, index2: Int) {
    val temp = this[index1]
    this[index1] = this[index2]
    this[index2] = temp
}


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

int main() {
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  if (abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d)) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}

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

using namespace std;

int main(){
    int N;
    double x;
    string u;
    cin >> N;
    double ans = 0.0;
    for(int i = 0; i < N; ++i){
        cin >> x >> u;
        if(u == "JPY"){
            ans += x;
        }else{
            ans += 380000.0*x; 
        }
    }

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC096_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();
            char[][] map = new char[h][w];
            for (int i = 0; i < h; i++) {
                map[i] = in.next().toCharArray();
            }

            String ans = "Yes";
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (map[i][j] == '.') {
                        continue;
                    }

                    boolean cantFlag = true;
                    if (0 < i) {
                        if (map[i - 1][j] == '#') {
                            cantFlag = false;
                        }
                    }

                    if (0 < j) {
                        if (map[i][j - 1] == '#') {
                            cantFlag = false;
                        }
                    }

                    if (i < h - 1) {
                        if (map[i + 1][j] == '#') {
                            cantFlag = false;
                        }
                    }

                    if (j < w - 1) {
                        if (map[i][j + 1] == '#') {
                            cantFlag = false;
                        }
                    }

                    if (cantFlag) {
                        ans = "No";
                        break;
                    }
                }
            }

            out.print(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    cout << (n + 1) / 2 << "\n";
}

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

int main() {
  string a, b;
  cin >> a >> b;

  int n = a.size(), m = b.size();

  if (n > m) {
    cout << "GREATER" << endl;
  } else if (n < m) {
    cout << "LESS" << endl;
  } else {
    for (int i = 0; i < n; i++) {
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        return 0;
      } else if (a[i] < b[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
    ll n;
    cin >> n;
    ll ar[n];
    for(ll  i = 0; i < n; i++)
    {
        cin>>ar[i];

    }
    ll cnt=0;
    for(ll i=1; i< n ; i++){
        if(ar[i-1] >= ar[i]){
            cnt+=  abs(ar[i-1]- ar[i]);
             ar[i]=ar[i-1];
        }
    }
    cout<<cnt;
}

int main(){
    int t=1; 
    // cin>>t;
    while(t--){
   
    solve();
    }

}


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

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

long long MOD = 1000000000 + 7;
// modint
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;


int main(){
  cout << setprecision(10);
  int N; cin >> N;
  string S; cin >> S;
  map<char,int> m;
  for(auto c: S){
    m[c]++;
  }
  mint ans = 1;
  for(auto x: m){
    cerr << x.first << " " << x.second << endl;
    ans *= (x.second+1);
  }
  cout << ans-1 << endl;
}



Measured memory_bytes: 3764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int a,b,c;cin>>a>>b>>c;
  int x;
  x = 10*a+b+c;
  if(x<10*b+a+c){
    x=10*b+a+c;
  }
  if(x<10*c+a+b){
    x=10*c+a+b;
  }
  cout<<x<<endl;
}

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

int main()
{
	int64_t n;
	cin >> n;
	int64_t a[n];
	for (auto &i : a)
	{
		cin >> i;
	}
	auto score = [&](int64_t b) {
		int64_t r = 0;
		for (int64_t i = 0; i < n; i++)
		{
			r += abs(a[i] - (b + i + 1));
		}
		return r;
	};
	int64_t l = -(1ll << 40), r = (1ll << 40);
	while (3 <= r - l)
	{
		int64_t ll = (2 * l + r) / 3, rr = (l + 2 * r) / 3;
		int64_t sl = score(ll), sr = score(rr);
		if (sl <= sr)
		{
			r = rr;
		}
		else
		{
			l = ll;
		}
	}
	cout << score(l + 1) << endl;
	return 0;
}

Measured memory_bytes: 1792
def insertionSort(arr)
  puts arr.join(' ')
  (1..(arr.length - 1)).each {|i|
    v = arr[i]
    j = i - 1
    while j >= 0 and arr[j] > v
      arr[j + 1] = arr[j]
      j = j - 1
    end
    arr[j+1] = v
    puts arr.join(' ')
  }
end

n = STDIN.gets.to_i
arr = STDIN.gets.split(' ').map{ |x| x.to_i }
insertionSort(arr)

Measured memory_bytes: 8760
N, C = map(int, input().split())
stc = [None] * N
for i in range(N):
    stc[i] = list(map(int, input().split()))
stc.sort()
recorders = []
for s, t, c in stc:
    ok = False
    for i, rec in enumerate(recorders):
        t2, c2 = rec
        if c == c2 and t2 <= s or c != c2 and t2 < s:
            recorders[i] = [t, c]
            ok = True
            break
    if not ok:
        recorders.append([t, c])
print(len(recorders))


Measured memory_bytes: 57688
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    L = [0] * n
    R = [0] * n
    for i in range(n):
        L[i] = i + 1 + A[i]
        R[i] = i + 1 - A[i]

    DL = Counter(L)
    DR = Counter(R)

    res = 0
    for k, v in DL.items():
        if DR.get(k, 0) != 0:
            res += DR.get(k) * v
        else:
            DR[k] = v

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 83968
#include <stdio.h> 
int main(){
  int N,i,a,k;
  int s[10001];
  scanf("%d", &N);
  for(i=0;i<N;i++){
  scanf("%d",&a);
  s[i]=a;
  }
  int y;
  for(i=0;i<N;i++){
  y = s[i]; 
      while((y%2)==0){
      y=y/2;
      k++; 
      if((y%2)!=0){
      break;
      }
  }
  } 

  printf("%d",k);
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = tuple<int, int>;

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

P ps[10100];

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

    while(true){
        int N, M;
        std::cin >> N >> M;
        if(!N){break;}

        for(int i=0;i<N;++i){
            std::cin >> snd(ps[i]) >> fst(ps[i]);
        }

        sort(ps, ps+N);
        reverse(ps, ps+N);

        ll res = 0ll;
        for(int i=0;i<N;++i){
            int p, d;
            tie(p, d) = ps[i];
            int x = min(M, d), y = d - x;

            res += 1ll * y * p;
            M -= x;
        }

        std::cout << res << std::endl;
    }
}



Measured memory_bytes: 3184
#include <iostream>

using namespace std;

int cache[45];

int fibonacci(int n) {
    if (cache[n] != -1) {
        return cache[n];
    } else {
        int ret = fibonacci(n - 1) + fibonacci(n - 2);
        cache[n] = ret;
        return ret;
    }
}

int main() {
    for (int i = 0; i < 45; ++i)
        cache[i] = -1;
    cache[0] = cache[1] = 1;

    int n;
    cin >> n;
    cout << fibonacci(n) << '\n';
}



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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
long long gcd(long long a, long long b);
long long lcm(long long a, long long b);

void solve()
{
    ll a, b;
    cin >> a >> b;
    ll ans = lcm(a, b);
    cout << ans << "\n";
}

int main()
{
    solve();
    return 0;
}

long C(long n, long r)
{
    if (n < r)
        return 0;
    long p[n + 1][n + 1];
    p[0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        p[i][0] = 1;
        p[i][i] = 1;
        for (int j = 1; j <= i - 1; j++)
        {
            p[i][j] = p[i - 1][j] + p[i - 1][j - 1];
        }
    }
    return p[n][r];
}

long long gcd(long long a, long long b)
{
    if (a < b)
        swap(a, b);
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

long long lcm(long long a, long long b)
{
    return (max(a, b) / gcd(a, b)) * min(a, b);
}

Measured memory_bytes: 256
N=int(input())
A=[]*N
A=input().split()
c=True
for i in range(N):
    A[i]=int(A[i])
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            c=False
if (c==True):
    print('APPROVED')
else:
    print('DENIED')

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

bool isSecond(int a, int b, int c){
    return (c > b && a <= b) || (a > b && c <= b);
}

int main(){
    int n;
    cin >> n;
    int v[n]= {};
    for(int i=0; i<n; i++)  cin >> v[i];
    
    int count = 0;
    for(int i=1; i<n-1; i++){
        if(isSecond(v[i-1], v[i], v[i+1])) count++;
    }
    cout << count << endl;
    return 0;
}


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

using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);

}

int LIS(vector <int> &a) {
    vector <int> b;
    for (int x : a) {
        auto Pos = lower_bound(b.begin(), b.end(), x + 1);
        if (Pos == b.end()) b.push_back(x);
        else *Pos = x;
    }
    return (int)b.size();
}
void solve() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int &x: a) cin >> x;
    reverse(a.begin(), a.end());
    cout << LIS(a);
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


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

int di[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dj[] = {1, -1, 0, 0, 1, -1, 1, -1};
int main() {
    int h, w;
    while (cin >> h >> w, h) {
        vector<string> s(h);
        for (auto &si: s) cin >> si;
        set<string> se;
        vector<string> res;
        for (int k = 0; k < 8; k++) {
            for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
                string tmp;
                int ni = i, nj = j;
                do {
                    (ni += di[k] + h) %= h;
                    (nj += dj[k] + w) %= w;
                    tmp += s[ni][nj];
                    if (se.count(tmp)) res.emplace_back(tmp);
                    else se.emplace(tmp);
                } while (ni != i || nj != j);
            }
        }
        int len = 0;
        for (auto &si: res) len = max(len, (int)si.size());
        string ans = string(len, 'a');
        for (auto &si: res) if (si.size() == len) ans = min(ans, si);
        if (len < 2) cout << 0 << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 36388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		if (a == 1) a = 14;
		int b = Integer.parseInt(sc.next());
		if (b == 1) b = 14;
		System.out.println((a > b)? "Alice" : (a < b)? "Bob" : "Draw");
	}
}

Measured memory_bytes: 22996
//
//  main.c
//  Space Coconut Grab
//
//  Created by x15071xx on 2016/06/09.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int x=0,y=0,z=0;
    int e,m=99999;
    
    
    while (1) {
        
        m=99999999;
        
        scanf("%d",&e);
        
        if (e==0) {
            break;
        }
        
        for (z=0; z*z*z <= e; z++) {
            for (y=0; y*y + z*z*z <= e; y++) {
                x = e - z*z*z - y*y;
                if (m > x+y+z){
                    m = x+y+z;
                }
            }
        }
        printf("%d\n",m);
    }
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,b[N];
long long k,x[N],tmp[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&x[i]);
	for(int i=n;i;i--)	x[i]-=x[i-1];
	scanf("%d%lld",&m,&k);
	for(int i=1;i<=n;i++)	b[i]=i;
	for(int x,i=1;i<=m;i++){
		scanf("%d",&x);
		swap(b[x],b[x+1]);
	}
	while(k){
		if(k&1){
			for(int i=1;i<=n;i++)	tmp[i]=x[i];
			for(int i=1;i<=n;i++)	x[i]=tmp[b[i]];
		}
		k>>=1;
		for(int i=1;i<=n;i++)	tmp[i]=b[i];
		for(int i=1;i<=n;i++)	b[i]=tmp[tmp[i]];
	}
	double sum=0;
	for(int i=1;i<=n;i++)
		sum+=x[i],printf("%.1lf\n",sum);
	return 0;
}


Measured memory_bytes: 3456
#! /usr/bin/python
# -*- coding: utf-8 -*-

def main():
    # input
    while(True):
        try:
            data = int(raw_input())
            print(countArea(data))
        except EOFError:
            break

def countArea(n):
    ans = 2
    while(n > 1):
        ans = ans + n
        n -= 1

    return ans

if __name__=='__main__':
    main()

Measured memory_bytes: 4200
#include <functional>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

//#define NDEBUG

int main()
{
    string t, p;
#ifndef NDEBUG
    cin >> t;
    cin >> p;
#else
    t = "aizucamp";
    p = "azu";
    // t = "abracadabra";
    // p = "rada";
    t = "aabc";
    p = "aabc";
#endif

    t += "$";
    p += "$";

    auto ppc = [](const std::string& s, int n, const std::vector<bool>& v) {
        stringstream ss;
        for (int i = 0; i < s.size(); ++i) {
            if (v[i]) {
                ss << "\033[31m";
            }
            if (i == n) {
                ss << "[" << s[i] << "]";
            }
            else {
                ss << s[i];
            }
            if (v[i]) {
                ss << "\033[0m";
            }
        }
        return ss.str();
    };
    auto pp = [](const std::string& s, int n) {
        stringstream ss;
        for (int i = 0; i < s.size(); ++i) {
            if (i == n) {
                ss << "[" << s[i] << "]";
            }
            else {
                ss << s[i];
            }
        }
        return ss.str();
    };
    auto ppp = [ppc, pp] {

    };

    vector<bool> exists(p.size() - 1);
    bool duplicated = false;
    int i = 0;
    int j = 0;
    char tmp = '!';
    while (j != t.size()) {
#ifdef NDEBUG
        cout << "T " << pp(t, j) << endl;
        cout << "P " << ppc(p, i, exists) << endl;
        cout << tmp << endl;
        cout << boolalpha << "duplicate: " << duplicated << "\n" << endl;
#endif
        if (p[i] == t[j]) {
            if (!exists[i]) {
                exists[i] = true;
                tmp = p[i];
                i += 1;
            }
        }
        else if (tmp == t[j]) {
            duplicated = true;
        }
        else {
            if (exists[i]) {
                i += 1;
            }
        }
        j += 1;
    }
#ifdef NDEBUG
    cout << "T " << pp(t, j) << endl;
    cout << "P " << ppc(p, i, exists) << endl;
    cout << tmp << endl;
    cout << boolalpha << "duplicate: " << duplicated << "\n" << endl;
#endif
    if (accumulate(begin(exists), end(exists), true, logical_and<>())) {
        if (!duplicated) {
            cout << "yes" << endl;
            return 0;
        }
    }
    cout << "no" << endl;
}

Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c1 = sc.nextInt();
		int c2 = sc.nextInt();

		int N[][];
		N = new int[c1][2];

		int M[][];
		M = new int[c2][2];

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

			N[i][0] = sc.nextInt();
			N[i][1] = sc.nextInt();
			// System.out.println(N[i][0] + "." +N[i][1]);
		}

		for (int i=0; i < c2; i++){
			M[i][0] =  sc.nextInt();
			M[i][1] =  sc.nextInt();
		}

		int md = 0;
		int cp =0;
		for (int i =0;i < c1; i++){
			md = 2147483647;
			cp =0;
			for (int j=0; j < c2; j++){
				int d = Math.abs(N[i][0]-M[j][0]) + Math.abs(N[i][1]-M[j][1]);
				if (d < md){
					md = d;
					cp = j +1;
				}
			}
			System.out.println(cp);
		}

		sc.close();
	}

}


Measured memory_bytes: 21844