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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

int main() {
    string s, t;
    cin >> s >> t;
    if (sz(s) >= sz(t)) {
        puts("No");
    } else if (t.substr(0, sz(s)) == s) {
        puts("Yes");
    } else {
        puts("No");
    }


    return 0;
}

Measured memory_bytes: 3624
n = int(input())
w = [input() for _ in range(n)]
if len(set(w)) != len(w):
    print("No")
else:
    prev = w[0]
    for i in range(1,len(w)):
        if prev[len(prev)-1] != w[i][0]:
            print("No")
            exit() 
        else:
            prev = w[i]
    print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	cout<<N*N*N<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
R,C,K=map(int, sys.stdin.readline().split())

value=defaultdict(lambda: 0)
value=[ [0 for _ in range(C+1)] for __ in range(R+1) ]
for _ in range(K):
    r,c,v=map(int, sys.stdin.readline().split())
    value[r][c]=v

dp0=[0]*(C+1)
dp1=[0]*(C+1)
dp2=[0]*(C+1)
dp3=[0]*(C+1)

for r in range(1,R+1):
    for c in range(1,C+1):
        #今のマスにアイテムがある場合
        if 0<value[r][c]:
            dp3[c]=max( dp3[c-1], dp2[c-1]+value[r][c] )
            dp2[c]=max( dp2[c-1], dp1[c-1]+value[r][c] )
            dp1[c]=max( dp1[c-1], dp0[c-1]+value[r][c], dp0[c]+value[r][c] )
            dp0[c]=max( dp0[c-1], dp0[c] )
        #今のマスにアイテムがない場合
        else:
            dp0[c]=max( dp0[c-1], dp0[c] )
            dp1[c]=max( dp1[c-1], dp1[c] )
            dp2[c]=max( dp2[c-1], dp2[c] )
            dp3[c]=max( dp3[c-1], dp3[c] )

    #上の行にアイテムをコピー
    for c in range(1,C+1):
        dp0[c]=max( dp0[c], dp1[c], dp2[c], dp3[c] )
    dp1=[0]*(C+1)
    dp2=[0]*(C+1)
    dp3=[0]*(C+1)

print dp0[C]


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

int main(){
	long long int ans=0;
	int n,b=0;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		if(a.at(i)<0){
			b++;
			a.at(i)=(-1)*a.at(i);
			ans+=a.at(i);

		}else{
			ans+=a.at(i);
		}
	}
	sort(a.begin(),a.end());
	if(b%2){
		ans-=2*a.at(0);
	}
	cout << ans << endl;	
}

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

using namespace std;
int a[100005],b[100005];
string s;
int main()
{
    int n,m,d=0,c=0;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        int q;
        cin >> q >> s;
        if(s=="WA" && a[q]==0)
        {
            b[q]++;
        }
        else if(s=="AC" && a[q]==0)
        {
            d++;
            a[q]=1;
        }
    }
    for(int i=0;i<=n;i++)
    {
        if(a[i]==1)
          c+=b[i];
    }
    cout << d << " " << c << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    long long int n,tmp = 0;
    string s;

    cin >> n;

    vector<long long int>v(3,0);

    for(int i = 0;i < n;i++){
        char c;
        cin >> c;
        s += c;
        if(s[i] == 'R'){
            v[0]++;
        }else if(s[i] == 'G'){
            v[1]++;
        }else{
            v[2]++;
        }
    }

    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            int k = 2*j-i;
            if(k >= n)break;
            if(2*j == i+k && s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
                tmp++;

        }
        
    }


    cout << (v[0]*v[1]*v[2])-tmp << endl;

    return 0;
}

Measured memory_bytes: 3632
n = int(input())
s = []
for i in range(n):
    s.append(input())
m = int(input())
t = []
for i in range(m):
    t.append(input())

point_list = []
for i in range(n):
    point = 0
    for j in range(n):
        if s[i] == s[j]:
            point = point + 1
    for k in range(m):
        if s[i] == t[k]:
            point = point - 1
    point_list.append(point)
print(max(0, max(point_list)))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n, 0);
  rep(i, n){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int ans = INT_MAX;
  rep(i, n-k+1){
    // cout << v[i+k-1] << ' ' << v[i] << endl;
    ans = min(ans, v[i+k-1] - v[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;
 
typedef unsigned long long ll;
 
int main()
{
    double A, B, X;
    cin >> A >> B >> X;
    double S = X / A;
    double rad;
    
    if(S > (A * B/2)){
        double h = (A * B - S)*2/A;
        rad = atan2(h, A);
    }
    else{
        double w = (S * 2) / B;
        rad = atan2(B, w);
    }
    
    double PI = acos(-1);
    double deg = rad / (2*PI) * 360;
    printf("%.10f\n", deg);
    
    return 0;
}

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



Measured memory_bytes: 35692
using System;

class Search
{
    public bool LinearSearch(int[] a, int n, int key) {
        a[n] = key;
        int i = 0;
        while (a[i] != key) {
            i++;
        }
        return i != n;
    }
}

class A
{
    public static void Main() {
        int n, q, count = 0;
        int[] s;
        Search search = new Search();
        s = new int[100001];
        n = int.Parse(Console.ReadLine());
        string[] data = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++) {
            s[i] = int.Parse(data[i]);
        }
        q = int.Parse(Console.ReadLine());
        string[] data2 = Console.ReadLine().Split(' ');
        for (int i = 0; i < q; i++) {
            if (search.LinearSearch(s, n, int.Parse(data2[i]))) {
                count++;
            }
        }
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 10204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int gcd(int x, int y) {
  if(y == 0) {
    return x;
  } else{
    return gcd(y, x % y);
  }
}

int gcd2(int x, int y, int z){
  int a = gcd(x, y);
  if(z == 0) {
    return a;
  } else{
    return gcd(z, a % z);
  }
}
  
int main(){
  int k, sum = 0;
  cin >> k;
  k++;
  rep(i, 1, k){
    rep(j, 1, k){
      rep(l, 1, k){
        sum += gcd2(i, j, l);
      }
    }
  }
  
  cout << sum << "\n";
}
  
  
  
  
  
  
  
  
  
  

Measured memory_bytes: 3640
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)
#define MOD (1e9+7)

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int n;
int p[100];
int ans = 0;

int main() {
	cin >> n;
	REP(i, n) cin >> p[i];
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1] ||
			p[i - 1] > p[i] && p[i] > p[i + 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

		while(n-- > 0){
			t = new int[5][5];
			int m = 0;
			boolean[] used = new boolean[7];
			boolean trueFlg = true;

			for(int i=0;i<5;i++){
				for(int j=0;j<5;j++){
					t[i][j] = sc.nextInt();

					//ツ督ッツつカツ青板篠堋つェツ出ツづつォツづづ按つ「ツつゥツづ個確ツ認
					if(t[i][j] != 0){
						if(!used[t[i][j]]){
							m++;
							used[t[i][j]] = true;
						}
						else{
							trueFlg = false;
						}
					}
				}
			}
			if(m != 6) trueFlg = false;

			//ツサツイツコツδ債づ青ャツ猟ァツつオツづつ「ツづゥツつゥツづ個確ツ認
			if(trueFlg){
				int sy=-1,sx=-1;
				for(sy=0;sy<5;sy++){
					for(sx=0;sx<5;sx++) if(t[sy][sx] != 0) break;
					if(sx != 5) break;
				}

				Dice d = new Dice(0,0,0,0,0,0);
				makeDice(d,sx,sy);
				trueFlg = d.isDice();
			}

			System.out.println(trueFlg ? "true" : "false");
		}
	}

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

	private static void makeDice(Dice d,int x,int y){
		d.b = t[y][x];
		t[y][x] = 0;

		for(int i=0;i<4;i++){
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx>=0 && nx<5 && ny>=0 && ny<5 && t[ny][nx]>0){
				d.move(i);
				makeDice(d,nx,ny);
				d.move((i+2)%4);
			}
		}
	}
}

class Dice{
	int t,b,w,e,n,s;

	Dice(int t,int b,int w,int e,int n,int s){
		this.t = t;
		this.b = b;
		this.w = w;
		this.e = e;
		this.n = n;
		this.s = s;
	}

	boolean isDice(){
		return t+b==7 && w+e==7 && n+s==7;
	}

	void move(int dir){
		Dice d = this.copy();
			
		switch(dir){
		case 0:
			t = d.s;
			b = d.n;
			n = d.t;
			s = d.b;
			break;
		case 1:
			t = d.w;
			b = d.e;
			w = d.b;
			e = d.t;
			break;
		case 2:
			t = d.n;
			b = d.s;
			n = d.b;
			s = d.t;
			break;
		case 3:
			t = d.e;
			b = d.w;
			w = d.t;
			e = d.b;
			break;
		}
	}

	Dice copy(){
		return new Dice(t,b,w,e,n,s);
	}
}

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

using namespace std;

int main()
{
    int A, B;   cin >> A >> B;

    int Cur = 1;
    int Ans = 0;

    while(Cur < B)
    {
        Cur += A - 1;
        Ans++;
    }

    cout << Ans << endl;
}


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

#define long long long int
using namespace std;

// @author: pashka

long gcd(long a, long b) {
    while (b > 0) {
        long c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    long m;
    cin >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    long x = a[0];
    for (int i = 1; i < n; i++) {
        x = x / gcd(x, a[i]) * a[i];
        if (x > m) {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        if ((x / a[i]) % 2 == 0) {
            cout << 0;
            return 0;
        }
    }
    // x, 3x, 5x, ...
    // max k : (2k + 1) x <= m
    // k <= (m / x - 1) / 2
    long res = (m / x - 1) / 2 + 1;
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 640
import sys

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

x=0
for i in range(K):
  if B > A:
    break
  B = B*2
  x += 1
  if i == K-1:
    ans = 'No'
    print(ans)
    sys.exit()

ans = 'Yes' if C*2**(K-x) > B else 'No'

print(ans)


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

int main(){
    string s,s1,s2,s3;
    int q, t, f;
    bitset<1> mode;
    char c;
    cin >> s >> q;
    for(int i=0; i<q; i++){
        cin >> t;
        if(t==2){
            cin >> f >> c;
            if((f==1 && mode==0) || (f==2 && mode==1)){
                s1=s1+c;
            }else {
                s=s+c;
            }
        }else {
            mode = ~mode;
        }
   }
    reverse(s1.begin(), s1.end());
    s=s1+s;
   if(mode==1){
       reverse(s.begin(), s.end());
   }
   cout << s << endl;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

vector<int> G[101];

vector<ll> vs; 

void renzoku(string &s){
    int len = 1;
    for(int i = 1;i < s.size();i++){
        if(s[i-1] == s[i]){
            len++;
        }else{
            vs.push_back(len);
            len = 1;
        }
    }
    vs.push_back(len);
}

void show(){
    for(int i = 0;i < vs.size();i++){
        cout << vs[i] << endl;
    }
}

int main(){
    string s;
    int k;
    cin >> s >> k;

    ll ans = 0;

    renzoku(s);
    // show();
    if(vs.size() == 1){
        ans = s.size() * k / 2;
    }else{
        for(int i = 0;i < vs.size();i++){
            ans += (vs[i]/2) * k;
        }
        if(s[0] == s[s.size()-1]){
            ans -= (vs[0]/2 + vs[vs.size()-1]/2 - (vs[0] + vs[vs.size()-1])/2)*(k-1);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)


func main() {
	var n, a, b, surplus, times int
	fmt.Scan(&n, &a, &b)

	surplus = n % (a+b)
	times = n / (a+b)
	if a == 0 {
		fmt.Println(0);
	} else if a > surplus {
		fmt.Println(surplus + a*times)
	} else {
		fmt.Println(a*times + a)
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100000

int main(){

  int n, i;
  int A[MAX];

  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ){
    scanf("%d", &A[i]);
  }

  for ( i = 1; i <= n; i++ ) {
    printf("node %d: key = %d, ", i, A[i]);
    
    if( i / 2 >= 1 ) printf("parent key = %d, ", A[i/2]);
    if( i*2 <= n ) printf("left key = %d, ", A[i*2]);
    if( i*2+1 <= n ) printf("right key = %d, ", A[i*2+1]);

    printf("\n");
  }  
  return 0;
}

Measured memory_bytes: 608
Sa=str(input())
Sb=str(input())
Sc=str(input())
def battle(Sa,Sb,Sc):
    now='a'
    while len(Sa)>=0 and len(Sb)>=0 and len(Sc)>=0:
        if now=='a':
            if len(Sa)==0:return 'A'
            now=Sa[0]
            Sa=Sa[1:]
        elif now=='b':
            if len(Sb)==0:return 'B'
            now=Sb[0]
            Sb=Sb[1:]
        elif now=='c':
            if len(Sc)==0:return 'C'
            now=Sc[0]
            Sc=Sc[1:]
print(battle(Sa,Sb,Sc))

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a;
    scanf("%d",&a);
    if(a%100%10 == 7){
        printf("Yes");
    }
    else{
        a=a/10;
        if(a%10==7){
            printf("Yes");
        }
        else{
            a=a/10;
            if(a==7){
                printf("Yes");
            }
            else{
                printf("No");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1728
/*
      author : Nishikawa
      created: 05.08.2020 16:15:21
*/

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


int main(){
    int N;
    cin >> N;
    vector<ll> vec(N+1);
    for(int i=1; i<=N; i++) cin >> vec[i];
    sort(vec.begin()+1,vec.end(),greater<int>());

    ll sum=0;
    if(N==2) sum=vec[1];
    else{
        if(N%2==0){
            sum+=vec[1];
            for(int i=2; i<=N/2; i++) sum+=2*vec[i];
        }
        else{
            sum+=vec[1];
            for(int i=2; i<=(N-1)/2; i++) sum+=2*vec[i];
            sum+=vec[(N-1)/2+1];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4824
#include <algorithm>
#include<bits/stdc++.h>
#include <ios>
#include <iterator>
using namespace std;
#define ll long long
#define f(n)  for(int i=0;i<n;i++) 
#define pb push_back
#define mp make_pair
#define vi vector< int>
#define all(v)   v.begin(),v.end()  
#define take(n)   ll int n;cin>>n;
void speed (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
int main() {
	speed();
 int r;
    cin>>r;
    double ans=6.28318530717958623200*r;
    cout.precision(20);
    cout<<fixed<<ans;
	return 0;
}

 

Measured memory_bytes: 3788
#include<iostream>
using namespace std;
int inrec(int w,int h,int x,int y)
{
	if ((x>=0&&x<=w)&&(y>=0&&y<=h))
		return 0;
	else 
		return 1;
}
int main()
{
	int x,y,r,w,h;
	int flag;
	cin>>w>>h>>x>>y>>r;
	flag=inrec(w,h,x-r,y)+inrec(w,h,x+r,y)+inrec(w,h,x,y-r)+inrec(w,h,x,y+r);
	if (flag==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;	
	return 0;
}


Measured memory_bytes: 3104
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    
    N,X,Y = LMIIS()
    X -= 1
    Y -= 1
    dp =[[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(i+1,N):
            if i <= X < Y <= j:
                dp[i][j] = j - i  - (Y - X) + 1
            elif  i <= X and j <= Y:
                dp[i][j] = min(j-i, Y-j+1+X-i)
            elif X <= i and j <= Y:
                dp[i][j] = min(j-i,Y-j+1+i-X)
            elif X <= i and Y <= j:
                dp[i][j] = min(j-i,j-Y+1+i-X)

            else:
                dp[i][j] = j - i
    num_length = [0] * N
    for i in range(N):
        for j in range(i+1,N):
            num_length[dp[i][j]] += 1
    
    for i in range(1,N):
        print(num_length[i])
    # print(dp)


if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else if(s=="Rainy"){
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zh=0xff0000,MAXN=1e6+10;
int n,k,m,fa[1005];


int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a<=5)
        printf("0");
    else if(a<=12)
        printf("%d",b/2);
    else
        cout<<b;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
N = int(input())
L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

ans = 0
for i in range(N):
    for j in range(N):
        if i != j:
            ans += L[i] * L[j]
print(ans // 2)

Measured memory_bytes: 3316
def d_blue_and_red_balls(N, K, MOD=10**9 + 7):
    class Combination(object):
        """
        順列組み合わせ
        参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb
        """
        __slots__ = ["mod", "factorial", "inverse"]

        def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_n + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_n, 0, -1):
                inv_append(inv[-1] * i % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if r == n or r == 0:
                return 1
            if r > n:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

    comb = Combination(max(N - K + 1, K - 1))
    ans = [comb.combination(N - K + 1, i) * comb.combination(K - 1, i - 1) %
           MOD for i in range(1, K + 1)]
    return '\n'.join(map(str, ans))

N, K = [int(i) for i in input().split()]
print(d_blue_and_red_balls(N, K))

Measured memory_bytes: 3316
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define mod 1000000007
#define ll long long
#define N 1005
char S[N];
int A[N][N];
int h, w, l1, l2, cnt, tot;
int Pow(int a, ll k)
{
	int ret = 1;
	while (k)
	{
		if (k & 1)
			ret = (ll)ret * a % mod;
		a = (ll)a * a % mod;
		k >>= 1;
	}
	return ret;
}
struct Matrix
{
	int X[2][2];
	Matrix(){memset(X, 0, sizeof(X));}
	void Init()
	{
		memset(X, 0, sizeof(X));
		for (int i = 0; i < 2; i++)
			X[i][i] = 1;
	}
}W;
void Add(int &a, int b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}
void Mul(Matrix &A, Matrix &B)
{
	Matrix C;
	for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++)
			for (int k = 0; k < 2; k++)
				Add(C.X[i][j], (ll)A.X[i][k] * B.X[k][j] % mod);
	A = C;
}
void Pow(Matrix &A, ll k)
{
	Matrix ret;
	ret.Init();
	while (k)
	{
		if (k & 1)
			Mul(ret, A);
		Mul(A, A);
		k >>= 1;
	}
	A = ret;
}
int n, m;
ll k;
int main()
{
	scanf("%d%d%lld", &n, &m, &k);
	if (k <= 1)
	{
		puts("1");
		return 0;
	}
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", S + 1);
		for (int j = 1; j <= m; j++)
		{
			A[i][j] = (S[j] == '#');
			if (A[i][j])
				cnt++;
		}
	}
	for (int i = 1; i <= m; i++)
		if (A[1][i] && A[n][i])
			l1++;
	for (int i = 1; i <= n;i++)
		if (A[i][1] && A[i][m])
			l2++;
	if (!l1 && !l2)
	{
		printf("%d\n", Pow(cnt, k - 1));
		return 0;
	}
	if (l1 && l2)
	{
		puts("1");
		return 0;
	}
	if (l1)
	{
		for (int i = 1; i < n; i++)
			for (int j = 1; j <= m; j++)
				if (A[i][j] && A[i + 1][j])
					tot++;
	}
	else
	{
		for (int i = 1; i <= n; i++)
			for (int j = 1; j < m; j++)
				if (A[i][j] && A[i][j + 1])
					tot++;
	}
	W.X[0][0] = cnt;
	W.X[0][1] = tot;
	W.X[1][1] = l1 + l2;
	Pow(W, k - 2);
	int ans = ((ll)W.X[0][0] * tot % mod + (ll)W.X[0][1] * (l1 + l2) % mod) % mod;
	ans = (Pow(cnt, k - 1) - ans) % mod;
	if (ans < 0)ans += mod;
	printf("%d\n", ans);
}


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

int Euler_Phi(int n){
	  int res = n;
	  for(int i=2; i*i <= n;  i++){
			if(n%i == 0) {
				  res  = res / i * (i-1);
				  for(; n%i == 0 ; n /= i);
			}
	  }
	  if(n!=1) res = res / n * (n-1);
	  return res;

}

int main(){
	  int n; cin >> n;
	  cout << Euler_Phi(n) << endl;

}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(a);
    cii(b);
    cii(t);
    int ans = t / a * b;
    co(ans);
    return 0;
}

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

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = GetNumber();
            var nums = GetNumbersInt(N);
            var count = BubbleSort(nums);
            System.Console.WriteLine(string.Join(" ", nums.Select(x => x.ToString()).ToArray()));
            System.Console.WriteLine(count);
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int BubbleSort(int[] A)
        {
            var count = 0;
            for (int i = 0; i < A.Length - 1; i++)
            {
                for (int j = A.Length - 1; j >= i + 1; j--)
                {
                    if (A[j] < A[j - 1])
                    {
                        count++;
                        var tmp = A[j];
                        A[j] = A[j - 1];
                        A[j - 1] = tmp;
                    }
                }
            }
            return count;
        }

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10024
a, b, k = list(map(int, input().split()))
la = []
lb = []
for i in range(1, a+1):
    if a % i == 0:
        la.append(i)
        sa = set(la)
        lsa = list(sa)
        lsas = sorted(lsa)
        for j in lsas:
            if b % j == 0:
                lb.append(j)
s = set(lb)
lsb = list(s)
lsbs = sorted(lsb)
print(lsbs[len(lsbs)-k])


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		String[] c = new String[h * 2];
		for (int i = 0; i < c.length; i += 2)
			c[i] = c[i + 1] = sc.next();
		
		for (String s : c)
			System.out.println(s);
		
		sc.close();
	}
	
}




Measured memory_bytes: 30704
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {1,0};
const int dy[] = {0,1};
const ll INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<string> grid(n);
    rep(i, n) cin >> grid[i];
    mcf_graph<ll, ll> g(2*n*m+2);
    int start = 2*n*m;
    int goal = 2*n*m+1;
    vector<vector<int>> id(n, vector<int>(m));
    int index = 0;
    rep(i, n) rep(j, m) id[i][j] = index++;
    rep(i, n) rep(j, m) {
        if (grid[i][j]=='#') continue;
        if (grid[i][j]=='o') g.add_edge(start, id[i][j], 1, 0);
        g.add_edge(id[i][j]+n*m, goal, 1, INF-i-j);
    }
    
    vector<vector<bool>> used(n, vector<bool>(m));
    rep(i, n) rep(j, m) {
        rep(ii, n) rep(jj, m) used[ii][jj] = false;
        //debug(j);
        queue<P> q;
        q.emplace(i, j);
        used[i][j] = true;
        while (!q.empty()) {
            //debug(q.size());
            P now = q.front();
            q.pop();
            int x = now.fi;
            int y = now.se;
            g.add_edge(id[i][j], id[x][y]+n*m, 1, 0);
            rep(k, 2) {
                int ix = x + dx[k];
                int iy = y + dy[k];
                if (ix<0 || ix>=n || iy<0 || iy>=m) continue;
                if (used[ix][iy]) continue;
                if (grid[ix][iy]=='#') continue;
                used[ix][iy] = true;
                q.emplace(ix, iy);
            }
        }
    }
    ll flow = 0;
    ll total = 0;
    rep(i, n) rep(j, m) {
        if (grid[i][j]=='o') {
            flow++;
            total += INF-i-j;
        }
    }
    //debug(total);
    auto res = g.flow(start, goal, flow);
    ll ans = total - res.se;
    
    pr(ans);
    return 0;
}


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

int main(){
  long long l,r,buf;
  cin>>l>>r;
  buf=r-l;
  l=l%2019;
  r=l+buf;
  //0の場合
  if(r>=2019||r==0){
    cout<<0<<endl;
    return 0;
  }
  if((r>=673)&&(l<=673)){
    if((r%3==0)||(l%3==0)||(buf>=2)){
      cout<<0<<endl;
      return 0;
    }
  }
  
  buf=2018;
  int i,j;
  for(i=l;i<r;i++){
    for(j=i+1;j<=r;j++){
      if(buf>((i*j)%2019)) buf=(i*j)%2019;
    }
  }
  cout<<buf<<endl;
  return 0;
}

Measured memory_bytes: 256
while True:
  N,A,B,C,X=map(int,input().split())
  if N==0 and A==0 and B==0 and C==0 and X==0:
    break
  Y=list(map(int,input().split()))
  count=0
  real=0
  j=0
  while True:
    if X==Y[j]:
      count+=1
      j+=1
    if count==int(len(Y)):
      break
    if real>=10000:
      real=-1
      break
    X=(A*X+B)%C
    real+=1
  print(real)


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

int main() {
  int n,m;
  cin>>n>>m;
  ll vec[n][2],vecb[m][2];
  for(int i=0;i<n;i++){
    cin>>vec[i][0]>>vec[i][1];
  }
  for(int i=0;i<m;i++){
    cin>>vecb[i][0]>>vecb[i][1];
  }
  ll z;
  for(int i=0;i<n;i++){
    z=1e9;
    for(int j=0;j<m;j++){
      z=min(z,abs(vec[i][0]-vecb[j][0])+abs(vec[i][1]-vecb[j][1]));
    }
    for(int j=0;j<m;j++){
      if(abs(vec[i][0]-vecb[j][0])+abs(vec[i][1]-vecb[j][1])==z){
        cout<<j+1<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    a, b, x = [int(x) for x in input().split()]
    y = x / a
    if y < a * b / 2:
        c = 2 * y / b
        print(atan(b/c)*180/pi)
    else:
        z = a * b - y
        c = 2 * z / a
        print(atan(c/a)*180/pi)


    


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


Measured memory_bytes: 10108
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	ll r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
	}
ll lcm(ll x, ll y) {
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x*y);
}

int main()
{
	int n;
	vi y;
	cin >> n;
	int x[n];
	rep(i,n){
		cin >> x[i];
		y.pb(x[i]);
	}
	sort(y.begin(),y.end());
	rep(i,n){
		if(x[i]<y[y.size()/2]) cout << y[y.size()/2] << endl;
		else cout << y[y.size()/2-1] << endl;
	}
	return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;


int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> vs(n);
	rep(i, n) {
		cin >> vs[i];
	}
	sort(vs.begin(), vs.end());
	ll ans = 1;
	ll right = n - 1;
	ll left = 0;
	int sign = 1;
	if (k % 2) {
		ans = vs[n - 1];
		right--;
		if (ans < 0) {
			sign = -1;
		}
		k--;
	}
	while (k > 0) {
		ll c1 = vs[right] * vs[right - 1];
		ll c2 = vs[left] * vs[left + 1];
		if (c1 * sign >= c2 * sign) {
			ans *= c1 % mod;
			ans %= mod;
			right -= 2;			
		}
		else {
			ans *= c2 % mod;
			ans %= mod;
			left += 2;
		}
		k -= 2;
	}
	cout << (ans + mod) % mod<< endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[100010],ans=1;

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	rep(i,n)
	{
		if(a[i]==0)
		{
			cout<<0<<endl;
			return 0;
		}
	}
	rep(i,n)
	{
		if(a[i]>(LL)(1e18+ans-1)/ans)
		{
			puts("-1");
			return 0;
		}
		ans*=a[i];
	}
	if(ans>(LL)1e18) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	const ll KS = 1e9;
	rep(i, n){
		double s;
		cin >>s;
		a[i] = ll(s * KS + 0.5);
	}
	
	VL sk(400);
	rep(i, n){
		int y2=0, y5=0;
		for(ll w = a[i]; w%2==0 && w>0 && y2 <=18; w/=2) y2++;
		for(ll w = a[i]; w%5==0 && w>0 && y5 <=18; w/=5) y5++;
		sk[y2 * 20 + y5]++;
	}
	

	ll ans = 0;
	rep(i, 400){
		rep2(j, i+1, 400){
			if(i%20+j%20 >=18 && i/20+j/20 >=18)
				ans += sk[i] * sk[j];
		}
		if(sk[i]>=2 && i%20>=9 && i/20>=9) ans += sk[i] * (sk[i]-1) /2;
	}
	cout << ans<<"\n";
	
	return 0;
}



Measured memory_bytes: 4696
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,q;
char a[100005];
int d[100005];

int main()
{
    scanf("%d %d", &n, &q);
    scanf("%s",a+1);
    for(int i = 1;i <= n;i++)
    {
        d[i+1] = d[i];
        if(a[i+1] == 'C'&&a[i] == 'A')
        {
            d[i+1]++;
        }
    }
    int s,e;
    for(int i = 1;i <= q;i++)
    {
        scanf("%d %d", &s, &e);
        printf("%d\n",d[e]-d[s]);
    }
}

#endif // 1++


Measured memory_bytes: 1280
#include <bits/stdc++.h>
# define lli long long int
# define pb push_back
# define ff first
#define ss second
using namespace std;
lli n;
lli dp[100005]={0},a[100005]={0};
lli find(lli n)
{
     for(lli i=2;i<n;i++)
     {
          lli op1=abs(a[i]-a[i-1])+dp[i-1];
          lli op2=abs(a[i]-a[i-2])+dp[i-2];
          dp[i]=min(op1,op2);
     }
     return dp[n-1];
}
int main()
{
     lli n,j;
     cin>>n;
     for(j=0;j<n;j++)
     {
          cin>>a[j];
     }
     dp[1]=abs(a[0]-a[1]);
     cout<<find(n);
}


Measured memory_bytes: 5060
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
string S;
cin>>S;
int l=S.size();
string ans="AC";
if(S[0]!='A') ans="WA";

int cnt=0;
for(int i=1; i<=l; i++)
{
    if(isupper(S[i]))
    {
        if(i==1||i==l-1||S[i]!='C') {ans= "WA";} //S[1]とS[L-1]が小文字である
        ++cnt;
    }
}
if(cnt!=1) ans="WA";

cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#define rep(i,j,k) for(int i = j; i <= k; i++)
#define dow(i,j,k) for(int i = j; i >= k; i--)
#define fi first
#define se second
using namespace std;


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

const int N = 1e6 + 100;

int cnt[N];
int a[N], n;
int ans = 0;
int main() {
	scanf("%d", &n);
	rep(i,1,n) scanf("%d", &a[i]), cnt[a[i]]++;
	sort(a + 1, a + n + 1);
	rep(i,1,n) {
		if (a[i] == a[i-1]) continue;
		for (int j = 2; a[i] * j <= 1000000; j++) cnt[a[i] * j]++;
		if(cnt[a[i]] > 1) continue;
		ans ++;
		//for (int j = 2; a[i] * j <= 1000000; j++) cnt[a[i] * j]++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 8332
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,m,i=0,t,flag=0;
    scanf("%d",&n);
    m=n;
    while(n>0)
    {
        n--;
        scanf("%d",&t);
        if(t==1)
            flag=1;
        if(t==i+1)
            i++;
    }
    printf("%d\n",flag==1?m-i:-1);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    int w,a,b;
    cin>>w>>a>>b;
    if(a>b) swap(a,b);
    if(a<=b && b<=a+w) cout<<"0"<<endl;
    else cout<<min(b-a,b-a-w)<<endl;
    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/10/23  Problem: ABC 088 B / Link: http://abc088.contest.atcoder.jp/tasks/abc088_b  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	int N; cin >> N;
	VI a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	RSORT(a);
	FOR(i, 0, N) {
		if (i % 2 == 0)ans += a[i];
		else ans -= a[i];
	}
	
	
	cout << ans << "\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);
		long x = sc.nextLong();
		long count = (x / 11) * 2;
		long mod = x % 11;
		if (mod != 0) {
			count++;
			if (mod > 6) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23636
#include <stdio.h>

int main(void)
{
	int n,i;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	  scanf("%d",&a[i]);
	if(n%2==1)
	{
	  for(i=n-1;i>=0;i=i-2)
	    printf("%d ",a[i]);
	  for(i=1;i<n;i=i+2)
	    printf("%d ",a[i]);
	}
	else 
	{
	   for(i=n-1;i>=0;i=i-2)
	    printf("%d ",a[i]);
	   for(i=0;i<n;i=i+2)
	    printf("%d ",a[i]);
    }
	return 0;
 } 

Measured memory_bytes: 2816
<?php
  $N=intval(trim(fgets(STDIN)));
  fscanf(STDIN,"%s %s",$S,$T);

  $s_split=str_split($S);
  $t_split=str_split($T);
  $ans    =[]           ;

  for ($i=0; $i<$N; $i++) {
    $ans[]=$s_split[$i];
    $ans[]=$t_split[$i];
  }
  echo implode($ans)."\n";
?>

Measured memory_bytes: 3700
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    a,b,c,d = map(int,input().split())

    res = max(b*d,b*c)
    res = max(res,a*c)
    res = max(res,a*d)

    print(res)



main()


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

int main(){
  char	S[16] = {0};
  char	T[16] = {0};
  char	ss[16] = {0};
  char	tt[16] = {0};
  int	len;
  
  scanf("%s", S);
  scanf("%s", T);
  
  len = strlen(S);
  strncpy( tt, T, len );
  if( strcmp( S, tt ) == 0 ){
    if( strlen(T) == len+1 ){ printf("Yes"); return 0; }
  }
  printf("No");
  
  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
    string s;
    cin >> s;
    for (int i=0;i<12;++i) {
        cout << s[i];
        if (i+1 == 4) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];
  
  int man = 0;
  rep(i,n){
    man += b[i];
  }
  
  rep(i,n-1){
    if(a[i]+1==a[i+1])man+=c[a[i]];
  }
  
  cout << man << endl;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    if A[0] == 0:
        answer = []
        for a in (1, -1):
            cnt = 1
            S = a
            for i in range(1, N):
                s = S + A[i]
                if A[i] == 0:
                    if S > 0:
                        cnt += S + 1
                        S = -1
                    else:
                        cnt += abs(S) + 1
                        S = 1
                else:
                    if s == 0:
                        if S < 0:
                            cnt += 1
                            S = 1
                        else:
                            cnt += 1
                            S = -1
                    else:
                        if S * s > 0:
                            if S < 0:
                                cnt += abs(s) + 1
                                S = 1
                            else:
                                cnt += s + 1
                                S = -1
                        else:
                            S = s
            answer.append(cnt)
        print(min(answer))
    else:
        if A[0] > 0:
            cnt1 = 0
            S1 = A[0]
            cnt2 = A[0] + 1
            S2 = -1
        else:
            cnt1 = 0
            S1 = A[0]
            cnt2 = abs(A[0]) + 1
            S2 = 1
        answer = []
        for cnt, S in [(cnt1, S1), (cnt2, S2)]:
            for i in range(1, N):
                s = S + A[i]
                if A[i] == 0:
                    if S > 0:
                        cnt += S + 1
                        S = -1
                    else:
                        cnt += abs(S) + 1
                        S = 1
                else:
                    if s == 0:
                        if S < 0:
                            cnt += 1
                            S = 1
                        else:
                            cnt += 1
                            S = -1
                    else:
                        if S * s > 0:
                            if S < 0:
                                cnt += abs(s) + 1
                                S = 1
                            else:
                                cnt += s + 1
                                S = -1
                        else:
                            S = s
            answer.append(cnt)
        print(min(answer))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14332
open Scanf;;
open Printf;;

let rint () = scanf " %d" (fun x -> x);;

let () =
  let n = rint () in
  let h = Array.init n (fun _ -> rint ()) in
  let i = ref 0 in
  let ans = ref 0 in
  while !i < n do
    let j = !i in
    while !i + 1 < n && h.(!i) >= h.(!i + 1) do
      incr i
    done;
    ans := max !ans (!i - j);
    incr i;
  done;
  printf "%d\n" (!ans);
               


Measured memory_bytes: 5120