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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

ull INF = 1000000007;
ull dp[2002][2002];
ull sdp[2002][2002];

int main() {
  memset(dp, 0, sizeof(dp));
  memset(sdp, 0, sizeof(sdp));
  int N, M;
  cin >> N >> M;
  vector<ull> ls, lt;
  for (int i = 0; i < N; ++i) {
    ull d;
    cin >> d;
    ls.push_back(d);
  }
  for (int i = 0; i < M; ++i) {
    ull d;
    cin >> d;
    lt.push_back(d);
  }

  for (int n = 0; n < N; ++n) {
    ull s = ls[n];
    for (int m = 0; m < M; ++m) {
      ull t = lt[m];
      if (s == t) {
        dp[n][m] = 1;
        if (n > 0 && m > 0) dp[n][m] += sdp[n-1][m-1];
      }
      sdp[n][m] = dp[n][m];
      if (n > 0) sdp[n][m] += sdp[n-1][m];
      if (m > 0) sdp[n][m] += sdp[n][m-1];
      if (n > 0 && m > 0) sdp[n][m] -= sdp[n-1][m-1];
      sdp[n][m] = (sdp[n][m]+INF) % INF;
    }
  }
  cout << (sdp[N-1][M-1]+1) % INF << endl;
}


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

A = list(map(int,input().split()))
x=0
i=1
for i in range(N):
  y = A[i]-A[i-1]
  i =i+1
  if y>x:
    x=y
if ((K-A[N-1]+A[0])>x):
  x=K-A[N-1]+A[0]
print(K-x)


Measured memory_bytes: 25452
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
 
int main()
{
  int n, m, R; cin >> n >> m >> R;
  vector<int> r(R); FOR(i,0,R) cin >> r[i];
  sort(r.begin(), r.end());
  int a[m], b[m], c[m], dist[n+1][n+1];
  FOR(i,0,m) cin >> a[i] >> b[i] >> c[i];
  FOR(i,0,n+1){
    FOR(j,0,n+1){
      if(i==j) dist[i][j] = 0;
      else dist[i][j] = 1e9;
    }
  }
  // 連結してるとこはcを代入
  FOR(i,0,m){
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], c[i]);
    dist[b[i]][a[i]] = min(dist[b[i]][a[i]], c[i]);
  }
  // ワーシャルフロイド
  FOR(k,1,n+1) FOR(i,1,n+1) FOR(j,1,n+1) {
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  }
  int ans = 1e9;
  do {
    int d = 0;
    FOR(i,0,R-1) d += dist[r[i]][r[i+1]];
    ans = min(ans, d);
  } while(next_permutation(r.begin(), r.end()));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>                                                                        
using namespace std;
int main()
{
  int N;
  int ok=0;
  cin >>N;
  vector<int> p(N);
  int count=0;
  for(int i=0; i<N; i++)
    cin >> p.at(i);
  vector<int> test(N);
  for(int i=0; i<N; i++)
    test.at(i)=p.at(i);
  sort(test.begin(), test.end());
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i<j){
        swap(p.at(i),p.at(j));
      }
      for(int i=0; i<N; i++){
        if(p.at(i)==test.at(i)){
          count++;
        }
      }
      if(count==N){
        ok++;
      }
      if(i<j){
        swap(p.at(i),p.at(j));
      }
      count=0;
    }
  }
  if(ok==0)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>

#define INF 2000000000
#define MOD 1000000007

using namespace std;

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	int tmp;
	while (n--) {
		cin >> tmp;
		if (tmp % 2 == 1) {
			cnt++;
		}
	}
	if (cnt % 2 == 1) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n;
  int TYPE[5] = {10,50,100,500,1000};
  vector<int> vec;
  int firstFlag = 0;
  while(true){
    cin >> n;
    if(n == 0)break;
    if(firstFlag == 0){
      firstFlag = 1;
    }else{
      cout << endl;
    }
    vec = vector<int>(4,0);
    for(int i = 0;i < 4;i++){
      cin >> vec[i];
    }
    int ans = 0;
    int flag = -1;
    for(int i = 0;i < 4;i++){
      ans = ans + TYPE[i]*vec[i];
      /*if(ans < n){
	
      }else{
	flag = i;
	break;
	}*/
    }
    int otu = ans-n;
    int oturi[5];
    int keepO= 0;
    for(int i = 3;i >= 0;i--){
      keepO = otu%TYPE[i];
      oturi[i] = otu/TYPE[i];
      otu = keepO;
    }
    for(int i = 0;i < 4;i++){
      if(oturi[i] < vec[i]){
	cout <<TYPE[i] << " " << vec[i] - oturi[i] << endl;
      }
    }
    /*    for(int i = flag +1 ;i < 4-1;i++){
      if(i == 3 || i == 1){
	if(vec[i] >= 2){
	  cout <<TYPE[i] << " " << (vec[i]/2)*2  << endl;
	}
      }
      else{ 
	if(vec[i] >= 5){
	  cout <<TYPE[i] << " " << (vec[i]/5)*5 << endl;
	}
      }
    }

    */
    /*int keep10 = (n%50)/10;//
    if(keep10 <= vec[0]){
      vec[0] = vec[0]-keep10;
    }else{
      vec[1] = vec[1] - 1;
    }
    int keep50 = (n%100)/10 - keep10;
    if(keep50 <= vec[1]){
      vec[1] = vec[1]-keep50;
    }else{
      vec[2] = vec[2] - 1;
    }
    int keep100 = (n%500)
    */
    }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K,X,Y=3;
    cin>>N>>K>>X;
    if(N==K)Y-=1;
    if(N==X)Y-=1;
    if(K==X)Y-=1;
    if(N==K&&K==X)Y=1;
    cout<<Y<<endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= b) {
    for (int i = 0; i<b; i++) {
      cout << a;
    }
  }
  else {
    for (int i = 0; i<a; i++) {
      cout << b;
    }
  }
  cout << endl;
}

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

class Program{

  static int a, b, c, k, l;

  static int Main() {

    string[] nyu = new string[3];

    nyu = Console.ReadLine().Split(' ');
    a = int.Parse(nyu[0]);
    b = int.Parse(nyu[1]);
    c = int.Parse(nyu[2]);

    int[] nya = new int[]{a, b, c};

    k = int.Parse(Console.ReadLine());

    l = nya.Max();
    l = l * (int)Math.Pow(2, k) + a + b + c - nya.Max();

    Console.WriteLine("{0}", l);

    return 0;
  }

}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;
  ll now = 0;
  ll ans = 0;
  REP(i, s.size()){
    if(s[i]=='W'){
      ans += i-now;
      now++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 720
class Dice():
    top=1
    n=2
    e=4
    w=3
    s=5
    dice=[1,2,3,4,5,6]
    def __init__(self,num):
        self.dice=num

    def roll(self,direction):
        if(direction=="N"):
            self.top,self.n,self.s = self.n,7-self.top,self.top
        elif(direction=="E"):
            self.top,self.e,self.w = self.e,7-self.top,self.top
        elif(direction=="W"):
            self.top,self.e,self.w = self.w,self.top,7-self.top
        elif(direction=="S"):
            self.top,self.n,self.s = self.s,self.top,7-self.top


d=list(map(int,input().split()))
dice=Dice(d)
direct=list(input())
for i in range(len(direct)):
    dice.roll(direct[i])

print(dice.dice[dice.top-1])


Measured memory_bytes: 5604
a,b,c,d,e,f=map(int,input().split())
l=[]
for i in range(0,(f//(100*a))+1):
  for j in range(0,(f//(100*b))+1):
    if 100*a*i+100*b*j>f:
      pass
    else:
      l.append(100*a*i+100*b*j)
l1=[]
del l[0]
max1=0
g=0
h=0
for i in l:
  l2=[]
  m=min(f-i,(i//100)*e)
  max2=0#satounoryou
  for j in range(0,(m//c)+1):
    for k in range(0,(m//d)+1):
      if j*c+k*d<=m and j*c+k*d>max2:
        max2=j*c+k*d
  if max1<=100*max2/(i+max2):
    g=i
    h=max2
    max1=100*max2/(i+max2)
print(g+h,h)


Measured memory_bytes: 3064
using System;
using System.Linq;
class program{
  static void Main(){
    long n = long.Parse(Console.ReadLine());
    string a = "";
    while(n > 0){
      a += (char)((n-1)%26+97);
      n = (n-1)/26;
    }
    string ans = string.Concat(a.Reverse());
    Console.Write(ans);
  }
}

Measured memory_bytes: 27804
while 1:
    n,w = map(int,raw_input().split())
    if n == 0: break
    v = [0.0]*11
    m = 0
    for i in range(n):
        p = int(raw_input())/w
        v[p] += 1.0
        m = max(m,p)
    vm = max(v)
    ans = 0.01
    for i in range(m):
        ans += (v[i]/vm)*(1-i*1.0/m)
    print ans

Measured memory_bytes: 4252
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

# 購買する全パターンを回す
most_row_price = 10**10
for i in range(2**n):
    comb = str(bin(i)[2:]).zfill(n)
    
    # 購買パターン毎の購入金額と理解度を算出する
    understanding = [0] * m # 理解度の初期化
    total_money = 0 # 合計購入金額の初期化
    for j in range(n):
        
        # 購入しないケースは除外する
        if comb[j] == '0':
            continue
            
        # 購入するケースだけ、金額算出する
        total_money += ca[j][0]
        
        # 当該パターンの理解度を算出する
        for k in range(m):
            understanding[k] += ca[j][k+1]           

    for j in range(m):
        if understanding[j] < x:
            break
    else:
        most_row_price = min(total_money, most_row_price)

if most_row_price == 10**10:
    print(-1)
else:
    print(most_row_price)

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define MAXN (1<<15)+1
int n,m,a,b,c,sum[MAXN],f[MAXN][21],p[21][21],res,ans;
int main(){
	scanf("%d%d",&n,&m);
	int maxs=(1<<n)-1;
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&a,&b,&c);
		p[a][b]=p[b][a]=c;
		res+=c;
	}
	for(int s=0;s<=maxs;s++){
		for(int i=1;i<=n;i++)
		  if(s&(1<<(i-1))){
			for(int j=1;j<=n;j++)
			  if(s&(1<<(j-1))){
			  	sum[s]+=p[i][j];
			  }
		}
		sum[s]>>=1;
	}
	memset(f,-1,sizeof(f));
	f[1][1]=0;
	for(int s=0;s<=maxs;s++){
		for(int i=1;i<=n;i++){
			if(f[s][i]==-1) continue;
			for(int j=1;j<=n;j++){
				if(s&(1<<(j-1))) continue;
				if(!p[i][j]) continue;
				f[s|(1<<(j-1))][j]=max(f[s|(1<<(j-1))][j],f[s][i]+p[i][j]);
			}
			int rest=(maxs^s)|(1<<(i-1));
			for(int ss=rest;ss;ss=rest&(ss-1)){
				f[s|ss][i]=max(f[s|ss][i],f[s][i]+sum[ss]);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=maxs;i++)
	  ans=max(ans,f[i][n]);
	printf("%d\n",res-ans);
}

Measured memory_bytes: 3072
N = int(input())
S = input()

ans = 0
for i in range(1, len(S)):
  L = set(S[:i])
  R = S[i:]
#  print(L, R)
  cnt = 0
  for j in L:
    if j in R:
      cnt += 1
  ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3060
import java.util.*;

import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod = 1000000007;
	static int inf = (int) 1e15;
	static ArrayList<Integer>[] adL, adH;
	static int n, q;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
        int n=sc.nextInt();
         //int p=0;
         long ans=Long.MAX_VALUE;
         int []a=new int [n];
         for(int i=0;i<n;i++)
        	 a[i]=sc.nextInt();
         Arrays.sort(a);
         //System.out.println(Arrays.toString(a));
         for(int i=a[0];i<=a[n-1];i++) {
        	 long tem=0;
        	 for(int j=0;j<n;j++)
        		 tem+=(i-a[j])*(i-a[j]);
        //	 System.out.println(i+" "+tem);
        	 ans=Math.min(ans, tem);
         }
         System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    //Seiranchan!
    int N;
    cin >> N;
    long long  A=2,B=1,sum=0;;
    long long L;
    if(N==1){
        cout << 1 <<endl;
    }else{
        for(int i=1;i<N;i++){
            L = A+B;
            A=B;
            B=L;
            sum +=L;
        }
        cout << L <<endl;
    }    
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int n, m, X[100005], R[100005];
	
	cin >> n >> m;
	
    rep(i, m)
		cin >> X[i];

    sort(X, X + m);
	
    rep(i, m-1)
        R[i] = X[i + 1] - X[i];
		
    sort(R, R + m - 1);
    int ans = 0;
	
    rep(i, m - n)
        ans += R[i];
	
    cout << ans;
	
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
/******* MY EVERY AC WILL BE A TRIBUTE TO SSR ********/
#define vi vector
#define lli long long int
#define vli vi<lli>
#define pb push_back
#define pll pair<lli,lli>
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(),greater<lli>()
#define clear(x) x.clear()
#define rep(i,n) for(lli i=0;i<(lli)n;i++)
#define rep1(i,n) for(lli i=1;i<=(lli)n;i++)
#define rep2(i,n) for(lli i=1;i<(lli)n;i++)
#define refor(i,n) for(lli i=(lli)n;i>=0;i--)
#define range(i,l,r) for(lli i=(lli)l;i<=(lli)r;i++)
#define big(x,y) (x>y)?x:y
#define small(x,y) (x<y)?x:y
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
using namespace std;
lli gcd(lli a,lli b) {return b==0?a:gcd(b,a%b);}
lli lcm(lli a,lli b) {return (a*b)/gcd(a,b);}
bool isprime(lli x) {for(lli i=2;i<=sqrt(x);i++) { if(x%i == 0) return false;} return true;}
lli modpow(lli x,lli y) {x%=mod;lli res=1;while(y>0){if(y&1) res*=x%mod; y=y>>1; x=x*x%mod;} return res%mod;}
lli ncr(lli n,lli k) {lli res=1; if(k>n-k) k=n-k; rep(i,k){res*=(n-i);res/=(i + 1);} return res;}
lli bintodec(lli n) {lli decimal=0,i=0,rem;while (n!=0){rem = n%10;n/=10;decimal += rem*pow(2,i);++i;}return decimal;}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
     
     lli x;
     cin>>x;
     if(x>=30)
      cout<<"Yes\n";
      else
      cout<<"No\n";

    return 0;
}











Measured memory_bytes: 3696
#include <iostream>

using namespace std;
long long n,i,k,a[3005], dp[3005][3005];
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];

    for(k=0;k<n;k++)
    {
        for(i=1;i+k<=n;i++)
        {
            if(k==0)
                dp[i][i]=a[i];

            else
                dp[i][i+k]=max(a[i]-dp[i+1][i+k], a[i+k]-dp[i][i+k-1]);
        }
    }
    cout<<dp[1][n];
    return 0;
}


Measured memory_bytes: 70016
n =  int(input())
A = [int(input()) for _ in range(n)]
no1, no2 = 0, 0
for a in A:
    if a>no1:
        no1=a
    elif a>no2:
        no2=a
for a in A:
    if a==no1:
        print(no2)
    else:
        print(no1)

Measured memory_bytes: 69080
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc081/tasks/abc081_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A):
    ans = 0
    divisor = 2

    while True:
        for a in A:
            if a % divisor != 0:
                return ans
        divisor *= 2
        ans += 1


def main(args):
    N = int(input())
    A = [int(x) for x in input().split()]
    ans = solve(A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  int n,a,b,c;
  scanf("%d",&n);
  a=n/100;
  b=n%100/10;
  c=n%10;
  if(a>=b && a>=c)
  {
    printf("%d\n",a*111);
  }
  else
  {
    int d=(a+1)*111;
    printf("%d\n",d);
  }
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

long long int a, b;

int main(void) {

	cin >> a >> b;
	long long int sum = 0;
	for (int i = 1; i < b - a;i++) {
		sum += i;
	}

	cout << sum - a << endl;

	//system("pause");
	return 0;
};

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

const int N = 6010;

string dp[N]; char s[N];

int a[N], b[N], bel[N], mark[N];

int main() {
    int n; scanf("%d%s", &n, s + 1);
    for (int i = 1, ct1 = 0, ct2 = 0; i <= n * 2; i++) {
        if (s[i] == 'a') a[++ct1] = i, bel[i] = ct1;
        else b[++ct2] = i, bel[i] = ct2;
    }
    for (int i = n; i >= 1; i--) {
        dp[i] = dp[i + 1];
        if (b[i] > a[i]) {
            int pos = i + 1;
            while (pos <= n && min(a[pos], b[pos]) <= b[i]) pos++;
            dp[i] = max(dp[i], "ab" + dp[pos]);
        } else {
            int r = a[i]; string tmp; memset(mark, 0, sizeof(mark));
            mark[b[i]] = mark[r] = 1;
            for (int j = b[i] + 1; j < r; j++) if (s[j] == 'b') 
                r = max(r, a[bel[j]]), mark[j] = mark[a[bel[j]]] = 1;
            for (int j = b[i]; j <= n * 2; j++) if (mark[j]) tmp += s[j];
            int pos = bel[r] + 1;
            while (pos <= n && min(a[pos], b[pos]) <= r) pos++;
            dp[i] = max(dp[i], tmp + dp[pos]);
        }
    }
    cout << dp[1] << endl;
}

Measured memory_bytes: 20052
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;

	int kumi = 0;
	rep1(i, 1000) {
		if ((i - 1) * i / 2 == N) {
			kumi = i;
			break;
		}
	}
	if (kumi == 0) {
		co("No");
	}
	else {
		co("Yes");
		co(kumi);
		string S[1000];
		rep(i, kumi) S[i] = to_string(kumi - 1);

		int k1 = 0;
		int k2 = 0;
		rep1(i, N) {
			k2++;
			if (k2 >= kumi) {
				k1++;
				k2 = k1 + 1;
			}
			S[k1] += " " + to_string(i);
			S[k2] += " " + to_string(i);
		}
		rep(i, kumi) co(S[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <stdio.h>
#include <algorithm>
//#include <string>
//#include <math.h>
//#include <vector>

#define a2i(c) (int)c-97
#define i2a(i) (char)(i+97)

using namespace std;



int change(string S, char x){
  int i;
  int cnt=0, maxcnt=0, tail=0;


  for(i=0;i<(int)S.length();i++){
    if(S[(int)S.length()-i-1]!=x){
      tail++;
    }else{
      break;
    }
  }
  
  for(i=0;i<(int)S.length()-tail;i++){
    if(S[i]!=x){      
      cnt++;
      if(cnt>maxcnt)
	maxcnt=cnt;
    }
    else{
      cnt = 0;
    }
  }

  if(tail == (int)S.length())
    return tail; 
  
  //  printf("%c: %d %d\n",x,maxcnt,tail);

  if(tail>maxcnt) return tail;		   
  else return maxcnt;
}

int main() {
  string S;

  int i;
  int cnt,tmp;

  
  getline(cin, S);
  cnt = S.length();
  
  for(i=0;i<26;i++){ // Possible to spead up (in average 13 times)
    tmp = change(S,i2a(i)); 
    if(cnt > tmp)
      cnt = tmp;
  }

  cout << cnt;
  return 0;  
}


Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]
student_pos_list = [[int(j) for j in input().split()] for i in range(n)]
checkpoint_list = [[int(j) for j in input().split()] for i in range(m)]

for student_pos in student_pos_list:
    min_d = 20**8+1
    min_pt_index = m+1
    for i, checkpt in enumerate(checkpoint_list):
        d = abs(student_pos[0] - checkpt[0]) + abs(student_pos[1] - checkpt[1])
        if d < min_d:
            min_d = d
            min_pt_index = i+1

    print(min_pt_index)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int arr[10005];

void solve(int n , int k){
	int count = 0; 
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(count == k){
			break; 
		}
		else{
			count++;
			ans += arr[i];
		}
	}
	cout << ans << endl;
}

int main(){
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
	}
	sort(arr , arr + n);

	solve(n , k);
}

Measured memory_bytes: 3168
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		if(b - a == c - b){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23124
def is_ok(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[n//2 + i]:
            return False
    return True


def main():
    S = input()
    ans = len(S) - 2
    while not is_ok(S[:ans]):
        ans -= 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

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

    ll R, D, X; cin >> R >> D >> X;
    F0R(i, 10) {
        X = R * X - D;
        cout << X << endl;
    }

    return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int x = sc.nextInt()-1;
		int y = sc.nextInt()-1;
		
		// 計算
		int result = 0;
		int[][] dist = new int[n][n];
		for(int i = 0; i < n; i++){
		    boolean[] visited = new boolean[n];
		    ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		    q.add(i);
		    visited[i] = true;
		    while(!q.isEmpty()){
		        int now = q.poll();
		        if(now == x){
		            if(!visited[y]){
		                q.add(y);
		                visited[y] = true;
		                dist[i][y] = dist[i][now] + 1;
		                //System.out.println("now:" + now + " next:" + y + " dist:" + (dist[i][now] + 1));
		            }
		        }
		        if(now == y){
		            if(!visited[x]){
		                q.add(x);
		                visited[x] = true;
		                dist[i][x] = dist[i][now] + 1;
		                //System.out.println("now:" + now + " next:" + x + " dist:" + (dist[i][now] + 1));
		            }
		        }
		        if(now > 0){
		            if(!visited[now-1]){
		                q.add(now-1);
		                visited[now-1] = true;
		                dist[i][now-1] = dist[i][now] + 1;
		                //System.out.println("now:" + now + " next:" + (now-1) + " dist:" + (dist[i][now] + 1));
		            }
		        }
		        if(now < n-1){
		            if(!visited[now+1]){
		                q.add(now+1);
		                visited[now+1] = true;
		                dist[i][now+1] = dist[i][now] + 1;
		                //System.out.println("now:" + now + " next:" + (now+1) + " dist:" + (dist[i][now] + 1));
		            }
		        }
		    }
		}
		//System.out.println(Arrays.deepToString(dist));
		int[] cnt = new int[n];
		for(int i = 0; i < n; i++){
		    for(int j = 0; j < n; j++){
		        cnt[dist[i][j]]++;
		    }
		}
		for(int i = 1; i < n; i++){
		    System.out.println(cnt[i]/2);
		}
		
		// 出力
		//System.out.println(result);
	}
}



Measured memory_bytes: 74936
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

  long long int k;
  cin >> k;

  cout << 50 << endl;

  long long int ans = 49 + k / 50;
  long long int p[50] = {};
  for ( long long int i = 0; i < 50; i++ ) {
    p[i] = ans;
  }
  for ( long long int i = 0; i < k % 50; i++ ) {
    for ( long long int j = 0; j < 50; j++ ) {
      if ( j == i ) {
	p[j] += 50;
      }else {
	p[j]--;
      }
    }
  }
  for ( long long int i = 0; i < 50; i++ ) {
    if ( i != 0 ) cout << " ";
    cout << p[i];
  }
  cout << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
  int n, m;
  cin >> n;
  m = n;
  int tmp = 0;
  for (int i = 0; i <= 8; i++)
  {
    tmp += n % 10;
    n /= 10;
    if (n == 0)
      break;
  }
  if (m % tmp == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3552
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d;
    cin >> n;
    q *= 4;h *= 2;
    s = min(q,s);s = min(h,s);
    if (2*s <= d){
        cout << n*s;
    }
    else{
        cout << d*(n/2) + s*(n%2);
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for (i = 0; i < n1; i++) L[i] = A[left + i];
  for (i = 0; i < n2; i++) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for (k = left; k < right; k++) {
  	if (L[i].value <= R[j].value) {
  		A[k] = L[i++];
  	} else {
  		A[k] = R[j++];
  	}
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if (left + 1 < right) {
  	mid = (left + right) / 2;
  	mergeSort(A, n, left, mid);
  	mergeSort(A, n, mid, right);
  	merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for (j = p; j < r; j++) {
  	if (A[j].value <= x.value) {
  		i++;
  		t = A[i]; A[i] = A[j]; A[j] = t;
  	}
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if (p < r) {
  	q = partition(A, n, p, r);
  	quickSort(A, n, p, q - 1);
  	quickSort(A, n, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
  	scanf("%s %d", S, &v);
  	A[i].suit = B[i].suit = S[0];
  	A[i].value = B[i].value = v;
  }
  
  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);
  
  for (i = 0; i < n; i++) {
  	if (A[i].suit != B[i].suit) stable = 0;
  }
  
  if (stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  for (i = 0; i < n; i++) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  
  return 0;
}


Measured memory_bytes: 4148
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int value = 0;
		int num = 0;
		int lines = 0;
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(",");

			int v = Integer.parseInt(nico[0]);
			int n = Integer.parseInt(nico[1]);
			value = value + v * n;
			num = num + n;
			lines++;
		}

		System.out.println(value);
		System.out.println(Math.round((double)num / lines));
	}
}

Measured memory_bytes: 25824
program main
 implicit none
 integer A(3,3)
 integer :: get(3,3)=0
 integer N
 integer,allocatable :: b(:)
 integer i
 integer ii,jj
 integer :: bingo=0

 read *,A(1,1),A(1,2),A(1,3)
 read *,A(2,1),A(2,2),A(2,3)
 read *,A(3,1),A(3,2),A(3,3)
 read *,N
 allocate(b(N))
 do i=1,N
  read *,b(i)
 end do

 do i=1,N
  do ii=1,3
   do jj=1,3
    if ( A(ii,jj) == b(i) ) get(ii,jj)=1
   end do
  end do
 end do

 do i=1,3
  if ( get(i,1)==1 .and. get(i,2)==1 .and. get(i,3)==1 ) bingo=1
 end do
 do i=1,3
  if ( get(1,i)==1 .and. get(2,i)==1 .and. get(3,i)==1 ) bingo=1
 end do
  if ( get(1,1)==1 .and. get(2,2)==1 .and. get(3,3)==1 ) bingo=1
  if ( get(3,1)==1 .and. get(2,2)==1 .and. get(3,1)==1 ) bingo=1

 if ( bingo == 1 ) then
  print '(A)', 'Yes'
 else
  print '(A)', 'No'
 end if

 endprogram main


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

const int LIM = 100000;
int n, a[LIM], b[LIM], dif[LIM], ans, num, l, r;

int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) dif[i] = a[i] - b[i];

    sort(dif, dif + n);
    r = n - 1;
    while (l <= r) {
        if (dif[l] >= 0) break;
        if (-dif[l] > num) {
            // extra num is insufficient
            if (dif[r] <= 0) {
                // Bi > Ci
                ans = -1;
                break;
            } else {
                // add dif[r] to extra num
                num += dif[r--];
                ans++;
            }
        } else {
            // add extra num to dif[l]
            num += dif[l++];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);

        String s = scanner.nextLine();

        while(!s.equals(".")){
            Deque<Character> stack = new ArrayDeque<Character>();

            boolean flag = true;
            for(int i = 0; i < s.length(); i++){
                char c = s.charAt(i);
                if(c == '(' || c == '['){
                    stack.push(c);
                }
                else if (c == ')' || c == ']'){
                    if(stack.isEmpty()){
                        flag = false;
                        break;
                    }
                    char d = stack.pop();
                    if((d == '(' && c == ']') || (d == '[' && c == ')')){
                        flag = false;
                        break;
                    }
                }
            }
            if(!stack.isEmpty()) flag = false;

            if(flag)
                System.out.println("yes");
            else
                System.out.println("no");

            s = scanner.nextLine();
        }

    }
}



Measured memory_bytes: 45492
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define scani(x) scanf("%d",&x)
#define scanc(x) scanf("%s",x)
#define printi(x) printf("%d",x)
#define printin(x) printf("%d\n",x)
#define printc(x) printf("%s",x)
#define repd(i,n,m) for(int i = n; i > m; i--)
#define repu(i,n,m) for(int i = n; i < m; i++)
#define allprintu(i,n,m,a) for(int i = n; i < m; i++){if(i != m-1){printf("%d ",a[i]);}else{printf("%d",a[i]);}}
#define allprintd(i,n,m,a) for(int i = n; i > m; i--){if(i != 0){printf("%d ",a[i]);}else{printf("%d\n",a[i]);}}
	
#define MAX 100000
int n,k;
int b[MAX];

int check(long long int p){
	long long int sum = 0;
	int i = 0;
	repu(j,0,k){
		sum = 0;
		while(sum + b[i] <= p){
			sum += b[i];
			i++;
			if(i == n){
				return n;
			}
		}
	}
	return i;
}

long long int solve(){
	long long int left = 0, right = 100000*10000, mid;
	int v;
	while(right - left > 1){
		mid = (left + right)/2;
		v = check(mid);
		if(v >= n){
			right = mid;
		}else{
			left = mid;
		}
	}
	return right;
}
int main(void){
	scani(n);
	scani(k);
	repu(i,0,n){
		scani(b[i]);
	}
	long long int result = solve();
	printf("%llu\n",result);
	return 0;
}


Measured memory_bytes: 2148
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner cs = new Scanner(System.in);
        int n = cs.nextInt();
        for (int i = 1; i <= n; i++) {
            int x =i;
            if (x % 3 == 0) {
                System.out.printf(" %d", i);
            }
            else {
                while (true) {
                    if (x % 10 == 3) {
                        System.out.printf(" %d", i);
                        break;
                    }
                    x /= 10;
                    if (x != 0) continue;
                    else break;
                }
            }
 
        }        System.out.printf("\n");
 
    }
}


Measured memory_bytes: 40916
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
long long max(long long a,long long b){
  if(a<b) return b;
  else return a;

}
int main(){
int k,x; cin>>k>>x;
int mn=max(-1000000,x-k+1);
int mx=min(1000000,x+k-1);

for(int i=mn;i<=mx;i++)
cout<<i<<' ';

}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = [int(item) for item in input().split()]
cnt = Counter(a)

key_num = len(cnt.keys())
rank = [0] * key_num 
keys = list(cnt.keys())
keys.sort(reverse=True)
for i, key in enumerate(keys):
    rank[i] = cnt[key]
cur = [0] * key_num 
cur[0] = 1
for i in range(n):
    tmp = cur[:]
    free = 0
    for j in range(key_num):
        if rank[j] > cur[j] and free > 0:
            if cur[j] + free > rank[j]:
                free -= rank[j] - cur[j]
                cur[j] = rank[j]
            else:
                cur[j] += free
                free = 0
        free += tmp[j] 
if sum(cur) == 2**n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40896
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<20);
static const int W=0;
static const int G=1;
static const int B=2;

int n;
vector<pair<int ,int> > adj[MAX];

void dij(){
  priority_queue<pair<int ,int> > PQ;
  int color[MAX];
  int d[MAX];
  int i;

  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=W;
  }
  
  d[0]=0;
  PQ.push(make_pair(0,0));
  color[0]=G;

  while(!PQ.empty()){
    pair<int,int> f=PQ.top();
    PQ.pop();
    int u;
    u=f.second;
    color[u]=B;

    if(d[u]<f.first*(-1)) continue;

    int j;

    for(j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==B) continue;

      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;

	PQ.push(make_pair(d[v]*(-1),v));
	color[v]=G;
      }
    }
  }
  for(i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INFTY ? -1:d[i])<<endl;
  }
}

int main(){
  int k,u,v,c,i,j;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>u>>k;
    for(j=0;j<k;j++){
      cin>>v>>c;
      adj[u].push_back(make_pair(v,c));
    }
  }
  dij();
  return 0;
}



Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int n;
    cin >> n;
    int a = n / 100;
    int b = n / 10 % 10;
    int c = n % 10;

    if(a >= b){
        if(a * 10 + a > b * 10 + c || b == c){
            cout << a << a << a << endl;
        }else{
            if(a == 9)cout << 9 << 9 << 9 << endl;
            else cout << a + 1 << a + 1 << a + 1 << endl;
        }
    }else{
        if(a * 10 + a > b * 10 + c) cout << a << a << a << endl;
        else cout << a+1 << a+1 << a+1 << endl;
    }
    /*デバック用*/
    //cout << "a:" << a <<" b:" <<  b << " c:" << c;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);

    int N = stdIn.nextInt();
    int K = stdIn.nextInt();
    int nowNum = 1;

    for(int i = 1; i <= N; i++){
      if(K >= nowNum){
        nowNum = 2 * nowNum;
      }
      else{
        nowNum = nowNum + K;
      }
    }

    System.out.println(nowNum);
  }

}


Measured memory_bytes: 23892
/*
    Mbak Sana Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,m,i,j,k,x,y,ans,curr,temp;
    cin >> n;
    for(i=1;i<=50000;i++)
    {
        double price = i * 1.08;
        ans = floor(price);
        if(ans == n)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    printf(":(\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        String result = s.substring(0, s.length() - 8);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23764
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        int ans = 0;
        for(int i=0; i<m; i++){
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        if(m>1){
            int[] y = new int[m-1];
            for(int i=0; i<m-1; i++){
                y[i] = x[i+1] - x[i];
            }
            Arrays.sort(y);
            for(int i=0; i<m-n; i++){
                ans += y[i];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50428
#include<stdio.h>

int gcd(int,int);

int main(){
  int x,y;

  scanf("%d%d",&x,&y);

  printf("%d\n",gcd(x,y));

  return 0;
}

int gcd(x,y){

  int r;

  if(x >= y){
    while(y !=0){
      r = y;
      y = x % y;
      x = r;
    }
    return x;
  }

  else{
    while(x != 0){
      r = x;
      x = y % x;
      y = r;
    }
    return y;
  }
}

Measured memory_bytes: 592
a, b = map( int, open( 0 ).read().split())

import math

def max( int: a, b ) -> int:
  if a < b:
    return b
  return a

def min( int: a, b ) -> int:
  if a < b:
    return a
  return b

def gcd( a, b ):
  x = max( a, b )
  y = min( a, b )

  b = x
  r = y
  while( r != 0 ):
    a = b
    b = r
    r = a % b
  return b

print( int( a * b / gcd( a, b ) ))


Measured memory_bytes: 38384
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll s,w;
  cin >> s >> w;

  cout << (w >= s ? "unsafe" : "safe") << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
 using namespace std;
 const int maxn=105;
 int a[maxn],flag[maxn];
 int main()
 {
 	int n;
 	scanf("%d",&n);
 	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
 	int ans=inf,pos=-1,sum=0;
 	for(int i=1;i<=100;i++){
 		sum=0;
 		for(int j=1;j<=n;j++){
 			sum+=(a[j]-i)*(a[j]-i);
		 }
		if(sum<ans){
			ans=sum;
			pos=i;
		}
	 }
	 cout<<ans<<endl;
 	return 0;
  } 

Measured memory_bytes: 256
#include <cstdio>

int p[30];
int old = 0;
int N;
int tmp;
int diff, diff_old;
int ans = 0;

int main()
{
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &tmp);
        diff = tmp - old;
        old = tmp;

        if (i == 0) {
            diff = 0;
        } else if (i > 1) {
            //            printf("i :%d\n", i);
            //           printf("diff %d %d\n", diff, diff_old);
            if (diff * diff_old > 0) {
                //              printf("diff %d %d\n", diff, diff_old);
                //             printf("%d %d\n", tmp, old);
                ans++;
            }
        }
        diff_old = diff;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
import fractions

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

all_AB = B-A+1
lcm_CD = C*D//fractions.gcd(C,D)

div_1A_C = (A-1)//C
div_1B_C = B//C
div_AB_C = div_1B_C-div_1A_C

div_1A_D = (A-1)//D
div_1B_D = B//D
div_AB_D = div_1B_D-div_1A_D

div_1A_CD = (A-1)//lcm_CD
div_1B_CD = B//lcm_CD
div_AB_CD = div_1B_CD-div_1A_CD

print(all_AB-div_AB_C-div_AB_D+div_AB_CD)


Measured memory_bytes: 5048
//AtCoder ABC097 C - K-th Substring
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string s; cin>>s;
    ll K; cin>>K;
    auto sorted=s;
    sort(sorted.begin(),sorted.end());
    unordered_set<char> sett;
    ll idx=0;
    while(idx<sorted.size()&&K>sett.size()){
        sett.insert(sorted[idx++]);
    }
    unordered_set<string> candidate_set;
    for(auto&& c:sett){
        for(ll i=0;i<s.size();++i){
            if(s[i]==c){
                for(ll l=1;l<=K;++l){
                    candidate_set.insert(string(s,i,l));
                }
            }
        }
    }
    //vectorへ
	vector<string> vec(candidate_set.size());
    std::copy(candidate_set.begin(), candidate_set.end(), vec.begin());
    sort(vec.begin(),vec.end());
    cout<<vec[K-1]<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return(1);
    ll sol=power(a,b/2,m);
    sol=(sol*sol)%m;
    if(b%2==1)
        sol=(sol*a)%m;
    return(sol);
}
ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
void solve()
{
    int m,d,sol=0;
    cin>>m>>d;
    sol=m-1;
    if(d>=m)
        sol=sol+1;
    cout<<sol;
}
int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int gcd(int a, int b) {
	if (a%b) {
		return gcd(b,a%b);
	}else {
		return b;
	}
}
int main() {
	int a = 0;
	int b = 0;
	int max = 0;
	int d = 0;

	while (cin >> a >> b) {
		if (a > b) {
			max = b;
		}
		else {
			max = a;
		}
		d = gcd(a, b);
		a = a / d * b;
		cout << d << ' ' << a << "\n";
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
using namespace std;


int main()
{
    int N;
    cin >> N;
    int p[N];
    for(int i = 0; i<N; i++) cin >> p[i];
    int Max= 0;
    int num = 0;
    for(int i = 0; i<N; i++)
    {
        if (Max < p[i])
        {
            Max = p[i];
            num = i;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        if(i != num) ans += p[i];
    }
    cout << ans + p[num]/2 << endl;
}

Measured memory_bytes: 256