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

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

    int n;
    cin>>n;

    long long sum = 0;
    for (int i=1; i<=n; i++) {
        int x;
        cin>>x;
        sum += x;
    }
    if (sum%2)  cout<<"NO\n";
    else        cout<<"YES\n";
}


Measured memory_bytes: 3640
import numpy as np
import sys


def main():
    sin = sys.stdin.buffer
    H, W = map(int, sin.readline().split())
    a = np.frombuffer(sin.read(H * (W + 1)), dtype='B') == ord('.')
    a = a.reshape((H, W + 1))
    L = np.empty((H, W + 1), dtype='i4')
    R = np.empty((H, W + 1), dtype='i4')
    T = np.empty((H, W + 1), dtype='i4')
    B = np.empty((H, W + 1), dtype='i4')

    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[H - 1] = a[H - 1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W + 1):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, W] = a[:, W]
    for i in range(W - 1, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())


main()

Measured memory_bytes: 110192
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << (a-b) % c << endl;
}


Measured memory_bytes: 256
while 1:
    n, m = [int(i) for i in input().split()]

    if n == 0 and m == 0:
        break
    
    taro = []
    hanako = []

    for i in range(n):
        s = int(input())
        taro.append(s)
    for i in range(m):
        s = int(input())
        hanako.append(s)

    sum_taro = sum(taro)
    sum_hanako = sum(hanako)

    ex_min = max(taro) + max(hanako)
    min_taro = 0
    min_hanako = 0

    for i in range(n):
        for j in range(m):
            ex_sum_taro = sum_taro - taro[i] + hanako[j]
            ex_sum_hanako = sum_hanako + taro[i] - hanako[j]
            if ex_sum_taro == ex_sum_hanako:
                if (min_taro == 0 and min_hanako == 0) or \
                   (min_taro + min_hanako < ex_min):
                    min_taro = taro[i]
                    min_hanako = hanako[j]
                    ex_min = min_taro + min_hanako

    if min_taro == 0 and min_hanako == 0:
        print(-1)
    else:
        print(min_taro, min_hanako)
        



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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 int INF = 1 << 30;

int main(){
    int d, w;
        while(1){
        cin >> d >> w;
        if(d == 0 && w == 0) break;
        vector< vector<int> > e(d, vector<int>(w, 0));
        rep(i, d){
            rep(j, w){
                cin >> e[i][j];
            }
        }
        int ans = 0;
        for(int i = 0; i <= d-3; i++){//position
            for(int j = 0; j <= w-3; j++){//position
                for(int k = 3; k <= d-i; k++){//len hight
                    for(int l = 3; l <= w-j; l++){//len width
                        int min_h = INF;
                        rep(m, k) min_h = min(e[i+m][j], min_h);
                        rep(m, l) min_h = min(e[i][j+m], min_h);
                        rep(m, k) min_h = min(e[i+m][j+l-1], min_h);
                        rep(m, l) min_h = min(e[i+k-1][j+m], min_h);
                        int max_h = 0;
                        int sum = 0;
                        bool flag = true;//water spill
                        for(int m = 1; m < k-1; m++){
                            for(int n = 1; n < l-1; n++){
                                max_h = max(e[m+i][n+j], max_h);
                                sum += min_h - e[m+i][n+j];
                                if(min_h <= e[m+i][n+j]) flag = false;
                            }
                        }
                        if(flag) ans = max(sum, ans);
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
BC = []

for i in range(M):
  bc = [int(i) for i in input().split()]
  BC.append(bc)

BC = sorted(BC, key=lambda x: x[1])
BC.reverse()

k = 0
for i in BC:
  if k == N:
    break
  if i[1] <= A[k]:
    break
  for j in range(i[0]):
    if k == N:
      break
    if i[1] > A[k]:
      A[k] = i[1]
      k += 1
    else:
      break

print(sum(A))


Measured memory_bytes: 82668
#include<stdio.h>
int main(void)
{
	int x,n;
	scanf("%d",&x);
	n=x%7;
	if(n==1){
	printf("fri\n");
	}
	else if(n==2){
	printf("sat\n");
	}
	else if(n==3){
	printf("sun\n");
	}
	else if(n==4){
	printf("mon\n");
	}
	else if(n==5){
	printf("tue\n");
	}
	else if(n==6){
	printf("wed\n");
	}
	else{
			printf("thu\n");
	}
	return 0;
}
	
	
	
	
	
	


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  int maxa=0, ai=0, sa=0;
  rep(i,n) {
    cin >> a[i];
    if (maxa <= a[i]) {
      sa = maxa;
      maxa = a[i];
      ai = i;
    } else if (sa <= a[i]) sa = a[i];
  }
  rep(i,n) {
    if (i != ai) cout << maxa << endl;
    else cout << sa << endl;
  }
  return 0;
}

Measured memory_bytes: 4060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#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
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    string s,t; cin >> s >> t;
    int ans=0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
        }
    cout << ans << endl;
}


Measured memory_bytes: 3800
#include <iostream>

using namespace std;

int n;
int a[100005][3];
int dp[100005][3];

int main(void)
{
  cin >> n;
  for(int i = 1; i <= n; i++){
    for(int j = 0; j < 3; j++) cin >> a[i][j];
  }
  for(int i = 0; i < 3; i++) dp[1][i] = a[1][i];
  for(int i = 2; i <= n; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(j == k) continue;
        dp[i][k] = max(dp[i][k], dp[i-1][j] + a[i][k]);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < 3; i++) ans = max(ans, dp[n][i]);
  cout << ans << endl;

  return 0;
}


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

int main()
{
	string str;
	long long n;
	long long res;
	cin >> str >> n;
	if(str.size() == 1){
		cout << n / 2 << endl;
		return 0;
	}else {
		int r = 0;
		int xx = str.size();
		for(int i = xx - 1; i > 0; i--){
			if(str[i] != str[i - 1]) {
				r = i;
				break;
			}
		}
		if(r == 0) cout << n * str.size() / 2 << endl;
		else{
			str = str + str;
			int lll = 1;
			int cnt = 0;
			for(int i = r; i < r + str.size() / 2 ; i++){
				if(str[i] == str[i + 1]) lll++;
				else{
					cnt = cnt + lll / 2;
					lll = 1;
				}
			}
			res = cnt * (n - 1);	
			lll = 1;
			cnt = 0;
			for(int i = 0; i < r ; i++){
				if(str[i] == str[i + 1]) lll++;
				else{
					cnt = cnt + lll / 2;
					lll = 1;
				}
			}
			res += cnt;
			res = res + (str.size() / 2 - r) / 2;
			cout << res << endl;
		}	
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  double w;
  while(scanf("%lf",&w)!=EOF){
    if     (w>91.00)printf("heavy\n");
    else if(w>81.00)printf("light heavy\n");
    else if(w>75.00)printf("middle\n");
    else if(w>69.00)printf("light middle\n");
    else if(w>64.00)printf("welter\n");
    else if(w>60.00)printf("light welter\n"); 
    else if(w>57.00)printf("light\n");  
    else if(w>54.00)printf("feather\n");  
    else if(w>51.00)printf("bantam\n");  
    else if(w>48.00)printf("fly\n");  
    else printf("light fly\n");
  }
  return 0;
}
 

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

using namespace std;

#define MAX_H 61
#define MAX_W 31
#define INF 1e9
#define Fi first
#define Se second
typedef pair<int,int> pii;

struct State{
  int d,x,y;
  bool f;
  State(){}
  State(int d,int x,int y,bool f) :
    d(d),x(x),y(y),f(f) {}
  bool operator > (const State &s)const{
    return d > s.d;
  }
};

int W,H;
int ps,pt;
pii S[MAX_W],T[MAX_W];
char field[MAX_H][MAX_W];
int dist[MAX_H][MAX_W][2];

const int dx[9] = {1,1,1,1,1,2,2,2,3};
const int dy[9] = {-2,-1,0,1,2,-1,0,1,0};

bool inField(int x,int y){
  return 0 <= x && x < W && 0 <= y && y < H;
}

int dijkstra(){
  priority_queue<State,vector<State>,greater<State> > Q;
  fill(dist[0][0],dist[0][0]+MAX_H*MAX_W*2,INF);
  for(int i = 0 ; i < ps ; i++){
    Q.push(State(0,S[i].Fi,S[i].Se,0)); 
    Q.push(State(0,S[i].Fi,S[i].Se,1));
    dist[S[i].Se][S[i].Fi][0] = 0;
    dist[S[i].Se][S[i].Fi][1] = 0;
  }

  while(!Q.empty()){
    State s = Q.top(); Q.pop();
    int x = s.x, y = s.y;

    if(dist[y][x][s.f] < s.d) continue;
    for(int i = 0 ; i < pt ; i++){
      if(x == T[i].Fi && y == T[i].Se){
        return s.d;
      }
    }
    if(s.f){
      for(int i = 0 ; i < 9 ; i++){
        int nx = x - dx[i];
        int ny = y + dy[i];
        if(!inField(nx,ny)) continue;
        if(field[ny][nx] == 'X') continue;
        int t = field[ny][nx] - '0';
        if(s.d + t < dist[ny][nx][0]){
          dist[ny][nx][0] = s.d + t;
          Q.push(State(dist[ny][nx][0],nx,ny,0));
        }
      }
    }else{
      for(int i = 0 ; i < 9 ; i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(!inField(nx,ny)) continue;
        if(field[ny][nx] == 'X') continue;
        int t = field[ny][nx] - '0';
        if(s.d + t < dist[ny][nx][1]){
          dist[ny][nx][1] = s.d + t;
          Q.push(State(dist[ny][nx][1],nx,ny,1));
        }
      }
    }
  }
  return -1;
}

int main(){
  dijkstra();
  while(cin >> W >> H, W){
    ps = pt = 0;
    for(int i = 0 ; i < H ; i++){
      for(int j = 0 ; j < W ; j++){
        cin >> field[i][j];
        if(field[i][j] == 'S'){
          S[ps++] = pii(j,i);
          field[i][j] = '0';
        }else if(field[i][j] == 'T'){
          T[pt++] = pii(j,i);
          field[i][j] = '0';      
        }
      }
    }
    cout << dijkstra() << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){
    map<string, int> S;
    vector<string> ans;
    int n;
    int ma = 0;

    cin>>n;

    for(int i = 0; i < n; ++i){
        string buff;
        cin >> buff;

        // 入力された文字列のイテレータを取得
        auto key = S.find(buff);

        // 既知であれば数を増やす
        if(key != S.end()){
            S[buff]++;
        }
        // 未知であればカウント開始
        else{
            S[buff] = 1;
        }

        // 最大数であればanswerを一新して更新
        if(S[buff] > ma){
            ans.clear();
            ans.emplace_back(buff);
            ma = S[buff];
        }
        // 最大数と等しければ追加
        else if(S[buff] == ma){
            ans.emplace_back(buff);
        }
    }
    // 文字列の大きさでソート
    sort(ans.begin(), ans.end());

    // base-ranged-forで出力
    for(auto str : ans){
        cout << str << endl;
    }
}

Measured memory_bytes: 26736
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static int N = 3;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int[] a = new int[N];
		for (i = 0; i <N; i++) {
			a[i] = parseInt(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		out.println(a[0]+a[1]);
	}
}


Measured memory_bytes: 21840
seq = [int(input()) for i in range(5)]
t = 0
d = 9

for s in seq:
    t += s
    t = (t - 1) // 10 + 1
    t *= 10
    
    d = min(d, (s - 1) % 10) 
    
print(t + d - 9)

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vi a(n), b(n);
	REP(i, n)cin >> a[i] >> b[i];
	vi c(m), d(m);
	REP(i, m)cin >> c[i] >> d[i];
	REP(i, n) {
		int res = INF, p;
		REP(j, m) {
			if (res > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				res = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				p = j;
			}
		}
		cout << p + 1 << endl;
	}
}


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

using namespace std;

int main()
{
	long long N, A, B, C, D, E;

	cin >> N;
	cin >> A >> B >> C >> D >> E;

	vector<long long> T;
	T.push_back( A );
	T.push_back( B );
	T.push_back( C );
	T.push_back( D );
	T.push_back( E );

	sort( T.begin(), T.end() );

	long long tp = N / T[0];
	cout << 5 + tp -1 + ((N%T[0])?1:0) << endl;;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> cnt(m, 0);
	rep(i, n) {
		int k; cin >> k;
		rep(i, k) {
			int a; cin >> a;
			cnt[a - 1]++;
		}
	}

	int ans = 0;
	rep(i, m) {
		if (cnt[i] == n) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Dice d = new Dice(
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt(),
            sc.nextInt()
        );
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            d.move(s.substring(i, i+1));
        }
        d.showTop();
    }
}

class Dice {
    public int[] ary;
    public Point p;
    public Dice(int a, int b, int c, int d, int e, int f) {
        ary = new int[6];
        ary[0] = a;
        ary[1] = b;
        ary[2] = c;
        ary[3] = d;
        ary[4] = e;
        ary[5] = f;
        p = new Point();
    }
    
    public void move(String s) {
        int t;
        switch(s) {
        case "N":
            t = ary[0];
            ary[0] = ary[1];
            ary[1] = ary[5];
            ary[5] = ary[4];
            ary[4] = t;
            p.y++;
            break;
        case "S":
            t = ary[0];
            ary[0] = ary[4];
            ary[4] = ary[5];
            ary[5] = ary[1];
            ary[1] = t;
            p.y--;
            break;
        case "E":
            t = ary[0];
            ary[0] = ary[3];
            ary[3] = ary[5];
            ary[5] = ary[2];
            ary[2] = t;
            p.x++;
            break;
        case "W":
            t = ary[0];
            ary[0] = ary[2];
            ary[2] = ary[5];
            ary[5] = ary[3];
            ary[3] = t;
            p.x--;
            break;
        }
    }
    public void showTop() {
        System.out.println(ary[0]);
    }
}

class Point {
    public int x;
    public int y;

    public Point() {
        x = 0;
        y = 0;
    }
}

Measured memory_bytes: 26372
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    String s=scn.nextLine();
    
    if(s.charAt(0)==s.charAt(1) && s.charAt(0)==s.charAt(2))
      System.out.println("No");
    
    else
      System.out.println("Yes");
  }
}

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

int main()
{
int i,n,j,k,nn,l=0,c=0,t=0,s=0,b=0,d=0,x=0,q=0;

int a[4][4];

for(i=1;i<=3;i++)
{
	for(j=1;j<=3;j++)
	cin>>a[i][j];
}
cin>>n;
for(nn=1;nn<=n;nn++)
{
	cin>>k;
	for(i=1;i<=3;i++)
   {
	for(j=1;j<=3;j++)
	{
		if(a[i][j]==k)
		a[i][j]=-1;
	}
   }
}
i=1;
	for(j=1;j<=3;j++)
	{
		if(a[i][j]==-1)
		c++;
	}
i=2;
	for(j=1;j<=3;j++)
	{
		if(a[i][j]==-1)
		l++;
	}
i=3;
	for(j=1;j<=3;j++)
	{
		if(a[i][j]==-1)
		t++;
	}
j=1;
	for(i=1;i<=3;i++)
	{
		if(a[i][j]==-1)
		s++;
	}
j=2;
	for(i=1;i<=3;i++)
	{
		if(a[i][j]==-1)
		b++;
	}
j=3;
	for(i=1;i<=3;i++)
	{
		if(a[i][j]==-1)
		d++;
	}
if(a[1][1]==-1 && a[2][2]==-1 && a[3][3]==-1)
     x=3;
     
if(a[1][3]==-1 && a[2][2]==-1 && a[3][1]==-1)
     q=3;     
	 
if(l==3 || c==3 || t==3 || s==3 || b==3 || d==3 || x==3 || q==3)
cout<<"Yes";
else
cout<<"No";	 						
}


Measured memory_bytes: 256
x,n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
a = 0
for i in range(52):
    if  not x-a in p:
        print(x-a)
        exit()
    elif not x+a in p:
        print(x+a)
        exit()
    else:
        a += 1


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

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

int main(){
int n;
cin>>n;
ll y;
cin>>y;
for(ll i=0;i<=n;i++){
  for(ll j=0;i+j<=n;j++){
    for(ll k=0;i+j+k<=n;k++){
      if((long long)10000*i+(long long)5000*j+(long long)1000*k==y&&i+k+j==n){
cout<<i<<" "<<j<<" "<<k<<" "<<endl;
return 0;

      }
    }
  }
}

cout<<-1<<" "<<-1<<" "<<-1<<" "<<endl;

  return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  char s[H+2][W+2] = {};
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      if(i==0 || i==H+1 || j==0 || j==W+1) cout << '#';
      else{
        cin >> s[i][j];
        cout << s[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int x, y;
  cin >> x >> y;
  int g[13];
  g[1] = g[3] = g[5] = g[7] = g[8] = g[10] = g[12] = 1;
  g[4] = g[6] = g[9] = g[11] = 2;
  g[2] = 3;
  if (g[x] == g[y]) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vpi = vector<pii>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpl = vector<pll>;
using vs = vector<string>;

int main()
{
    int h, n;
    cin >> h >> n;
    vi as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);

    int sun = 0;
    for(int num : as)
    {
        sun += num;
    }
    if(sun < h) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


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

int main(void) {
    string S,T; cin >> S >> T;
    int Tsize = T.size();
    int Ssize = S.size();
    int max = 0;
    if(S.find(T)!=std::string::npos || S==T) {
        cout << 0 << endl;
        return 0;
    }
    for(int i=0; i<=Ssize-Tsize; i++) {
        int x = 0;
        for(int j=0; j<Tsize; j++) {
            if(S[i+j] == T[j]) x++;
            if(max<x) max = x;
        }
    }
    int ans = Tsize - max;
    cout << ans << endl;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lesson1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            if (!(1 <= N && N <= 100)) return;
            // 整数の入力
            int[] A = new int[N];
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            for (int i = 0; i < A.Length; i++)
            {
                A[i] = int.Parse(input[i]);
                if (!(1 <= A[i] && A[i] <= 100)) return;
            }
            Array.Sort(A);
            Array.Reverse(A);
            int Anum = 0;
            int Bnum = 0;
            for(int i = 0; i<A.Length; i++)
            {
                if ((i % 2) == 0) Anum += A[i];
                else Bnum += A[i]; 
            }
            int diff = Anum - Bnum;
            Console.WriteLine(diff);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n; cin >> n;

    map<ll,ll> mp;
    for(ll i=1;i<=n;i++){
        ll v = i;
        for(int j=2;j<=i;j++){
            int cnt=0;
            while(v%j==0){
                cnt++;
                v/=j;
            }
            if(cnt>0) mp[j] += cnt;
        }
    }

    ll ans = 1;
    for(auto p : mp){
        ll v = p.second;
        ans *= (v+1);
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
#define FOR(i, n) for(int i = 0; i < n; i ++)
using namespace std;
void input();
int max(int32_t a, int b){
   return max((int)a, b);
}

int32_t main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n, k; cin >> n >> k;
   if(n % (k*2+1) != 0){
      cout << n / (k*2+1) + 1;
   }else{
      cout << n / (k*2+1);
   }
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> cnt(10, vector<int>(10));

    int d = 1;
    for (int i = 1; i <= n; i++){
        if (i / d >= 10){
            d *= 10;
        }
        cnt[i / d][i % 10]++;
    }

    int64_t ans = 0;
    for (int i = 1; i < 10; i++){
        for (int j = 1; j < 10; j++)
            ans += cnt[i][j] * cnt[j][i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    k = II()
    a, b = MI()

    ans = 'NG'
    for n in range(a, b+1):
        if n % k == 0:
            ans = 'OK'
            break
    if ans == 'OK':
        print(ans)
    else:
        print(ans)



if __name__ == '__main__':
    solve()


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

#define ll long long
#define ii pair<int, int>
#define int ll
#define lb long double
const int N = 1e5 + 10, mod = 1e9 + 7;

int po(int b, int p)
{
    if (!p)
        return 1;
    int mid = po(b, p/2);
    mid = (mid * mid) %mod;
    if (p & 1)
        return (mid * b) %mod;
    return mid;
}

int32_t main()
{
    ll na = 0;
    ll nb = 0;
    ll nc = 0;
    string s;
    cin >> s;
    int n = s.size();
    int q = 0;
    for (int i = 0; i < n; i ++)
        q += (s[i] == '?');
    q = 0;
    for (int i = 0; i < n; i ++)
    {
        if (s[i] == 'A')
            na += po(3, q);
        if (s[i] == 'B')
            nb += na;
        if (s[i] == 'C')
            nc += nb;
        if (s[i] == '?')
        {
            int c = nb, b = na;
            nc *= 3;
            nc += c;
            nb *= 3;
            nb += b;
            na *= 3;
            na += po(3, q++);
        }
        //cout << na << ' ' << nb << ' ' << nc << endl;
        na%= mod;
        nb%= mod;
        nc%= mod;
    }
    cout << nc << endl;
}

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

int main() {
  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  ll amari[220000];
  map<ll,ll> mp;
  ll ten = 10LL;
  if(p==2 || p==5) {
    ll ans = 0LL;
    rep(i,s.size()) {
      string t = "";
      t += s[i];
      ll m = stoi(t);
      if(m%p == 0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
  }
  reverse(s.begin(),s.end());
  rep(i,s.size()) {
    string t = "";
    t += s[i];
    ll m = stoi(t);
    if(i==0) {
      amari[i] = m%p;
      mp[amari[i]]++;
      continue;
    }
    amari[i] = (amari[i-1] + m*ten)%p;
    ten *= 10LL;
    ten %= p;
    mp[amari[i]]++;
  }
  ll ans = 0LL;
  mp[0]++;
  for(auto p : mp) {
    ll v = p.second;
    ans += v*(v-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2564
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a)-1:] == b[:1] && b[len(b)-1:] == c[:1] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

using namespace std;

int main(void){
	int h, w, i, j, mh, mw;
	double min;
	while(1){
		fscanf(stdin,"%d%d",&h,&w);
		if(h == 0 && w == 0) break;
		min = 0x7FFFFFFF;
		for(i = 1;i <= 150;i++){
			for(j = i + 1;j <= 150;j++){
				if(sqrt((double)(h * h + w * w)) < sqrt((double)(i * i + j * j)) || (sqrt((double)(h * h + w * w)) == sqrt((double)(i * i + j * j)) && h < i)){
					if(min > sqrt((double)(i * i + j * j))){
						min = sqrt((double)(i * i + j * j));
						mh = i, mw = j;
					}
				}
			}
			if(j != 151) break;
		}
		fprintf(stdout,"%d %d\n",mh,mw);
	}
	return 0;
}

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

int main(void){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n; i++) a[i]--;
  int num = 0;
  for(int i = 0; i < n; i++) if(i == a[a[i]]) num++;
  cout << num / 2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string str;
	int maxi[26] = {0};
	int count[26];
	for(int i = 0;i < 1;i++){
		cin >> str;
		for(int j = 0;j < 26;j++) count[j] = 0;
		for(int j = 0;j < str.length();j++){
			int c = str[j] - 'a';
			count[c]++;
		}
		for(int j = 0;j < 26;j++){
			maxi[j] = count[j];
		}
	}
	for(int i = 1;i < n;i++){
		cin >> str;
		for(int j = 0;j < 26;j++) count[j] = 0;
		for(int j = 0;j < str.length();j++){
			int c = str[j] - 'a';
			count[c]++;
		}
		for(int j = 0;j < 26;j++){
			if(count[j] < maxi[j]) maxi[j] = count[j];
		}
	}
	str = "";char al = 'a';
	for(int i = 0;i < 26;i++){
		for(int j = 0;j < maxi[i];j++){
			str = str+al;
		}
		al++;
	}
	cout << str << endl;
}


Measured memory_bytes: 256
(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))

(defun f(s)
  (let ((l (length s)))
    (labels ((g(s)
               (let ((l (length s)))
                 (string= (subseq s 0 (/ (if (oddp l) (1- l) l) 2)) (nreverse (subseq s (/ (if (oddp l) (1+ l) l) 2) l))))))
      (and (g s) (g (subseq s 0 (/ (1- l) 2))) (g (subseq s (1- (/ (+ l 3) 2)) l))))))

(let ((line (read-line nil nil)))
  (format t "~A~%" (if (f line) "Yes" "No")))

Measured memory_bytes: 15716
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;
 
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

int main() {
  int h, w;
  cin >> h >> w;
  
  string s[50];
  rep(i, h) {
    cin >> s[i];
  }
  
  const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  const int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') continue;
      
      int cnt = 0;
      for (int d = 0; d < 8; d++) {
        const int ni = i + dx[d];
        const int nj = j + dy[d];
        
        if (ni < 0 || ni >= h) continue;
        if (nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') cnt++;
      }
      s[i][j] = char(cnt + '0');
    }
  }
  
  rep(i, h) {
    cout << s[i] << endl;    
  }
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<double> P(N);
  rep(i, N) { cin >> P[i]; }

  vector<vector<double>> DP(N + 1, vector<double>(N + 1, 0.0));
  DP[0][0] = 1.0;
  rep(i, N) {
    rep(j, N) {
      DP[i + 1][j + 1] += DP[i][j] * P[i];
      DP[i + 1][j + 0] += DP[i][j] * (1.0 - P[i]);
    }
  }
  double Ans = 0.0;
  for (int i = N / 2 + 1; i <= N; i++) {
    Ans += DP[N][i];
  }
  cout << setprecision(10) << Ans << endl;
  return 0;
}


Measured memory_bytes: 70784
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
#include <utility>
#define FR first
#define SE second
#define inf 0x7fffffff
 
using namespace std;
 
typedef pair<int,int> pr;
 
int num[200005],id[200005];
 
namespace SGT {
 
int minn[800000][2];
 
void build(int l,int r,int o) {
  if (l==r) {
    minn[o][l&1]=num[l];
    minn[o][!(l&1)]=inf;
  }
  else {
    int m=((l+r)>>1);
    build(l,m,o*2);
    build(m+1,r,o*2+1);
    minn[o][0]=min(minn[o*2][0],minn[o*2+1][0]);
    minn[o][1]=min(minn[o*2][1],minn[o*2+1][1]);
  }
}
 
void update(int l,int r,int o,int p) {
  if (l==r) minn[o][l&1]=inf;
  else {
    int m=((l+r)>>1);
    if (m>=p) update(l,m,o*2,p);
    else update(m+1,r,o*2+1,p);
    minn[o][0]=min(minn[o*2][0],minn[o*2+1][0]);
    minn[o][1]=min(minn[o*2][1],minn[o*2+1][1]);
  }
}
 
int query(int l,int r,int o,int lx,int rx,int d) {
  if (l>=lx&&r<=rx) return minn[o][d];
  else {
    int m=((l+r)>>1);
    if (m>=rx) return query(l,m,o*2,lx,rx,d);
    if (m<lx) return query(m+1,r,o*2+1,lx,rx,d);
    return min(query(l,m,o*2,lx,rx,d),query(m+1,r,o*2+1,lx,rx,d));
  }
}
 
}
 
set <int> st;
priority_queue <int,vector<int>,greater<int> > que;
 
pr update(int x,int n) {
  int p=id[x];
  set<int>::iterator it=st.lower_bound(p);
  int r=(*it);it--;int l=(*it);
  int q=id[SGT::query(1,n,1,p+1,r-1,(p&1)^1)];
  st.insert(p);st.insert(q);
  SGT::update(1,n,1,p);SGT::update(1,n,1,q);
  if (l+1<=p-1) que.push(SGT::query(1,n,1,l+1,p-1,p&1));
  if (p+1<=q-1) que.push(SGT::query(1,n,1,p+1,q-1,(p&1)^1));
  if (q+1<=r-1) que.push(SGT::query(1,n,1,q+1,r-1,p&1));
  return pr(num[p],num[q]);
}
 
int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&num[i]);
    id[num[i]]=i;
  }
  SGT::build(1,n,1);
  que.push(SGT::query(1,n,1,1,n,1));
  st.insert(0);st.insert(n+1);
  for(int i=1;i<=(n>>1);i++) {
    int x=que.top();que.pop();
    pr ans=update(x,n);
    printf("%d %d ",ans.FR,ans.SE);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

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

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <int> v(n);
    generate(all(v),nxt);
    int test=INT_MAX;
    for(int i=-100;i<=100;i++)
    {int sum=0;
        for(int j=0;j<n;j++)
            sum+=pow(v[j]-i,2);
        if(sum<test)
            test=sum;
    }
    cout<<test<<endl;

    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include<iostream>

using namespace std;
 
int main()
{
	int a;
    char str[3];
        
    cin >> str;
    cin >> a;
    if(str[0]==str[2]){
   cout <<  "Yes" << endl;
    }else{
      cout <<  "No" << endl;
    }
   
   
  
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  char c, v[]="aeiou";
  scanf("%c", &c);

  for (int i=0; i<5; i++) {
    if (v[i]==c) {
      printf("vowel\n");
      return 0;
    }
  }
  
  printf("consonant\n");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int H[300],W[300],n,i,j,k;
   
  for(i=0;i<300;i++){
    scanf("%d%d",&H[i],&W[i]);
    if(H[i]==0&&W[i]==0) break;
  }
  n = i;
 
  for(i=0;i<n;i++){
    for(j=0;j<H[i];j++){
      for(k=0;k<W[i];k++){
	if(j%2==0){
	  if(k%2==0) printf("#");
	  else printf(".");
	}
	else{
	  if(k%2==0) printf(".");
	  else printf("#");
	}
      }
      printf("\n");
    }
    printf("\n");
  }
   
  return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

    int N; cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    ll sum = 0, d = 0;
    int cnt = 0;
    rep(i, N) {
        ll tmp = A[i] - B[i];
        if (tmp >= 0) {
            C.pb(tmp);
        } else {
            d -= tmp;
            cnt++;
        }
        sum += tmp;
    }

    sort(rall(C));
    rep(i, C.size()) {
        if (d <= 0) break;
        d -= C[i];
        cnt++;
    }

    if (sum >= 0) cout << cnt << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {

        Scanner scanner = new Scanner(System.in);        

        double r = scanner.nextDouble(); 
        
        double area = r * r * Math.PI;

        double around = 2 * r * Math.PI;

        System.out.printf("%f %f", area, around);

        scanner.close();

    }
}


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


#define ll long long



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

    ll k ; cin>>k;
    vector<ll> v,v1;

    ll s=0,s1=0;

    v.push_back(0);
    for(int i=0;i<m;++i){
        ll a; cin >> a;
        s+=a;
        v.push_back(s);
    }

      v1.push_back(0);
      for(int i=0;i<n;++i){
        ll b; cin >> b;
        s1+=b;
        v1.push_back(s1);
    }


    vector<ll> :: iterator it;

    int ans=0;

    for(int i=0;i<=m;++i){
            ll x = v[i];
            ll y=0;
            if(x<=k){
                y= k - x;
                if(y<0) continue;
                it = lower_bound(v1.begin(),v1.end(),y);
                int dist = it-v1.begin();
                if(dist>n || *it>y){
                 dist--;
                }

                ans=max((i)+dist,ans);
            }

    }

    cout<<ans<<endl;






    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
int main() {
    int A,B,T,a,b,t;
    cin >> A >> B >> T;
    t=0;
    b=0;
    while(1){
        t+=A;
        if(t<=T){ 
                b++;
                }else{
                break;
                }
    }
    cout << b*B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

string check_string(vector<int> nums)
{
	vector<int> check(4, 0);
    for(int i = 0; i < 4; i++){
    	if(nums[i] == 1)
          check[0] = 1;
        if(nums[i] == 9)
          check[1] = 1;
        if(nums[i] == 4)
          check[2] = 1;
        if(nums[i] == 7)
          check[3] = 1;
    }
  	return find(check.begin(), check.end(), 0) == check.end() ? "YES" : "NO";
}

int main()
{
	vector<int> nums;
  	for(int i = 0; i < 4; i++){
		string tmp;
		int num;
        cin >> tmp;
        num = stoi(tmp);
      	nums.push_back(num);
      	cerr << num << endl;
    }
  
  cout << check_string(nums) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n, m;
  cin >> n >> m;
  vl a(m);
  vl c(m, 0);
  rep(i, m) {
    ll b;
    cin >> a[i] >> b;
    rep(j, b) {
      ll x;
      cin >> x;
      x--;
      c[i] += (1 << x);
    }
    // cout << c[i] << endl;
  }
  vvl data(m, vl((1<<n), INF));
  data[0][0] = 0;
  data[0][c[0]] = a[0];
  for (int i = 1; i < m; i++) {
    for (int x = 0; x <= (1 << n)-1; x++) {
      data[i][0] = 0;
      data[i][x] = data[i-1][x];
    }
    for (int x = 0; x <= (1 << n)-1; x++) {
      int nx = x | c[i];
      // cout << i << ":" << x << " " << nx << endl;
      if (data[i-1][x] < INF) {
        data[i][nx] = min(data[i][nx], data[i-1][x] + a[i]);
      }
    }
    // for (int x = 0; x <= (1 << n) - 1; x++) {
    //   cout << data[i][x] << " ";
    // }
    // cout << endl;
  }
  if (data[m-1][(1<<n)-1] == INF) {
    cout << -1 << endl;
  } else {
    cout << data[m-1][(1<<n)-1] << endl;
  }
  return 0;
}


Measured memory_bytes: 32384
#include<iostream>
#include<cstdio>
#include<cstring>

int main(){
  char s1[101]={0};
  char s2[101]={0};
  int count=0,flag=0;

  while(scanf("%s",s1)!=EOF){
    int len=strlen(s1);
    /* if(len==1){
      count++;
      flag++;
      }*/
    for(int i=0;i<len;i++){
      s2[i]=s1[len-1-i];
    }
    s2[len]='\0';
    if(strcmp(s1,s2)==0){
      count++;
    }
    flag=0;
  }

  printf("%d\n",count);
  return(0);
}

Measured memory_bytes: 1136
local n=io.read("*n")
local a={}
for i=1,n do
    a[i]=io.read("*n")
end

local box={}
for i=n,1,-1 do
    local ball=0
    for j=2*i,n,i do
        ball=ball+(box[j] or 0)
    end
    if ball%2~=a[i] then
        box[i]=1
    end
end

local counter=0
for i=1,n do
    if box[i] then
        counter=counter+1
    end
end
print(counter)
for i=1,n do
    if box[i] then
        print(i)
    end
end

Measured memory_bytes: 6068
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

#define N_MAX 300

char S[N_MAX][N_MAX + 1];

char f(int i, int j, int N){
    if(N <= i){
        i = i - N;
    }
    if(N <= j){
        j = j - N;
    }

    return S[i][j];
}

int main(){
    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i++){
        scanf("%s", S[i]);
    }

    int sum = 0;
    for(int k = 0; k < N; k++){
        bool is_good = true;
        for(int i = 0; i < N; i++){
            if(!is_good){
                continue;
            }
            for(int j = i + 1; j < N; j++){
                if(f(i + k, j, N) != f(j + k, i, N)){
                    is_good = false;
                    break;
                }
            }
        }
        if(is_good){
            sum += 1;
        }
    }

    printf("%d\n", sum * N);
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
int a;
cin>>a;
if(a==1||a==2||a==3||a==4||a==5||a==6||a==7||a==8||a==9||a==10||a==12||a==14||a==15||a==16||a==18||a==20||a==21||a==24||a==25||a==27||a==28||a==30||a==32||a==35||a==36||a==40||a==42||a==45||a==48||a==49||a==56||a==54||a==63||a==64||a==72||a==81){
    cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var input string
	_, err := fmt.Scan(&input)
	if err != nil {
		panic(err)
	}
	var cnt = 0
	for _, s := range strings.Split(input, "") {
		i, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		cnt += i
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
def abc048_c():
  n, x = map(int, input().split())
  A = list(map(int, input().split()))
  ans = 0
  B = []
  if A[0] > x:
    ans += A[0] - x
    B.append(x)
  else:
    B.append(A[0])
  for i in range(1, n):
    tmp = B[-1] + A[i]
    if tmp > x:
      ans += tmp - x
      B.append(x - B[-1])
    else:
      B.append(A[i])
  print(ans)

abc048_c()

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

int a[200010], u[200010], p[200010];
int bit[500010], bitn = 1;
map<int,int> zip;
void init(int n){
	while(bitn < n)bitn <<= 1;
}
void add(int k){
	while(k <= bitn){
		bit[k]++;
		k += k&-k;
	}
}
int get(int k){
	int ans = 0;
	while(0 < k){
		ans += bit[k];
		k -= k&-k;
	}
	return ans;
}

void compress(int n){
	vector<int> v;
	for(int i = 0;i <= n;i++)v.push_back(p[i]);
	sort(v.begin(), v.end());
	for(int i = 0;i < v.size();i++){
		zip[v[i]] = i+1;
	}
}

signed main(){
	int n, k, ans = 0;
	scanf("%lld%lld", &n, &k);
	for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
	for(int i = 1;i <= n;i++)a[i] += a[i-1];
	for(int i = 1;i <= n;i++)u[i] = u[i-1]+k;
	for(int i = 1;i <= n;i++)p[i] = a[i]-u[i];
	compress(n);
	init(n+1);
	for(int i = 0;i <= n;i++){
		int x = zip[p[i]];
		ans += get(x);
		add(x);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 20848