akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemA solver = new ProblemA();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			char[] s = in.next().toCharArray();
			int ans = 0;
			int b = 0;
			for (int i = s.length - 1; i >= 0; i--) {
				if (s[i] == 'T') {
					++b;
				} else if (b == 0) {
					++ans;
				} else {
					--b;
				}
			}
			out.println(ans * 2);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}



Measured memory_bytes: 12116
#include <stdio.h>
int main(void){
  int n,y,a,b,c,z,A,B,C;
  scanf("%d %d",&n,&y);
  A=-1; B=-1; C=-1;
  for(a=0;a<=n;a++){
    for(b=0;b<=(n-a);b++){
      c=n-a-b;
	  z=a*10000+b*5000+c*1000;
	  if(z == y){
	    A=a; B=b; C=c;
	  }
	}
  }
  printf("%d %d %d",A,B,C);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	LL N, ans = 0;
	cin >> N;
	for(LL i = N; i; i = N / (N / i + 1)){
		LL R = N / i;
		LL A = (N % i == 0) ? i - (R - N % i) / R : 0;
		if(A > N / (N / i + 1)) {
			ans += A;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	int A;
	int B[3];
	int ans;
	string S;

	cin >> S;
	A = S[0] - '0';
	for (int i = 0; i < 3; i++)
	{
		B[i] = S[i + 1] - '0';
	}
	
	for (int msk = 0; msk < (1<<3); msk++)
	{
		int N = A;
		for (int i = 0; i < 3; i++)
		{
			if (msk&(1 << i)) {
				N += B[i];
			}
			else {
				N -= B[i];
			}
		}
		if (N == 7) {
			ans = msk;
			break;
		}
	}

	cout << A;
	for (int i = 0; i < 3; i++)
	{
		if (ans&(1 << i)) {
			cout << '+';
		}
		else {
			cout << '-';
		}
		cout << B[i];
	}
	cout << "=7" << endl;
	return 0;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//関係性は隣接行列で記録
//過半数：N/2.0で判定
//ある量からある量を引く系の問題：端から定義してやる
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

int main() {
	ll N; cin >> N;
	vector<string> S(N); rep(i, N)cin >> S[i];

	map<string, ll> p;
	rep(i, N) p[S[i]] = 1;


	ll cnt = 0;
	auto begin = p.begin(), end = p.end();
	for (auto it = begin; it != end; it++) {
		cnt++;
	}

	cout << cnt << endl;
//mapのキー：it->first mapのバリュー：it->second
}
	

Measured memory_bytes: 32984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
#define vi vector<long long>
#define pi pair<long long, long long>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define FAST_LOG2(x) (sizeof(unsigned long)*8 - 1 - __builtin_clzl((unsigned long)(x)))
#define clog2(x) (((x) - (1 << FAST_LOG2(x))) ? FAST_LOG2(x) + 1 : FAST_LOG2(x))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18;
const ll N = (1<<5);
const double PI = 3.1415926535897;

double a, b, x, ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    cin >> a >> b >> x;
    double h = x/(a*a);
    if(x==a*a*b/2){
        cout << 45;
    }
    else if(x>a*a*b/2){
        ans = atan(2*(b-h)/a);
        cout << fixed << setprecision(9) << ans*180.0/PI;
    }
    else{
        ans = atan(2*a*h/(b*b));
        cout << fixed << setprecision(9) << 90.0-ans*180.0/PI;
    }

}




Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<algorithm>
#define il inline
#define rg register
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long ll;
const int O=100010;
il int gi(){
	rg int o=0,fl=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')fl=-1,ch=getchar();
	while(isdigit(ch))o=o*10+ch-'0',ch=getchar();
	return o*fl;
}
ll n,a[O],tree[O<<1],sum[O],l=0x3f3f3f3f,r,ans;
il void add(int x,ll v){
	for(;x<=2e5;x+=lowbit(x))tree[x]+=v;
}
il int query(int x){
	int tot=0;
	for(;x;x-=lowbit(x))tot+=tree[x];
	return tot;
}
il bool check(int x){
	memset(tree,0,sizeof(tree));
	ans=0;
	for(int i=1;i<=n;++i)
		sum[i]=sum[i-1]+(a[i]>=x?1:-1);
	for(int i=0;i<=n;++i){
		ans+=query(sum[i]+O);
		add(sum[i]+O,1ll);
	}
	return ans>=n*(n+1)>>2;
}
int main( ){
	n=gi();
	for(int i=1;i<=n;++i){
		a[i]=gi();
		l=min(l,a[i]);
		r=max(r,a[i]);
	}
#define mid (l+r>>1)
	while(l<=r)
		if(check(mid))l=mid+1;
		else r=mid-1;
	printf("%lld\n",r);
#undef mid
	return 0;
}


Measured memory_bytes: 3328
from fractions import gcd

N, K = map(int, input().split())
A = list(map(int,input().split()))

g = A[0]
for i in range(1, N):
  g = gcd(g, A[i])

if K > max(A):
  print("IMPOSSIBLE")
elif K % g != 0:
  print("IMPOSSIBLE")
else:
  print("POSSIBLE")

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    if(n < 2){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        if(s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 1000000007
#define eps 1e-8
struct node{int to,nxt;}sq[10010];
int n,all=0,head[5050],siz[5050];
ll cnt[5050],dp[5050][5050],tmp[5050];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void add(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void dfs(int u,int fu)
{
	siz[u]=1;dp[u][1]=1;
	for (int i=head[u];i;i=sq[i].nxt)
	{
		int v=sq[i].to;
		if (v==fu) continue;dfs(v,u);
		rep(i,1,siz[u]+siz[v]) tmp[i]=0;
		rep(i,1,siz[u])
			rep(j,0,siz[v])
				tmp[i+j]=(tmp[i+j]+dp[u][i]*dp[v][j])%maxd;
		rep(i,1,siz[u]+siz[v]) dp[u][i]=tmp[i];
		siz[u]+=siz[v];
	}
	rep(i,0,siz[u]) 
	{
		if (i&1) continue;
		dp[u][0]=(dp[u][0]+dp[u][i]*cnt[i])%maxd;
	}
	dp[u][0]=maxd-dp[u][0];
}
		

int main()
{
	n=read();cnt[0]=1;
	rep(i,1,n-1)
	{
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	rep(i,2,n) 
	{
		if (i&1) continue;
		cnt[i]=cnt[i-2]*(i-1)%maxd;
	}
	dfs(1,0);
	printf("%lld",maxd-dp[1][0]);
	return 0;
}


Measured memory_bytes: 198528
#include <bits/stdc++.h>
using namespace std;
int n, k;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> k;
	int arr[n+1];
	vector<bool>dp(k+1, false);
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	for(int i=1;i<=k;i++){
		for(int j=1;j<=n;j++){
			if(arr[j]>i){
				break;
			}
			if(!dp[i-arr[j]]){
				dp[i]=true;
				break;
			}
		}
	}
	if(dp[k]){
		cout << "First" << '\n';
	}
	else{
		cout << "Second" << '\n';
	}
}

Measured memory_bytes: 256
import bisect

INF = 2 ** 60

A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    a, c = b - 1, d - 1
    res = INF
    for S in s[a:b+1]:
        for T in t[c:d+1]:
            d1 = abs(S - x) + abs(T - S)
            d2 = abs(T - x) + abs(T - S)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 79192
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int>>;
constexpr int TBC= -1;

void dfs(const Graph &dag, int from, vector<int> *dp){
  if(dp->at(from) != TBC){ return; }
  else{
    int ans_from= 0;
    for(auto to:dag.at(from)){
      dfs(dag, to, dp);
      ans_from= max(ans_from, dp->at(to)+ 1);
    }
    dp->at(from)= ans_from;
  }
}

int main(){
  int N,M;
  cin >> N >> M;

  Graph dag(N);
  int from,to;
  for(int j=0; j<M; j++){
    cin >> from >> to;
    from--; to--; // 1-indexed -> 0-indexed
    dag.at(from).emplace_back(to);
  }

  vector<int> dp(N, TBC); // dp.at(v): vを始点とするpathの最長長さ
  for(int v=0; v<N; v++){
    dfs(dag, v, &dp);
  }

  int ans= -1;
  for(int v=0; v<N; v++){
    ans= max(ans, dp.at(v));
  }

  cout << ans << endl;
}

Measured memory_bytes: 12380
#include<stdio.h>
int main(){
    int w, h, x, y, r;
    scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
    if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) printf("Yes\n");
    else printf("No\n");
}



Measured memory_bytes: 2148
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }
fn main() {
    input!(n: usize, d: usize, pos: [(i64, i64); n]);

    let mut counter = 0;
    for (x, y) in pos {
        if (x * x + y * y) as usize <= (d * d) {
            counter += 1;
        }
    }

    println!("{}", counter);
}


Measured memory_bytes: 5144
def solve() -> int:
    from collections import defaultdict

    mod = 10 ** 9 + 7

    n = int(input())
    a = tuple(map(int, input().split()))

    d = defaultdict(int)

    for a_ in a:
        d[a_] += 1
        if d[a_] > 2:
            return 0

    q, r = divmod(n, 2)
    if r == 1:
        if d[0] != 1:
            return 0
        cur = 2
        while cur < n:
            if d[cur] != 2:
                return 0
            cur += 2
        return (1 << q) % mod
    else:
        cur = 1
        while cur < n:
            if d[cur] != 2:
                return 0
            cur += 2
        return (1 << q) % mod


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 14824
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int func(int N)
{
        if (N < 10)
                return N;
        return func(N / 10) + N % 10;
}

int main()
{
        int N, L;
        cin >> N >> L;

        vector<string> S(N + 1);

        rep(i, N) cin >> S[i];
        sort(S.begin(), S.begin()+N);
        string ans ="";

        rep(i, N)
        {
                ans += S[i];
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)

using namespace std;
typedef long long ll;
 
int main(){
  int n;
  cin>>n;
  double val[n];
  rep(i, n){
    double a;
    cin>>a;
    val[i]=a;
  }
  
  double sum=0;
  rep(i, n){
    sum+=(double)1.0/val[i];}
  
  double ans=(double)1.0/sum;
  
cout<<fixed;
std::cout << std::setprecision(6) <<ans<<endl; 
  return 0;
 
 
}

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

int main() {
  int N; cin >> N;
  vector<ll> A(N), F(N), B(N);
  rep(i, 0, N) cin >> A[i];
  F[0] = A[0];
  ll t = A[0];
  rep(i, 1, N) F[i] = t = __gcd(A[i], t);
  B[N-1] = A.back();
  t = A.back();
  rem(i, N - 2, 0) B[i] = t = __gcd(t, A[i]);
  ll ans = max(F[N-2], B[1]);
  rep(i, 1, N - 1) {
    ans = max(ans, __gcd(F[i-1], B[i+1]));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
import sys
from bisect import bisect_right as bisect
def main():
    input = sys.stdin.readline
    s = input()[:-1]
    t = input()[:-1]
#    S = "abcdefghijklmnopqrstuvwxyz"
    A = [[] for k in range(26)]
    for k in range(len(s)):
        A[ord(s[k])-97] += [k+1]
    ans = 0
    now = 0
    for k in range(len(t)):
        a = ord(t[k]) - 97
        if len(A[a]) == 0:
            print(-1)
            exit(0)
        if A[a][-1] <= now:
            ans += len(s)
            now = A[a][0]
        else:
            now = A[a][bisect(A[a],now)]
    print(ans+now)

if __name__ == '__main__':
    main()


Measured memory_bytes: 46192
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		int cnt = 0;
		int flag = 0;
		for(int i = 0; i < n; i++){
			a[i] = sc.nextLong();
			if(a[i] == 0){
				flag = 1;
			}else if(a[i] < 0){
				cnt++;
			}
		}
		if(cnt%2 == 0 || flag == 1){
			long ans = 0;
			for(int i = 0; i < n; i++){
				ans += Math.abs(a[i]);
			}
			System.out.print(ans);
		}else{
			long ans = 0;
			long min = 1000000005;
			for(int i = 0; i < n; i++){
				ans += Math.abs(a[i]);
				min = Math.min(Math.abs(a[i]),min);
			}
			min = min*2;
			ans -= min;
			System.out.print(ans);
		}
	}
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N];
int b[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	vector<int> ans;
	for(int i=n; i>0; i--){
		int cnt = 0;
		for(int j=i; j<=n; j+=i){
			cnt += (b[j] == 1);
		}
		if (cnt%2 != a[i]) {
			b[i] = 1;
			ans.push_back(i);
		} 
	}
	cout << ans.size() << endl;
	for(auto x:ans) cout << x << ' ';

	return 0;
}


Measured memory_bytes: 2936
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")
 
#include <bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define f first
#define s second
#define y1 asafsaf
#define kz ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
 
const int N = 3e5 + 111, inf = 1e9, mod = 1e9 + 7;
const ll linf = 1e18;
const double pi = acos(-1.0);
 
int n;
set <int> s;
 
int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        int x;
        scanf("%d", &x);
        if(s.find(x) != s.end())
            s.erase(x);
        else s.insert(x);
    }
    cout << s.size();
    return 0;
}

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

#define ll long long
#define ar array

int main() {

    ios::sync_with_stdio(false);
	
	int a, b;
	
	cin >> a >> b;
	
	if (a > 8 || b > 8){
		cout << ":(" << endl;
	}
	else{
		cout << "Yay!" << endl;
	}

    return 0;
}


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

const int maxn = 2e5;
int n, a[maxn];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    a[i] -= i;
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += abs((long long)a[n / 2] - a[i]);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch){
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]){
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++){
        sum += p*(getChar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M - 1));}

int find(char str[]){
    long long key, i, h;
    key = getKey(str); // 文字列を数値に変換
    for (i = 0; ; i++){
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]){
    long long key, i, h;
    key = getKey(str); // 文字列を数値に変換
    for (i = 0; ; i++){
        h = (h1(key) + i*h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i=0; i<M; i++) H[i][0] = '\0';
    cin >> n;
    for (i = 0; i<n; i++){
        scanf("%s %s", com, str); // より高速な入力scanfを使用
        if (com[0] == 'i'){
            insert(str);
        }else {
            if (find(str)){
                cout << "yes" << endl;
            }else {

                cout << "no" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17560
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y,w;
    char hoge;
    cin>>w>>a>>b;
    ll al,bl;
    al=a+w;
    bl=b+w;
    if(a<=bl&&b<al||b<=al&&a<bl) cout<<0<<endl;
    else {
        cout<<min(abs(b-al),abs(a-bl))<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; cin >> n;
  unordered_map<string,int> str;
  ll ans  = 0;

  rep(i,n){
    string s; cin >> s;
    sort(all(s));
    if(str.count(s)){
      ans += str[s];
      str[s]++;
    }else{
      str[s]=1;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 10400
/**
 *   author: Shubham Srivastava
 *   created: 01 September 2019  17:35:02
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a,b;cin>>a>>b;
    double ans = ceil((b-a)/(double)(a-1));
    cout<<ans+1;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> s;

  int ans = 0;
  FOR(i, 1, n) {
    int t = 0;
    REP(j, n - i) {
      if(s[j] == s[j + i]) {
        t++;
        t = min(i, t);
        ans = max(ans, t);
      } else {
        t = 0;
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector <vll> vvll;
typedef pair <ll,ll> pll;
typedef vector <pll> vpll;

#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define newl '\n'
#define gcd __gcd
#define fo(i,k,n) for(ll i=k;i<n;i++)
#define rev(i,k,n) for(ll i=k;i>n;i--)
#define MOD 1000000007 //10^9 + 7
#define deb(x) cout<<x<<" "<<#x<<newl
#define all(x) x.begin(),x.end()
#define print(x) for(auto i=x.begin();i!=x.end();i++)cout<<*i<<' ';cout<<endl;

ll INF = 1000000000000000005LL;

ll power(ll x, ll y, ll p=MOD){ //positive y
    ll res = 1;
    x = x % p; 
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

ll inverse(ll a,ll m=MOD){
    return power(a,m-2,m);
}

vvll matmul(const vvll &a,const vvll &b,ll M=MOD){
    ll n=a.size(),m=a[0].size(),l=b[0].size();
    assert(m==b.size());
    vvll c(n,vll(l,0));
    fo(i,0,n)
    fo(j,0,l)
    fo(k,0,m)
    {
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%M;
    }
    return c;
}

vvll matpow(vvll a,ll p,ll M=MOD){
    assert(a.size()==a[0].size());
    ll n=a.size();
    vvll res(n,vll(n,0));
    fo(i,0,n)   res[i][i]=1;
    while(p>0)
    {
        if(p&1) res=matmul(res,a,M);
        a=matmul(a,a,M);
        p>>=1;
    }
    return res;
}

void solve(){
    ll n;
    cin>>n;

    if(n>=30) cout<<"Yes";
    else cout<<"No";
}

int main() {
    
    // fast io
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    //Number of Test cases
    ll T=1; 
    //cin>>T;
    
    while(T--){
        solve();
    }
    
    return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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() {
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
};


Measured memory_bytes: 256
import math
K=int(input())
A_lst=[int(_) for _ in input().split() ]

failed=False
if A_lst[-1]!=2:
    failed=True
else:
    stt, end=2,4
    for a in A_lst[-2::-1]:
        #print(stt, end, a)
        stt=a*math.ceil(stt/a)
        if stt>= end:
            failed=True
            break
        end=a*math.ceil(end/a)

if failed:
    print(-1)
else:
    print(stt, end-1)

Measured memory_bytes: 14408
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d",&a,&b);
	c=a*b;
	
	if(c%2==0){
		printf("\nEven\n\n");
	}else if(c%2==1){
		printf("\nOdd\n\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
N, K = map(int,input().split())
A = list(map(int,input().split()))

MOD = 1000000007

count1 = [0] * N
count = [0] * N
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            if i < j:
                count1[i] += 1
            count[i] += 1

result = 0
for i in range(N):
  result += count1[i] * K
  result %= MOD
  result += K * (K - 1) // 2 * count[i]
  result %= MOD

print(result)



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

#define STRLEN_MAX 200001

int	main(void)
{
  char	*s;
  char	*t;
  int	diff;
  int	i;
  
  i = 0;
  s = (char *)malloc(STRLEN_MAX * sizeof(char));
  t = (char *)malloc(STRLEN_MAX * sizeof(char));
  while(i < STRLEN_MAX)
  {
    s[i] = '\0';
    t[i] = '\0';
    i++;
  }
  scanf("%s", s);
  scanf("%s", t);
  i = 0;
  diff = 0;
  while (s[i] != '\0')
  {
    if (s[i] != t[i])
      diff++;
    i++;
  }
  free(s);
  free(t);
  printf("%d\n", diff);
  return (0);
}


Measured memory_bytes: 1724
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    ll N;
    cin >> N;
    ll H[N];
    rep(i,N) cin >> H[i];
    ll out = 1;
    rep(i,N){
        rep(j,i){
            if(H[j]>H[i]) break;
            if(j==i-1) out++;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = new int[n];
		for(int i=0;i<n;i++) {
			p[i] = sc.nextInt();
		}
		int ans =0;
		for(int i=0;i<n-2;i++) {
			if(p[i]< p[i+1] && p[i+1] < p[i+2]) {
				ans++;
			}else if(p[i]> p[i+1] && p[i+1] > p[i+2]){
				ans++;
			}
		}
		System.out.println(ans);
	}
	
}

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

#define ll long long

const int MaxN(100003);
ll s[MaxN], a[MaxN];
int pr[MaxN], tot;
map<ll, int> Sum;
map<ll, ll> Opp;
bool p[MaxN];

void init(int n)
{
	for(int i = 2; i <= n; i++)
		if(!p[i])
		{
			pr[++tot] = i;
			for(int j = i * i; j <= n; j += i)
				p[j] = true;
		}
}

inline ll Pow(int x, int cnt)
{
	ll res = 1;
	while(cnt--) res *= x;
	return res;
}

void work(ll x)
{
	ll res = 1, opp = 1;
	for(int i = 1; i <= tot; i++)
		if(x % pr[i] == 0)
		{
			int cnt = 0;
			while(x % pr[i] == 0)
				x /= pr[i], ++cnt;
			if(!(cnt %= 3)) continue;
			res *= Pow(pr[i], cnt);
			opp *= Pow(pr[i], 3 - cnt);
		}
	ll y = (ll) sqrt(x);
	if(y * y == x)
		res *= x, opp *= y;
	else res *= x, opp *= x * x;
	Sum[res]++, Opp[res] = opp, Opp[opp] = res;
}

int main()
{
	int n;
	init(2200);
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%lld", &s[i]);
		work(s[i]);
	}
	int ans = 0;
	for(auto &i : Sum)
	{
		if(i.first == 1) ans++;
		else
		{
			ans += max(i.second, Sum[Opp[i.first]]);
			i.second = Sum[Opp[i.first]] = 0;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

long cube(int x) {
    return 1l * x * x * x;
}

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

    if (k % 2 == 1) {
        cout << cube(n / k) << endl;
    } else {
        cout << cube(n / k) + cube((n + k / 2) / k) << endl;
    }
}

Measured memory_bytes: 256
#常に2なので定数宣言
T = 2
T.freeze

#値取得
n, m = gets.chomp.split.map(&:to_i)

=begin
答えが偶数になる場合は以下の通りしかない
偶数＋偶数 ＝ 偶数
奇数＋奇数 ＝ 奇数
つまりこれらの組み合わせ（重複なし）を求める
=end

#便宜的に配列生成
aryk = Array.new(m, "foo")
aryg = Array.new(n, "foo")

#奇数+奇数が成立する場合
wk1 = aryk.combination(T).to_a.count # n_C_k

#偶数+偶数が成立する場合
wk2 = aryg.combination(T).to_a.count # n_C_k

ans = wk1.to_i + wk2.to_i
puts ans

Measured memory_bytes: 2172
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void){
	char a[7],b[4];
	scanf("%s %s",a,b);
	strcat(a,b);
	int i,num=atoi(a);
	for(i=2;i<num/2;i++){
		if(num%i==0&&num/i==i){printf("Yes");return 0;}
	}
	printf("No");
	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  int arr[n];
  int dp[n];
  
  for(int i=0 ; i<n; i++)
  {
    cin>>arr[i];
  }
  dp[0] = 0;
  dp[1] = fabs(arr[1] - arr[0]);
  for(int i=2 ; i<n ; i++)
  {
    dp[i] = min(dp[i-1] + fabs(arr[i] - arr[i-1]) , dp[i-2] + fabs(arr[i] - arr[i-2]));
  }
  cout<<dp[n-1];
  
  return 0;
}
  
  

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(5e3 + 5);

/////////////////////////////////////////////////////////////
class ZAlgorithm {
 public:
  string s;
  string t;
  string phi;
  string sct;
  vector<int> z;

  ZAlgorithm(string s, string t, char phi) {
    this->z = vector<int>(t.size() + 1 + s.size(), 0);

    this->s = s;
    this->t = t;
    this->phi = phi;
    init();
  }

  void init() {
    sct = t + phi + s;
    make_z();
  }

  void make_z() {
    int n = sct.size();
    int l = 0, r = 0;

    z[0] = sct.size();

    for (int i = 1; i < n; ++i) {
      if (i > r) {
        l = r = i;
        while (r < n && sct[r - l] == sct[r]) r += 1;

        z[i] = r - l;
        r -= 1;
      } else {
        int k = i - l;  // focus at prefix-substring (begin with sct[k]) with which already dealed

        // no prefix-substring (begin with sct[i]) longer than (r - i + 1) could be expected
        // since, "sct[0..(r - l)] == sct[l..r]" entails "sct[k..(r - l)] == sct[i..r]",
        // but z[k] is smaller than length of sct[i..r]
        if (z[k] < r - i + 1) {
          z[i] = z[k];
        } else {  // there could be longer prefix-substring (begin with sct[i])
          l = i;
          while (r < n && sct[r - l] == sct[r]) r += 1;

          z[i] = r - l;
          r -= 1;
        }
      }
    }
  }

  bool match_from(int i) {
    return z[t.size() + 1 + i] == t.size();
  }

  int z_value(int i) {
    return z[t.size() + 1 + i];
  }
};
/////////////////////////////////////////////////////////////

int n;
string s;

int calc(int begin) {
  string target = s.substr(begin, s.size() - begin);

  int min_inds[MAX_N];
  int max_inds[MAX_N];

  for (int i = 0; i <= s.size(); ++i) {
    min_inds[i] = s.size();
    max_inds[i] = -1;
  }

  ZAlgorithm za(s, target, '_');

  for (int i = 0; i < s.size(); ++i) {
    int cur = za.z_value(i);
    min_inds[cur] = min(min_inds[cur], i);
    max_inds[cur] = max(max_inds[cur], i);
  }

  int ind_min = s.size();
  int ind_max = -1;
  for (int i = s.size(); i > 0; --i) {
    ind_min = min(ind_min, min_inds[i]);
    ind_max = max(ind_max, max_inds[i]);

    min_inds[i] = ind_min;
    max_inds[i] = ind_max;
  }

  int ret = 0;

  for (int i = 1; i < s.size(); ++i) {
    if (min_inds[i] == max_inds[i]) continue;

    if (min_inds[i] + i - 1 < max_inds[i]) {
      ret = max(ret, i);
    }
  }

  return ret;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  cin >> s;

  int ans = 0;

  for (int i = 0; i < s.size(); ++i) {
    ans = max(ans, calc(i));
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
<?php
$person = trim(fgets(STDIN));
$arr_place = explode(" ", fgets(STDIN));
$sum = 0;
foreach ($arr_place as $place) {
    $sum += intval($place);
}
$average = round($sum/$person);
$power = 0;
foreach ($arr_place as $place) {
    $power += pow(($place - $average), 2);
}
echo $power;
?>

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

int main (){

  char w[1000];

  char t[1000][1000];

  scanf("%s",w);

  int i=0;

  while(1){
 	
    scanf("%s",t[i]);

    if(strcmp(t[i],"END_OF_TEXT")==0)

      break;

    i++;

  }

  int a,b;

  for(a=0;a<=i-1;a++){

    for(b=0;t[a][b]!='\0';b++){

      if(t[a][b]<='Z'&&t[a][b]>='A'){

	t[a][b]-='A'-'a';

      }

    }

  }

  int k;

  int count=0;

  for(k=0;k<=i-1;k++){

    if(strcmp(t[k],w)==0)//ここいじったらランタイムでた

      count++;

  }

  printf("%d\n",count);

  return 0;

}

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

void testCase() {    
    
}
#define N 200001
int id = 2*N;
int color[1000000];
vector<int> tree[1000000];
vector<int> pino[1000000];
vector<int> puu[1000000];
ll subsize[1000000];
ll ans[1000000];

void dfs1(int node, int prev) {
    int sum = 1;
    for (int x : tree[node]) {
        if (x == prev) continue;
        dfs1(x,node);
        sum += subsize[x];
    }
    subsize[node] = sum;
}

void dfs2(int node, int prev) {
    if (node != 0) {
        puu[pino[color[node]].back()].push_back(node);
    }
    for (int x : tree[node]) {
        if (x == prev) continue;
        if (node != 0) {
            id++;
            int uusi = id;
            subsize[uusi] = subsize[x];
            puu[node].push_back(uusi);
            pino[color[node]].push_back(uusi);
        }
        dfs2(x,node);
        if (node != 0) pino[color[node]].pop_back();
    }
}

void solve(int node, int col) {
    if (node < N) {
        for (int x : puu[node]) solve(x,col);
        return;
    }
    ll count = 0;
    for (int x : puu[node]) count += subsize[x];
    count = subsize[node] - count;
    ans[col] += count*(count+1)/2;
    for (int x : puu[node]) solve(x,col);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> color[i];
    for (int i = 0; i < n-1; i++) {
        int a,b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    tree[0].push_back(1);
    dfs1(0,-1);
    
    for (int i = 1; i <= n; i++) pino[i].push_back(N + i);
    dfs2(0,-1);

    for (int i = 1; i <= n; i++) subsize[i+N] = n;
    for (int i = 1; i <= n; i++) solve(i+N, i);
    for (int i = 1; i <= n; i++) {
        cout << n*(n+1)/2 - ans[i] << "\n";
    }
}
















Measured memory_bytes: 125020
#include<iostream>
#define yes "YES"
#define no "NO"
using namespace std;

// Problem https://atcoder.jp/contests/abc060/tasks/abc060_b
// 2nd TRY


bool solver(int MULTI,int DEVIDEINT,int EQMOD){
    bool result;
    result = false;
    for(int j=1;j<=DEVIDEINT;j++){
        int checkNO;
        checkNO = (j * MULTI) % DEVIDEINT;
        if(checkNO == EQMOD){
            result = true;
            break;
        }
    }
    return result;
}

int main(void){
    bool answer;
    answer =false;
    int A,B,C;
    cin >> A >> B >> C;
    answer = solver(A,B,C);

    if(answer){
        cout << yes << endl;
    }
    else{
        cout << no << endl;
    }
    return 0;
}

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

const std::uint64_t mod = 1000000007;

int main() {
    std::uint32_t N; std::cin >> N;
    std::uint32_t cnt[3] = {0, 0, 0};
    std::uint64_t ans = 1;
    for (std::uint32_t i = 0; i < N; ++i) {
        std::uint32_t a; std::cin >> a;
        std::uint32_t c = 0;
        for (std::uint32_t j = 0; j < 3; ++j) {
            if (cnt[j] == a) ++c;
        }
        ans *= c;
        ans %= mod;
        for (std::uint32_t j = 0; j < 3; ++j) {
            if (cnt[j] == a) {
                cnt[j]++;
                break;
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

// const int MAX = 1010;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll total = 0;
    for (int i = 1; i < n; i++)
    {
        if (a[i] >= a[i - 1])
        {
            continue;
        }
        else
        {
            total += (a[i - 1] - a[i]);
            a[i] = a[i - 1];
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3976
def reconst(s, t):
  reconst = ""
  for i in range(len(s)):
    reconst += s[i]
    reconst += t[i]
  return reconst

o = input()
e = input()

if len(o) == len(e):
  print(reconst(o,e))
else:
  print(reconst(o[:-1],e) + o[-1])

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeTester.contest190622
{
    class ProblemD
    {
        static long taskNum = 0;
        // Key を締め切り、Value をかかる時間にすること
        static List<List<long>> tasks = new List<List<long>>();
        // static SortedDictionary<long, long> tasks = new SortedDictionary<long, long>();
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            taskNum = long.Parse(Console.ReadLine());
            for (int i = 0; i < taskNum; i++)
            {
                string[] inputs = Console.ReadLine().Split(' ');
                tasks.Add(new List<long>(){ long.Parse(inputs[1]), long.Parse(inputs[0]) });
            }
        }

        static void Logic()
        {
            // 締め切りが近い順にソート
            List<List<long>> sortedTasks = tasks.OrderBy(value => value[0]).ToList();
            long tmpSum = 0;
            foreach(List<long> task in sortedTasks)
            {
                tmpSum += task[1];
                DebugPrint(task[0].ToString() + " : " + tmpSum.ToString());
                if (tmpSum > task[0])
                {
                    answer = "No";
                    return;
                }
            }
            answer = "Yes";
        }

        static void Output()
        {
            Console.WriteLine(answer);

        }

        static void DebugPrint(string msg)
        {
            // 提出時に消す
            // Console.WriteLine(msg);
        }
    }
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

const ll inf = 1e18+7;
const int N = 1e6;
const int mod = 1e9+7;

ll k, a, b;

int main()
{
	string s, t;
	cin >> s >> t;
	for(int i = 0; i< 3; ++i)
		a+= (s[i] == t[i]);
	cout << a;
 	return 0;
}

Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

flag = 0
turn = 0
while True:
  if turn == 0:
    c -= b
  else:
    a -= d

  if a <= 0:
    break
  if c <= 0:
    flag = 1
    break
  
  turn = turn ^ 1

if flag == 0:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 9168
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int dp[1005][1005];
char map[1005][1005];
const int mod=1e9+7;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
     for(int j=1;j<=m;j++)
       cin>>map[i][j];
    
	memset(dp,0,sizeof(dp));
	dp[0][1]=1;
	for(int i=1;i<=n;i++){
	 for(int j=1;j<=m;j++){
	 	if(map[i][j]=='.')
	 	{
	 		dp[i][j]=dp[i][j-1]+dp[i-1][j];
	 		dp[i][j]=dp[i][j]%mod;
		 }
	 	
	 }
	}   
     cout<<dp[n][m];
    
    
    return 0;
}

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

using namespace std;

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

	vector<int> v;
	v.push_back(A + B);
	v.push_back(A - B);
	v.push_back(A * B);
	
	vector<int>::iterator it = max_element(v.begin(), v.end());

	cout << *it << endl;

	return 0;
}


Measured memory_bytes: 256
'''     ##     ##  #######  # #  ######
        ##     ##  ##   ##  ###    ##
        ##     ##  ##    #  # #    ##
        #########  #######  # #    ##    '''

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")

# for _testcases_ in range(int(input())):
n = int(input())
print((n*(n+1))//2)
'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int e_mx,e_mx_index,e_mx2,o_mx,o_mx_index,o_mx2;
vector<int> ecnt(100010),ocnt(100010);
int main() {
    ll n,k,ans = 0;
    cin >> n >> k;
    vector<ll> x(k,0);
    for (int i = 1; i <= n; ++i) {
        x[i%k]++;
    }
    for (ll a = 0; a < k; ++a) {
        ll b = (k-a)%k;
        ll c = (k-a)%k;
        if((b+c)%k != 0) continue;
        ans += x[a]*x[b]*x[c];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <cctype>
using namespace std;
typedef string::const_iterator State;

char Letter(State& begin){
  char ret = *begin;
  ++begin;
  return ret;
}

char term(State& begin){
  char x;
  int d=0;
  while(true){
    char c = *begin;
    if(c=='+'){
      ++d;
      ++begin;
    }
    else if(c=='-'){
      --d;
      ++begin;
    }
    else break;
  }
  x = Letter(begin);
  if(x=='?') return 'A';
  d+=x-'A';
  d = (d+80*26)%26;
  return (char)('A'+d);
}

string Ciper(State& begin){
  string ret="";
  while(true){
    char c = *begin;
    if(c=='\0') break;
    else if(c=='['){
      ++begin;
      string t = Ciper(begin);
      ++begin;
      reverse(t.begin(),t.end());
      ret+=t;
    }
    else if(c==']') break;
    else ret+=term(begin);
  }
  return ret;
}

int main(){
  string s;
  while(cin>>s,s!="."){
    State begin = s.begin();
    //cout << term(begin) << endl;
    cout << Ciper(begin) << endl;
  }
  return 0;
}

Measured memory_bytes: 1196