akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    int N, W;
    cin >> N >> W;

    vll w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    vvll dp(N + 1, vll(W + 1, 0));

    rep(i, N)
    {
        rep(j, W + 1)
        {
            if (j - w[i] >= 0)
            {
                //v[i]を入れる
                chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }

            chmax(dp[i + 1][j], dp[i][j]);
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 80256
s = list(input())
x, y = map(int, input().split())

s.append("last")
X = []
Y = []
f = "x"
cnt = 0
for i in range(len(s)):
    if s[i] == "F":
        cnt += 1
    elif f == "x":
        X.append(cnt)
        cnt = 0
        f = "y"
    else:
        Y.append(cnt)
        cnt = 0
        f = "x"

if X:
    x -= X[0]
    X.pop(0)

X.sort(reverse=True)
Y.sort(reverse=True)
for i in range(len(X)):
    if x >= 0:
        x -= X[i]
    else:
        x += X[i]
        
for i in range(len(Y)):
    if y >= 0:
        y -= Y[i]
    else:
        y += Y[i]
        
if x == 0 and y == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40176
#include <bits/stdc++.h>
using namespace std;
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}
int main(){
	int n;cin>>n;
	call(n);
	return 0;
}


Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include<iomanip>
using namespace std;

int main()
{
    long long N;
    vector<long long> L;
    cin>>N;
    long long temp = 0;
    for(int i= 0;i<N;i++)
    {
        cin>>temp;
        L.push_back(temp);
    }
    long long sum=0;

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

    for(int i = 0;i<N-2;i++)
    {
        for(int j = i+1;j<N-1;j++)
        {
            for(int k = j+1;k<N;k++)
            {
                if(L[k]>=L[i]+L[j])
                {
                    break;
                }
                if(L[i]<L[k]+L[j])
                {
                    if(L[j]<L[i]+L[k])
                    {
                        sum++;
                    }
                }
            }
        }
    }
    cout<<sum<<endl;
}

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

int main()
{
    int64_t X;
    cin >> X;

    int64_t n = 100;
    int64_t res = 0;
    while (n < X)
    {
        res++;
        n = n * 1.01;
    }
    cout << res << endl;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

vector<int> adj[MAXN + 2];
bool ind[MAXN + 2];

int dp[MAXN + 2];
int dfs(int u) {
	if(adj[u].size() == 0)
		return 0;
	if(dp[u])
		return dp[u];
	for(int v : adj[u])
		dp[u] = max(dp[u], dfs(v));
	return ++dp[u];
}

int main() {
	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
		ind[y] = true;
	}
	int ans = 0;
	for(int i = 1; i <= N; i++)
		if(!ind[i])
			ans = max(ans, dfs(i));
	cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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


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

	int n;
	cin >> n;

	vector<string> s(n);
	for (auto& v : s) {
		cin >> v;
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool flag = true;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++) {
				if (s[j][(k + i) % n] != s[k][(j + i) % n]) {
					flag = false;
				}
			}
		}

		if (flag) {
			ans += n;
		}
	}

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


Measured memory_bytes: 384
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt();
    let A = cin.getIntArray(N);
    let dp = new Array(N+1).fill(0).map(() => new Array(2).fill(Number.MIN_SAFE_INTEGER));
    dp[0][0] = 0;
    for (let n = 0; n < N; n++) {
        dp[n+1][0] = Math.max(...[dp[n+1][0], dp[n][0] + A[n], dp[n][1] - A[n]]);
        dp[n+1][1] = Math.max(...[dp[n+1][1], dp[n][0] - A[n], dp[n][1] + A[n]]);
    }
    console.log(dp[N][0]);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 56916
/*
For Bantako San
By shyyhs.

Using hash to insert and search for a perticular number.
Every insert and search is O(1) ideally.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
#define ll long long
#define MASK 0x0003FFFF
//#define Hsize ((1<<18)-1)
#define Hsize 300009
#define MAXN 210001 
ll sumZ=0; //sum from the beginning
int Ai; //This is Ai in the problem, we use it only once so array is not necessary.
int N; //N in the problem

struct T
{
    ll number,times;
    int next;
}hashBucket[MAXN];
int top=0;
int hashIndex[Hsize];


//x->hash(x)
inline int hashFunc(ll x)
{
    if (x<0) x=-x;
    return (x%300007);
    return (x&MASK);
}

//add the current sumZ to the hash table
void addToHash(ll sumZ)
{
    int index, HsumZ, beginP;
    HsumZ = hashFunc(sumZ);
    for (beginP=index=hashIndex[HsumZ]; index>0; index=hashBucket[index].next)
        if (hashBucket[index].number == sumZ) // there is already that number in the hashbucket
        {
            hashBucket[index].times+=1;
            return;
        } 
    top++;
    hashIndex[HsumZ]=top;
    hashBucket[top].number = sumZ;
    hashBucket[top].times = 1;
    hashBucket[top].next = beginP;
}

void init()
{
    scanf("%d",&N);
    addToHash(0);
    for (int i=0; i<N; ++i)
    {
        scanf("%d",&Ai);
        sumZ=sumZ+Ai;
        addToHash(sumZ);
    }
}

void work()
{
    ll answer=0;
    for (int i=1; i<=top; ++i)
        answer=answer+(((hashBucket[i].times)*(hashBucket[i].times-1))>>1) ;
    cout<<answer<<endl;
}
    
int main()
{
    init();
    work();
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int a,p;
    cin>>a>>p;
    cout<<(3*a+p)/2;

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
d = gets.split.map(&:to_i)
max = d.max

x = Array.new(max+1, 0)
d.each{|i|
  x[i] += 1
}

if x[0]!=1 || d[0] != 0
  p 0
else
  ans = 1
  MOD = 998244353
  (max-1).times{|i|
    ans *= (x[i+1] ** x[i+2]) % MOD
    ans %= MOD
  }
  p ans
end


Measured memory_bytes: 8836
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	int a,b;
	cin>>a>>b;
	
	cout<<(a+b+1)/2<<endl;
	
    return 0;
}


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

signed main(){
  int n; cin >> n;
  string s; cin >> s;
  bool ok = true;
  if(n % 2 != 0) ok = false;
  else{
    for(int i = 0; i < n / 2; i++){
      if(s[i] != s[i + n / 2]) ok = false;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np

if __name__ == '__main__':
    res = []
    H, W = map(int, input().split())
    f = [list(map(int, input().split())) for i in range(H)]
    for x in range(W-1, 0, -1):
        for y in range(H-1, -1, -1):
            if f[y][x] % 2 == 1:
                res.append((y+1, x+1, y+1, x))
                f[y][x-1] += 1
                f[y][x] -= 1
    for y in range(H-1, 0, -1):
        if f[y][0] % 2 == 1:
            res.append((y+1, 1, y, 1))
            f[y][0] -= 1
            f[y-1][0] += 1

    print(len(res))
    for y1, x1, y2, x2 in res:
        print(y1, x1, y2, x2)




Measured memory_bytes: 34152
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

#define SIZE 110

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int A[SIZE];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    int ans = A[N-1] - A[0];
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
map<ll,ll> mp;
int main()
{
	int n,i,j,k,x,y,ans,curr,temp,m;
	int tc;
    cin >> n;
    ll chaeng = 0;
    for(i=1;i<=n;i++) {
        ll now;
        cin >> now;
        chaeng += mp[i - now];
        mp[i + now]++;
    }
    cout << chaeng << endl;
	return 0;
}


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

 
int main() {
    int n;
    cin>>n;
    //累積和イージー
    vector<ll> R(n);
    ll a0;
    cin>>a0;
    R[0]=a0;
    rep(i,n-1){
        ll a;
        cin>>a;
        R[i+1]=R[i]+a;
    }

    ll ans=101010101010;
    rep(i,n-1){
        ans=min(abs(R[n-1]-2*R[i]),ans);
    }
    cout<<ans<<endl;
}

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

static const int INF = 1e9+7;

vector<int> coin(4);
vector<int> rev(4);
map<int,int> ans;
map<int,int> mul;
int cnt;

int main(){

    mul[0] = 10;
    mul[1] = 50;
    mul[2] = 100;
    mul[3] = 500;

    int cnt = 0;

    while(1){
        int cur;
        cin>>cur;
        if(cur == 0) break;
        for(int i=0; i<4; i++) cin>>coin[i];
        for(int i=0; i<4; i++) rev[i] = 0;

        int sum = 0;
        for(int i=0; i<4; i++){
            sum += mul[i]*coin[i];
        }

        sum -= cur;

        for(int i=3; i>=0; i--){
            while(sum/mul[i] > 0){
                sum -= mul[i];
                rev[i]++;
            }
        }

        if(cnt != 0)cout<<endl;

        for(int i=0; i<4; i++){
            int dif = coin[i] - rev[i];
            if(dif <= 0) continue;
            cout<<mul[i]<<" "<<dif<<endl;
        }

        cnt++;
    }

    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  int A = 1;
  for(int i = 0; i < N; i++){
    if(K < A){
      A += K;
    }
    else{
      A = A * 2;
    }
  }
  cout << A << endl;
}

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

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

	int n;
	cin >> n;
	
	int i = 1, sum = 0;
	while (sum + i < n) {
		sum += i;
		i++;
	}
	
	cout << i;
}

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

long long a, b, n;

int main() {
    scanf("%lld%lld%lld", &a, &b, &n);
    long long t = min(b - 1, n);
    printf("%d\n", (long long)((double)a * t / b) 
            - a * (long long)((double)t / b));
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
using namespace std;
int main(){
  while(true){
    int n;cin>>n;
    bool ok = true;
    if(n==0){
      return 0;
    }
    int a[n+1];
    for(int i = 0; n+1 > i; i++){
        cin>>a[i];
    }
    for(int i = 0; n+1 > i; i++){
        int dou;
        if(i==0){
          dou = a[2]-a[1];
        }else if(i==1){
          dou = a[2]-a[0];
        }else{
          dou = a[1]-a[0];
        }
        ok = true;
        for(int j = (2>i?3:2); n+1 > j; j++){
            if(i==j)continue;

            //cout << j << " " << (j-1==i?j-2:j-1) << "->" << a[j]-a[(j-1==i?j-2:j-1)] << ":" << dou << endl;
            if(dou != a[j]-a[(j-1==i?j-2:j-1)]){
                ok = false;
                //break;
            }
        }
        if(ok){
          cout << a[i] << endl;
            break;
        }
    }
    if(ok){
      continue;
    }
  }
}


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

int main() {
  int K,N,a1,a,b,mx=0,ans=0;
  cin>>K>>N;
  cin>>a;
  a1=a;
  for(int i=1;i<N;i++){
    cin>>b;
    mx=max(mx,b-a);
    a=b;
  }
  mx=max(mx,K+a1-a);
  ans=K-mx;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
int main() {
	string n;
	cin >> n;
 
	for (int i = 0; i < 3; i++) {
		if (n[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
 
	}
 
	cout << "No" << endl;
 
	return 0;
}

Measured memory_bytes: 3628
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var count = one[1];
  var list = nextIntArray();
  var output = 0;
  var add = Math.min(N, count);
  
  for(var i = 1; i <= add; i++){
    for(var k = 1; k <= i; k++){
    //iは左から取る回数。
    var right = i - k;
    var get = [];
    for(var j = 0; j < k; j++){
      get.push(list[j]);
    }
    for(var j = 0; j < right; j++){
      get.push(list[N - j - 1]);
    }
    var remove = count - i;
    if(remove > 0){
      get.sort(function(a,b){
      	return a - b;
      });
      for(var j = 0; j < remove; j++){
        if(get[0] < 0){
          get.shift();
        }else{
          break;
        }
      }
    }
    var sum = 0;
    for(var j = 0; j < get.length; j++){
      sum += get[j];
    }
    output = Math.max(output, sum);
    }
  }
  myout(output);
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    ll N;
    cin >> N;
    ll ans = 1e18;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            ans = min(ans, i + N / i - 2);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3612
def abc_3() :
	H, W = map(int, input().split())
	print (min(div_s1(H, W), div_s1(W, H), div_s2(H, W), div_s2(W, H)))

def div_s1(H, W) :
	min_diff = 10000000000
	for w in range(1, W) :
		s1 = w * H
		s2 = ((W - w) // 2) * H
		s3 = W * H - s2 - s1
		diff = max(s1, s2, s3) - min(s1, s2, s3)
		if diff < min_diff :
			min_diff = diff
	return min_diff

def div_s2(H, W) :
	min_diff = 10000000000
	for w in range(1, W) :
		s1 = w * H
		s2 = (W - w) * (H // 2)
		s3 = W * H - s2 - s1
		diff = max(s1, s2, s3) - min(s1, s2, s3)
		if diff < min_diff :
			min_diff = diff
	return min_diff

#for i in range(5) :
#	abc_3()
#	print ('input:', end = '')
#	if input() == 'q' :
#		exit()

abc_3()

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

#define ll long long 

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

    int k; cin >> k;
    // make all numbers
    queue<ll> q;
    vector<ll> ans;
    if (k <= 9) {
        cout << k << endl;
        return 0;
    }

    for (int i = 1; i <= 9; i++) {
        q.push(i);
        ans.push_back(i);
    }

    while (true) {
        ll x = q.front(); q.pop();
        for (int i = -1; i <= 1; i++) {
            if ((x % 10) + i >= 0 and (x % 10) + i <= 9) {
                ll y = x * 10 + (x % 10) + i;
                q.push(y);
                ans.push_back(y);
            }
        }

        if ((int) ans.size() >= k) {
            cout << ans[k-1] << endl;
            return 0;
        }


    }


    return 0; 
}



Measured memory_bytes: 4684
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
string s;
int a=0;
signed main()
{
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='x'){
			a++;
		}
	}
	if(a>=8){
		cout<<"NO";
	}else{
		cout<<"YES";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int n = s.size();
    bool ans = true;
    string t = s;
    reverse(ALL(t));
    if(s != t) ans = false;
    string a, b;
    int m = n / 2;
    a = s.substr(0, m);
    b = a;
    reverse(ALL(b));
    if(a != b) ans = false;
    if(n % 2 == 1) m++;
    a = s.substr(m, n);
    b = a;
    reverse(ALL(b));
    if(a != b) ans = false;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int M=50;
const int N=1010;
int x[N],y[N];
int abs(int x)
{
	return x>0?x:-x;
}
int t;
int d[M];
char ans[N][M];
int n;
void gao(int k)
{
	t++;
	d[t]=k;
	for(int i=1;i<=n;i++)
		if(abs(x[i])>abs(y[i]))
		{
			if(x[i]>0)
			{
				x[i]-=k;
				ans[i][t]='R';
			}
			else
			{
				x[i]+=k;
				ans[i][t]='L';
			}
		}
		else
		{
			if(y[i]>0)
			{
				y[i]-=k;
				ans[i][t]='U';
			}
			else
			{
				y[i]+=k;
				ans[i][t]='D';
			}
		}
}
int main()
{
	//open2("d");
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=30;i>=1;i--)
	{
		int k=(1<<i);
		bool tf=false;
		for (int u=1;u<=n;u++)
		{
			if (abs(x[u])>k) tf=true;
			if (abs(y[u])>k) tf=true;
		}
		if (tf)	gao(k);
		tf=false;
		for (int u=1;u<=n;u++)
		{
			if (abs(x[u])>k) tf=true;
			if (abs(y[u])>k) tf=true;
		}
		i=i+tf;
	}
	//for (int u=1;u<=n;u++) printf("%d %d\n",x[u],y[u]);
	int tt=t;
	for(int i=1;i<=39-tt;i++)
		gao(1);
	if(x[1]||y[1])
		gao(1);
	//for (int u=1;u<=n;u++) printf("%d %d\n",x[u],y[u]);
	for(int i=1;i<=n;i++)
		if(x[i]||y[i])
		{
			printf("-1\n");
			return 0;
		}
	printf("%d\n",t);
	for(int i=1;i<=t;i++)
		printf("%d ",d[i]);
	printf("\n");
	for(int i=1;i<=n;i++)
		printf("%s\n",ans[i]+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, L;
  cin >> N >> L;
  vector<int> a(N);
  rep(i, N)
  {
    cin >> a[i];
  }
  int last = -1;
  rep(i, N - 1)
  {
    if (a[i] + a[i + 1] >= L)
    {
      last = i + 1;
      break;
    }
  }

  if (last == -1)
    cout << "Impossible" << endl;
  else
  {
    cout << "Possible" << endl;
    for (int l = 1; l < last; l++)
    {
      cout << l << endl;
    }
    for (int r = N - 1; r >= last; r--)
    {
      cout << r << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main(void)
{
	int n;
	int d;
	int i, j, k;
	int x[15][15];
	int sum;
	int a, jou, su = 1, co;

	sum = jou = co = 0;
	scanf("%d %d", &n, &d);
	for (i = 0; i < n; i++) {
		for (j = 0; j < d; j++) {
			scanf("%d", &x[i][j]);
		}
	}
	for (i = 0; i < n - 1; i++) {
		for (k = i + 1; k < n; k++) {
			for (j = 0; j < d; j++) {
				a = x[i][j] - (x[k][j]);
				sum += a * a;//2乗だから+になる
			}
			jou = 0;
			su = 1;
			while (sum > jou) {
				jou = su * su;
				su++;
				if (sum == jou) {
					co++;
				}
			}
			sum = 0;
		}
	}
	printf("%d\n", co);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
struct UnionFind{
	vector<int> par,rank;
	UnionFind(int N){
		par.assign(N,0);
		rank.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]) swap(x,y);

		//x becomes root
		par[y]=x;
		if(rank[x]==rank[y]) rank[x]++;
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N,M;
	cin >> N >> M;
	V<ll> a(N);
	rep(i,N) cin >> a[i];
	UnionFind UF(N);
	rep(i,M){
		int x,y;
		cin >> x >> y;
		UF.unite(x,y);
	}
	if(M == N-1){
		cout << 0 << endl;
		return 0;
	}
	map<int,V<ll>> mp;
	rep(v,N) mp[UF.find(v)].pb(a[v]);
	int K = mp.size();
	V<ll> al;

	ll ans = 0;

	for(auto it: mp){
		auto v = it.sc;
		sort(all(v));
		ans += v[0];
		rep1(i,v.size()-1) al.pb(v[i]);
	}
	sort(all(al));
	if(al.size() < K-2){
		cout << "Impossible" << endl;
		return 0;
	}
	rep(i,K-2) ans += al[i];
	cout << ans << endl;
}


Measured memory_bytes: 12800
n, m = map(int,input().split())
pena_list = [[0, 0] for i in range(n)]
ac = 0
wa = 0
teishutu = []

for i in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC' and pena_list[p-1][0] == 0:
        ac += 1
        wa += pena_list[p-1][1]
        pena_list[p-1][0] = 1
    elif s == 'WA':
        pena_list[p-1][1] += 1

print(ac, wa)


Measured memory_bytes: 13172
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int y=s.size();
  int a=0;
  for(int i=0;i<y;i++){
    char x=s[y-1];
    for(int j=0;j<y-1;j++){
      s[y-j-1]=s[y-j-2];
    }
    s[0]=x;
    if(s==t){
      a++;
    }
  }
  if(a>0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
  int i,j,k,n,x,t,e,ans=-1;
  scanf("%d %d %d",&n,&t,&e);
 
  for(i=0;i<n;i++){
    scanf("%d",&x);
    for(j=-e;j<=e;j++){
      if(!((t+j)%x)){
	ans=i+1;
	break;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}
 

Measured memory_bytes: 596
line = input()
N = int(line)
line = input()
H = list(map(int, line.split()))

count = 1
for index, height in enumerate(H):
    tmp_count = 0
    if index == 0:
        continue
    for i in range(0,index):
        if H[i] > H[index]:
            continue
        tmp_count += 1
    if tmp_count == index:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    char op;
    while(true){
        cin >> a >> op >> b;
        if(op == '?') break;
        
        if(op == '+'){
            cout << a + b << endl;
        }else if(op == '-'){
            cout << a - b << endl;
        }else if(op == '*'){
            cout << a * b << endl;
        }else if(op == '/'){
            cout << a / b << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
int a[1001];
vi adj[1001];
int s[1001];

void dfs(int u, int p)
{
	vector<int> dp(5001,int(1e9));
	dp[0]=0;
	for(int i=0;i<adj[u].size();i++)
	{
		int v=adj[u][i];
		dfs(v,u);
		vector<int> dp2(5001,int(1e9));
		for(int j=0;j<=5000;j++)
		{
			if(j-a[v]>=0)
			{
				dp2[j] = min(dp2[j],dp[j-a[v]]+s[v]);
			}
			if(j-s[v]>=0)
			{
				dp2[j] = min(dp2[j],dp[j-s[v]]+a[v]);
			}
		}
		dp=dp2;
	}
	s[u]=int(1e9);
	for(int i=0;i<=a[u];i++)
	{
		//cerr<<u<<' '<<i<<' '<<dp[i]<<'\n';
		s[u]=min(s[u],dp[i]);
	}
	//cerr<<u<<' '<<s[u]<<'\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int p; cin>>p;
		p--;
		adj[p].pb(i+1);
	}
	for(int i=0;i<n;i++) cin>>a[i];
	dfs(0,-1);
	if(s[0]>=int(1e9))
	{
		cout<<"IMPOSSIBLE\n";
	}
	else
	{
		cout<<"POSSIBLE\n";
	}
}


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

void matrix_like_computation(const int);
void listen_input(int *[],const int);
void calc_sums(int *[],const int);
void echo_matrix(int *[],const int);

int main()
{
	int data_count;
	while(scanf("%d",&data_count),data_count)
	{
		matrix_like_computation(data_count);
	}
	
	return 0;
}

void matrix_like_computation(const int data_count)
{
	int prep_roop;
	int matrix[11][11];
	int *export_matrix[11];
	for(prep_roop=0;prep_roop<11;prep_roop++)
	{
		export_matrix[prep_roop]=matrix[prep_roop];
	}
	listen_input(export_matrix,data_count);
	calc_sums(export_matrix,data_count);
	echo_matrix(export_matrix,data_count);
}

void listen_input(int* matrix[],const int data_count)
{
	int ver_count,hor_count;
	char input_buff[64];
	
	for(ver_count=0;ver_count<data_count;ver_count++)
	{
		while
		(
			fgets(input_buff,sizeof(input_buff),stdin),
			!strcmp(input_buff,"\n")
		);
		matrix[0][ver_count]=atoi(strtok(input_buff," "));
		for(hor_count=1;hor_count<data_count;hor_count++)
		{
			matrix[hor_count][ver_count]=atoi(strtok(NULL," "));
		}
	}
}

void calc_sums(int *matrix[],const int data_count)
{
	int ver_count,hor_count,ver_sum,hor_sum,all_sum=0;
	
	//横と全合計
	for(ver_count=0;ver_count<data_count;ver_count++)
	{
		hor_sum=0;
		for(hor_count=0;hor_count<data_count;hor_count++)
		{
			hor_sum+=matrix[hor_count][ver_count];
			all_sum+=matrix[hor_count][ver_count];
		}
		matrix[data_count][ver_count]=hor_sum;
	}
	matrix[data_count][data_count]=all_sum;
	
	//縦
	for(hor_count=0;hor_count<data_count;hor_count++)
	{
		ver_sum=0;
		for(ver_count=0;ver_count<data_count;ver_count++)
		{
			ver_sum+=matrix[hor_count][ver_count];
		}
		matrix[hor_count][data_count]=ver_sum;
	}
}
void echo_matrix(int *matrix[],const int data_count)
{
	int ver_count,hor_count;
	for(ver_count=0;ver_count<=data_count;ver_count++)
	{
		for(hor_count=0;hor_count<=data_count;hor_count++)
		{
			printf("%5d",matrix[hor_count][ver_count]);
		}
		printf("\n");
	}
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

class Human {
public:
    queue<int> a;

    Human(VLL _a) {
        REP(i, _a.size()) a.push(_a[i]);
    }

    int next() {
        if(a.empty()) return -1;
        int res = a.front();
        a.pop();

        return res;
    }
};

set<int> used_list;
vector<Human> memo[301];

void solve(long long N, long long M, std::vector<std::vector<long long>> A){
    REP(i, N) {
        Human human(A[i]);
        int idx = human.next();
        memo[idx].PB(human);
    }

    int result = INF;
    REP(i, M) {
        int target_idx = 0;
        int max_size = 0;

        REP1(j, M+1) {
            if (max_size < (int) (memo[j].size())) {
                target_idx = j;
                max_size = memo[j].size();
            }
        }

        result = min(result, max_size);
        bool valid = true;
        used_list.insert(target_idx);

        REP(j, memo[target_idx].size()) {
            while(true) {
                int next_idx = memo[target_idx][j].next();
                if(next_idx == -1) {
                    cout << result << endl;
                    return;
                }
                if(used_list.count(next_idx) == 0) {
                    memo[next_idx].PB(memo[target_idx][j]);
                    break;
                }
            }
        }

        memo[target_idx].clear();
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(M));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            scanf("%lld",&A[i][j]);
        }
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 10880
#include <iostream>

using namespace std;

bool card[4][14];
char marks[]={'S', 'H', 'C', 'D'};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	char mark;
	int num;
	cin>>n;
	for(int i=0; i<n; i++) {
		cin>>mark>>num;
		if     (mark=='S') card[0][num]=true;
		else if(mark=='H') card[1][num]=true;
		else if(mark=='C') card[2][num]=true;
		else if(mark=='D') card[3][num]=true;
	}
	for(int i=0; i<4; i++) {
		for(int j=1; j<=13; j++) {
			if(!card[i][j]) cout<<marks[i]<<' '<<j<<'\n';
		}
	}
	return 0;
}



Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    for (int i=0; i<3; i++) {
        if (s[i] == s[i+1]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int i, n, arr[100];
	int rInd=0;
	int left=0, right=0;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &arr[i]);
		right+=arr[i];
	}
	int ans=100000;
	while(rInd<n){
		ans=min(ans, abs(left-right));
		//printf("actual ans: %d-%d: %d\n", left, right, left-right);
		left+=arr[rInd];
		right-=arr[rInd++];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())

# https://tmori-banner.com/abc168/
# http://dorilu.net/blog/?th=2008100100
# 1週を60分するうちのm分時
tyousin = M*360/60
# 1週を12時間かけるうちのh時　長針に影響される部分
tansin = H*360/12 + M*360/60/12
 
kakudosa = tyousin - tansin
# https://sci-pursuit.com/math/radian.html
# 度をラジアンに変換
result_root = A**2 + B**2 - 2*A*B*math.cos(math.radians(kakudosa))
# 予言定理のあれで平方根が辺の長さ
print(math.sqrt(result_root))

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

using namespace std;

using ll=long long;

const ll inf = 1e9;

int main(){
    ios::sync_with_stdio(false);
    int n,m,l,k,a,h;
    while(cin>>n>>m>>l>>k>>a>>h,m){
        vector<ll>cap{a,h};
        vector<vector<ll>>dist(n,vector<ll>(n,inf));
        for(int i=0;i<l;++i){
            int ca;
            cin>>ca;
            cap.push_back(ca);
        }
        for(int i=0;i<k;++i){
            int u,v,c;
            cin>>u>>v>>c;
            dist[u][v]=c;
            dist[v][u]=c;
        }
        for(int k=0;k<n;++k){
            for(int i=0;i<n;++i){
                for(int j=0;j<n;++j){
                    if(dist[i][j] > dist[i][k]+dist[k][j]){
                        dist[i][j]=dist[i][k]+dist[k][j];
                    }
                }
            }
        }
        vector<vector<ll>>d(l+2,vector<ll>(l+2,inf));
        for(int i=0;i<cap.size();++i){
            for(int j=0;j<cap.size();++j){
                d[i][j]=dist[cap[i]][cap[j]];
                if(d[i][j]>m)d[i][j]=inf;
            }
        }
        for(int k=0;k<l+2;++k){
            for(int i=0;i<l+2;++i){
                for(int j=0;j<l+2;++j){
                    if(d[i][j] > d[i][k]+d[k][j]){
                        d[i][j]=d[i][k]+d[k][j];
                    }
                }
            }
        }
        if(d[0][1]>=inf)cout<<"Help!"<<endl;
        else{
            ll ans=max((ll)0,d[0][1]-m);
            cout<<ans+d[0][1]<<endl;
        }
    }
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = 1; ;i++){
        if(k*i > b){
            break;
        }
        if(a <= k * i && k * i <= b){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

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

int main(){
  string s = "QWERTYUIOPASDFGHJKLZXCVBNM";
  char c;
  cin >> c;
  string ans = "a";
 for(int i = 0; i < s.size(); i++){
   if(c == s[i]) {ans = "A"; break;}
 }
 cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    int N;
    cin >> N;
    VI A(N);
    map<int, int> count;
    for(int i=1; i<N; i++){
        cin >> A[i];
        count[A[i]]++;
    }
    rep(i,N){
        cout << count[i+1] << endl;
    }
}


Measured memory_bytes: 13520
n = int(input())
l = list(map(int, input().split()))
ll = len(l)
res = 0
ans = 10000000000
 
for i in range(1, 101):
    for j in range(ll):
        res += (l[j] - i)**2
    ans = min(ans, res)
    res = 0
 
print(ans)

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

#define    ll     long long int

string s, t, mx;

int isOk(string a, string b)
{
    int i, l = (int) a.size();
    for (i = 0; i < l; i++) {
        if (a[i] == '?' || a[i] == b[i]) {
            continue;
        }
        return 0;
    }
    return 1;
}

string makeIt(string s)
{
    int i, l = (int) s.size();
    for (i = 0; i < l; i++) {
        if (s[i] == '?')
            s[i] = 'a';
    }
    return s;
}

int main( )
{
    int ls, lt, i, j, k;
    for (i = 0; i < 52; i++) {
        mx.push_back('z');
    }
    cin >> s >> t;
    ls = (int) s.size();
    lt = (int) t.size();
    for (i = 0; i + lt - 1 < ls; i++) {
        string sub = s.substr(i, lt);
        //cout << sub << ' ' << t << '\n';
        if (isOk(sub, t)) {
            string tmp = s.substr(0, i) + t + s.substr(i + lt, ls - lt - i);
            mx = min(mx, makeIt(tmp));
        }
    }
    if ((int) mx.size() > ls ) {
        cout << "UNRESTORABLE\n";
    }
    else {
        cout << mx << '\n';
    }
    return 0;
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    
    vector< complex< double > > P(N);

    for (auto &p : P) p = {input< double >(), input< double >()};

    auto r = [&](complex< double > p) {
        double res = 0;
        for (auto &c: P) {
            chmax(res, abs(p - c));
        }
        
        return res;
    };

    auto f = [&](double x) {
        double ly = 0, ry = 1000;
        range(_, 0, 100) {
            double mly = (2 * ly + ry) / 3;
            double mry = (ly + 2 * ry) / 3;

            if (r({x, mly}) > r({x, mry})) ly = mly;
            else ry = mry;
        }

        return r({x, ly});
    };
    
    double lx = 0, rx = 1000;
    range(_, 0, 100) {
        double mlx = (2 * lx + rx) / 3;
        double mrx = (lx + 2 * rx) / 3;

        if (f(mlx) > f(mrx)) lx = mlx;
        else rx = mrx;
    }

    
    cout << f(lx) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline

def check(i, j):
    global grid
    if grid[i][j] == '#':
        return '#'
    cnt = 0
    for k in range(-1, 2):
        for l in range(-1, 2):
            cnt += grid[i+k][j+l] == '#'
    return str(cnt)

def main():
    global grid
    H, W = map(int, readline().split())
    grid = []
    grid.append(['*']*(W+2))
    for _ in range(H):
        grid.append(['*'] + list(readline()[:-1]) + ['*'])
    grid.append(['*']*(W+2))

    for i in range(1, H+1):
        for j in range(1, W+1):
            grid[i][j] = check(i, j)
    
    for i in range(1, H+1):
        print(''.join(grid[i][1:W+1]))
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 2*1e5+5;

vector<int> h, b;

int bit[MAXN];

void update(int x, int u) {
	while(x < MAXN) {
		bit[x] = max(bit[x], u);
		x += x & -x;
	}
}

int query(int x) {
	int mx = 0;
	while(x > 0) {
		mx = max(bit[x], mx);
		x -= x & -x;
	}
	return mx;
}

int32_t main() {
	
	FAST;
	int n;
	cin >> n;
	h.resize(n);
	b.resize(n);
	
	for(int i = 0; i < n; i++)
		cin >> h[i];
	for(int &i : b)
		cin >> i;
	
	for(int i = 0; i < n; i++)
		update(h[i], query(h[i]-1) + b[i]);
			
	cout << query(MAXN-1) << endl;
}


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

int main(){
  int n,T,i;
  cin>>n>>T;
  int c[n],t[n];
  for(i=0;i<n;i++)cin>>c[i]>>t[i];
  int cnt=0;
  int p[n];
  for(i=0;i<n;i++){
    if(t[i]<=T){
      p[cnt]=c[i];
      cnt++;
    }
  }
  if(cnt==0){
    cout<<"TLE";
  }else{
    sort(p,p+cnt);
    cout<<p[0];
  }
}

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

using namespace std;

int main() {
    int q; cin >> q;
    long a, b;
    cin >> a >> a >> b;
    multiset<long> alist;
    alist.insert(a);
    auto center = alist.begin();
    int len = 1;
    long sum = b;
    for (int i = 1; i < q; i++) {
        // cerr << "center " << *center << ' ' << sum << '\n';
        int type; cin >> type;
        if (type == 1) {
            cin >> a >> b;
            sum += abs(*center - a) + b;
            alist.insert(a);
            if (len%2 == 1 && a < *center) 
                center--;
            else if (len%2 == 0 && a >= *center) {
                long prev = *center;
                center++;
                sum -= *center - prev;
            }
            len++;
        } else
            cout << *center << ' ' << sum << '\n';
    }
    return 0;
}


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

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	ll N;
	cin >>N;
	ll S=0;
	Rep1(i, N) {
		if (0==i%3)
			continue;
		if (0==i%5)
			continue;
		S+=i;
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 3592