akhauriyash/Code-Regression huggingface dataset:
import collections
def II(): return int(input())
N=II()
L=[]
for i in range(N):
  s=input()
  L.append(s)
c=collections.Counter(L)
print('AC x',c['AC'])
print('WA x',c['WA'])
print('TLE x',c['TLE'])
print('RE x',c['RE'])

Measured memory_bytes: 16620
n,m=map(int,input().split())
a=[];b=[];c=[];d=[]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
for i in range(m):
    C,D=map(int,input().split())
    c.append(C)
    d.append(D)
for i in range(n):
    x=[]
    for j in range(m):
        x.append([abs(a[i]-c[j])+abs(b[i]-d[j]),j+1])
    x.sort()
    print(x[0][1])

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define ii pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef long double ld;

using namespace std;

int main(){
    cs
    int n,k,x,y;
    cin>>n>>k;
    vector<int> v(n+1);
    rep(i,k){cin>>x;rep(j,x) {cin>>y;v[y]++;}}
    x=0;
    repp(i,1,n) if(v[i]==0) x++;
    cout<<x;
}

Measured memory_bytes: 3656
import numpy as np

h, w, k = map(int, input().split())

cake = np.zeros((h, w))

for i in range(h):
    inputline = input()
    for j in range(w):
        if inputline[j] == ".":
            cake[i][j] = 0
        else:
            cake[i][j] = 1

s = np.sum(cake, axis=1)
first = 0
for i in range(h):
    if s[i]:
        first = i
        break

ans = np.zeros((h, w), dtype=np.uint64)
num = 1

for i in range(h):
    flag = 0
    if not s[i]:
        continue
    for j in range(w):
        if cake[i][j] and flag:
            num += 1
        elif cake[i][j]:
            flag += 1
        ans[i][j] = num
    num += 1

for i in range(h):
    if s[i] == 0 and i == 0:
        ans[i] = ans[first]
    elif s[i] == 0:
        ans[i] = ans[i-1]

for i in range(h):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 14392
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    ll n,k,ans;cin>>n>>k;
    plvec p(n);
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        p[i]=mp(a,b);
    }
    sort(all(p));
    ll cnt=0;
    while(true){
        if(p[cnt].sc>=k){
            ans=p[cnt].ft;
            break;
        }
        k-=p[cnt].sc;
        cnt++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        System.out.print(a[0]);
        for (int c = 1; c < n; c++) {
            System.out.print(" " + a[c]);
        }
        System.out.println();

        for (int i = 1; i < n; i++) {
            int v = a[i];
            int j = i-1;
            while (j >= 0 && a[j] > v) {
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = v;

            System.out.print(a[0]);
            for (int c = 1; c < n; c++) {
                System.out.print(" " + a[c]);
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 32624
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"::"<<x<<endl;
using namespace std;
typedef long long ll;

void solve()
{
	int n,m;
	cin>>n>>m;
	int ans=n*(n-1)/2;
	ans+=m*(m-1)/2;
	cout<<ans<<'\n';	
}

int main()
{
	
	int t;
	t=1;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
alice = 0
bob = 0
flag_alice = True
for num in a:
    if flag_alice:
        alice += num
        flag_alice = False
    else:
        bob += num
        flag_alice = True
print(alice - bob)

Measured memory_bytes: 3060
/* #                          */

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <deque>
#include <map>
//#pragma warning(disable:4996)

using namespace std;


/** Type Define **/
typedef long long int           ll;
typedef pair<int, int>          pii;
typedef pair<ll, ll>            pll;
typedef vector<string>          vs;
typedef vector<bool>            vb;
typedef vector<int>             vi;
typedef vector<long long>		vl;
typedef vector<vi>              vvi;
typedef vector<vl>				vvl;
typedef vector<char>            vch;

constexpr int               inf =   	0x3f3f3f3f;
constexpr long long 		INF = 		9123456789123456789;
constexpr long long         MOD =       1000000007LL;
/*************************************************/
string s;

void sol() {

}

int main() {
	ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cin.tie(nullptr);
	cin >> s;
  	for(int i=0; i<s.size(); i++)
      cout << 'x';
  	cout <<endl;

    return 0;
}

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

int main()
{
	int n , k;
	cin>>n>>k;
	if(k&1)
	{
		long long cnt = 0LL;
		for(int i = 1; i <= n; i++)
		{
			if(i%k==0) cnt ++;
		}
		cout<<cnt*cnt*cnt<<endl;
	}
	else
	{
		long long cnt = 0LL;
		for(int i = 1; i <= n; i++)
		{
			if(i%k==0) cnt ++;
		}
		long long cnt1 = 0 ;
		int ok  = k/2;
		for(int i = 1; i <= n; i++)
		{
			if(i%k== ok) cnt1 ++;
		}
		cout<<cnt*cnt*cnt + cnt1*cnt1*cnt1<<endl;
	}
	return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    ll H;
    cin >> H;

    ll logH = 0;
    while (H > 1) {
        ++logH;
        H /= 2;
    }

    ll ans = 0;
    for (int i = 0; i <= logH; i++) {
        ans += (1LL << i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;

ll a[maxn];
int n,k;

int main() {
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt","w",stdout);
  std::ios::sync_with_stdio(false);
  cin >> n >> k;
  int pos = 0;
  int flag = 1;
  for(int i = 0 ; i < n ;++i)
  {
     int tmp;
     cin >> tmp ;
     a[i] = abs(tmp);
     if(flag && tmp >= 0)
      {
        pos = i;
        flag = 0;
      }
  }
  if(pos == 0 && flag == 1 )
    pos = n;
  //cout << pos <<endl;
  k--;
  ll ans = 9223372036854775807;
  for(int i = 0 ; i < n ; ++i)
  {
     if(i + k >= n) break;
     
     if(i + k < pos && i < pos)
     {
       ans = min (ans , a[i]);
     }
     else if(i + k >= pos && i >= pos)
     {
       ans = min (ans , a[i+k]);
     }
     else if(i + k >= pos && i < pos)
     {
       ans = min(ans,2*a[i]+a[i+k] );
       ans = min (ans,2*a[i+k]+a[i]);
     }
     //cout << ans << endl ;
  }
  cout << ans <<endl;


  

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

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
	ll ans=0;
	rep(i,s.sz){
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout<<ans;
}

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

int N; 
vector<int> A;
vector<int> B;
int num = 0;
int main(){
    cin >> N;
    for (int i = 0; i < N; i++){
        string s;
        cin >> s;
        int s_size = s.length();
        s[s_size] = 'N';
        for (int j = 0; j < s.length(); j++){
            if (s[j] == 'A' && s[j + 1] == 'B'){
                num += 1;
            }
        }
        if(s[0] == 'B'){
            A.push_back(i);
        }
        if(s[s_size - 1] == 'A'){
            B.push_back(i);
        }
    }
    if (A.size() == 0 || B.size() == 0){
        cout << num << endl;
    }
    else if (A.size() != B.size()){
        cout << num + min(A.size(), B.size()) << endl;
    }else{
        if (equal(A.cbegin(), A.cend(), B.cbegin())){
            cout << num +A.size() - 1 << endl;
        }
        else{
            cout << num +min(A.size(), B.size()) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define pii pair<int,int>
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define fio freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define vll vector<long long int>
#define vpii vector<pair<int,int>>
#define dsc [](int a,int b)->bool {return a>b;}
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define MAX 1000000000000000000
#define test int t; cin>>t;
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()

using namespace std;

ll nxt(){
    ll x;
    cin>>x;
    return x;
}

int main()
{
    #ifndef ONLINE_JUDGE
        fio
    #endif
    IOS
    
    ll n = nxt();
    vector<ll>a(n);
    generate(all(a),nxt);
    vector<ll>sum(n);
    ll pre = 0;
    for(int i = n-1; i>=0; i--){
        sum[i] = pre+a[i];
        pre = sum[i];
    }

    ll res = 0;

    for(int i = 0; i<n-1; i++){
        ll tmp = ((a[i]%MOD) * (sum[i+1]%MOD))%MOD;
        res = ((res%MOD)+(tmp%MOD))%MOD;
    }

    cout<<res<<endl;

    return 0;
}

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

int main(){
    string S;
    cin >> S;

    int N = S.length();
    int n = 0;

    int a = (N - 1) / 2;
    int b = (N + 3) / 2;

    for (int i = 0; i < N; i++){
        if (S[i] != S[N - i - 1]){
            n++;
        }
    }

    for (int i = 0; i < a; i++){
        if (S[i] != S[a - i - 1]){
            n++;
        }
    }

    for (int i = b; i < N; i++){
        if (S[i - 1] != S[N - i + b - 1]){
            n++;
        }
    }

    if (n == 0){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


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

/*............................*/

#define uint uint64_t
#define mx 100001
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define mp make_pair
#define pb push_back
#define inf INT_MAX
#define pi acos(-1)
#define eps 1e-8
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / __gcd(a, b)
#define input(ara, n)          \
   for (int i = 0; i < n; i++) \
   scanf("%d", &ara[i])
#define inputl(ara, n)                   \
   for (long long int i = 0; i < n; i++) \
   scanf("%lld", &ara[i])
#define pf(a) printf("%d\n", a);
#define pfl(a) printf("%lld\n", a);
#define pfi(a) printf("%d ", a);
#define pfll(a) printf("%lld ", a);
#define sc(a) scanf("%d", &a)
#define scc(a, b) scanf("%d %d", &a, &b)
#define sccdbl(a, b) scanf("%lf %lf", &a, &b)
#define sccc(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scccdbl(a, b, c) scanf("%lf %lf %lf", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define sccl(a, b) scanf("%lld %lld", &a, &b)
#define scccl(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
using namespace std;
vector<pii> node[100001];
bool visited[100001];
ll color[100001];
void dfs(ll u)
{
   visited[u] = true;
   for (ll i = 0; i < node[u].size(); i++)
   {
      ll v = node[u][i].first;
      ll w = node[u][i].second;
      if (!visited[v])
      {
         if (w % 2 == 0)
         {
            color[v] = color[u];
         }
         else
         {
            color[v] = 1 - color[u];
         }
         dfs(v);
      }
   }
}
int main()
{
   // int t;
   // sc(t);
   // while (t--)
   // {

   // }
   ll n, u, v, w;
   scl(n);
   for (ll i = 0; i < n - 1; i++)
   {
      scccl(u, v, w);
      node[u].pb(mp(v, w));
      node[v].pb(mp(u, w));
   }
   color[1] = 1;
   dfs(1);
   for (ll i = 1; i <= n; i++)
   {
      pfl(color[i]);
   }
   return 0;
}


Measured memory_bytes: 12008
#include<iostream>
using namespace std;
typedef long long ll;

int N,K;

int A[14][10];
int B[14][10];

int check(int y,int m){
  if(m==2){
    if(y%400==0)return 29;
    else if(y%100==0)return 28;
    else if(y%4==0)return 29;
    else return 28;
  }else if(m==4||m==6||m==9||m==11)return 30;
  else return 31;
}

ll t[100];
ll u[100];

void make(){
  int y=0,m=1,d=1;
  while(y<10000){
    
    int sum=0;
    sum+=B[0][y/1000];
    sum+=B[1][(y/100)%10];
    sum+=B[2][(y/10)%10];
    sum+=B[3][y%10];
    sum+=B[4][m/10];
    sum+=B[5][m%10];
    sum+=B[6][d/10];
    sum+=B[7][d%10];
    t[sum]++;

    d++;
    int last=check(y,m);
    if(d>last){
      d=1;m++;
    }
    if(m>12){
      m=1;y++;
    }
  }
}

void make2(){
  int h=0,m=0,s=0;
  while(h<24){

    int sum=0;
    sum+=B[8][h/10];
    sum+=B[9][h%10];
    sum+=B[10][m/10];
    sum+=B[11][m%10];
    sum+=B[12][s/10];
    sum+=B[13][s%10];
    u[sum]++;
    
    s++;
    if(s>59){
      s=0;m++;
    }
    if(m>59){
      m=0;h++;
    }
  }
}

void init(){
  for(int i=0;i<14;i++){
    for(int j=0;j<10;j++){
      A[i][j]=1;
      B[i][j]=0;
    }
  }
  for(int i=0;i<100;i++)t[i]=u[i]=0;
}

int main(){
  while(cin>>N>>K){
    init();
    for(int i=0;i<K;i++){
      int a,b;
      cin>>a>>b;
      A[a][b]=0;
    }
    for(int i=0;i<14;i++){
      B[i][1]=A[i][2]+A[i][5];
      B[i][2]=A[i][0]+A[i][2]+A[i][3]+A[i][4]+A[i][6];
      B[i][3]=A[i][0]+A[i][2]+A[i][3]+A[i][5]+A[i][6];
      B[i][4]=A[i][1]+A[i][2]+A[i][3]+A[i][5];
      B[i][5]=A[i][0]+A[i][1]+A[i][3]+A[i][5]+A[i][6];
      B[i][6]=A[i][0]+A[i][1]+A[i][3]+A[i][4]+A[i][5]+A[i][6];
      B[i][7]=A[i][0]+A[i][2]+A[i][5];
      B[i][8]=A[i][0]+A[i][1]+A[i][2]+A[i][3]+A[i][4]+A[i][5]+A[i][6];
      B[i][9]=A[i][0]+A[i][1]+A[i][2]+A[i][3]+A[i][5]+A[i][6];
      B[i][0]=A[i][0]+A[i][1]+A[i][2]+A[i][4]+A[i][5]+A[i][6];
    }
    make();
    make2();

    ll ans=0;
    for(int i=0;i<=N;i++){
      ans+=t[i]*u[N-i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n,m ;
	cin >> n >> m ;
	int left=0,right=n ;
	for(int i=0;i<m;i++){
		int a,b ;
		cin >> a >> b ;
		left = max(left,a) ;
		right = min(right,b) ;
	}
	cout << max(0,right-left+1) << endl ;
}


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


int main() {
  int a,b,x;
  cin>>a>>b>>x;
  double p,q;
  if(x>a*a*b/2){
      q=(a*a*b-x)*2;p=a*a*a;
  }
  else{q=(a*b*b);p=x*2;}
  double radian=atan2(q,p);
  double degree=radian*180/M_PI;
  cout << fixed << setprecision(10);
  cout<<degree<<endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
if H % 3 == 0 or W % 3 == 0:
    print(0)
else:
    x = []
    for h in range(1, H):
        x.append([h * W, (H - h) * (W // 2), (H - h) * (W - W // 2)])
        x.append([h * W, (H - h) // 2 * W, ((H - h) - (H - h) // 2) * W])

    for w in range(1, W):
        x.append([H * w, (W - w) * (H // 2), (W - w) * (H - H // 2)])
        x.append([H * w, (W - w) // 2 * H, ((W - w) - (W - w) // 2) * H])
    print(min(max(v) - min(v) for v in x))

Measured memory_bytes: 82036
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
int main(){
    int N,M;
    long long a[50],b[50],c[50],d[50],m,ans;
    cin >> N >> M;
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=0;i<M;i++){
        cin >> c[i] >> d[i];
    }
    for(int i=0;i<N;i++){
        m = 100000000000000;
        for(int j=0;j<M;j++){
            if(m>abs(a[i]-c[j])+abs(b[i]-d[j])){
                m = abs(a[i]-c[j])+abs(b[i]-d[j]);
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int i,j;

    char moji[100];

    scanf("%s", moji);

    for (i = 0; moji[i] != '\0'; ++i);

    for (j = 0; j < i; j++)
    {
         printf("x");
    }
   

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N, C; cin >> N >> C;

    vector<P> sushi;
    REP(_, N) {
      lint x, v; cin >> x >> v;
      sushi.push_back(P(x, v));
    }
    vector<P> forward;
    lint forward_max = sushi[0].second - sushi[0].first;
    forward.push_back(P(forward_max, forward_max));
    
    FOR(i, 1, N) {
      lint sum = forward[i-1].first + sushi[i].second - sushi[i].first + sushi[i-1].first;

      if(sum >= forward_max) {
        forward_max = sum;
      }
      forward.push_back(P(sum, forward_max));
    }

    vector<P> rev;
    lint rev_max = sushi[N-1].second - (C-sushi[N-1].first);
    rev.push_back(P(rev_max, rev_max));
    
    FOR(i, 1, N) {
      lint sum = rev[i-1].first + sushi[N-1-i].second - (C-sushi[N-1-i].first) + (C-sushi[N-i].first);

      if(sum >= rev_max) {
        rev_max = sum;
      }
      rev.push_back(P(sum, rev_max));
    }

    lint res = 0;
    res = max(res, forward_max);
    res = max(res, rev_max);

    REP(i, N-1) {
      lint tmp = forward[i].first;
      tmp -= sushi[i].first;
      tmp += rev[N-2-i].second;
      
      res = max(res, tmp);
    }

    REP(i, N-1) {
      lint tmp = rev[i].first;
      tmp -= C-sushi[N-1-i].first;
      tmp += forward[N-2-i].second;
      res = max(res, tmp);
    }
    
    
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    string S; cin >> S;
    set<char> t;

    for(auto c: S){
        t.insert(c);
    }
    
    if(t.size() == 4) cout << "Yes" << endl;
    else if(t.size() == 2){
        if((t.find('N') != t.end() && t.find('S') != t.end())
        ||  t.find('W') != t.end() && t.find('E') != t.end() ){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	string s;
	int a;
	cin >> a >> s;
	cout << (a >= 3200 ? s : "red") << endl;
	return 0;
}


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

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

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1e9+7;

ll dp[1000005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll sum = 0, tmp = 1, ans = 1;
    for(int i=1;i<=n;i++){
        if(i >= 4){
            sum = (sum + dp[i-3])%mod;
            tmp = (tmp + sum)%mod;
        }
        dp[i] = tmp;
        if(i < n) ans = (ans + dp[i]*1ll*(n-1)%mod*(n-1))%mod;
        ans = (ans + dp[i]*1ll*(n-1))%mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 11592
class segmentTreeMin():
    # とりあえず9 * 12桁
    inf = 2**31 - 1
    dat = []
    lenData = -1

    def __init__(self):
        pass

    def load(self, l):
        # len(l)個よりも大きい2の二乗を得る
        self.lenData = 2 ** (len(l) - 1).bit_length()  # len 5 なら 2^3 = 8
        self.dat = [self.inf] * (self.lenData * 2)
        # 値のロード
        for i in range(len(l)):
            self.dat[self.lenData - 1 + i] = l[i]
        self.build()

    def build(self):
        for i in range(self.lenData - 2, -1, -1):
            self.dat[i] = min(self.dat[2 * i + 1], self.dat[2 * i + 2])

    def setValue(self, i, a):
        """
        set a to list[i]
        """
        #print("setValue: {0}, {1}".format(i, a))
        nodeId = (self.lenData - 1) + i
        #print(" first nodeId: {0}".format(nodeId))
        self.dat[nodeId] = a
        while nodeId != 0:
            nodeId = (nodeId - 1) // 2
            #print(" next nodeId: {0}".format(nodeId))
            self.dat[nodeId] = min(self.dat[nodeId * 2 + 1], self.dat[nodeId * 2 + 2])

    def querySub(self, a, b, nodeId, l, r):
        """
        [a,b) 区間の親クエリに対するノードnodeへ[l, r)の探索をデリゲート
        区間については、dataの添え字は0,1,2,3,4としたときに、
        [0,3)なら0,1,2の結果を返す
        """
        #print("querySub: a={0}, b={1}, nodeId={2}, l={3}, r={4}".format(a, b, nodeId, l, r))
        if (r <= a or b <= l):
            return self.inf
        if a <= l and r <= b:
            #print(" > return(have): {0}".format(self.dat[nodeId]))
            return self.dat[nodeId]
        resLeft = self.querySub(a, b, 2 * nodeId + 1, l, (l + r) // 2)
        resRight = self.querySub(a, b, 2 * nodeId + 2, (l + r) // 2, r)
        #print(" > return(lr): {0}".format(min(resLeft, resRight)))
        return min(resLeft, resRight)

    def query(self, a, b):
        return self.querySub(a, b, 0, 0, self.lenData)


initVal = 2**31 - 1
n, q = map(int, input().split())
dat = [initVal] * n
stm = segmentTreeMin()
stm.load(dat)
stm.build()
for _ in range(q):
    cmd, a, b = map(int, input().split())
    if cmd == 0: # update
        stm.setValue(a, b)
    else:
        print(stm.query(a, b+1))



Measured memory_bytes: 9492
/* 
 * Author: pawanmsr
 */

// #include <iostream>
// #include <iomanip>
// #include <string>
// #include <vector>
// #include <algorithm>
// #include <queue>
// #include <deque>
// #include <bitset>
// #include <iterator>
// #include <list>
// #include <stack>
// #include <map>
// #include <set>
// #include <functional>
// #include <numeric>
// #include <utility>
// #include <limits>
// #include <fstream>
// #include <cstring>

#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

// Macro //
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>

// Global //
ll x;

// Functions //


// Main //
int main(int argc, char const *argv[])
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    
    /* code */
    cin >> x;
    ll a = x / 500;
    x %= 500;
    ll b = x / 5;
    cout << 1000 * a + 5 * b << endl;
    return 0;
}


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

int main(){
	int x,a,b;
	scanf("%d %d %d",&x,&a,&b);
	int ax=x-a;
	int bx=x-b;
	if (ax<0){
		ax=-ax;
	}
	if (bx<0){
		bx=-bx;
	}
	if (ax>bx){
		printf("B\n");
	}
	else{
		printf("A\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
txy = [[0,0,0]] + [list(map(int,input().split())) for _ in range(N)]

check = True
for i in range(1,N+1):
  K = txy[i][0] - txy[i-1][0]
  tmp = K - abs(sum(txy[i][1:]) - sum(txy[i-1][1:]))
  if tmp < 0 or tmp % 2 == 1:
    check = False
    break
    
print("Yes" if check else "No")

Measured memory_bytes: 28160
#include<iostream>
#include<vector>
#include<stack>
#include<string>
#include<math.h>
#include<iomanip>

#define PI 3.1415926535

using namespace std;

int main(void) {
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double thetaA = 2.0 * PI * (double)H / 12.0;
	thetaA += 2.0 * PI * (double)M / (12.0 * 60.0);
	if (thetaA < 0) thetaA += 2 * PI;
	if (2 * PI < thetaA) thetaA -= 2 * PI;
	double thetaB = 2.0 * PI * (double)M / 60.0;
	if (thetaB < 0)thetaB += 2 * PI;
	if (2 * PI < thetaB)thetaB -= 2 * PI;
	double xa, ya, xb, yb;

	xa = A * sin(thetaA);
	ya = A * cos(thetaA);
	xb = B * sin(thetaB);
	yb = B * cos(thetaB);

	double dx = xa - xb;
	double dy = ya - yb;
	double dist = sqrt(dx * dx + dy * dy);

	cout << fixed << setprecision(15) << dist << endl;

	return 0;
}

Measured memory_bytes: 4100
#include<stdio.h>

int main(){
  int n,box[55556]={},box2[56],i,j,cnt;
  scanf("%d",&n);
  for(i=2;i<55555;i++)
    box[i]=1;
  for(i=2;i<55555;i++){
    if(box[i]){
      if(i%10==1)
        box2[cnt++]=i;
      for(j=i*i;j<55555;j+=i)
        box[j]=0;
    }
    if(cnt==n)
      break;
  }
  for(i=0;i<n;i++)
    printf("%d ",box2[i]);
  printf("\n");
}

Measured memory_bytes: 384
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] height = new int[N];
        for (int i = 0; i < height.length; i++) {
            height[i] = sc.nextInt();
        }

        int[] dp = new int[N]; // min cost to reach the i+1th stone
        dp[0] = 0;
        for (int i = 1; i < N; i++) {
            dp[i] = (int) 2e9;
            for (int jump = 1; jump <= K && i - jump >= 0; jump++) {
                int step = Math.abs(height[i] - height[i - jump]);
                dp[i] = Math.min(dp[i], step + dp[i - jump]);
            }
        }
        out.println(dp[N - 1]);
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

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

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

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

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

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

Measured memory_bytes: 35164
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N, K := getInt(), getInt()
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt() - 1
	}

	if N >= K {
		pos := 0
		for i := 0; i < K; i++ {
			pos = a[pos]
		}
		out(pos + 1)
		return
	}

	m := make([]int, N)
	pos := 0
	cnt := 0
	for i := 1; i <= N; i++ {
		m[pos] = i
		// out(pos, a[pos])
		pos = a[pos]
		cnt++
		if m[pos] != 0 {
			break
		}
	}
	// out("----")
	// out(m, pos, cnt)
	loop := cnt + 1 - m[pos]
	// out(loop, cnt, m[pos])
	K -= m[pos] - 1
	// out(K)
	K %= loop
	// out("mod", K)
	for i := 0; i < K; i++ {
		pos = a[pos]
	}
	out(pos + 1)
}


Measured memory_bytes: 6428
n = input()
digit = len(n)
a753 = 0
a75 = 0
a73 = 0
a53 = 0
now = 0
i = digit - 1
# now + i = digit - 1
while now < digit:
  tmp = int(n[i])
  add = 3 ** now
  sun = (3 ** (now+1) - 3) // 2
  add2 = 2 ** now
  sun2 = 2 ** (now+1) - 2
  if tmp == 8 or tmp == 9:
    a753 = sun + 3 * add
    a75 = sun2 + 2 * add2
    a73 = sun2 + 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 7:
    a753 += 3 * add
    a75 += 2 * add2
    a73 += 2 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 6:
    a753 = sun + 2 * add
    a75 = sun2 + 1 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 2 * add2
  elif tmp == 5:
    a753 += 2 * add
    a75 += 1 * add2
    a73 = sun2 + 1 * add2
    a53 += 2 * add2
  elif tmp == 4:
    a753 = sun + 1 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 1 * add2
    a53 = sun2 + 1 * add2
  elif tmp == 3:
    a753 += 1 * add
    a75 = sun2 + 0 * add2
    a73 += 1 * add2
    a53 += 1 * add2
  else:
    a753 = sun + 0 * add
    a75 = sun2 + 0 * add2
    a73 = sun2 + 0 * add2
    a53 = sun2 + 0 * add2
    a = 3 * now - 3
  now += 1
  i -= 1
all1 = (10 ** digit - 1) // 9
a = 3 * digit
if int(n) < 7 * all1:
  a -= 1
if int(n) < 5 * all1:
  a -= 1
if int(n) < 3 * all1:
  a -= 1
#print(a753,a75,a73,a53,a)
print(a753 - a75 - a73 - a53 +a)

Measured memory_bytes: 3188
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val set = mutableSetOf<Int>()
    for (i in 0 until n) {
        val m = sc.nextInt()
        if (set.contains(m)) {
            set.remove(m)
        } else {
            set.add(m)
        }
    }
    println(set.count())
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 44216
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n,k,a[100001],i,mini=300000000,x,y;
	scanf("%d%d",&n,&k);
	for(i=0; i<n; i++){
		scanf("%d",&a[i]);
	}
	for(i=0; i<n-k+1; i++){
		x=abs(a[i])+abs(a[i+k-1]-a[i]);
		if(mini>x){
			mini=x;
		}
		y=abs(a[i+k-1])+abs(a[i+k-1]-a[i]);
		if(mini>y){
			mini=y;
		}
	}
	printf("%d\n",mini);
	return 0;
}

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



int parent(int x){
  return x/2;
}

int right(int x){
  return x*2+1;
}

int left(int x){
  return x*2;
}


int main(){

  int H,i,a[MAX+1];

  scanf("%d",&H);

  for(i=1;i<=H;i++){

    scanf("%d",&a[i]);
  }

  for(i=1;i<=H;i++){

    printf("node %d: key = %d, ",i,a[i]);
    
    if(parent(i) >= 1)
      printf("parent key = %d, ",a[parent(i)]);

    if(left(i) <= H)
      printf("left key = %d, ",a[left(i)]);

    if(right(i) <= H)
      printf("right key = %d, ",a[right(i)]);
    
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, tmp = 0, t = 1;
  cin >> n;
  string s = "";
  if(n == 0) s = "0";
  while(n != 0){
    int c, d = 1;
    c = (abs(n)/t) % 2;
    s = (char)('0'+ c) + s;
    if(tmp % 2 == 1) d = -1;
    n -= d*t*c;
    ++tmp;
    t *= 2;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N = int(input())

    if N == 3 or N == 5 or N == 7:
        print("YES")
    else:
        print("NO")

main()


Measured memory_bytes: 5412
#include<iostream>
#include<vector>
#include<cmath>
#include<utility>
#include<algorithm>
using namespace std;
int main(void) {
	std::string str;
	cin >> str;
	int sum = 0;
	for (int i = 0; i < str.length(); i++)
		if (str[i] == '1')sum++;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int min(int a, int b) {
	return (a<b)?a:b;
}

int main() {
	long a,b,n;
	cin >> n >> a >> b;
	if (a > b) {
		cout << 0;
		return 0;
	}
	
	if (n==1 and a!=b) {
		cout << 0;
		return 0;
	}
	
	long ma = b*n-b+a;
	long mi = a*n-a+b;
	
	
	cout << ma-mi+1;
}

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

int n, m;
string s;

typedef pair<int, int> P;
typedef vector<int> VI;

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

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

int main()
{
	int a,tot;
	cin>>a;
	int A[a],B[a],C[a-1];
	for(int i=0;i<a;i++)
	{
		cin>>A[i];
	}
	for(int t=0;t<a;t++)
	{
		cin>>B[t];
	}
	for(int y=1;y<a;y++)
	{
		cin>>C[y-1];
	}
	//輸入 
	for(int q=1;q<a;q++)
	{
		if(A[q]-A[q-1]==1)
		{
			tot=tot+B[A[q]-1]+C[A[q]-2];
			//printf("%d\n",tot);
		}
		else
		{
			tot=tot+B[A[q]-1];
			//printf("%d\n",tot);
		}
	}
	tot=tot+B[A[0]-1];
	cout<<tot;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string s ;
cin>>s;
int cnt=0;
for(int i=0;i<s.size();i++)
    {
        if(s[i]=='x') 
        cnt++;
    }
if(cnt<=7) 
cout<<"YES"<<endl;
else cout<<"NO"<<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(), (v).end()

const int mod = 1000000007;
const int inf = mod * mod;
const int d5 = 100100;
int n, m, l;
int d[330][330];
int fu[330][330];


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    for (int i = 0; i < 330; i++)
    {
        for (int j = 0; j < 330; j++)
        {
            d[i][j] = inf * (i != j);
            fu[i][j] = inf * (i != j);
        }
    }
    cin >> n >> m >> l;
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for (int k = 0; k < 330; k++)
    {
        for (int i = 0; i < 330; i++)
        {
            for (int j = 0; j < 330; j++)
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for (int i = 0; i < 330;i++){
        for (int j = 0; j < 330;j++){
            if(d[i][j]<=l){
                fu[i][j] = 1;
            }
        }
    }

    for (int k = 0; k < 330; k++)
    {
        for (int i = 0; i < 330; i++)
        {
            for (int j = 0; j < 330; j++)
            {
                fu[i][j] = min(fu[i][j], fu[i][k] + fu[k][j]);
            }
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        if(fu[s][t]!=inf)
            cout << fu[s][t]-1 << endl;
        else
            cout << -1 << endl;

    }
}


Measured memory_bytes: 2304
n = int(input())
a = list(map(int,input().split()))

mx = 0
chmx = 0

for i in range(1,n):
    if(a[i]<=a[i-1]):
        chmx += 1
    else:
        if(chmx>mx):
            mx = chmx
        chmx = 0
     
if(chmx>mx):
    mx = chmx
   
print(mx)

Measured memory_bytes: 63856
/**
 *  author: mahfuzz
 *  created: 08.12.2019
**/
 
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define debug(x) cout << #x << ':' << x << "\n";
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int max_n = 1e6+5;
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    s[5] = ' ';
    s[13] = ' ';
    
    cout << s << "\n";
    
        
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
ans=0
mod=10**9+7
import math
if n==m:
    ans=2*math.factorial(n)*math.factorial(m)
elif abs(n-m)==1:
    ans=math.factorial(n)*math.factorial(m)
else:
    ans=0
print(ans%mod)
    

Measured memory_bytes: 5176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007
#define MSG(a) cout << #a << " " << a << endl;
#define print(a) cout << a << endl;
template <class T, class C>
void chmax(T &a, C b)
{
    a > b ?: a = b;
}
template <class T, class C>
void chmin(T &a, C b) { a < b ?: a = b; }

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

// vector の出力
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    size_t last = v.size() - 1;
    for (size_t i = 0; i < v.size(); ++i)
    {
        out << v[i];
        if (i != last)
            out << " ";
    }
    return out;
}

int main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //////////////////////////////////////////

    string a;
    cin >> a;
    if (a.find('a') != string::npos &&
        a.find('b') != string::npos &&
        a.find('c') != string::npos)
    {
        print("Yes");
    }
    else
    {
        print("No");
    }
    return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>

int main()
{
  int i,j,v;
  int A[100],N;
  
  scanf("%d",&N);
  for(i=0; i<N; ++i){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
    if(i!=N-1)printf(" ");
 
 }
  printf("\n");

  for(i=1; i<N; i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      
    }
    A[j+1]=v;
    
    for(j=0;j<N;j++){
      printf("%d",A[j]);
      if(j!=N-1)printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		char[] d = a.toCharArray();
		char[] e = b.toCharArray();
		int r= 0;
		for(int i = 0;i < d.length;i++) {
			if(!(d[i]==(e[i]))) {
				r++;
			}
		}
		System.out.println(r);
		sc.close();
	}
}


Measured memory_bytes: 41932
import scala.io.StdIn._

object Main extends App {


  val x = readInt()

  def solve(): Int = {
    var ans = x
    while(!isPrime(ans)) ans += 1
    ans
  }

  def isPrime(num: Int): Boolean = {
    if(num <= 1) false
    else if(num == 2) true
    else !(2 until num).exists(num % _ == 0)
  }

  println(solve())

}



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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int a, b, c, d, e, f;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	a*=100; b*=100;
	int sugar = 0, ans = a;
	double p = 0;
	for (int i = 0; i <= f; i+=a) {
		for (int j = 0; j <= f; j+=b) {
			for (int k = 0; k <= f; k+=c) {
				for (int l = 0; l <= f; l+=d) {
					if (i+j+k+l > f) continue;
					if (i+j == 0 || 100.*(k+l)/(i+j) > e) continue;
					if ((100.*(k+l))/(i+j+k+l) > p) {
						p = (100.*(k+l))/(i+j+k+l);
						sugar = k+l;
						ans = i+j+k+l;
					}
				}
			}
		}
	}
	printf("%d %d", ans, sugar);
	
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  // yesの条件を先に持って来たほうが条件が少なく済むことに気づく
  if ( ( x <= W - r && x - r >= 0 ) && ( y <= H -r && y - r >= 0 )){ cout << "Yes" << endl; }
  else { cout << "No" << endl; }
  return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

void solve() {

    int n;
    cin >> n;
    vi v(n);
    for (auto& x : v) cin >> x;
    vi dp(n);
    dp[n - 1] = 0;
    dp[n - 2] = abs(v[n - 1] - v[n - 2]);

    for (int i = n - 3; i >= 0; i--) {
        dp[i] = min(abs(v[i + 1] - v[i]) + dp[i + 1], abs(v[i + 2] - v[i]) + dp[i + 2]);
    }

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


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);


    solve();



    return 0;
}

Measured memory_bytes: 4004
n = int(input())
judge = [input() for _ in range(n)]
ans = [0]*4
for i in judge:
    if i == "AC":
        ans[0] += 1
    elif i == "WA":
        ans[1] += 1
    elif i == "TLE":
        ans[2] += 1
    else:
        ans[3] += 1

print("AC x {}".format(ans[0]))
print("WA x {}".format(ans[1]))
print("TLE x {}".format(ans[2]))
print("RE x {}".format(ans[3]))

Measured memory_bytes: 16320
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var N = Number(input[0])
	//文字列から10進数に変換するときはparseIntを使います
    var a = input[1].split(" ") 
	var b = input[2].split(" ") 
    var c = input[3].split(" ") 
    
    var answer = 0
    
    for(var i =0; i<N ;i++){
      
      var aa = Number(a[i])
      var zz = Number(b[aa - 1])
      
      answer = answer + zz
     
      if(i != 0 && aa == Number(a[i - 1]) + 1){
        var cc = Number(c[aa - 2])
        answer = answer + cc
      }    
     }
    
	//出力
	console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372