akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define lli long long int
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";

int main()
{

    fast;

    lli x;
    cin>>x;
    if(x>=30)
        cout<<"Yes";
    else
        cout<<"No";






    return 0;


}


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

int n;
vector<int>a(100050, 0);
bool visit[100050];
int cnt;

int button(int num){
	cnt += 1;
	visit[num] = true;
	if(a[num] == 2) return cnt;
	if(a[num] != 2 && visit[a[num]] == false) return button(a[num]);
	if(a[num] != 2 && visit[a[num]] == true) return -1;
}


int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i+1];
		visit[i+1] = false;
	}
	int ans = button(1);
	cout << ans << endl;
}

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

pair<long long, int> a[1111];
int top;
void pus(long long x) {
	int sum = 0;
	for (long long y = x; y; y /= 10) sum += y%10;
	while (top > 0 && a[top-1].first * sum > a[top-1].second * x) top --;
	a[top++] = make_pair(x, sum);
}

int main() {
	int k; cin >> k;
	for (int i = 1; i < 1000000; i ++) pus(i); 
	long long cur = 10;
	for (int p = 7; p <= 15; p ++, cur *= 10) {
		for (int i = 100000; i < 1000000; i ++) pus((i+1) * cur - 1);
	}
	for (int i = 0; i < k; i ++) cout << a[i].first << endl;
	return 0;
}

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

const int MAX_N = 110;
const int INF = 1e8;
int d[MAX_N][MAX_N];
int cost[MAX_N][MAX_N];

int main(){
  int N,M;
  cin >> N >> M;
  for(int i = 0 ; i < N  ; i++){
    for(int j = 0 ; j < N ; j++){
      cost[i][j] = d[i][j] = INF;
      if(i == j)d[i][j] = 0;
    }
  }

  for(int i = 0 ; i < M ; i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--,b--;
    cost[a][b] = d[a][b] =  c;
    cost[b][a] = d[b][a] =  c;
  }
  
  for(int k = 0 ; k < N ; k++){
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
	if(d[i][k] + d[k][j] < d[i][j]){
	  d[i][j] = d[i][k] + d[k][j];
	}
      }
    }
  }

  int ans = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(cost[i][j] > d[i][j] && cost[i][j] != INF)ans++;
    }
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<cstdio>

#define t(a) ((a == 'S') ? (0) : (1))

using namespace std;

int N;
char S[100001];
char ans[100001];
char sw[3] = "SW";
bool f1 = true;

char dp(short int b, short int t, char r);

int main(){

  scanf("%d", &N);
  scanf("%s", S);

  for(int l = 0; l < 4 && f1; l++){
    ans[0] = sw[l/2];//ssww
    ans[1] = sw[l%2];//swsw
    for(int m = 1; m < N && f1; m++){
      if(m < N-1 ){
        ans[m+1] = dp(t(ans[m-1]), t(ans[m]), S[m]);//1 <= m <= N-2, ans[N-1]まで求める
      }else if(ans[0] == dp(t(ans[N-2]), t(ans[N-1]), S[N-1])){//m = N-1, ans[0]に入るべき値を確認
        if(ans[1] == dp(t(ans[N-1]), t(ans[0]), S[0])){
          f1 = false;
        }
      }
    }
  }

  if(f1){
    printf("-1");
  }else{
    for(int i = 0; i < N; i++){
      printf("%c", ans[i]);
    }
    /*
    ans[N] = '\0';
    printf("%s", ans);
    */
  }

  return 0;

}

char dp(short int b, short int t, char r){

  if((b+t)%2 == 0){
    if(r == 'o'){
      return 'S';
    }else{//r == 'x'
      return 'W';
    }
  }else{//(a+b)%2 == 1
    if(r == 'o'){
      return 'W';
    }else{//r == 'x'
      return 'S';
    }
  }

  /*
  if( b == 's' && t == 's' && r == 'o') return 's';
  if( b == 's' && t == 'w' && r == 'o') return 'w';
  if( b == 'w' && t == 's' && r == 'o') return 'w';
  if( b == 'w' && t == 'w' && r == 'o') return 's';
  if( b == 'w' && t == 'w' && r == 'x') return 'w';
  if( b == 'w' && t == 's' && r == 'x') return 's';
  if( b == 's' && t == 'w' && r == 'x') return 's';
  if( b == 's' && t == 's' && r == 'x') return 'w';
  */
  return '\0';

}


Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	cin >> s;
	int count = 0, j = 0;
	for (int i = 0; i <s.length(); i++) {
		if (s.at(i) == 'R') {
			j++;
		}
		else {
			if (count < j) {
				count = j;
				j = 0;
			}
		}
	}
	if (count < j) {
		count = j;
		j = 0;
	}
	cout << count;
}

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

int main(){
  int n;cin >> n;
  int a[3*n];rep(i,3*n){
    cin >> a[i];
  }
  sort(a, a+3*n);
  long long ans = 0;
  int i = 2;
  while(i <= 2*n){
    // cout << i << "\n";
    ans += a[3*n -i];
    i+=2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
N,M = map(int,input().split())
cnt = [0 for i in range(N+1)]
A = []
for i in range(M):
	P,val = map(int,input().split())
	A.append( (val,P,i) )
A.sort()

B = []
for val,P,i in A:
	cnt[P] += 1
	B.append( (i,"{:06}{:06}".format(P,cnt[P]))  )
B.sort()

for i ,b in B:
	print(b)

Measured memory_bytes: 36404
#include<bits/stdc++.h>
using namespace std;
int a[200005],L[100001],R[100001];long long cnt=0;
void merge(int l,int mid,int r){
	int n1=mid-l,n2=r-mid;
	for(int i=1;i<=n1;i++) L[i]=a[l+i-1];
	for(int i=1;i<=n2;i++) R[i]=a[mid+i-1];
	int i=1,j=1;L[n1+1]=R[n2+1]=1<<30;
	for(int k=l;k<r;k++){
		if (L[i]<R[j]){
			a[k]=L[i++];
		}
		else{
			a[k]=R[j++];
			cnt+=n1-i+1;
		}
	}
}
void mergesort(int l,int r){
	if (l+1<r){
		int mid =(l+r)/2;
		mergesort(l,mid);
		mergesort(mid,r);
		merge(l,mid,r);
	}
}

int main(){
	int n;cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	mergesort(1,n+1);
	printf("%lld\n",cnt);
}

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

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

const int N = 1e4 + 5, M = 1e2 + 2, T = 10 + 1, mod = 1e9 + 7;

string s;
int D, dp[N][M][T];

int sum(int a, int b) {
	a += b;
	if(a >= mod)
		a -= mod;
	if(a < 0)
		a += mod;
	return a;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> s >> D;
	int n = s.size();
	for (int i = 0; i < 10; i++)
		dp[1][i % D][i] = 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < D; j++) {
			for (int k = 0; k < 10; k++) {
				int rem = (((j - k) % D) + D) % D;
				for (int v = 0; v < 10; v++)
					dp[i][j][k] = sum(dp[i][j][k], dp[i - 1][rem][v]);
			}
		}
	}
	int ans = 1e9 + 6;
	int cur = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < (s[i] - '0'); j++)
			ans = sum(ans, dp[n - i][(D - cur) % D][j]);
		cur += s[i] - '0';
		cur %= D;
	}
	if(cur % D == 0)
		ans = sum(ans, 1);
	cout << ans << "\n";
}


Measured memory_bytes: 44160
//sumitrust2019
//Chandigarh University
//author: shivamkr21 (pseduo coders)
#include<bits/stdc++.h>
//#include "boost/multiprecision/cpp_int.hpp"
//#define eint int1024_t
#define lli long long int
#define endl "\n"
#define vint vector<int>
#define vvint vector< vector<int> >
#define pub push_back 
#define mod 1000000007
//using namespace boost::multiprecision;
using namespace std;
lli fun_cal(lli x, lli y, lli l, lli r);
int main()
{
    std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	lli n,res=0;
	cin>>n;

	if(n>=100 && n<=105)
		res=1;
	else if(n>=200 && n<=210)
		res=1;
	else if(n>=300 && n<=315)
		res=1;
	else if(n>=400 && n<=420)
		res=1;
	else if(n>=500 && n<=525)
		res=1;
	else if(n>=600 && n<=630)
		res=1;
	else if(n>=700 && n<=735)
		res=1;
	else if(n>=800 && n<=840)
		res=1;
	else if(n>=900 && n<=945)
		res=1;
	else if(n>=1000 && n<=1050)
		res=1;
	else if(n>=1100 && n<=1155)
		res=1;
	else if(n>=1200 && n<=1260)
		res=1;
	else if(n>=1300 && n<=1365)
		res=1;
	else if(n>=1400 && n<=1470)
		res=1;
	else if(n>=1500 && n<=1575)
		res=1;
	else if(n>=1600 && n<=1680)
		res=1;
	else if(n>=1700 && n<=1785)
		res=1;
	else if(n>=1800 && n<=1890)
		res=1;
	else if(n>=1900 && n<=1995)
		res=1;
	else if(n>=2000 && n<=2100)
		res=1;
	else if(n>2100)
		res=1;

	cout<<res;
	
	
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,ans=0;
    cin>>n;
    map<string,int>p;
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
    sort(s.begin(),s.end());
    ans+=p[s];
    p[s]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_N 100
int main() {
    int N, T[MAX_N], M, X[MAX_N], P[MAX_N];
    cin >> N;
    rep(i, N) cin >> T[i];
    cin >> M;
    rep(i, M) cin >> P[i] >> X[i];
    rep(i, M) {
        int sum = 0;
        rep(k, N) {
            if (k + 1 == P[i]) {
                sum = sum + X[i];
            } else {
                sum = sum + T[k];
            }
            // cout << sum << " ";
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import product

N,M=map(int,input().split())
S = []
for i in range(M):
  k,*s = map(int,input().split())
  S.append(s)
P=list(map(int,input().split()))

ans=0
for p in product(range(2),repeat=N):
  cnt1 = 0
  for i in range(M):
    cnt2 = 0
    for j in range(len(S[i])):
      if p[S[i][j]-1]==1:
        cnt2 += 1
    if cnt2 % 2== P[i]:
      cnt1 += 1
  if cnt1 == M:
    ans += 1

print(ans)

Measured memory_bytes: 9084
#提出コードみました
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
list = {i:0 for i in range(1,n+1)}
for i in ab:
  list[i[0]] += 1
  list[i[1]] += 1
for j in list.values():
  print(j)
  

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

#define h 2000
#define w 4000

int main()
{
    int n, k;
    int table[h + 1][w + 1]{};
    int max{};
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
    {
        long long x, y;
        char c;
        scanf("%lld%lld %c", &x, &y, &c);
        int y_rem = y % k, y_quo = y / k;
        int x_rem = (x + ((c == 'B') + y_quo % 2) * k) % (2 * k); 
        table[y_rem + 1][x_rem + 1]++;
        table[y_rem + k + 1][x_rem + k + 1]++;
        table[y_rem + 1][x_rem + 2 * k + 1]++;
        table[y_rem + k + 1][(x_rem + 3 * k + 1) % (4 * k)]++;
    }
    for (int i = 1; i <= 2 * k; i++)
    {
        for (int j = 2; j <= 4 * k; j++)
        {
            table[i][j] += table[i][j - 1];
        }
    }
    for (int i = 1; i <= 4 * k; i++)
    {
        for (int j = 2; j <= 2 * k; j++)
        {
            table[j][i] += table[j - 1][i];
        }
    }
    for (int white_y = 0; white_y < k; white_y++)
    {
        for (int white_x = 0; white_x < k * 2; white_x++)
        {
            int tmp = table[white_y + k][white_x + k] + table[white_y][white_x]
                    - (table[white_y + k][white_x] + table[white_y][white_x + k]);
            if (tmp > max) max = tmp;
        }
    }
    
    printf("%d\n", max);
    return 0;
}

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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int n; cin>>n;
	vector< int > v(n);
	for(int &i : v) cin >> i;
	if(n&1){
		cout<<1<<endl;
	}else{
		sort(v.begin(), v.end());
		int mid = n >> 1;
		cout<<v[mid] - v[mid - 1]<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}



Measured memory_bytes: 3712
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] l = new int[ N ];
    for(int i =  0 ;i < N ;i ++){
      l[ i ] = sc.nextInt();
    }
    Arrays.sort(l);

    int result = 0 ;
    for(int i = 0 ;i < K ;i ++){
      result = result + l[ N - i - 1];
    }
    System.out.println(result);
  }
}


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

int main(){
    string s;
    int price = 700;
    cin >> s;
    if (s[0] == 'o'){
        price += 100;
    }
    if (s[1] == 'o'){
        price += 100;
    }
    if (s[2] == 'o'){
        price += 100;
    }
    cout << price << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
int x[9];

int min(int a,int b){
  if(a<b) return a;
  return b;
}
int max(int a,int b){
  if(a>b) return a;
  return b;
}
 
 
signed main(){
  int n;
  cin>>n;
  lp(i,n){
    int a;
    cin>>a;
    a/=400;
    a=min(a,8);
    x[a]++;
  }
  int cnt=0;
  lp(i,8)if(x[i]>0)cnt++;
  cout<<max(cnt,1)<<" "<<cnt+x[8]<<endl;
  return 0;
}
 


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int a,b,c,tmp,i;

while(1)
{
scanf("%d %d %d",&a,&b,&c);
if(1<=a,b,c&&a,b,c<=10000);
break;
}

for(i=1;i<=3;i++){
if(a>b)
{
tmp=a;
a=b;
b=tmp;
}
else if(b>c)
{
tmp=b;
b=c;
c=tmp;
}
}

printf("%d %d %d\n",a,b,c);

return 0;
}

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

using namespace std;

const int MaxN = 200005;

int n;
int a[MaxN], dpp[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    long long Res = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        Res = Res + dpp[a[i]];
        dpp[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << Res - dpp[a[i]] + 1 << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int ans=0;
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n/2){
        if(s[i]!=s[n-1-i])ans++;
    }
    cout << ans;
    
	return 0;
}

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

int main(){
	int R;
	cin >> R;
	
	if(R < 1200) cout << "ABC" << endl;
	else if(R<2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 1; i <= (ll)(n); ++i)

int main() {

    int n; cin >> n;
    vector<vector<int>> abc(n, vector<int>(3));
    rep(i, n) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];

    // dpは2次元配列で行う
    // dp[i][j] == i日目にjを実行した時の幸福度の最大値
    vector<vector<int>> dp(n, vector<int>(3,0));

    rep(i, n) {
        rep(j, 3) {
            // 1日目の対応
            if(i == 0) {
                dp[i][j] = abc[i][j];
            } else {
                rep(k, 3) {
                    // dp構築の肝
                    // 前日のdpと合わせて最大のものを見つける
                    // aその時連続して同じことはできないので、 j == kの場合は何もしない
                    // k==0(aをやる場合), 前日(j)は1,2(bかc)を選んだ場合のdpが候補になる
                    // i-1日目がb or cのdpにi日目にaをやった場合の幸福度が大きい方をi日目にaをやった場合の幸福度の最大と言える
                    if(j == k) continue;
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + abc[i][j]);
                }
            }
        }
    }

    // 最終日にa,b,cを実施した時に一番幸福度が大きいのが答えになる
    int ans = max(max(dp[n-1][0],dp[n-1][1]), dp[n-1][2]);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main()
{
  vector<vector<bool > >dp(25,vector<bool>(2005,false));
  int N;
  cin >> N;
  int A[25];
  dp[0][0] = true;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for(int i = 0; i < N; i++) {
    for(int j = 0; j < 2005; j++) {
      if(dp[i][j] == false)continue;
      if(j + A[i] < 2005) {
	dp[i + 1][j + A[i]] = true;
      }
      dp[i + 1][j] = true;
    }
  }
  int q,m;
  cin >> q;
  while(q--) {
    cin >> m;
    if(dp[N][m] == true)cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  int N,K,C;
  string S;
  
  cin >> N >> K >> C;
  cin >> S;
  
  int WDL[N];
  int dist=C;
  int WD=0;
  WDL[0] = 0;
  for(int i = 0;i < N;i++)
  {
    bool can_work = (S[i] == 'o') && (dist >= C);
    if (can_work)
    {
      WDL[i] = ++WD;
      dist = 0;
    }
    else
    {
      if(i!=0)
      {
      WDL[i] = WDL[i-1];
      dist++;
      }
    }
  }

  int WDR[N];
  dist=C;
  WD=0;
  WDR[N-1] = 0;
  for(int i = N-1;i  >= 0;i--)
  {
    bool can_work = (S[i] == 'o') && (dist >= C);
    if (can_work)
    {
      WDR[i] = ++WD;
      dist = 0;
    }
    else
    {
      if(i!=N-1)
      {
      WDR[i] = WDR[i+1];
      dist++;
      }
    }
  }
  
  /*
  for(int i = 0;i < N;i++) cout << WDL[i] << ' ';
  cout << endl;
    for(int i = 0;i < N;i++) cout << WDR[i] << ' ';
  cout << endl;
  */
  //muri
  if(WDL[N-1] < K)
  {
    return 0;
  }
  
  //kaku higa damenabaaidemo hatarakeru?
  // -> hatarakerunara not hissu
  if(WDR[1] < K)
  {
    cout << 1 << endl;
  }
  
  for(int i=1;i<N-1;i++)
  {
    if(S[i] == 'x') continue;
    
    bool ok = false;

    if(C==0 && WDL[i-1] + WDR[i+1]>=K)
    {
      ok = true;
    }
    
    for(int j=0;j<C;j++)
    {
      int l =i-C+j;
      int r =i+j+1;
      int ln = 0;
      if (l>=0) ln = WDL[l];
      int rn = 0;
      if (rn<N) rn = WDR[r];
      if(ln+rn>=K)
      {
        ok=true;
        break;
      }
    }
    
    if(!ok)
    {
      cout << i+1 << endl;
    }
    
  }
  
  if(WDL[N-2] < K && N >= 2)
  {
    cout << N << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3332
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;

    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

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

    if(a[0] + k - a[n - 1] > max) max = a[0] + k - a[n - 1];

    cout << k - max << endl;
    return 0;
}

Measured memory_bytes: 1024
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/

#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")

#include <bits/stdc++.h>
using namespace std;

#define    int                      long long int

#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    ppl                      pair <int , pii>               
#define    sp(x)                    setprecision(x)


int32_t main()
{
    speed upp
    string s1,s2,s3;
    cin>>s1>>s2;
    int n,m;
    cin>>n>>m;
    
    cin>>s3;
    if(s1==s3)
        cout<<n-1<<" "<<m;
    else if(s2==s3) 
        cout<<n<<" "<<m-1;
    else
        cout<<n<<" "<<m;
        
}

Measured memory_bytes: 256
N = gets.chomp.to_i
ws = gets.chomp.split(' ').map(&:to_i)
min = ws.inject(:+)

(N-1).times do |i|
    if (ws.slice((i+1)..(N-1)).inject(:+) - ws.slice(0..i).inject(:+) ).abs < min
        min = (ws.slice((i+1)..(N-1)).inject(:+) - ws.slice(0..i).inject(:+)).abs
    end
end
p min

Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node  {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if ( t == nil ) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}


void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}


int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ) {
        scanf("%s%d", com, &key);
        if ( com[0] == 'i' ) { insert(key); np++; size++; }
        else if ( com[0] == 'd' ) {
            if ( strlen(com) > 6 ) {
                if ( com[6] == 'F' ) deleteFirst();
                else if ( com[6] == 'L' ) deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 33848
def main():
    N = int(input())
    A = [x - i for i, x in enumerate(map(int, input().split()), start=1)]
    A.sort()

    m = A[N // 2]  # 個数の偶奇によらず、この点は絶対値の総和を最小にする

    ans = sum(abs(x - m) for x in A)

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  rep(i,m){cin>>b[i];
          }
  rep(i,n){
    rep(j,m){
      cin>>a[i][j];
    }
  }
  
  int ans=0;
  
  
  rep(i,n){
    int sum=0;
    rep(j,m){
      sum+=a[i][j]*b[j];
    }
    if(sum+c>0)ans++;
  }
  
  cout<<ans<<endl;
    
  
  
}


Measured memory_bytes: 256
// GRL_1_B
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#define   N   1000000000
using namespace std;

struct edge{
	int adj;
	int dis;
};

int main(){
	int V, E, r, s, t, d, x, count=0;
	vector<vector<edge> > A;
	vector<int> distance;
	queue<int> ver;

	edge e;

	cin>>V>>E>>r;

	A.resize(V);
	for(int i=0;i<V;i++){
		distance.push_back(N);
	}
	distance[r] = 0;

	for(int j=0;j<E;j++){
		cin>>s>>t>>d;
		e.adj = t;
		e.dis = d;
		A[s].push_back(e);
	}
	
	ver.push(r);

	while(count<=V){
		queue<int> vern;
		while(!ver.empty()){
			x = ver.front();
			for(int i=0;i<A[x].size();i++){
				if(distance[A[x][i].adj] > distance[x] + A[x][i].dis){
					distance[A[x][i].adj] = distance[x] + A[x][i].dis;
					vern.push(A[x][i].adj);
				}
			}
			ver.pop();
		}
		if(vern.empty()) break;
		ver = vern;
		count++;
	}

	if(count > V){
		cout<<"NEGATIVE CYCLE"<<endl;
	}else{
		for(int i=0;i<V;i++){
			if(distance[i] >= N)
				cout<<"INF"<<endl;
			else
				cout<<distance[i]<<endl;
		}
	}
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll a, b;

int main(){
    cin >> a >> b;
    if(a <= 0 && b >= 0){cout << "Zero" << endl;}
    else if(a > 0 && b > 0){cout << "Positive" << endl;}
    else {
        if((b-a+1)%2==0)cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int D, G, n, c;
int nums[11];
int scores[11];
int ans, res, sum;
int m;

int main () {
  cin >> D >> G;
  G /= 100;

  for (int i = 0; i < D; i++) {
    cin >> n >> c;
    nums[i] = n;
    scores[i] = (i+1)*n+c/100;
    // cout << nums[i] << " " << scores[i] << endl;
  }

  ans = 1000; /// max

  for (int bit = 0; bit < (1<<D); bit++) {
    // cout << "bit" <<  bit << endl;
    m = -1;
    res = 0;
    sum = 0;
    for (int i = 0; i < D; i++) {
      if (bit&(1<<i)) {
        // cout << "i:" << i  << " " << (bit&(1<<i))<< endl;
        sum += scores[i];
        res += nums[i];
      } else m = i; /// フルで使用してない最大の数
    }
    // cout << sum << " " << m << endl;
    if (sum < G) { /// 合計値が達成してない時だけ考える
      int k = (G-sum+m)/(m+1); /// 必要な数
      if (k > nums[m]) continue; /// 最大数以上必要なときはもう一つフルで取るのでパス
      else res += k;
    }
    if (res < ans) ans = res;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,k,count=1,r=1,z=1,rp=0;cin >> n >> k;
  vector<long long> a(n),seen(n,-1);
  for (int i=0;i<n;i++) cin >> a[i];
  seen[0]=0;
  while (r) {
    z=a[z-1];
	if (seen[z-1]==-1) seen[z-1]=count;
	else {rp=count-seen[z-1];r=0;count--;}
	count++;
	if (count==k) r=0;
  }
  
  if (count==k) {
    cout << a[z-1] << endl;
  }
  else {
    k-=count;
	k=k%rp;
	if (k==0) cout << z << endl;
	else {
	  r=1;count=1;
	  while (r) {
        z=a[z-1];
	    count++;
	    if (count==k) r=0;
	  }
	  cout << a[z-1] << endl;
    }
  }
  
}

Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
using ld = long double;

using tp = tuple<int, int, int>;
using ttp = tuple<ld, int, int, int>;

const ld INF = 1e20;

int main()
{
	cout << fixed << setprecision(5);
	int n, m;
	while (cin >> n >> m, n | m) {
		int s, g;
		cin >> s >> g; s--, g--;
		vector<vector<tp>> G(n);
		for (int i = 0; i < m; i++) {
			int x, y, d, c;
			cin >> x >> y >> d >> c; x--, y--;
			G[x].emplace_back(y, d, c);
			G[y].emplace_back(x, d, c);
		}
		vector<vector<vector<ld>>> d(n, vector<vector<ld>>(n, vector<ld>(33, INF)));
		priority_queue<ttp, vector<ttp>, greater<ttp>> pq;
		pq.emplace(0.0, 0, s, s);
		while (!pq.empty()) {
			auto p = pq.top(); pq.pop();
			int v = get<2>(p), f = get<3>(p), ve = get<1>(p);
			ld cos = get<0>(p);
			if (d[v][f][ve] != INF) continue;
			d[v][f][ve] = cos;
			for (auto e : G[v]) {
				int to = get<0>(e), st = get<2>(e);
				ld dis = get<1>(e);
				if (to == f) continue;
				for (int i = -1; i <= 1; i++) if (ve + i <= st) {
					if (d[to][v][ve + i] == INF) {
						pq.emplace(cos + dis / (ve + i), ve + i, to, v);
					}
				}
			}
		}
		ld res = INF;
		for (int i = 0; i < n; i++) {
			res = min(res, d[g][i][1]);
		}
		if (res == INF) cout << "unreachable" << endl;
		else cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 19732
#include "stdio.h"
#include "stdlib.h"
#include <iostream>
using namespace std; 

int main(void)
{
    int N, Y;
    int m = -1, g = -1, s = -1;
    cin>> N >> Y;

    for(int i = 0 ; i <= N; i++)
    {
        for(int j = 0 ; j <= N - i; j++)
        {

            if(10000*i + 5000*j + 1000*(N - (i + j)) == Y)
            {
                m = i;
                g = j;
                s = (N - (i + j));
                break;
            }
            
        }
    }

    cout << m << " " << g << " " << s;

    return 0;
}

Measured memory_bytes: 256
import fractions
def main():
    N, M = (int(_) for _ in input().split())
    S = input()
    T = input()
    g = fractions.gcd(N, M)
    for i in range(N):
        if i % (N//g) == 0 and S[i] != T[M*i//N]:
            print(-1)
            break
    else:
        print(N * M // g)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 5340
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long c,ans,sum[1000005],val[1000005],v[1000005],id[1000005];
void calc(){
	for (int i=n; i>=1; i--){
		sum[i]=sum[i+1]+v[i];
		val[i]=sum[i]-(c-id[i]);
	}
	for (int i=n; i>=1; i--)
		val[i]=max(val[i],val[i+1]);
	long long ss=0;
	for (int i=1; i<=n; i++){
		ss+=v[i];
		ans=max(ans,ss-id[i]);
		ans=max(ans,ss-id[i]*2+val[i+1]);
	}
}
int main(){
	scanf("%d%lld",&n,&c);
	for (int i=1; i<=n; i++)
		scanf("%lld%lld",&id[i],&v[i]);
	calc();
	for (int i=1; i<=n; i++) id[i]=c-id[i];
	for (int i=1; i<=n/2; i++){
		swap(id[i],id[n-i+1]);
		swap(v[i],v[n-i+1]);
	}
	calc();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=3005,M=N<<1;

int v[M],nxt[M];
int head[N],a[N];
int n;

il void addedge(int p,int x,int y){
	v[p]=y,nxt[p]=head[x],head[x]=p;
}

il bool dfs(int u,int p){
	for(int e=head[u];e;e=nxt[e]){
		if(v[e]==p) continue;
		if(a[v[e]]>=a[u]) continue;
		if(!dfs(v[e],u)) return true;
	}
	return false;
}

int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",a+i);
	rep(i,1,n-1){
		int x,y;
		scanf("%d%d",&x,&y);
		addedge(lch(i),x,y);
		addedge(rch(i),y,x);
	}
	rep(i,1,n) if(dfs(i,0)) printf("%d ",i);
	puts("");
	return 0;
} 

Measured memory_bytes: 256
n=int(input())
lst=list(map(int,input().split()))
lst=sorted(lst)
if(n>2):
    sm=0
    sm+=lst[-1]
    k=0
    i=2
    num=2
    while(num<n):
        k+=1
        sm+=lst[-i]
        if(k==2):
            k=0
            i+=1
        num+=1
elif(n==2):
    sm=lst[-1]

print(sm)


Measured memory_bytes: 31532
import sys
import math
import bisect

def solve(s):
    n = len(s)
    if n % 2 == 1:
        return False
    for i in range(0, n, 2):
        if s[i:i+2] != 'hi':
            return False
    return True

def main():
    H = int(input())
    W = int(input())
    n = int(input())
    A = []
    for h in range(H + 1):
        for w in range(W + 1):
            val = H * w + h * W - h * w
            if val >= n:
                A.append(h + w)
    print(min(A))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
S=input()
N=len(S)

T=[0]
for i in range(N):
    p = int(S[-1-i])
    T.append( (T[-1]+ pow(10,i,2019)*p)%2019 )
    
from collections import Counter
ans=0
U=dict(Counter(T))
for num in U:
    ans += U[num]*(U[num]-1)//2
print(ans)

Measured memory_bytes: 16692
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
    I am too dumb to realize that i am too dumb.
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli n,a,b,ans=0,i,k;
    cin>>n>>k;
    if(k==0)
    {
        cout<<n*n;
        exit(0);
    }
    rep(i,0,1+n)
    {
        if(i<=k)
        {

        }
        else
        {
            ans+=(i-k)*(n/i);
            lli temp=n%i;
            ans+=max(0LL,temp-k+1);
//            cout<<i<<" "<<(i-k)*(n/i)+max(0LL,temp-k)<<endl;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
// run : ctrl + c 

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

// struct UnionFind{
//     vector<int> par;
//     Unionfind(int n){
//         par = vector<int>(n,-1);
//     }
//     int root(int a){
//         if(par[a]<0) return a;
//         return par[a] = root(par[a]);
//     }
//     int size(int a){
//         a = root(a);
//         return -par[a];
//     }
//     bool unite(int a,int b){
//         a = root(a);
//         b = root(b);
//         if(a==b) return false;

//         if(par[b] < par[a]){
//             swap(a,b);
//         }
//         par[a] += par[b];
//         par[b] = a;
//         return true;
//     }
//     bool same(int a,int b){
//         a = root(a);
//         b = root(b);
//         return (a == b);
//     }
// };

class UnionFind{
    public:
    //親の番号を格納する。親だった場合は-(その集合のサイズ)
    vector<int> parent;

    UnionFind(int N){
        parent = vector<int>(N,-1);
    }

    int root(int A){
        if(parent[A] < 0) return A;
        return parent[A]=root(parent[A]);
    }

    int size(int A){
        return -parent[root(A)];
    }

    bool unite(int A, int B) {
        A = root(A), B = root(B);
        if(A == B) return false; 

        if(size(A) < size(B)) swap(A,B);
        parent[A] += parent[B];
        parent[B] = A;
        return true;
    }

    bool same(int A, int B){
        return root(A)==root(B);
    } 
};


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    int n,m;
    while(cin>>n>>m){
        if(n==0) return 0;
        array<int,3> d[m];
        for(int i=0;i<m;i++){
            int x,y,c;
            cin>>x>>y>>c;
            x--,y--;
            d[i] = {c,x,y};
        }
        sort(d,d+m);
        int cnt = 0;
        UnionFind uni(n);
        for(int i=0;i<m;i++){
            if(uni.same(d[i][1],d[i][2])) continue;
            cnt++;
uni.unite(d[i][1],d[i][2]);
            if(cnt == n/2){
                cout << d[i][0] << endl;
                break;
            }
        }

    }

}



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

int main()
{
    int a, b, c, d, e, count = 0;

    cin >> a >> b >> c >> d >> e;


    if(a == 0)
        cout << "1";

    else if( b == 0)
        cout << "2";
    else if(c == 0)
        cout << "3";
    else if(d == 0)
        cout << "4";
    else if(e == 0)
        cout << "5";

    return 0;
}


Measured memory_bytes: 3560
input = [int(x) for x in input().split()]

A = input[0]
B = input[1]
C = input[2]

isPoor = False
if (A==B):
    if (A!=C):
        isPoor = True
elif (A==C):
    if (A!=B):
        isPoor = True

elif (B==C):
    if (A!=B):
        isPoor = True

if (isPoor):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

char a[55][55],c[55][55];

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

int main(void){
	          int i,j,k,u;

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

	      	  int h,w;
	      	  cin >> h >> w;
	      	  vector<string> b(h);
	      	  for(j=0;j<h;j++) cin >> b[j];

	      	  for(i=0;i<h;i++){
	      		  for(j=0;j<w;j++){
	      			  a[i+1][j+1]=b[i][j];
	      		  }
	      	  }

	      	  for(i=1;i<=h;i++){
	      		  for(j=1;j<=w;j++){
	      			  if(a[i][j]=='#'){
	      				  c[i][j]='#';
	      				  continue;
	      			  }
	      			  int d=0;
	      		    for(k=-1;k<=1;k++){
	      		        for(u=-1;u<=1;u++){
	      		        	if(k==0 && u==0) continue;
	      			    int nx=i+k,ny=j+u;
	      			    if(a[nx][ny]=='#'){
	      			    	d++;
	      			    }
	      			}
	      		    }

	      		    c[i][j]=d+'0';

	      		  }
	      	  }

	      	  for(i=1;i<=h;i++){
	      		  for(j=1;j<=w;j++){
	      			  cout << c[i][j];
	      		  }
	      		  cout << endl;
	      		  }


	          return 0;
}


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

int main(){
    int N;
    cin >> N;
    int cand = 0;
    int a[4];
    a[0] = N % 10; N /= 10;
    a[1] = N % 10; N /= 10;
    a[2] = N % 10; N /= 10;
    a[3] = N % 10;

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

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

int main() {
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;

    for (int i = 2; i < MAX; i++) {
        if (!is_prime[i]) continue; // すでにiは素数でない判定が下っているのでスルー
        for (int j = i*2; j < MAX; j += i) {
            is_prime[j] = 0; // jはiの倍数なので素数ではない
        }
    }

    vector<int> a(MAX, 0); // 「2017-like」か
    for (int i = 0; i < MAX; i++) {
        if (i%2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) {
            a[i] = 1;
        }
    }

    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; i++) {
        s[i+1] = s[i] + a[i];
    }

    int Q; cin >> Q;
    for (int q = 0; q < Q; q++) {
        int l, r; cin >> l >> r;
        r++;
        cout << s[r] - s[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
S = list(input())
sum = 0

for i in range(2**(len(S)-1)):
    op_list = ["+"]*(len(S)-1)

    for j in range(len(S)-1):
        if (i>>j)&1:
            op_list[j]=""

    s = ""

    for k in range(len(S)-1):
        s = s + S[k]+op_list[k]

    s = s + S[len(S)-1]

    sum = sum + eval(s)

print(sum)

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

int main(){
    int n,ca=0,cb=0;cin>>n;vector<string> w(n);
    for(int i=0;i<n;i++) cin>>w.at(i);
    for(int i=0;i<n-1;i++){
        if(w.at(i).at(w.at(i).size()-1)==w.at(i+1).at(0)) ca++;
    }
    sort(w.begin(),w.end());
    for(int i=0;i<n-1;i++){
        if(w.at(i)!=w.at(i+1)) cb++;
    }
    if(ca==n-1&&cb==n-1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
P = np.array([0] + lr(), np.float64)
P = (P+1) / 2
Pcum = P.cumsum()
expectation = Pcum[K:] - Pcum[:-K]
answer = expectation.max()
print(answer)


Measured memory_bytes: 33740
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  string s1,s2,u; int a,b;
  cin>>s1>>s2;
  cin>>a>>b;
  cin>>u;
  if(u==s1) a--;
  else b--;
  cout<<a<<" "<<b;
  
  
  
  
  
  
  
 return 0; 
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
}

Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::collections::BTreeSet;

fn dfs(es: &Vec<Vec<usize>>, rest: &mut BTreeSet<usize>, visited: &mut BTreeSet<usize>, n: usize) {
  visited.insert(n);
  rest.remove(&n);
  for i in &es[n] {
    if visited.contains(i) {
      continue;
    }
    dfs(es, rest, visited, *i);
  }
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (n, m) = (xs[0], xs[1]);
  let ps: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse::<usize>().unwrap() - 1).collect();
  let mut es: Vec<Vec<usize>> = vec![vec![]; n];
  for _ in 0..m {
    let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    let (x, y) = (xs[0] - 1, xs[1] - 1);
    es[x].push(y);
    es[y].push(x);
  }
  let mut rest: BTreeSet<usize> = (0..n).collect();
  let mut count: usize = 0;
  while !rest.is_empty() {
    let n = *rest.iter().next().unwrap();
    let mut visited: BTreeSet<usize> = BTreeSet::new();
    dfs(&es, &mut rest, &mut visited, n);
    let vs: BTreeSet<usize> = visited.iter().map(|v| ps[*v]).collect();
    count += visited.iter().filter(|v| vs.contains(v)).count();
  }
  println!("{}", count);
}

Measured memory_bytes: 24700
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "math"
)

func main(){
    r := nextFloat64()
    fmt.Printf("%f %f\n", r*r*math.Pi, 2*r*math.Pi);
}
 
/* templates */
 
func Max(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a ...int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}
 
func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}
 
func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 1128
#include<iostream>
#include<memory>
#include<string>

template<class T>
struct node {
	node* pre;
	T key;
	std::unique_ptr<node<T>> next;

	node( const T&t ):
		pre{nullptr}
		,key{t}
		,next{nullptr}{}

	node( T&& t ) :
		pre{ nullptr }
		, key{ std::move(t) }
		, next{ nullptr }{}

	node(node&&) = default;
};

template<class T>
class dlist {
public:
	using node_type = node<T>;

private:
	std::unique_ptr<node<T>> core;
	node<T>* last;
protected:
	template<class X>
	auto make_node(X&&t) {
		return std::make_unique<node_type>(
			std::forward<X>(t)
			);
	}

public:
	dlist() :
		core{ nullptr }
		, last{}{}
	
	void insert(const T&value) {

/*
		std::cout <<">> in "<< value <<" "
			<< (core?"c":"!c")<< "\n";
*/
		if (!core) {
			core = make_node(value);
			last = core.get();
			return;
		}
		
		
		auto* here = core.get();
		while (here->pre != nullptr) 
			here = here->pre;
		
		auto new_node = make_node(value);
		std::swap(new_node, core);
		core->next = std::move(new_node);
		core->next->pre = core.get();
		
//		here->pre = new_node.get();
//		here->pre->next = core;
//		std::swap(here, core);
		//here->next->pre = here;
	}

	auto find(const T&value)const->node<T>* {
		auto* here = core.get();

		while (here != nullptr) {
			if (here->key == value)
				return here;
			here = here->next ?
				here->next.get() : nullptr;
		}

		return nullptr;
	}

	void del_front() {
		if (!core->next) {
			core.reset();
			return;
		}
		auto& next = core->next;
		next->pre = nullptr;
		core = std::move(next);
	}

	void del_back() {
		if (!core->next) {
			core.reset();
			return;
		}


		auto* pre = last->pre;
		last->pre->next.reset();
		last = pre;
		/*
		auto* here = core.get();

		while ( here->next ) {
			here = here->next.get();
		}
		
		here->pre
		here->pre->next.reset();
		*/
	}

	auto del(const T&value)->void {
		auto* p = find(value);
		if (p == nullptr)
			return ;
		/*
		std::cout << "del n\n";
		std::cout << (p->pre ? "p" : "!p") << " "
			<< (p->next ? "n":"!n") << "\n";
		*/

		if (!p->pre && !p->next) {
			core.reset();

		}else if (!p->pre && p->next) {
		//	auto*p = core->next.get();
			this->del_front();
		//	return p;
		}
		else if (p->pre && !p->next) {
			this->del_back();
		}
		else {
//			std::cout << (p->next ? "pn" : "!pn") << "\n";
			auto*pre = p->pre;
			auto&next = p->next;
			next->pre = pre;
			pre->next = std::move(next);
			//p->pre->next = std::move(p->next);
		}
	}

	auto print()const ->void{
		auto* here = this->core.get();
		if ( !here )
			return;
		
		while (here) {
			std::cout << here->key;
			std::cout << ( here->next ? " " : "\n");
			
			here = here->next
				? here->next.get() : nullptr;
		}
	}
};

int main() {

	std::cout.sync_with_stdio(false);

	int n; std::cin >> n;
	dlist<int> dl;

	for (int i{}; i < n; ++i) {
		std::string s;
		std::cin >> s;

		if (s == "insert") {
			int k; std::cin >> k;
			dl.insert(k);

		}
		else if (s == "delete") {
			int k; std::cin >> k;
		//	std::cout << ">> call del n\n";
			dl.del(k);
		}
		else if (s == "deleteFirst") {
			dl.del_front();
		}
		else
			dl.del_back();

		//dl.print();
	}

	dl.print();

}


Measured memory_bytes: 36328