akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;
    static int inf = 0x7ffffff;

    public static void main(String[]$) throws Exception {
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(Math.max(0, a - b - b));
    }

    static class System {
        static PrintWriter out = new PrintWriter(java.lang.System.out);

        static {
            Runtime.getRuntime().addShutdownHook(new Thread(System.out::flush));
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(java.lang.System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }

        char[][] nextCharArray(int n, int m) {
            char[][] a = new char[n][m];
            for (int i = 0; i < n; i++) {
                a[i] = next().toCharArray();
            }
            return a;
        }

        int[] nextIntArray(int n, java.util.function.IntUnaryOperator op) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsInt(nextInt());
            }
            return a;
        }

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

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

        long[] nextLongArray(int n, java.util.function.LongUnaryOperator op) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = op.applyAsLong(nextLong());
            }
            return a;
        }
    }
}


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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,r,l) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(_typeof_((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;

const int MOD=1000000007;
int no_of_bits(long long n)
{
    int count=0;
    while(n>0)
    {
        n=n>>1;
        count++;
    }
    return count;
}
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
void printFrequency(vector<int> v) 
{ 
    unordered_map<int, int> M; 
  
     
    for (int i = 1; i<v.size(); i++) { 
  
        if (M.find(v[i]) == M.end()) { 
            M.insert(make_pair(v[i], 1)); 
        } 
 
        else { 
            M[v[i]]++; 
        } 
    } 

}
void add_self(int &a, int b){
  a+=b;
  if(a>=MOD){
    a-=MOD;
  }
}

void sub_self(int &a, int b){
  a-=b;
  if(a<0){
    a+=MOD;
  }
}

int search(vi x,int n,int i){
  int l=0,h=n-1,mid;
  while(l<=h){
    mid=(l+h)/2;
    if(x[mid]<i){
      l=mid+1;
    }else{
      h=mid-1;
    }
  }
  return l;
}
bool check9(string s){
    for(int i=0;i<s.size();i++) if(s[i]!='9') return 0;
    return 1;
}

const int INF=-2000;
const ll INF_=1e13;
void solve(){
   int n;
   cin>>n;
   if(360%n==0) cout<<360/n;
   else{
       ll i=n,count=1;
       while(i%360!=0){
           i+=n;
           count++;
       }
       cout<<count;
   }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

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

Measured memory_bytes: 3652
/* ?°?????????????
??\??????????????§????????????????????°??????????????§?????????????????§????????????????????§?????£????????????????????????????????§??????AIZU???????????????????????????????????????????????£???????????????????????°??????????????????????????????????????????????????¨?¨??????¢??§?§????????????°?????????????????????????????????

#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>

void koch(double p1x, double p1y, double p2x, double p2y, int n) {
	
	if (n == 0) return;
	
	double sx, sy, ux, uy, tx, ty, lx, ly;
	
	if (p1x > p2x)
	{
		lx = p1x - p2x;
		tx = p2x + lx/3.0;
		sx = p2x + 2.0*lx/3.0;
		if (p1y > p2y)
		{
			ly = p1y - p2y;
			ty = p2y + ly/3.0;
			sy = p2y + 2.0*ly/3.0;
			ux = (sx - tx)*cos(M_PI/3.0) - (sy - ty)*sin(M_PI/3.0) + sx;
			uy = (sx - tx)*sin(M_PI/3.0) - (sy - ty)*cos(M_PI/3.0) + sy;
		}
		else
		{
			ly = p2y - p1y;
			sy = p1y + ly/3.0;
			ty = p1y + 2.0*ly/3.0;
			ux = (sx - tx)*cos(M_PI/3.0) - (ty - sy)*sin(M_PI/3.0) + sx;
			uy = (sx - tx)*sin(M_PI/3.0) - (ty - sy)*cos(M_PI/3.0) + sy;
		}
	}
	else
	{
		lx = p2x - p1x;
		sx = p1x + lx/3.0;
		tx = p1x + 2.0*lx/3.0;
		if (p1y > p2y)
		{
			ly = p1y - p2y;
			ty = p2y + ly/3.0;
			sy = p2y + 2.0*ly/3.0;
			ux = (tx - sx)*cos(M_PI/3.0) - (sy - ty)*sin(M_PI/3.0) + sx;
			uy = (tx - sx)*sin(M_PI/3.0) - (sy - ty)*cos(M_PI/3.0) + sy;
		}
		else
		{
			ly = p2y - p1y;
			sy = p1y + ly/3.0;
			ty = p1y + 2.0*ly/3.0;
			ux = (tx - sx)*cos(M_PI/3.0) - (ty - sy)*sin(M_PI/3.0) + sx;
			uy = (tx - sx)*sin(M_PI/3.0) - (ty - sy)*cos(M_PI/3.0) + sy;
		}
	}
	koch(p1x, p1y, sx, sy, n - 1);
	printf("%.8f %.8f\n", sx, sy);
	koch(sx, sy, ux, uy, n - 1);
	printf("%.8f %.8f\n", ux, uy);
	koch(ux, uy, tx, ty, n - 1);
	printf("%.8f %.8f\n", tx, ty);
	koch(tx, ty, p2x, p2y, n - 1);
}

int main(void) {
	double p1x = 0.0, p1y = 0.0, p2x = 100.0, p2y = 0.0;
	int n;
	scanf("%d", &n);
	
	printf("%.8f %.8f\n", p1x, p1y);
	koch(p1x, p1y, p2x, p2y, n);
	printf("%.8f %.8f\n", p2x, p2y);
	
	return 0;
}

???????????§?§????????????°????????§??????
*/

#include <bits/stdc++.h>
using namespace std;
int n;
class Point{
  public:
  double x;
  double y;
  Point(){}
  Point(double _x, double _y){
    x = _x;
    y = _y;
  }
  Point operator+(const Point &p)const{
    Point res;
    res.x = x + p.x; res.y = y + p.y;
    return res;
  }
  double length(){
    return sqrt(x*x+y*y);
  }
};
 
void func(int i, Point l, Point r){
  if(i == n) return;
  Point s, t, u;
  Point sum = r+l;
  s = Point((l.x * 2.0 + r.x)/3.0, (2*l.y + r.y)/3.0);
  t = Point((l.x + 2*r.x)/3.0, (l.y + 2*r.y)/3.0);
  u = Point(cos(M_PI/3)*(t.x - s.x) - sin(M_PI/3)*(t.y - s.y) + s.x,
            sin(M_PI/3)*(t.x - s.x) + cos(M_PI/3)*(t.y - s.y) + s.y
           );
  func(i+1, l, s);
  printf("%.10f %.10f\n", s.x, s.y);
  func(i+1, s, u);
  printf("%.10f %.10f\n", u.x, u.y);
  func(i+1, u, t);
  printf("%.10f %.10f\n", t.x, t.y);
  func(i+1, t, r);
  return;
}
 
int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  Point p1(0, 0), p2(100, 0);
  printf("%.10f %.10f\n", p1.x, p1.y);
  func(0, p1, p2);
  printf("%.10f %.10f\n", p2.x, p2.y);
 
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define MOD1 1000000007
#define MOD2 1000000009
#define ll long long int
#define li long int
#define fi first
#define se second
#define ffl fflush(stdout);
#define whT int t; cin>>t; while(t--)
int main() 
{
/*	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else*/
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	//#endif
	li a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	ll at=abs(v*t);
	ll bt=abs(w*t);
	if(a<b) {
		if(a+at>=b+bt) {
			cout<<"YES";
		} else cout<<"NO";
		return 0;
	} else if(a>b) {
		if(a-at<=b-bt) {
			cout<<"YES";
		} else cout<<"NO";
		return 0;
	}
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);
    Map<Integer, Integer> map = new HashMap<>();

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        char[] arr = sc.next().toCharArray();

        StringBuffer sb = new StringBuffer();

//        System.out.println(arr[0]-'0');

        long ans = 0;

        int[] str = new int[3];

        outer:
        for (int i=0; i<2; i++) {
            ans = 0;
            for (int j=0; j<2; j++) {
                for (int k=0; k<2; k++) {
                    int a1 = arr[0] - '0';
                    int a2 = arr[1] - '0';
                    int a3 = arr[2] - '0';
                    int a4 = arr[3] - '0';
                    if (i==0) ans = a1 + a2;
                    else ans = a1 - a2;
                    if (j==0) ans += a3;
                    else ans -= a3;
                    if (k==0) ans += a4;
                    else ans -= a4;
                    if (ans == 7) {
                        str[0] = i;
                        str[1] = j;
                        str[2] = k;
                        break outer;
                    }
                }
            }
        }

//        System.out.println(str[0]);

        sb.append((arr[0]-'0'));
        sb.append( (str[0]==0) ? "+" : "-" );
        sb.append((arr[1]-'0'));
        sb.append( (str[1]==0) ? "+" : "-" );
        sb.append((arr[2]-'0'));
        sb.append( (str[2]==0) ? "+" : "-" );
        sb.append((arr[3]-'0'));
        sb.append("=");
        sb.append("7");

        System.out.println(sb.toString());

    }

}


Measured memory_bytes: 24916
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int B = 1;
	string ans;

	cin >> N;

	if (N == 0)
	{
		cout << "0" << endl;
		return 0;
	}

	while (N != 0)
	{
		if (N%abs(B * 2) != 0)
		{
			ans += '1';
			N -= B;
		}
		else
		{
			ans += '0';
		}
		B *= (-2);
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}

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

using namespace std;

string s,x;

int okk(string z,char ch)
{
	int i;
	for(i=0;i<z.size();i++)
		if(z[i]!=ch)
			return 0;
	return 1;
}

int get(char ch)
{
	int i;
	int ok=0;
	s=x;
	for(i=0;i<s.size();i++)
		if(s[i]==ch)
			ok=1;
	if(!ok)
		return (1<<30);
	string cur=s; int ans=0;
	while(!okk(cur,ch))
	{
		s=cur;
		cur="";
		for(i=0;i<s.size()-1;i++)
		{
			if(s[i]==ch||s[i+1]==ch)
				cur+=ch;
			else
				cur+=s[i];
		}
		ans++;
	}
	return ans;
}

int main()
{
	cin >> s;
	x=s;
	int i;
	int ans=(1<<30);
	for(i='a';i<='z';i++)
		ans=min(ans,get(i));
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * Triangle.cpp
 * Create:20180430
 * Description:三角形の２辺a,bとその間の角cから
 * 面積と外周の長さ、aを底辺としたときの高さを求めるプログラム
 */
#include <iostream>
#include <cmath>

double radian(int c){
  return (double)c * M_PI / 180;
}

double area(double a, double b, double radC){
  double area = (a * b * sin(radC)) / 2;
  return area;
}

double outer(double a, double b, double radC){
  double outer = a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(radC)));
  return outer;
}

double a_height(double a, double b, double radC){
  return (area(a, b, radC) * 2) / a;
}

int main(int argc, char* argv[]){
  double a, b;
  int c;

  std::cin >> a >> b >> c;
  double rad = radian(c);
  printf("%.8f\n", area(a, b, rad));
  printf("%.8f\n", outer(a, b, rad));
  printf("%.8f\n", a_height(a, b, rad));

  return 0;
}


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

#define ll long long
#define endl "\n"

const int mx = 1000005;
const ll MOD = 1e9+7;

ll factorial[mx];

ll power(ll a, ll b){
	ll res = 1;
	
	while (b > 0){
		if (b%2){
			res = (res * a)%MOD;
		}
		a = (a*a)%MOD;
		b /= 2;
	}
	
	return res;
}

ll inverse(ll a){
	return power(a, MOD - 2);
}

ll combination(ll n, ll r){
	
	if (n < r) return 0;
	if (n == r or r == 0) return 1;
	ll ans = factorial[n];
	ll also = inverse(factorial[r]);
	ans = (ans*also)%MOD;
	also = inverse(factorial[n-r]);
	ans = (ans*also)%MOD;
	
	return ans;
}

ll way(ll first_x, ll first_y, ll last_x, ll last_y){
	ll x = last_x - first_x;
	ll y = last_y - first_y;
	return combination(x+y, x);
}

int main ()
{

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define int ll
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);

	
	factorial[0] = 1;
	for (int i=1; i<mx; i++){
		factorial[i] = factorial[i-1]*i;
		if (factorial[i] >= MOD) factorial[i] %= MOD;
	}
	
	//cerr << combination(5, 2) << endl;
	//cerr << combination(10, 5) << endl;
	
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	
	int ans = 0;
	for (int i=b+1; i<=w; i++){
		int one = way(1, 1, h-a, i);
		int two = way(h-a+1, i, h, w);
		
		one = (one*two)%MOD;
		
		ans = (ans + one)%MOD;
	}
	    	
	cout << ans << endl;
	
    return 0;

}

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

#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long int lli;

int main()
{
	fio;
	string s,t;
	cin>>s>>t;
	int n=s.length();
	while(n--)
	{
		rotate(s.begin(),s.begin()+1,s.end());
		if(s==t)
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  int i;
  char buf[100],*prev,*ind;
  double p[8];
  while(fgets(buf,100,stdin)!=NULL){
    prev=ind=buf;
    i=0;
    while((ind=strchr(ind,' '))!=NULL){
      *ind='\0';
      ind++;
      p[i++]=atof(prev);
      prev=ind;
    }
    p[i]=atof(prev);
    if((p[1]-p[3])*(p[5]-p[7])
       ==-(p[0]-p[2])*(p[4]-p[6])){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> eki(M),sta(M),c(M);
  typedef pair<int,int> P;
  map<P,int> m;
  std::vector<P> v(2*M+N);
  for(int i=0;i<M;i++){
    cin>>eki[i]>>sta[i]>>c[i];eki[i]--;sta[i]--;
    m[P(eki[i],c[i])]=m[P(sta[i],c[i])]=0;
  }
  for(int i=0;i<N;i++)m[P(i,-1)]=0;
  int cnt=0;
  for(auto &p:m){
    v[cnt]=p.first;
    p.second=cnt++;
  }
  std::vector<P> edge[cnt];
  for(int i=0;i<M;i++){
    edge[m[P(eki[i],c[i])]].push_back(P(m[P(sta[i],c[i])],0));
    edge[m[P(sta[i],c[i])]].push_back(P(m[P(eki[i],c[i])],0));
  }
  std::vector<set<int>> s(N);
  for(auto p:m)if(~p.first.second)s[p.first.first].insert(p.first.second);
  for(int i=0;i<N;i++){
    for(int p:s[i]){
      P q=P(i,p);
      edge[m[q]].push_back(P(m[P(i,-1)],0));
      edge[m[P(i,-1)]].push_back(P(m[q],1));
    }
  }
  priority_queue<P,vector<P>,greater<P>> que;
  que.push(P(0,m[P(0,-1)]));
  std::vector<int> d(cnt,INF);d[m[P(0,-1)]]=0;
  while(que.size()){
    P p=que.top();que.pop();
    int k=p.first,n=p.second;
    if(d[n]<k)continue;
    for(auto q:edge[n]){
      if(d[n]+q.second<d[q.first]){
        d[q.first]=d[n]+q.second;
        que.push(P(d[q.first],q.first));
      }
    }
  }
  if(d[m[P(N-1,-1)]]==INF)fin(-1);
  else fin(d[m[P(N-1,-1)]]);
}

/*
解説AC
そもそもO(M)の頂点列挙すら考えてなかったのは反省かな
場所と状態まで含めて頂点を作ることで特殊な最短距離も求められるようになる
ただし設定によっては今回のように辺が膨れ上がることがある（同じ場所同士全てに辺を貼らないといけないとか）
そう言う場合にはそれらの辺を１本に変換できる頂点を追加出来ないか考える（同じ場所同士を繋ぐ専用の頂点を別に用意するとか）
*/


Measured memory_bytes: 117620
def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]
    # print("A: {}".format(A))
    # print("n: {}".format(n))
    # print("b: {}".format(b))
    outs = [[False for _ in range(3)] for _ in range(3)]
    is_bingo = False
    for i in range(3):
        for j in range(3):
            outs[i][j] = A[i][j] in b
    
    # check row
    for i in range(3):
        is_bingo = outs[i][:] == [True for _ in range(3)]
        if is_bingo:
            return "Yes"

    # check column
    for i in range(3):
        is_bingo = [outs[j][i] for j in range(3)] == [True for _ in range(3)]
        if is_bingo:
            return "Yes"
    # check x
    is_bingo = [outs[i][i] for i in range(3)] == [True for _ in range(3)]
    if is_bingo:
        return "Yes"
    is_bingo = [outs[i][-i-1] for i in range(3)] == [True for _ in range(3)]
    if is_bingo:
        return "Yes"
    return "No"

if __name__ == "__main__":
    print(main())

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.L;
		
		
		if(n%2==1){
			Console.WriteLine("{0}",0);
			return;
		}
		long ans=n/10;
		
		for(long i = 50;i<=n;i*=5) {
			ans+=n/i;
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

    auto clk=clock();
    typedef long long ll;
    typedef vector<int> vi;
    typedef pair<int,int> pi;
    #define F first
    #define S second
    #define PB push_back
    #define MP make_pair
    #define Mod 1000000007
    #define REP(i,a,b) for (int i = a; i <= b; i++)
    #define all(x) x.begin(),x.end()

    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        string s; cin>>s;
        ll k; cin>>k;
        s+="0";
        vector<ll>v;
        int count=1;
        for(int i=1;i<s.size();i++){
            if(s[i]==s[i-1]){
                count++;
            }
            else{
                v.push_back(count);
                count=1;
            }
        }
        ll ans=0,temp=0;
        for(int i=0;i<v.size();i++) ans+=v[i]/2;
        if(v.size()>1 && s[0]==s[s.size()-2]) {
            v[0]+=v.back();
            v.pop_back();
            for(int i=0;i<v.size();i++) temp+=v[i]/2;
        }
        else if(v.size()==1){
            ans=(v[0]*k)/2;
        }
        else{
            ans=ans*k;
        }
        cout<<ans+temp*(k-1)<<"\n";
        cerr<<"\n"<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<"\n";
        return 0;
    }


Measured memory_bytes: 256
S = input()
if len(S)%2 == 0 and S[0] == S[len(S)-1]:
  print("First")
elif len(S)%2 == 0 and S[0] != S[len(S)-1]:
  print("Second")
elif len(S)%2 != 0 and S[0] == S[len(S)-1]:
  print("Second")
else:
  print("First")

Measured memory_bytes: 39152
def solve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    cnt0 = 0
    cnt1 = 0
    cnt2 = 0
    for i in range(N):
        if A[i]<0:
            cnt1+=1
        elif A[i]>0:
            cnt2+=1
        else:
            cnt0+=1
    if 0<cnt2+cnt0<N:
        M = sum(list(map(abs, A)))
        print(M)
        hu = A[0]
        sei = A[cnt1]
        tmp1 = sei
        for i in range(1, cnt1):
            print(tmp1, A[i])
            tmp1-=A[i]
        tmp2 = hu
        for i in range(cnt1+1, N):
            print(tmp2, A[i])
            tmp2-=A[i]
        print(tmp1, tmp2)
    elif cnt0 == N:
        print(0)
        for i in range(N-1):
            print(0, 0)
    elif cnt2==0 :
        if cnt0 >0:
            M = sum(list(map(abs, A)))
            print(M)
            hu = A[0]
            sei = A[cnt1]
            tmp1 = sei
            for i in range(1, cnt1):
                print(tmp1, A[i])
                tmp1-=A[i]
            tmp2 = hu
            for i in range(cnt1+1, N):
                print(tmp2, A[i])
                tmp2-=A[i]
            print(tmp1, tmp2)
        else:
            M = -sum(A)+A[-1]*2
            print(M)
            tmp = A[-1]
            for i in range(N-1):
                print(tmp, A[i])
                tmp = tmp-A[i]
    else:
        M = sum(A)-A[0]*2
        print(M)
        tmp = A[0]
        for i in range(1, N-1):
            print(tmp, A[i])
            tmp = tmp-A[i]
        print(A[N-1], tmp)
solve()           
        

Measured memory_bytes: 62428
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

int f(int n) {
  int res = 0;
  repp(x, 1, 100) {
    repp(y, 1, 100) {
      repp(z, 1, 100) {
        int sum = x * x + y * y + z * z + x * y + y * z + z * x;
        if (sum == n)
          res++;
        else if (sum > n)
          break;
      }
    }
  }
  return res;
}

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

  repp(i, 1, N) {
    cout << f(i) << endl;
  }
}

Measured memory_bytes: 3564
n = int(input())
C = [0] + [int(input()) for i in range(n)]
p = 10 ** 9 + 7

DP = [0] * (n + 1)
last = [0] * int(2e5 + 1)
DP[0] = 1

for i in range(n):
    if C[i + 1] == C[i]:
        DP[i + 1] = DP[i] % p
    else:
        DP[i + 1] = (DP[i] + last[C[i + 1]]) % p
    last[C[i + 1]] = DP[i + 1]

print(DP[n])

Measured memory_bytes: 20360
n, k = map(int, input().split())
v = list(map(int, input().split()))

def solve(L, R, D):
  # print((L, R, D))
  LL = v[:L] if L > 0 else []
  RR = v[-R:] if R > 0 else []
  targetList = LL + RR
  # print(targetList)
  targetList.sort()
  ret = 0
  newList = targetList[::]
  for i in range(min(len(targetList), D)):
    if targetList[i] < 0:
      del newList[0]
  ret = sum(newList)
  # print((ret, newList))
  return ret

result = 0
for i in range(min(k+1, n+1)):
  for j in range(min(k+1, n+1)-i):
    t = solve(i, j, k-i-j)
    if t > result:
      result = t

print(result)

Measured memory_bytes: 41308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
			int a =sc.nextInt();
			int b =sc.nextInt();
			
			int c;
			c=a*b;
			
			if(c%2==0){
				System.out.println("Even");
			} else {
				System.out.println("Odd");
			}
		}
}

Measured memory_bytes: 21204
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort()
b.sort()
c.sort()

cntb = 0
cntc = 0
ans = 0

lib = [0] * n
flag = True

for i in range(n):
    if not flag:
        break
    bi = b[i]
    while bi >= c[cntc]:
        cntc += 1
        if cntc == n:
            flag = False
            break
    lib[i] = n - cntc

lib2 = [sum(lib)]

for i in range(n):
    lib2.append(lib2[-1] - lib[i])

flag = True

for i in range(n):
    if not flag:
        break
    ai = a[i]
    while ai >= b[cntb]:
        cntb += 1
        if cntb == n:
            flag = False
            break
    if not flag:
        break
    ans += lib2[cntb]

print(ans)


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

int main(){
	
	int n,m;
	
	while(cin>>n>>m,n+m){
		vector<int>H(n+1),W(m+1);
		map<int,int>M;
		int ans=0;
		H[0]=W[0]=0;	
		for(int i=1;i<=n;i++)cin>>H[i];
		for(int i=1;i<=m;i++)cin>>W[i];
		for(int i=1;i<=n;i++)H[i]+=H[i-1];
		for(int i=1;i<=m;i++)W[i]+=W[i-1];
		for(int i=0;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				M[H[j]-H[i]]++;
			}
		}
		for(int i=0;i<=m;i++){
			for(int j=i+1;j<=m;j++){
				ans+=M[W[j]-W[i]];
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


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

#define all(C) C.begin(),C.end()
typedef long long int Long;
typedef long double Double;
const int MAXN = 1e5 + 5;

Long a, b, c, k;

int main() {
  scanf("%lld%lld%lld%lld", &a, &b, &c, &k);

  if(k & 1)
    printf("%lld\n", b - a);
  else
    printf("%lld\n", a - b);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[200000],L;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        L^=a[i];
    }
    for(int i=0;i<n;i++){
        cout<<(L^a[i])<<" ";
    }
    cout<<endl;
}


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

using namespace std;
typedef long long ll;

const int N = 200'010, P = 10'010;
char s[N];
int r[N], cnt[P];

int main() {
    int n, p;
    scanf("%d%d", &n, &p);
    scanf("%s", s + 1);
    ll ans = 0;
    if (p == 2 || p == 5) {
        for (int i = 1; i <= n; i++) {
            if ((s[i] - '0') % p == 0) ans += i;
        }
        printf("%lld\n", ans);
        return 0;
    }
    int pw = 1;
    cnt[0] = 1;
    for (int i = n; i >= 1; i--) {
        r[i] = (pw * (s[i] - '0') + r[i + 1]) % p;
        cnt[r[i]]++;
        pw = 10 * pw % p;
    }
    for (int i = 0; i < p; i++) ans += 1ll * cnt[i] * (cnt[i] - 1) / 2;
    printf("%lld\n", ans);
}


Measured memory_bytes: 4756
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
//printf("%.10f\n", n);
ll yo[12345678], ta[12345678];
signed main() {
    ll n = 0, m;
    string s; cin >> s >> n;
    for (int h = 0; h < s.size(); h++) {
        if (s[h] != 'a' && (ll)s[h] + n >= 123) {
            n -= (123 - (ll)s[h]); s[h] = 'a';
        }
    }
    while ((ll)s[s.size() - 1] + n >= 123) {
        n -= 26;
    }
    s[s.size() - 1] = (char)((ll)s[s.size() - 1] + n);
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	char a;
	int j = 0,o = 0,i = 0;
	int jlv = 0,olv = 0,ilv = 0;
	int mx = 0;
	while(scanf("%c",&a) != EOF){
        if(a == 10)break;
        if(a == 'J'){
            if(o != 0 || i != 0 || o != 0 && i != 0){
                j = o = i = jlv = olv = ilv = 0;
            }
            if(j == 0){
                j++;
            }
            else j++;
            //printf("j   j = %d o = %d i = %d jlv = %d olv = %d ilv = %d\n",j,o,i,jlv,olv,ilv);
        }
        if(a == 'O'){
            if(j != 0){
                jlv = j;
                j = 0;
            }
            if(i != 0){
                i = ilv = 0;
                jlv = 0;
            }
            if(o == 0) o++,olv = o;
            else o++,olv = o;
            //printf("o   j = %d o = %d i = %d jlv = %d olv = %d ilv = %d\n",j,o,i,jlv,olv,ilv);
        }
        if(a == 'I'){
            if(olv != 0){
                j = o = 0;
            }
            if(olv == 0)j = 0;
            if(jlv != 0 && olv != 0){
                j = o = 0;
                i++;
                ilv = i;
            }
            if(jlv >= olv && ilv >= olv)mx = max(mx,olv);
            //printf("i   j = %d o = %d i = %d jlv = %d olv = %d ilv = %d\n",j,o,i,jlv,olv,ilv);
        }
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

vector<int> tpsort(const vector<vector<int>>& g) {
	int V = g.size();
	vector<int> indeg(V, 0);
	stack<int> S;

	for (int i = 0; i < V; ++i) {
		for (int j = 0; j < g[i].size(); ++j) {
			++indeg[g[i][j]];
		}
	}
	for (int i = 0; i < V; ++i) {
		if (indeg[i] == 0) { S.push(i); }
	}

	vector<int> ret;
	while (S.size() > 0) {
		int u = S.top(); S.pop();
		ret.push_back(u);
		for (int i = 0; i < g[u].size(); ++i) {
			--indeg[g[u][i]];
			if (indeg[g[u][i]] == 0) {
				S.push(g[u][i]);
			}
		}
	}
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> to(N);
	for (int i = 0; i < N - 1 + M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
	}

	vector<int> tp = tpsort(to);
	vector<int> par(N, -1);
	par[tp[0]] = 0;
	for (int i = 0; i < tp.size(); ++i) {
		int u = tp[i];
		for (int j = 0; j < to[u].size(); ++j) {
			par[to[u][j]] = u + 1;
		}
	}

	for (int i = 0; i < N; ++i) {
		cout << par[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 7024
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(_,v.size())cout<<" "<<v[_];cout<<endl;
#define show2d(v) rep(_,v.size()){rep(__,v[_].size())cout<<" "<<v[_][__];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int n,t;
	cin>>n>>t;
	ll out=inf;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		if(b<=t)out=min(out,a);
	}
	if(out==inf)cout<<"TLE"<<endl;
	else cout<<out<<endl;
	
}

/*
int n,m;
vvi nex[2],dp(2);
vi in;
void f(int a){
	int N=-1,t=m;
	while(t){
		vi dp(n,-1);
		int w=0;
		rep(i,n)if(dp[i]==-1){
			int l=i,r=i+1;
			while(r<n&&in[r]-in[r-1]<=t)r++;
			loop(j,l,r)dp[j]=r;
		}
		nex[a].pb(dp);
		t/=2;
		N++;
	}
	dp[a]=vi(1<<N,-1);
	dp[a][0]=0;
	rep(i,1<<N)if(dp[a][i]-n)rep(j,N)if((i&1<<j)==0)cmax(dp[a][i|1<<j],nex[a][j+1][dp[a][i]]);
}
int main(){
	cin>>n>>m;
	in=vi(n);
	rep(i,n)cin>>in[i];
	
	f(0);
	rep(i,n)in[i]*=-1;
	sort(all(in));
	f(1);
	
	rep(i,n){
		int l=n-nex[1][0][i]-1,r=nex[0][0][i];
		bool h=false;
		
	}
	
}
*/








Measured memory_bytes: 256
/*input
CODEFESTIVAL
*/
#include <iostream>
#include <string>
using namespace std;
string s;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>s;
	bool ok = false, ok1 = false;
	for(int i=0;i<s.size();++i){
		if (s[i] == 'C') ok = true;
		else if (s[i] == 'F' && ok) { ok1 = true; break; }
 	}
	cout<<(ok1 ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
	int n, x;
	while(1){
	    cin>>n>>x;
		if(n == 0 && x == 0)break;
		int count = 0;
		for(int i = 1; i <= n; i++){
			for(int j = i + 1; j <= n; j++){
				for(int k = j + 1; k <= n; k++){
					if(i + j + k == x) count ++;
				}
			}
		}
		
		cout << count << endl;
	}
	return 0;
}



Measured memory_bytes: 3108
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
string a,b;
cin>>a>>b;
if((a.size()==b.size()&&a>b)||a.size()>b.size())cout<<"GREATER"<<endl;
else if(a==b)cout<<"EQUAL"<<endl;
else cout<<"LESS"<<endl;
}

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

public class Program
{

    public void Proc()
    {
        int inputCount = int.Parse(Reader.ReadLine());

        string[] words = new string[inputCount];

        for (int i = 0; i < words.Length; i++) {
            words[i] = Reader.ReadLine();
        }

        string ans = "No";
        if(IsRuled(words)) {
            ans = "Yes";
        }
        Console.WriteLine(ans);


    }

    private bool IsRuled(string[] words) {
        if(words.Length != words.Distinct().Count()) {
            return false;
        }

        for (int i = 1; i < words.Length; i++) {
            if(words[i-1].Last() != words[i].First()) {
                return false;
            }
        }
        return true;
    }


    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"




9
basic
c
cpp
php
python
nadesico
ocaml
lua
assembly



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


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

using namespace std;
using ll = long long;

#define inf 9000000000000
#define mx 1003

int n, m;
int a[mx], b[mx], c[mx];
ll dp[mx][1 << 15];

ll solve(int i, int mask) {
    if (i == m) {
        if (mask == (1 << n) - 1) return 0;
        return inf;
    }
    
    if (mask == (1 << n) - 1) return 0;
    auto& ans = dp[i][mask];
    if (ans != -1) return ans;
    ans = inf;
    int nask = mask | c[i];
    ans = a[i] + solve(i + 1, nask);
    ans = min(ans, solve(i + 1, mask));
    return ans;
}

int main() {
    cin >> n >> m;
    int mark = 0;
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        int mask = 0;
        for (int j = 0; j < b[i]; j++) {
            int x; cin >> x;
            x--;
            mask |= (1 << x);
        }

        c[i] = mask;
        mark |= mask;
    }

    if (mark != (1 << n) - 1) {
        cout << -1 << endl;
        return 0;
    }

    memset(dp, -1, sizeof dp);
    auto ans = solve(0, 0);
    cout << ans << endl;   
}

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

using namespace std;

#define pb push_back
const int maxi=1e6+2;
int a[maxi];
vector<int> v[maxi];
long long n,k;
string s;
long long ans;
int main()
{
   cin>>n>>k;

   long long  nula=0;
   long long  kp=0;
   for (int i=1;i<=n;i++)
    if (i%k==0) nula++; else
    if (i%k==k/2) kp++;

   ans=(nula*(nula-1)*(nula-2))+nula+3*(nula)*(nula-1);

   if (k%2==0)
   {
       ans+=(kp*(kp-1)*(kp-2))+kp+3*(kp)*(kp-1);;
   }

  cout<<ans<<endl;

  return 0;
}
//bicu tuzan ako ne budu dva constructive


Measured memory_bytes: 24832
from heapq import*
import sys
input=sys.stdin.readline
 
def DIJKSTRA(point,d):
    cost      = [1e18]*(n+1)
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost

n=int(input())
d=[[]for i in range(n+1)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])

q,k=map(int,input().split())
y=DIJKSTRA(k,d)
 
for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])


Measured memory_bytes: 92576
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string S,T;
	cin >> S >> T;
	if (S.size() == T.size()-1 && S == T.substr(0,T.size()-1))
		cout << "Yes\n";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 3644
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

char g;
char fie[4][13];
int val[4][13];
int score[4];
int main(void){
	while(1){
		scanf("%c%*c",&g);
		if(g=='#')break;
		for(int i=0;i<4;i++){
			for(int j=0;j<13;j++){
				char a;
				scanf("%c%c%*c",&a,&fie[i][j]);
				if(a>='0' && a<='9'){
					val[i][j]=a-'0';
				}else{
					if(a=='T')val[i][j]=10;
					if(a=='J')val[i][j]=11;
					if(a=='Q')val[i][j]=12;
					if(a=='K')val[i][j]=13;
					if(a=='A')val[i][j]=14;
				}
			}
		}
		memset(score,0,sizeof(score));
		int lead=0;
		for(int i=0;i<13;i++){
			int win=-1,ws=-1;
			for(int j=0;j<4;j++){
				int sc=val[j][i];
				if(fie[j][i]==g)sc+=100;
				if(fie[j][i]!=g && fie[j][i]!=fie[lead][i])continue;
				if(sc>ws){
					ws=sc;
					win=j;
				}
			}
			lead=win;
			score[win]++;
		}
		if(score[0]+score[2]>score[1]+score[3]){
			printf("NS %d\n",score[0]+score[2]-6);
		}else{
			printf("EW %d\n",score[1]+score[3]-6);
		}
	}
	return 0;
}

Measured memory_bytes: 960
suit = "H"
cou_car = int(input())
exist_flg = [[True for i in range(13)] for j in range(4)]
for i in range(cou_car):
    disc = input()
    disc_car = disc.split(" ")
    disc_num =int(disc_car[1])
    disc_sui = disc_car[0]
    num_suit = 5
    if disc_sui == "S":
        num_suit = 0
    elif disc_sui == "H":
        num_suit = 1
    elif disc_sui == "C":
        num_suit = 2
    elif disc_sui == "D":
        num_suit = 3
    exist_flg[num_suit][disc_num - 1] = False
for j in range(52):
    if int((j - j % 13) / 13)  == 0:
        suit = "S"
    elif int((j - j % 13) / 13) == 1:
        suit = "H"
    elif int((j - j % 13) / 13) == 2:
        suit = "C"
    elif int((j - j % 13) / 13) == 3:
        suit = "D"
    if exist_flg[int((j -j % 13) / 13)][j % 13]:
        print(suit + " " + str(j % 13 + 1))


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

using namespace std;

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

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// 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;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

  ll x,y;
  cin >> x >> y;

  ll ans = 0;

  if(x * y > 0)
  {
    ans = abs(y-x) + ( x < y ? 0 : 2);
  }
  else if(x == 0)
  {
    ans = abs(y) + ( y < 0 ? 1 : 0);
  }
  else if(y == 0)
  {
    ans = abs(x) + ( x < 0 ? 0 : 1);
  }
  else
  {
    ans = abs( y + x ) + 1;
  }  

  cout << ans << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int 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;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, ans=1;
  std::cin >> N;
  std::vector<int> yama(N);
  range(i, N) std::cin >> yama[i];
  ranges(i, 1, N){
    int flag = 1;
    range(j, i){
      if(yama[i]<yama[j]) flag=0;
    }
    if(flag==1) ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main() {
  int N,maxc,maxd;
  cin >> N;

  maxc = 0;
  maxd = 0;
  int c[N], d[N];

  for (int i; i < N; i++) {
    cin >> c[i] >> d[i];
  }

  for (int i; i < N; i++) {
    if ( maxc < c[i]) {
      maxc = c[i];
      maxd = c[i] + d[i];
    }
  }

  cout << maxd << endl;
  return 0;
}

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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int Ans=0;
  for(int i=0; i<=A; i++){
    for(int j=0; j<=B; j++){
      for(int k=0; k<=C; k++){
        if(i*500+j*100+k*50==X){
          Ans++;
        }
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if(x+r<=w&&x-r>=0&&y+r<=h&&y-r>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val k = sc.nextInt()

  var str = ""
  var x = n
  while (x > 0) {
    val r = x % k
    str = r.toInt + str
    x = x / k
  }
  println(str.length)
}


Measured memory_bytes: 27828