akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    ll N,L;
    cin >>N>>L;

    ll Napp=N*(N-1)/2+N*L;
    ll ms=LLINF,m;
    rep(i,N){
        if(chmin(ms,abs(L+i)))m=L+i;
    }
    
    cout << Napp-m <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
const int N=3e3+10;
const long double pi=acos(-1);
int main(){
	int n,a[N],pos,l;
	long double x=0,y=0;
  	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
		long double theta=(a[i]+a[j])*pi/l;
      	int cnt1=j-i-1;
      	int cnt2=n-2-cnt1;
		x+=cos(theta)*(cnt2-cnt1);
		y+=sin(theta)*(cnt2-cnt1);
	}
	long long int tot=1LL*n*(n-1)*(n-2)/6;
	printf("%.20lf %.20lf\n",(double)x/tot,(double)y/tot);
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int a[20],n;
int main(){
    char c=getchar();
    while(c>47)a[++n]=c-48,c=getchar();
    bool ok=1;
    for(int i=2;i<=n;++i)if(a[i]!=9)ok=0;
    int ans=9*(n-1)+a[1];
    if(!ok)--ans;
    printf("%d\n",ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 256
wordDic={}

for ascii in range(97, 123):
    wordDic[chr(ascii)]=0

while True:
    try:
        word = input().lower()
        for key in wordDic:
            for char in range(len(word)):
                if key==word[char]:
                    wordDic[key]=wordDic[key]+1
    except EOFError:
        break
    
for key in wordDic:
    print(key+" : "+str(wordDic[key]))
    
#reading lines by EOF in Python is not identical to doing it in C or C+++, I think this is one of the most simple or intuitive.



Measured memory_bytes: 5560
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint=====================================
N, K = map(int, input().split())
N, M = map(int, input().split())
A, B = map(int, input().split())

H, W = map(int, input().split())

L, R = map(int, input().split())

1行のstring=================================
S, T = input().split()

1行の整数配列================================
P = list(map(int,input().split()))

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
D = list(map(int,input().split()))

L = list(map(int,input().split()))
R = list(map(int,input().split()))

T = list(map(int,input().split()))

改行あり整数==================================
X = []
Y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    X.append(x1)
    Y.append(y1)

A = []
for i in range(N):
    a=int(input())
    A.append(a)

Pair = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    Pair.append((x1, y1))
    
2次元整数配列=====================================
A = []
for i in range(N):
    tmp = list(map(int,input().split()))
    A.append(tmp)


N行M列の初期化====================================
dp = [[VAL] * RETU for i in range(GYO)]

'''




N, M = map(int, input().split())
H = list(map(int,input().split()))
A = []
B = []
for i in range(M):
    x1,y1=[int(i) for i in input().split()]
    x1 -= 1
    y1 -= 1
    A.append(x1)
    B.append(y1)

near = [] # i番目の展望台と隣接している展望台の高さ
for i in range(N):
    near.append([])

for i in range(M):
    near[A[i]].append(H[B[i]])
    near[B[i]].append(H[A[i]])

ans = 0
for i in range(N):

    my_height = H[i]

    is_highest = True;
    for h in near[i]:
        if my_height <= h:
            is_highest = False
            break

    ans += is_highest

print(ans)

Measured memory_bytes: 33188
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,W = map(int,input().split())
w = []
h = []
for i in range(n):
    a,b = map(int,input().split())
    w.append(a)
    h.append(b)
dp = [[0]*(W+1) for i in range(n+1)]
for i in range(n):#i番目の種類の荷物まで使う
    for j in range(W+1):
        if j < w[i]: dp[i+1][j] = dp[i][j]#更新できない
        else:
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+h[i])
print(dp[n][W])

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

int main(){
    ll n;
    cin >> n;
    string ans = "Three";
    rep(i, 0, n) {
        char c;
        cin >> c;
        if(c == 'Y') ans = "Four";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
int n,m,ansx,ansy,ans,a[100005],b[100005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<m;i++)scanf("%d",&b[i]);
	for(int i=0;i<n-1;i++)
	{
		int x=(a[i+1]-a[i])%md;
		x=1ll*x*(i+1)%md*(n-i-1)%md;
		ansx=(ansx+x)%md;
	}
	for(int i=0;i<m-1;i++)
	{
		int y=(b[i+1]-b[i])%md;
		y=1ll*y*(i+1)%md*(m-i-1)%md;
		ansy=(ansy+y)%md;
	}
	int ans=1ll*ansx*ansy%md;
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	int m, i, j, k, tong[27], tong1[27];
	char a[1000];
	while(scanf("%d",&m)!=EOF) {
		memset(tong,0,sizeof(tong));
		memset(tong1,0,sizeof(tong));
		m--;
		scanf("%s",a);
		j = strlen(a);
		for(i=0;i<j;i++) {
			tong[a[i]-'a']++;
		}
		while(m--){
			scanf("%s",a);
			j = strlen(a);
			for(i=0;i<j;i++) {
				tong1[a[i]-'a']++;
			}
			for(i=0;i<26;i++) {
				if(tong1[i]<tong[i]) {
					tong[i]=tong1[i];
				}
			}
			memset(a,0,sizeof(a));
			memset(tong1,0,sizeof(tong1));
		}
		for(i=0;i<27;i++) {
		//	printf("%d ",tong[i]);
			if(tong[i]>0) {
				tong[i]-=1;
				printf("%c",i+'a');
				i--;
			}
			else{
			//	printf(",,,");
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 128
from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]
dot_cnt = 0
for g in grid:
    dot_cnt += g.count('.')
sy = 0
sx = 0
gy = H - 1
gx = W - 1

deq = deque()
deq.append((0, 0))
grid[0][0] = 0

y_list = [-1, 1, 0, 0]
x_list = [0, 0, -1, 1]

while deq:
    y, x = deq.popleft()
    if y == gy and x == gx:
        break
    for i in range(len(y_list)):
        dy = y + y_list[i]
        dx = x + x_list[i]
        if dy < 0 or H <= dy or dx < 0 or W <= dx:
            continue
        if grid[dy][dx] == '.':
            deq.append((dy, dx))
            grid[dy][dx] = grid[y][x] + 1
if grid[gy][gx] == '.':
    print(-1)
else:
    print(dot_cnt - (grid[gy][gx] + 1))


Measured memory_bytes: 3316
k = int(input())
lis = [i for i in range(1,10)]
tmp = [i for i in range(1,10)]
while len(lis)<k+1:
    tmp2 = []
    for i in tmp:
        la = i%10
        if la==0:
            tmp2.append(i*10)
            tmp2.append(i*10+la+1)
        elif la==9:
            tmp2.append(i*10+la)
            tmp2.append(i*10+la-1)
        else:
            tmp2.append(i*10+la-1)
            tmp2.append(i*10+la)
            tmp2.append(i*10+la+1)
    lis.extend(tmp2)
    tmp = [i for i in tmp2]

lis.sort()
#print(lis)
print(lis[k-1])


Measured memory_bytes: 92768
#include <bits/stdc++.h>
using namespace std;
long long n,s1,s2,vals[200005],sufans[200005],prefans[200005];

int main(){
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 0 ; i < n ; i += 1){
        cin >> vals[i];
        if(i % 2 == 0){
            s1 += vals[i];
        }else{
            s2 += vals[i];
        }
    }
    for(int i = n-1 ; i >= 0 ; i -= 1){
        if((n-i)%2 == 0){
            sufans[i] = vals[i] + max(sufans[i+2],sufans[i+3]);
        }else{
            sufans[i] = vals[i] + sufans[i+2];
        }
    }
    for(int i = 0 ; i < n ; i += 1){
        if((i+1)%2 == 0){
            long long a = -1000000000000000000;
            if(i-3 >= 0){
                a = prefans[i-3];
            }
            prefans[i] = vals[i]+max(prefans[i-2],a);
        }else{
            long long a = 0;
            if(i-2 >= 0){
                a = prefans[i-2];
            }
            prefans[i] = vals[i]+a;
        }
    }
    if(n % 2 == 0){
        cout << max(prefans[n-1],prefans[n-2]) << endl;
        return 0;
    }
    long long maxi = sufans[2];
    for(int i = 0 ; i+3 <= n ; i += 1){
        if((i+1)%2 == 0){
            maxi = max(maxi,sufans[i+3]+max(prefans[i],prefans[i-1]));
        }else{
            maxi = max(maxi,prefans[i]+max(sufans[i+3],sufans[i+4]));
        }
    }
    cout << max(maxi,prefans[n-2]) << endl;
}

Measured memory_bytes: 8324
import java.io.*;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String s=sc.nextLine();
    String t=sc.nextLine();
    t=t.substring(0,t.length()-1);
    if(s.equals(t))
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 35736
//#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<iostream>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const ll maxn=1e6+5;
const int mod=998244353;
ll n,m,p;
ll x,y;
vector<int>v[15][15];
int work(int x)
{
    int ans;
    while(x)
    {
        ans=x;
        x/=10;
    }
    return ans;
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        v[i%10][work(i)].push_back(i);
    /*for(int i=1;i<=9;i++)
        sort(v[i].begin(),v[i].end());*/
    ll res=0;
    for(int i=1;i<=n;i++)
    {
        int temp=work(i);
        if(temp) res+=v[temp][i%10].size();
    }
    printf("%lld\n",res);
    return 0;
}
/***
***/


Measured memory_bytes: 1536
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;
typedef long long ll;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n,W;
    cin>>n>>W;
    ll w[n+1],v[n+1];
    for(int i=0;i<=n-1;i++){
        cin>>w[i+1]>>v[i+1];
    }
    ll dp[n+1][n*1000+1];
    dp[0][0]=0;
    for(int i=1;i<=n*1000;i++){
        dp[0][i]=1000000000000;
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n*1000;j++){
            if(j-v[i]>=0){
                dp[i][j]=min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
            }else{
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    ll m;
    for(int i=0;i<=n*1000;i++){
        if(dp[n][i]<=W){
            m=i;
        }
    }
    cout<<m<<endl;
    return 0;
}



Measured memory_bytes: 79104
my ($N) =split(/ /,<>);

my $s = <>; chomp $s;
my @dat = split(//,$s);

my $WC=0;
my $RC=0;
my @DB;

for(my $i=0;$i<$N;$i++){
    if( $dat[$i] eq "W"){ $WC++;}
    #if( $dat[$i] eq "W"){ $WC++;}
    $DB[$i] = $WC;
}

for(my $i=1;$i<=$N;$i++){
    if( $RC>= $DB[-$i]){ last;}
    if( $dat[-$i] eq "R"){ $RC++;}
}

print "$RC";

Measured memory_bytes: 27008
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    int n;
    cin >> n;
    vector<int> list(n + 1);
    rep(i, n - 1)
    {
        int a;
        cin >> a;
        ++list[a];
    }

    rep(i, n)
    {
        cout << list[i + 1] << endl;
    }
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;
int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for(ll &a : A) cin >> a;
    vector<ll> dp(K + 10, 0);
    dp[0] = 1;
    for(ll i = 0; i < N; i++){
        vector<ll> tmp(K + 10);
        vector<ll> sum(dp.size() + 1);
        for(ll j = 0; j <= K; j++) sum[j + 1] = (sum[j] + dp[j]) % MOD;
        for(ll j = 0; j <= K; j++){
            ll left = max<ll>(0, j - A[i]);
            ll right = j + 1;
            tmp[j] = (sum[right] - sum[left] + MOD) % MOD;
        }
        dp = move(tmp);
    }
    cout << dp[K] << endl;
    return 0;
}


Measured memory_bytes: 2640
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	mm := make([]int, n+1)
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, n+1)
	}
	for i := 0; i < n; i++ {
		mm[i] = getNextInt(scanner)
		mm[i+1] = getNextInt(scanner)
	}

	for l := 2; l <= n; l++ {
		for i := 1; i <= n-l+1; i++ {
			j := i + l - 1
			for k := i; k <= j-1; k++ {
				d := dp[i][k] + dp[k+1][j] + mm[i-1]*mm[k]*mm[j]
				if dp[i][j] == 0 || dp[i][j] > d {
					dp[i][j] = d
				}
			}
		}
	}

	fmt.Fprintln(writer, dp[1][n])

	writer.Flush()
}



Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v1(n),v2(n);
  for(int i=0;i<n;i++){
    cin>>v1[i];
  }
  v2[0]=0;
  v2[1]=abs(v1[1]-v1[0]);
  for(int i=2;i<n;i++){
    v2[i]=min(abs(v1[i-1]-v1[i])+v2[i-1],abs(v1[i-2]-v1[i])+v2[i-2]);
  }
  cout<<v2[n-1];
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)
n=int(input())
a=[[] for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    a[u-1].append((v-1,w))
    a[v-1].append((u-1,w))
b=[None for i in range(n)]
def k(v,dis):
    b[v]=dis
    for next_v,w in a[v]:
        if b[next_v]!=None:
            continue
        if w%2==0:
            k(next_v,dis)
        else:
            k(next_v,1-dis)
k(0,0)
for i in range(n):
    print(b[i])

Measured memory_bytes: 79488
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(int n){return n==0?1:10*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

const int mod = TEN(9) + 7;

int N, M;
vector<pii> edges;
struct UF {
    vi data;
    void init(int n)
    {
        data.resize(n);
        fill(all(data), -1);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (size(x) < size(y)) swap(x, y);
        data[x] += data[y];
        data[y] = x;
    }
    bool same(int x, int y)
    {
        return root(x) == root(y);
    }
    int size(int x)
    {
        x = root(x);
        return -data[x];
    }
    bool is_root(int x)
    {
        return x == root(x);
    }
};

UF uf;

signed main()
{
    cin >> N >> M;

    rep(i, M) {
        int a, b; cin >> a >> b;
        --a, --b;
        edges.emplace_back(a, b);
    }

    int ans = 0;

    rep(i, M) {
        uf.init(N);

        rep(j, M) {
            if (i == j) continue;
            uf.unite(edges[j].fst, edges[j].scd);
        }

        if (uf.size(0) < N) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

typedef struct{
	long long int code;
	int steps;
} puzz;

int q[10000000][14],size[30000];
long long int FR,TO,SW;
puzz* hash[30000][100];

void swap (int* x,int* y){
	int z;
	z=*x;
	*x=*y;
	*y=z;
}

long long int convert(int a[]){
	long long int ret=0;
	int i;
	for(i=0;i<13;i++)ret=ret*13+a[i];
	return ret;
}

void hashadd(long long int code,int step){
	int ccc=code%30000;
	puzz* ppp=(puzz*)malloc(sizeof(puzz));
	ppp->code=code;
	ppp->steps=step;
	if(size[ccc]>99){fprintf(stderr,"SIZE OVER!! (%d)\n",ccc);return;}
	hash[ccc][size[ccc]]=ppp;
	size[ccc]++;
}

int hashsearch(long long int code){
	int ccc=code%30000;
	int i=size[ccc]-1;
	for(;i>=0;i--){
		if(hash[ccc][i]->code==code)return hash[ccc][i]->steps;
	}
	return -1;
}

void mark(int x,int y){
	int k;
	long long int cd;

	swap(&q[FR][x],&q[FR][y]);
	cd=convert(q[FR]);

	if(SW==1 || hashsearch(cd)<0){
		for(k=0;k<14;k++){q[TO][k]=q[FR][k];}
		q[TO][13]++;
		if(SW==0)hashadd(cd,q[TO][13]);
		TO++;
	}

	swap(&q[FR][x],&q[FR][y]);

}

void check(){
	if(q[FR][0]==0){mark(0,2);}
	if(q[FR][1]==0){mark(1,2);mark(1,5);}
	if(q[FR][2]==0){mark(2,0);mark(2,1);mark(2,3);mark(2,6);}
	if(q[FR][3]==0){mark(3,2);mark(3,7);}
	if(q[FR][4]==0){mark(4,5);}
	if(q[FR][5]==0){mark(5,1);mark(5,4);mark(5,6);mark(5,9);}
	if(q[FR][6]==0){mark(6,2);mark(6,5);mark(6,7);mark(6,10);}
	if(q[FR][7]==0){mark(7,3);mark(7,6);mark(7,8);mark(7,11);}
	if(q[FR][8]==0){mark(8,7);}
	if(q[FR][9]==0){mark(9,5);mark(9,10);}
	if(q[FR][10]==0){mark(10,6);mark(10,9);mark(10,11);mark(10,12);}
	if(q[FR][11]==0){mark(11,7);mark(11,10);}
	if(q[FR][12]==0){mark(12,10);}
}


int main(){
	int i,ans;
	long long int cd;

	for(i=1;i<12;i++)q[0][i]=i;
	q[0][0]=0;q[0][12]=0;q[0][13]=0;
	hashadd(convert(q[0]),0);

	FR=0;TO=1;SW=0;

	while(FR<TO && q[FR][13]<=13){
		check();
		FR++;
	}

	while(scanf("%d",&q[0][0])*q[0][0]>=0){
		for(i=1;i<13;i++)scanf("%d",&q[0][i]);
		q[0][13]=0;FR=0;TO=1;SW=1;ans=9999;
		//for(i=0;i<30000;i++)size2[i]=0;

		while(FR<TO){
			cd=hashsearch(convert(q[FR]));
			if(cd>=0){
				ans=(int)cd+q[FR][13];
				break;
			}
			if(q[FR][13]<6)check();
			FR++;
		}

		if(ans>20)printf("NA\n"); else printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 36712
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main()
{string s;
  cin >> s;
REP(i,s.size()){
if(s[i]!=s[s.size()-i-1]){
  cout << "No";
  return 0;
}
}
REP(i,(s.size()-1)/2){
if(s[i]!=s[(s.size()-1)/2-1-i]){
  cout << "No";
  return 0;
}
}
for(int i = 0;i<(s.size()-1)/2;i++){
if(s[i+(s.size()+3)/2-1]!=s[s.size()-i-1]){
  cout << "No";
  return 0;
}
}
cout << "Yes";
return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  ll m = min(A,B);
  m = min(m,C);
  m = min(m,D);
  m = min(m,E);
  
  ll t = (N + m - 1) / m + 4; 
  
  cout << t << endl;   
}

Measured memory_bytes: 256
T=int(input())
for i in range(T):
    N,A,B,C,D=map(int,input().split())

    M={0:0,1:D}

    def f(N):
        if N in M:
            return M[N]
        
        p,q=N//2*2,(N+1)//2*2
        r,s=N//3*3,(N+2)//3*3
        t,u=N//5*5,(N+4)//5*5
        R=min(D*N,
              D*abs(N-p)+A+f(p//2),
              D*abs(N-q)+A+f(q//2),
              
              D*abs(N-r)+B+f(r//3),
              D*abs(N-s)+B+f(s//3),
              
              D*abs(N-t)+C+f(t//5),
              D*abs(N-u)+C+f(u//5),
              )

        M[N]=R
        return R
    
    print(f(N))

Measured memory_bytes: 96152
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
a = [i for i in range(10)]
for num in itertools.product(a, repeat=3):
    p = 0
    for i,j in enumerate(s):
        if j == str(num[p]):
            p += 1
            if p == 3:
                res += 1
                break
print(res)

Measured memory_bytes: 67544
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e10
)

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)

	x, n := nextInt(), nextInt()
	if n == 0 {
		fmt.Println(x)
		return
	}

	m := make(map[int]bool)
	for i := 0; i < n; i++ {
		m[nextInt()] = true
	}

	for i := 0; i <= x; i++ {
		if _, ok := m[x-i]; !ok {
			fmt.Println(x-i)
			return
		}
		if _, ok := m[x+i]; !ok {
			fmt.Println(x+i)
			return
		}
	}
}

func intSlicePrint(el ...int) {
	first := true
	for _, v := range el {
		if v < 0 {
			continue
		}
		if !first {
			fmt.Printf(" ")
		}
		fmt.Printf("%v", v)
		first = false
	}
	fmt.Println("")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1772
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class DVariousSushi {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            pair[] food = new pair[n];
            for (int i = 0; i < n; ++i) {
                food[i] = new pair();
                food[i].t = in.nextInt();
                food[i].d = in.nextInt();
            }
            Arrays.sort(food, (a, b) -> (b.d - a.d));
            PriorityQueue<Integer> dup = new PriorityQueue<>();
            HashSet<Integer> vis = new HashSet<>();
            long sum = 0;
            for (int i = 0; i < k; ++i) {
                if (vis.contains(food[i].t)) dup.add(food[i].d);
                else vis.add(food[i].t);
                sum += food[i].d;
            }

            long ans = sum + (long) vis.size() * vis.size();
            for (int i = k; i < n && !dup.isEmpty(); ++i) {
                if (!vis.contains(food[i].t)) {
                    vis.add(food[i].t);
                    sum -= dup.poll() - food[i].d;
                    ans = Math.max(ans, sum + (long) vis.size() * vis.size());
                }
            }
            out.println(ans);
        }

        private class pair {
            int d;
            int t;

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int main(){
    vector<int>a(3);
    int d;
    for(int i=0; i<3; i++) cin >> a[i];
    cin >> d;

    if(abs(a[2]-a[0])<=d){
        cout << "Yes" << endl;
    } else if (abs(a[1]-a[0])<=d && abs(a[2]-a[1])<=d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from sys import stdin
N = int(stdin.readline().rstrip())

XL = []
for i in range(N):
    x, l = [int(_) for _ in stdin.readline().rstrip().split()]
    XL.append([x-l, x+l])
XL = sorted(XL, key=lambda x: x[1])

ans = 0
tmp = -10**9
for i in range(N):
    if XL[i][0] >= tmp:
        tmp = XL[i][1]
        ans += 1
print(ans)

Measured memory_bytes: 59868
#include<stdio.h>
	int main() {
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);

		if (a >= b && a >= c) {
			printf("%d\n", b + c);
		}
		else if (b >= a && b >= c) {
			printf("%d\n", a + c);
		}
		else {
			printf("%d\n", a+b);
		}
		


		return 0;
	}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 #define MAX 1000000000005
 #define ll long long int
 int main()
 {
  ll t,k;
        ll c=0,d=0,e,n,sum=1,i,sum1=1,sum2=1,sum3=1,r,sum4=1,a,b,f,g,h;
          cin>>a>>b>>c>>d;
            e=max(a,b);
            f=min(a,b);
            g=max(c,d);
            h=min(c,d);
           cout<<max({e*g,e*h,g*e,g*f,f*g,f*h,h*e,h*f});



 }


Measured memory_bytes: 3632
def upper_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  r
end
 
EPS = 1e-9

n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_f) }.transpose
time_set = n.times.map{ [] }
prob_set = n.times.map{ [] }

factorial = (1..m).each_with_object([1]) { |i, arr| arr << arr[-1] * i }
n.times do |i|
  s = l / v[i]
  (m + 1).times do |j|
    time_set[i] << s + t[i] * j
    prob_set[i] << (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * factorial[m] / factorial[m - j] / factorial[j]
  end
end
prob_sum = prob_set.map{ |ps| (0..m).map{ |i| ps[i..-1].reduce(:+) } }

n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    n.times do |k|
      next if i == k
      idx = upper_bound(time_set[k], time_set[i][j] + EPS)
      if idx == m + 1
        prob = 0
        break
      end
      prob *= prob_sum[k][idx]
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9244
n = int(input())
a = 0
b = list(map(int,input().split()))
for x in range(1,n-1):
    if min(b[x-1], b[x], b[x+1]) == b[x]:
        a += 0
        continue
    elif max(b[x-1], b[x], b[x+1]) == b[x]:
        a += 0
        continue
    else:
        a += 1
        continue
print(a)

Measured memory_bytes: 3060
x,n = map(int,input().split())
p = list(map(int,input().split()))
i = 0
ans = 0
while True:
  if(x-i in p):
    if(x+i in p):
      None
    else:
      ans = x+i
      break
  else:
    ans = x-i
    break
  i += 1
print(ans)

      

Measured memory_bytes: 9172
n = int(raw_input())
ls = []
bp = 0
for i in range(n):
	cmd = raw_input()
	if cmd[0] == "i":
		ls.append(cmd[7:])
	elif cmd[6] == " ":
		try:
			x = ls[::-1].index(cmd[7:])
			if x!=-1:
				del ls[-x-1]
		except:
			pass
	elif cmd[6] == "F":
		ls.pop()
	else:
		bp += 1

print " ".join(map(str, ls[bp:][::-1]))

Measured memory_bytes: 124608
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	p := newPermutation(n)
	i := p.index(aa)
	if i-1 >= 0 {
		fmt.Fprintln(writer, stringlist(p.get(i-1)))
	}
	fmt.Fprintln(writer, stringlist(p.get(i)))
	if i+1 < p[n-1]*n {
		fmt.Fprintln(writer, stringlist(p.get(i+1)))
	}
}
func stringlist(aa []int) string {
	s := make([]string, len(aa))
	for i := 0; i < len(aa); i++ {
		s[i] = fmt.Sprintf("%d", aa[i])
	}
	return strings.Join(s, " ")
}

type permutation []int

func newPermutation(n int) permutation {
	p := make(permutation, n)
	p[0] = 1
	for i := 1; i < n; i++ {
		p[i] = p[i-1] * i
	}
	return p
}
func (p permutation) index(a []int) int {
	n := len(p)
	ans := 0
	used := make([]bool, n)
	for i := 0; i < n; i++ {
		sum := 0
		used[a[i]-1] = true
		for j := a[i] - 1; j >= 0; j-- {
			if used[j] {
				continue
			}
			sum++
		}
		ans += sum * p[n-1-i]
	}
	return ans
}

func (p permutation) get(index int) []int {
	n := len(p)
	ans := make([]int, n)
	used := make([]bool, n)
	for i := 0; i < n; i++ {
		ans[i] = index / p[n-1-i]
		index %= p[n-1-i]
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if used[j] {
				continue
			}
			if ans[i] == 0 {
				ans[i] = j + 1
				used[j] = true
				break
			}
			ans[i]--
		}
	}
	return ans
}



Measured memory_bytes: 1232
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
//int a[100001];
const int INF=100000009;
int N,A,B,C;
vector<int> l;
int dfs(int cur,int a,int b,int c){
    if(cur==N){
        if(min(a,min(b,c))>0) return abs(a-A)+abs(b-B)+abs(c-C)-30;
        else return INF;
    }
    int ret0=dfs(cur+1,a,b,c);
    int ret1=dfs(cur+1,a+l[cur],b,c)+10;
    int ret2=dfs(cur+1,a,b+l[cur],c)+10;
    int ret3=dfs(cur+1,a,b,c+l[cur])+10;

    return min(min(ret0,ret1),min(ret2,ret3));
}
int main(){
    cin>>N>>A>>B>>C;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        l.push_back(a);
    }
    cout<<dfs(0,0,0,0)<<endl;
    return 0;
}

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

#define N_MAX 100001
#define NIL -1

struct node{
  int parent, sibiling, child;
};

int n;
node T[N_MAX];
int D[N_MAX];

void insert(){
  int i, j;
  int s, p, c, m, tmp_s;
  
  for(i=0; i<n; i++) T[i].parent=T[i].sibiling=T[i].child=NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &p, &m);

    for(j=0; j<m; j++){
      scanf("%d", &s);
      T[s].parent=p;
      
      if(j==0) T[p].child=s;
      else T[tmp_s].sibiling=s;

      tmp_s=s;	    
    }
  }  
}

void setd(int i, int d){
  D[i]=d;

  if(T[i].sibiling != NIL) setd(T[i].sibiling, d);
  if(T[i].child != NIL) setd(T[i].child, d+1);
}

void depth(){
  int i, root;
  
  for(i=0; i<n; i++){
    if(T[i].parent==NIL){
      root=i;
      break;
    }
  }

  setd(root, 0);
}

void print(int i){
  int j, s=T[i].child;
  printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, D[i]);

  if(T[i].parent==NIL){
    printf("root, [");
    for(j=0; ; j++){
      if(j==0){
	if(s==NIL) break;
	printf("%d", s);
	s=T[s].sibiling;
      }
      else{
	if(s==NIL) break;
	printf(", %d", s);
	s=T[s].sibiling;
      }
    }
    printf("]\n");
  }
  else if(T[i].child==NIL) printf("leaf, []\n");
  else{
    printf("internal node, [");
    for(j=0; ; j++){
      if(j==0){
	if(s==NIL) break;
	printf("%d", s);
	s=T[s].sibiling;
      }
      else{
	if(s==NIL) break;
	printf(", %d", s);
	s=T[s].sibiling;
      }
    }
    printf("]\n");
  }
}

int main(void){
  int i;

  scanf("%d", &n);
  insert();
  depth();
  
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



Measured memory_bytes: 7888
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
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; }
using namespace std;

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

    int n; cin>>n;
    vector<int> a(n);

    int abs_max=-1,use;
    rep(i,n){
        cin>>a[i];
        if(chmax(abs_max,abs(a[i]))){
            use=i;
        }
    }

    vector<P> ans;
    rep(i,n)if(i!=use){
        a[i]+=a[use];
        ans.push_back(P(use+1,i+1));
    }
    if(a[use]>=0){
        rep(i,n-1){
            if(a[i]>a[i+1]){
                a[i+1]+=a[i];
                ans.push_back(P(i+1,i+2));
            }
        }
    }else{
        for(int i=n-1; i>0; i--){
            if(a[i-1]>a[i]){
                a[i-1]+=a[i];
                ans.push_back(P(i+1,i));
            }
        }
    }

    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i].first<<' '<<ans[i].second<<endl;
    }

}

Measured memory_bytes: 256
A,B,C,K=map(int,input().split())

ans=0
if A<=K:
    K-=A
    ans=A
    if B<=K:
        K-=B
        if C<=K:
            ans-=C
        else:
            ans-=K
    else:
        B=K-B
else:
    ans=K
print(ans)

Measured memory_bytes: 9080
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize = read_as_vec()[0];

    let a = read_as_vec::<u64>();

    if a[0] != 0{
        println!("0");
        return;
    }
    let mut dp = vec![vec![0;3];n];

    dp[0][0] = 1;

    for i in 1..n{
        for j in 0..3{
            dp[i][j] = dp[i-1][j];
        }
        let mut found = false;
        for j in 0..3{
            if a[i] == dp[i][j]{
                dp[i][j] += 1;
                found = true;
                break;
            }
        }
        if !found{
            println!("0");
            return;
        }
        dp[i].sort();
        dp[i].reverse();
    }

    let mut ans = 3;

    for i in 1..n{
        ans *= dp[i-1].iter().filter(|x| **x == a[i]).count();
        ans %= 1_000_000_007;
    }

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


Measured memory_bytes: 12540
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll power(ll a,ll n)
{
	if(n==0)
	return 1;
	if(n%2==0)
	return power((a*a)%mod,n/2)%mod;
	return ((a%mod)*(power((a*a)%mod,n/2))%mod)%mod;
}


int main()
{
char s;
  cin>>s;
  if(isupper(s))
    cout<<"A";
  else
    cout<<"a";
return 0;
}

Measured memory_bytes: 3640
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
ll d[50][50],c1[505][505],ans[3][50];
int main(){
	std::ios::sync_with_stdio(false);
	ll n,c,res=inf,i,j,k,val;
	res*=inf;
	cin>>n>>c;
	rep(i,c){
		rep( j,c){
			cin>>d[i][j];
		}
	}	
	rep(i,n){
		rep(j,n){
			cin>>c1[i][j];
			c1[i][j]--;
		}
	}
	rep(i,n){
		rep(j,n){
			val=(i+j)%3;
			rep(k,c){
				ans[val][k]+=d[c1[i][j]][k];
			}
		}
	}
	rep(i,c){
		rep(j,c){
			rep(k,c){
				if(i!=j&&j!=k&&i!=k)
					res=min(res,ans[0][i]+ans[1][j]+ans[2][k]);
			}
		}
	}
	cout<<res<<endl;
} 
	

Measured memory_bytes: 2432
use std::io::Read;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let mut l: Vec<i64> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();
    l.sort();

    println!(
        "{}",
        if l[n - 1] < (&l[0..n - 1]).iter().sum() {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 4352
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);		//???????????????????????\?????£?¨?

		while(sc.hasNext()){
			String line;		//??\??????????????°?????\???????????°
			int i;		//????????????
			int a=0;		//kotae?????????????????????
			int b;
			int n=0;
			int suu;		//?????????????¶?????????°?????\????????¨??????
			String mozi;		//????????????????????°???
			int[] shoki = new int[10];
			String[] tugi = new String[2];		//???????????°????????\????????????
			String[] kotae = new String[9];		//???????????\????????????
			String[] hai = new String[10];		//??\??????????????°???String??§???????????\??????
			line = sc.nextLine();		//??\?????????????????????line???????????\??????
			hai = line.split("");		//??°?????????????????\??????
				for(int d=0; d < hai.length; d++){
					shoki[d] = Integer.parseInt(hai[d]);		//String???int????????????
				}

			while(n < 9){
				n = n + 1;
				a = 0;
				if(n>1 && n<11){
					for(b = 0;b<kotae.length ; b++){		//??????????????°????????´???
						shoki[b] = Integer.parseInt(kotae[b]);
					}
				}
				for(i = 0; i<10-n;i++){
					suu =shoki[i] +shoki[i+1];
					mozi = String.valueOf(suu);		//int????????????????????????????????\??????
					tugi= mozi.split("");		//?????????????????????????????\??????

					if(suu > 9){
						kotae[a] = tugi[1];		//????????????kotae?????????????????\??????
						a++;
					}else{
						kotae[a] = tugi[0];
						a++;
					}
				}
			}

			System.out.println(kotae[0]);
		}
	}
}

Measured memory_bytes: 26920
import java.util.*;
public class Main {

	//f©Ç¤©ð»Ê·éÖ
	private boolean isPrime(int n){
		for(int i=2; i * i <= n; i++){
			if(n % i == 0){
				return false;
			}
		}
		return true;
	}

	public void doIt(){
		Scanner sc = new Scanner(System.in);

		//GgXelXÌÓé¢
		final int MAX = 999999;
		boolean [] prime = new boolean[MAX + 1];
		for(int i=2; i < prime.length; i++){
			prime[i] = true;
		}
		for(int i=2; i * i < MAX; i++){
			if(isPrime(i)){
				for(int j = i + i; j <= MAX; j += i){
					prime[j] = false;
				}
			}
		}

		while(true){
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int sum = 0;
			int count = 1;
			for(int i=0; count <= n; i++){
				if(prime[i]){
					sum += i;
					count++;
				}
			}
			System.out.println(sum);
		}
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 13000
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream &operator << (ostream &os, const vector<T> &);
template<size_t n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, const tuple<T...> &){}
template<size_t n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream &os, const tuple<T...> &t){
    os << (n == 0 ? "" : " ") << get<n>(t); _ot<n+1>(os, t);
}
template<class...T> ostream &operator << (ostream &os, const tuple<T...> &t){
    _ot<0>(os, t); return os;
}
template<class T, class U> ostream & operator << (ostream &os, const pair<T,U> &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T> ostream &operator << (ostream &os, const vector<T> &v){
    for(size_t i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : ", "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << make_tuple(__VA_ARGS__) \
                   << " (L : " << __LINE__ << ")" << endl)
#else
#define dump(...)
#endif
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}
int const mod = 1000000007;
auto const inf = numeric_limits<int>::max()/8;

using ld = long double;
const ld eps = 1e-10;

ld bisectionMethod(ld x0, ld x1, function<ld(ld)> f){
    ld y0 = f(x0), y1 = f(x1);
    int s0 = fabs(y0) < eps ? 0 : y0 < 0 ? -1 : 1;
    int s1 = fabs(y1) < eps ? 0 : y1 < 0 ? -1 : 1;
    assert(s0 * s1 <= 0);
    if(y0 > y1) swap(x0, x1);
    ld m;
    for(int i = 0; i < 200; i++){
        m = (x0 + x1) / 2;
        if(f(m) > 0) x1 = m;
        else x0 = m;
    }
    return m;
}

vector<ld> quadraticEquation(ld a, ld b, ld c){
    ld d = b*b - 4*a*c;
    if(fabs(a) < eps) return fabs(b) > eps ? vector<ld>{ -c/b } : vector<ld>{};
    if(d < -eps) return {};
    if(d < eps) return { -b / (2*a), -b / (2*a) };
    int sign = (b >= 0) ? 1 : -1;
    ld x0 = (-b - sign * sqrt(abs(d))) / (2*a), x1 = c / (a*x0);
    return { x0, x1 };
}

vector<ld> cubicEquation(ld a, ld b, ld c, ld d){
    if(fabs(a) < eps) return quadraticEquation(b,c,d);
    if(a < 0) a = -a, b = -b, c = -c, d = -d;
    ld x0 = bisectionMethod(-1e8, 1e8, [&](ld x){
            return a*x*x*x + b*x*x + c*x + d;
        });
    ld A = 1, B = b/a + x0, C = c/a + B*x0;
    dump(A,B,C);
    auto res = quadraticEquation(A,B,C);
    dump(res);
    res.push_back(x0);
    sort(res.begin(), res.end());
    return res;
}

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        vector<ld> xs = cubicEquation(a,b,c,d);
        int neg = 0, pos = 0;
        for(auto &x : xs) if(x < -eps) ++neg; else if(x > eps) ++pos;
        cout << pos << " " << neg << endl;
    }
}

Measured memory_bytes: 3056