akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;
vector<int>adj[100005];
int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

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

Measured memory_bytes: 2560
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
base = []
if n == 1 and m == 0:
    print(0)
    exit()
elif n == 2 and m == 0:
    print(10)
    exit()
elif n == 3 and m == 0:
    print(100)
    exit()
if n >= 1:
    base.append('1')
if n >= 2:
    base.append('0')
if n == 3:
    base.append('0')
dic = defaultdict(int)
for i in range(m):
    s,c = readInts()
    s -= 1
    if dic[s] != 0:
        if int(base[s]) == c:
            pass
        else:
            print(-1)
            exit()
    else:
        dic[s] = 1
        base[s] = str(c)
    if s == 0 and c == 0 and n >= 2:
        print(-1)
        exit()
print(*base,sep='')


Measured memory_bytes: 10472
#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 <math.h> // sqrt
#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 <iomanip> // setprecision
#include <bitset> // bitset
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    if (N < 10) {
        cout << N << endl;
    }
    else if (N < 100) {
        cout << 9 << endl;
    }
    else if (N < 1000) {
        cout << N - 90 << endl;
    }
    else if (N < 10000) {
        cout << 909 << endl;
    }
    else if (N < 100000) {
        cout << N - 9090 << endl;
    }
    else {
        cout << 90909 << endl;
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <string>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
using namespace std;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dy = ty - sy;
    int dx = tx - sx;
    cout << string(dy, 'U')  << string(dx, 'R');
    cout << string(dy, 'D')  << string(dx, 'L');
    cout << 'L' << string(dy + 1, 'U')  << string(dx + 1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D')  << string(dx + 1, 'L') << 'U';
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i).unshift(0).push(0)
sum = 0
(n+1).times do |i|
    sum += (a[i]-a[i+1]).abs
end

n.times do |i|
    puts sum-(a[i+1]-a[i]).abs-(a[i+2]-a[i+1]).abs+(a[i]-a[i+2]).abs
end

Measured memory_bytes: 12036
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::*;
use smallvec::alloc::collections::VecDeque;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        h:usize,
        w:usize,
        ch:usize,
        cw:usize,
        dh:usize,
        dw:usize,
        map:[String;h],
    }

    let ch = ch - 1;
    let cw = cw - 1;
    let dh = dh - 1;
    let dw = dw - 1;

    let map = map
        .into_iter()
        .map(|s| s.chars().collect_vec())
        .collect_vec();

    let mut queue = VecDeque::new();
    queue.push_back((ch, cw));

    let mut warp_queue = VecDeque::new();

    let mut dp = vec![vec![U_INF; w + 10]; h + 10];
    dp[ch][cw] = 0;
    let mut seen = vec![vec![false; w + 10]; h + 10];
    let mut seen_by_walk = vec![vec![false; w + 10]; h + 10];

    while !(queue.is_empty() && warp_queue.is_empty()) {
        if queue.is_empty() {
            queue.append(&mut warp_queue);
        }

        let (i, j) = queue.pop_front().unwrap();
        if seen[i][j] {
            continue;
        }

        seen[i][j] = true;

        let next = next_by_walk(i, j, h, w);

        for (k, s) in next {
            if map[k][s] == '.' && !seen[k][s] && !seen_by_walk[k][s] {
                seen_by_walk[k][s] = true;
                queue.push_back((k, s));
                dp[k][s] = (dp[k][s]).min(dp[i][j]);
            }
        }

        let next = next_by_warp(i, j, h, w);

        for (k, s) in next {
            if map[k][s] == '.' && !seen[k][s] && !seen_by_walk[k][s] {
                warp_queue.push_back((k, s));
                dp[k][s] = (dp[k][s]).min(dp[i][j] + 1);
            }
        }
    }

    if dp[dh][dw] == U_INF {
        println!("{}", -1);
        return;
    }

    println!("{}", dp[dh][dw]);
}

fn next_by_walk(i: usize, j: usize, h: usize, w: usize) -> Vec<(usize, usize)> {
    let i = i as isize;
    let j = j as isize;

    vec![(i - 1, j), (i, j - 1), (i, j + 1), (i + 1, j)]
        .into_iter()
        .filter(|(i, j)| (0..h as isize).contains(i) && (0..w as isize).contains(j))
        .map(|(i, j)| (i as usize, j as usize))
        .collect_vec()
}

fn next_by_warp(i: usize, j: usize, h: usize, w: usize) -> Vec<(usize, usize)> {
    let i = i as isize;
    let j = j as isize;

    let mut vec = Vec::new();
    for a in 0..5 {
        for b in 0..5 {
            if a == 2 && b == 2 {
                continue;
            }

            vec.push((i + a - 2, j + b - 2));
        }
    }

    vec.into_iter()
        .filter(|(i, j)| (0..h as isize).contains(i) && (0..w as isize).contains(j))
        .map(|(i, j)| (i as usize, j as usize))
        .collect_vec()
}


Measured memory_bytes: 18996
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k;
long long a[N],b[N],sum;
int main()
{
	 scanf("%d",&n);
	 for (i=1;i<=n;++i) scanf("%d%d",&a[i],&b[i]);
	 for (i=n;i;--i)
	 {
	 		a[i]+=sum;
	 		if (a[i]%b[i]==0) continue;
			long long now=(a[i]/b[i]+1)*b[i];
			sum+=now-a[i]; 
	 }
	 cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long
#define MINUS(a) memset(a,0xff,sizeof(a))

int dp[100001];

int main(){
    int n, ans = 0, tmp = 0;;
    cin>>n;
    int h[n];
    for(int i=0; i<n; i++){
        cin>>h[i];
    }

    for(int i=1; i<n; i++){
        int a, b;
        if(h[i-1]>=h[i]){
            tmp++;
            //cout<<tmp<<endl;
        }
        else{
            ans = max(tmp, ans);
            tmp = 0;
        }
    }

    ans = max(tmp, ans);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	string s;
	cin>>s;
	int ans=0;
	if(s[0]==s[1] && s[1]==s[2] & s[0]=='R')
		cout<<3;
	else if(s[0]==s[1] && s[0]=='R')
		cout<<2;
	else if(s[1]==s[2] && s[1]=='R')
		cout<<2;
	else if(s[0]=='R' || s[1]=='R' || s[2]=='R')
		cout<<1;
	else
		cout<<0;
	return 0;
}


Measured memory_bytes: 3644
s = input()
t = input()
ss = []
tt = []
stable = []
ttable = []
scnt = 0
tcnt = 0
for i in range(len(s)):
  for x in stable:
    if s[i] == x[0]:
      ss.append(x[1])
      break
  else:
    scnt += 1
    stable.append([s[i],scnt])
    ss.append(scnt)
for i in range(len(t)):
  for x in ttable:
    if t[i] == x[0]:
      tt.append(x[1])
      break
  else:
    tcnt += 1
    ttable.append([t[i],tcnt])
    tt.append(tcnt)
if ss == tt:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 6832
A,B = map(int,input().split())
S = input()
S1= S[:A]
S2 = S[A]
S3 = S[A+1:]

if S1.isdecimal() == 1 and S2 == '-' and S3.isdecimal() == 1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int m1,m2,d1,d2;
	cin >> m1 >> d1;
	cin >> m2 >> d2;
	if (d1 < d2) {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();

		sc.close();

		if (S.matches("(hi)+")) {
			out.println("Yes");

		} else {
			out.println("No");
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 22868
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs("1_06.txt");//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    ifstream ifs("test4.txt");
    
    int N;
    cin >> N;
    int nn=N;
    
    int sum=0;
    while(N>0){
        sum+=N%10;
        N/=10;
    }
    if(nn%sum==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

s = list(get_input())

d = {char:0 for char in [chr(ord('a')+i) for i in range(26)]}
for line in s:
    for x in line.lower():
        if(x in d):
            d[x] += 1

for k in d:
    print(k + " : " + str(d[k]))



Measured memory_bytes: 5568
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int re=0;
	if(N<=111) re=111;
	else if(N<=222) re=222;
	else if(N<=333) re=333;
	else if(N<=444) re=444;
	else if(N<=555) re=555;
	else if(N<=666) re=666;
	else if(N<=777) re=777;
	else if(N<=888) re=888;
	else re=999;
	System.out.print(re);
    }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

ll modpow(ll x, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % MOD;
		x = x * x % MOD;
		n >>= 1;
	}
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<ll> x(n), y(m);
	for (int i = 0; i < n; i++) cin >> x[i];
	for (int i = 0; i < m; i++) cin >> y[i];

	ll ans = 0;
	ll tmp1 = 0;

	for (int j = 0; j < m / 2; j++) {
		ll tmp = (y[m - 1 - j] - y[j]) % MOD;
		tmp = tmp * (m - 1 - 2 * j) % MOD;
		(tmp1 += tmp) %= MOD;
	}
	for (int i = 0; i < n / 2; i++) {
		ll tmp = (x[n - 1 - i] - x[i]) % MOD;
		tmp = tmp * tmp1 % MOD * (n - 1 - 2 * i) % MOD;
		ans = (ans + tmp) % MOD;	
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

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

        int n = sc.nextInt();
        boolean flg = false;

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (i * j == n) {
                    flg = true;
                    break;
                }
            }
        }

        if (flg) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  ll A, B;
  cin >> A >> B;
  ll G = __gcd(A, B);
  int cnt = 1;
  for (ll i=2; i*i<=G; ++i) {
    if (G%i == 0) {
      ++cnt;
    }
    while (G%i == 0) {
      G/=i;
    }
  }
  if (G != 1) {
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3652
N = int(input())
s = input()
LWW = 0
LWE = 0
LEW = s[1:].count('W')
LEE = s[1:].count('E')
ans = LWW + LEE
for i in range(1,len(s)):
    if s[i] =="W":
        LEW -=1
    else:
        LEE -=1
    if s[i-1] == 'W':
        LWW +=1
    else:
        LWE +=1
    ans = min(ans,LWW+LEE)
print(ans)    


Measured memory_bytes: 9732
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes";
		return 0;
	}
	else if(abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes";
		return 0;
	}
	cout << "No";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int ans = 0;
	static int N;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		dfs(0);
		System.out.println(ans);
	}
	static void dfs(long x) {
		if (x > N) {
			return;
		}
		String s = String.valueOf(x);
		if (s.contains("7")
			&& s.contains("5")
				&& s.contains("3")) {
			ans++;
		}
	dfs(x*10 + 7);
	dfs(x*10 + 5);
	dfs(x*10 + 3);
	}
}


Measured memory_bytes: 24148
N = int(input())
D,X = map(int,input().split())
A = [int(input()) for i in range(N)]

ans = 0
def ceil(n): # ceiling関数
    if n > int(n):
        return(int(n)+1)
    else:
        return(int(n))
for i in range(N):
    ans += ceil(D/A[i])
ans += X
print(ans)

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

using namespace std;

#define REP(i, a, b) for ( int i = (a), _end_ = (b); i <= _end_; ++ i )
#define mem(a) memset ( (a), 0, sizeof ( a ) )
#define str(a) strlen ( a )
typedef long long LL;

const int maxn = 1500010;

int n;
priority_queue<double,vector<double>,greater<double> > Q;

int main()
{
    scanf("%d", &n);
    REP(i, 1, n) { double x; scanf("%lf", &x); Q.push(x); }
    REP(i, 1, n - 1) 
    {
        double x = Q.top(); Q.pop();
        double y = Q.top(); Q.pop();
        Q.push((x + y) / 2.0);
    }
    printf("%lf\n", Q.top());
    return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

#define int ll

int N, Q;
string S;
int acc[500000][30];
vector<int> pls[30];
vector<int> mns[30];

signed main(){
    cin >> N >> S >> Q;
    int t, i, l, r;
    char c;
    REP(k, N) REP(j, 30) acc[k][j] = 0;
    REP(k, N){
        REP(j, 30){
            if(k == 0) break;
            acc[k][j] = acc[k - 1][j];
        }
        acc[k][S[k] - 'a']++;
    }
    REP(k, Q){
        cin >> t;
        if(t == 1){
            cin >> i >> c;
            i--;
            mns[S[i] - 'a'].push_back(i);
            pls[c - 'a'].push_back(i);
            S[i] = c;
        }else{
            cin >> l >> r;
            l--; r--;
            int ans = 0;
            REP(j, 30){
                int cnt;
                if(l > 0) cnt = acc[r][j] - acc[l - 1][j];
                else cnt = acc[r][j];
                for(int index : mns[j]){
                    if(l <= index && index <= r) cnt--;
                }
                for(int index : pls[j]){
                    if(l <= index && index <= r) cnt++;
                }
                if(cnt > 0) ans++;
            }
            PRINT(ans);
        }
    }
}




Measured memory_bytes: 118404
//### In The Name Of GOD ###

//%% Remember; (((He))) is The (((Accepter))) %%

// GOD IS GREATER ...

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;
typedef long double ld ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 8 * 1000 * 1000 + 200;
const int MAXN =  100 * 1000 + 1;
const int MLOG = 18;
const int NMAX = 20;

vector<int> prime;

int is_p(int a){
	for(int i : prime)
		if(a % i == 0) return false;
	return true;
}

signed main(){
	IO;
	int dp[MAXN][3]; // dp[i][b] mishavad marhaleye i om ba b ta parntez baz
	int n;
	cin >> n >> dp[0][0];
	dp[0][2] = dp[0][1] = - INF * INF;
	for(int i = 1; i < n; i++){
		char op;
		int a;
		cin >> op >> a;
		if(op == '-'){
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - a;
			dp[i][2] = max(dp[i - 1][2], dp[i - 1][1]) + a;
			dp[i][0] = max({dp[i - 1][0] - a, dp[i][1], dp[i][2]});
			//cout << '-';
		}else{
			dp[i][0] = max({dp[i - 1][0], dp[i - 1][1], dp[i - 1][2]}) + a;
			dp[i][1] = dp[i - 1][1] - a;
			dp[i][2] = dp[i - 1][2] + a;
			//cout << '+';
		}
		//cout << dp[i][0] << ' ' << dp[i][1] << ' ' << dp[i][2] << endl;
	}
	cout << dp[n - 1][0];
}

Measured memory_bytes: 2560
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3060
using System;

namespace AtCoderTest
{
    class Program
    {
        static void Main()
        {
            var buf = Console.ReadLine().Trim().Split();
            long A = long.Parse(buf[0]);
            long V = long.Parse(buf[1]);

            buf = Console.ReadLine().Trim().Split();
            long B = long.Parse(buf[0]);
            long W = long.Parse(buf[1]);

            var buf2 = Console.ReadLine().Trim();

            long T = long.Parse(buf2);

            bool result;

            if (W >= V)
            {
                result = A == B;
            }
            else
            {
                result = (Math.Abs((double)(B-A))) / ((double)(V-W)) <= (double)T;
            }


            if (result) {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }



            
            
            
        }
    }

}


Measured memory_bytes: 27464
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

type runes []rune

func (rs runes) Len() int           { return len(rs) }
func (rs runes) Swap(i, j int)      { rs[i], rs[j] = rs[j], rs[i] }
func (rs runes) Less(i, j int) bool { return rs[i] < rs[j] }

func main() {
	// sc.Split(bufio.ScanWords)
	var N int
	fmt.Scanf("%d", &N)
	// N = nextInt()
	mp := make(map[string]int)
	for i := 0; i < N; i++ {
		var tmp string
		fmt.Scanf("%s", &tmp)
		s := []rune(tmp)
		sort.Sort(runes(s))
		mp[string(s)]++
	}
	ans := 0
	for _, n := range mp {
		ans += n * (n - 1) / 2
	}
	fmt.Println(ans)

}


Measured memory_bytes: 11520
//#define _USE_MATH_DEFINES
#include <iostream>
//#include <stdio.h>
//#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <cmath>

using namespace std;

class Dice
{
public:
	Dice(int num[6]);
	int check_R(int t,int f);
	int T,F,R;
private:
	int _num[6];
	int _pattern[6][3];
};

//?????????????????????
Dice::Dice(int num[6])
{
	for (int i = 0; i < 6; i++){
		_num[i] = num[i];
	}

	T = _num[0];
	F = _num[1];
	R = _num[2];

	int buf[6][3] = { { 1, 2, 3 }, { 2, 6, 3 }, { 3, 6, 5 }, { 4, 6, 2 }, { 5, 1, 3 }, { 6, 5, 3 } };
	for (int i = 0; i < 6; i++){
		for (int j = 0; j < 3; j++){
			_pattern[i][j] = buf[i][j];
		}
	}
}

int Dice::check_R(int t, int f){

	int ti = -1, fi = -1, ri = -1;

	for (int i = 0; i < 6; i++){
		if (t == _num[i])ti = i;
		if (f == _num[i])fi = i;
	}

	if (ti == -1 || fi == -1) return -1;

	if (fi == _pattern[ti][1] - 1) ri = _pattern[ti][2] - 1;
	if (fi == _pattern[ti][2] - 1 ) ri = 7 -_pattern[ti][1] - 1;
	if (fi == 7 - _pattern[ti][1] - 1) ri = 7 -_pattern[ti][2] -1;
	if (fi == 7 - _pattern[ti][2] - 1) ri = _pattern[ti][1] -1;

	return _num[ri];
}



int main(){

	int num1[6],num2[6];
	char c;

	for (int i = 0; i < 6; i++){
		cin >> num1[i];
	}
	Dice d1(num1);

	for (int i = 0; i < 6; i++){
		cin >> num2[i];
	}
	Dice d2(num2);


	if (d1.R == d2.check_R(d1.T, d1.F)) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main(){
  char s[10001];
  int i,J,I;
  while(scanf("%s",s)!=EOF){
    I=J=0;
    for(i=2;s[i];i++){
      if(s[i]-'I'||s[i-1]-'O')continue;
      if(s[i-2]=='J')J++;
      if(s[i-2]=='I')I++;
    }
    printf("%d\n%d\n",J,I);
  }
  return 0;
}
      

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

#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORV(i,a,b) for(int i=a;i*i<=b;i++)
#define Forv(i,a,b) for(int i=a;i*i<b;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define Ford(i,a,b) for(int i=a;i>b;i--)
#define Fill(s,a) memset(s,a,sizeof(s))
#define pb push_back
#define mp make_pair
#define fi first
#define se second

string s;
vector<pair<int, int> > a;
int ans = 0;

int main()
{
    cin>>s;
    For(i, 0, s.size())
    {
        int cnt;
        if(s[i] == 'J')
        {
            cnt = 0;
            while(s[i] == 'J')
            {
                cnt++;
                i++;
            }
            a.pb(mp(1, cnt));
        }
        if(s[i] == 'O')
        {
            cnt = 0;
            while(s[i] == 'O')
            {
                cnt++;
                i++;
            }
            a.pb(mp(2, cnt));
        }
        if(s[i] == 'I')
        {
            cnt = 0;
            while(s[i] == 'I')
            {
                cnt++;
                i++;
            }
            a.pb(mp(3, cnt));
        }
        i--;
    }
    if(a.size()<=2)
    {
        cout<<"0\n";
        return 0;
    }
    For(i, 0, a.size()-2)
        if(a[i].fi == 1 && a[i+1].fi == 2 &&a[i+2].fi == 3 && min(a[i].se, min(a[i+1].se, a[i+2].se)) == a[i+1].se)
        {
            ans = max(ans, min(a[i].se, min(a[i+1].se, a[i+2].se)));
            i+=2;
        }
    cout<<ans<<'\n';
}

Measured memory_bytes: 12328
h,w=map(int,input().split())
s=[input() for _ in range(h)]
from collections import deque
def bfs(i,j):
    if s[i][j]=='#':
        return 0
    ret=-1
    todo=[]
    next_todo=[(i,j)]
    seen=[[0]*w for _ in range(h)]
    seen[i][j]=1
    while next_todo:
        ret+=1
        todo=deque(next_todo)
        next_todo=[]
        while todo:
            hi,wi=todo.popleft()
            if hi>0 and seen[hi-1][wi]==0 and s[hi-1][wi]=='.':
                seen[hi-1][wi]=1
                next_todo.append((hi-1,wi))
            if hi<h-1 and seen[hi+1][wi]==0 and s[hi+1][wi]=='.':
                seen[hi+1][wi]=1
                next_todo.append((hi+1,wi))
            if wi>0 and seen[hi][wi-1]==0 and s[hi][wi-1]=='.':
                seen[hi][wi-1]=1
                next_todo.append((hi,wi-1))
            if wi<w-1 and seen[hi][wi+1]==0 and s[hi][wi+1]=='.':
                seen[hi][wi+1]=1
                next_todo.append((hi,wi+1))
    return ret
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,bfs(i,j))
print(ans)


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

int main()
{
  int k;
  string s="ACL";
  cin >> k;

  rep(i,k){
    cout << s ;
  }
  return 0;

}

Measured memory_bytes: 3592
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
B = [0 for _ in range(M-1)]
for i in range(M-1):
  B[i] = A[i+1] - A[i]
B.sort()
if N!=1:
  B=B[:-(N-1)]
print(sum(B))


Measured memory_bytes: 13968
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long int li;
typedef unsigned long long int ull;
typedef long double ld;
#define Max 500001
#define mod 1000000007
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define endl "\n"
void bye()
{
	
	exit(0);
}
signed main()
{
	fast;
	ll t,pro=1,n,m,temp,k,l,r,mid,i,j,x,y,z,rem,ind,ans=0,mx=LONG_LONG_MIN,mn=LONG_LONG_MAX,cnt=0,curr=0,prev,sum=0,flag=0,i1=-1,i2=-1;
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1];
	return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

bool check(vector<int>& moves, int start, int goal)
{
  set<int> cur;
  cur.insert(start);
  for (int i = 0; i < (int)moves.size(); ++i) {
    set<int> next;
    for (set<int>::iterator iter = cur.begin(); iter != cur.end(); ++iter) {
      next.insert(*iter + moves[i]);
      next.insert(*iter - moves[i]);
    }
    cur = next;
  }
  return cur.count(goal) == 1;
}

int main()
{
  string s; cin >> s;
  int gx, gy;
  scanf("%d %d", &gx, &gy);
  int n = s.size(), dir = 0, i = 0;
  int sx = 0;
  while (i < n && s[i] == 'F') {
    ++sx; ++i;
  }
  vector<int> xmoves, ymoves;
  while (i < n) {
    if (s[i] == 'T') {
      dir = (dir + 1) % 2;
      ++i;
    }
    else {
      string::size_type pos = s.find_first_of('T', i);
      int d = (pos == string::npos) ? (n - i) : (pos - i);
      if (dir % 2 == 0) { xmoves.push_back(d); }
      else { ymoves.push_back(d); }
      i += d;
    }
  }
  bool ok = check(xmoves, sx, gx) and check(ymoves, 0, gy);
  printf("%s\n", ok ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	ans := 0
	for i := 0; i < n; i++ {
		if (i+1)%2 == 0 {
			readInt()
			continue
		}
		if readInt()%2 == 1 {
			ans++
		}
	}

	fmt.Println(ans)
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1772
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int x = 0;
    while(n--){
        string s;
        cin >> s;
        if(s[0] == 'A'){
            x++;
        }
        else{
            x--;
            if(x < 0){
                cout << "NO" << endl;
                return 0;
            }
        }
        
    }
    if(x != 0)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  int n;
  cin>>n;
  vv(pil) paths(n);
  rep(i,n-1){
    int u,v;
    ll w;
    cin>>u>>v>>w;
    u--;v--;
    paths[u].pb({v,w});
    paths[v].pb({u,w});
  }
  vi visit(n,0);
  vi color(n,0);
  queue<int> q;
  q.push(0);
  visit[0]=1;
  while(!q.empty()){
    int from = q.front(); q.pop();
    visit[from] = 1;
    for(auto p:paths[from]){
      if(visit[p.first]) continue;
      q.push(p.first);
      if(p.second%2==0){
        color[p.first] = color[from];
      }else{
        color[p.first] = 1^color[from];
      }
    }
  }
  rep(i,n){
    cout<<color[i]<<endl;
  }


} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 8704
#include <iostream>
using namespace std;
int N, A[10010]; // ?°?????????????????????????
int min(int *a, int size) {
    int min = a[0];
    for(int i=0;i<size;i++){
        if(a[i]<min){
            min = a[i];
        }
    }
    return min;
}

int max(int *a, int size) {
    int max = a[0];
    for(int i=0;i<size;i++){
        if(a[i]>max){
            max = a[i];
        }
    }
    return max;
}

long long sum(int *a, int size) {
    long long sum = 0;
    for(int i=0;i<size;i++){
        sum += a[i];
    }
    return sum;
}

int main() {
    cin >> N;
    for (int i=0; i<N; ++i)
        cin >> A[i];
    cout << min(A,N) << " " << max(A,N) << " " << sum(A,N) << endl;
}

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

int main(){
  int n,m,i,a;
  cin >> n >> m;
  a=100*n+1800*m;
  for(i=0;i<m;i++){
    a *= 2;
  }
  cout << a << endl;
}

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

struct pp{
    string name;
    int time;
};

class Que{
    public:
    int Max;
Que(int n){
    Max=n+1;//nが容量数。1っこ多めに。
    array=new pp[Max];
    head=0;tail=0;
}
bool isEmpty(){
    return head==tail;
}
bool isFull(){
    return head==(tail+1)%Max;
}
void enqueue(pp x){
    array[tail]=x;
    if(tail+1==Max)tail=0;
    else{tail++;}
}
pp dequeue(){
    pp x=array[head];
    if(head+1==Max)head=0;
    else{head++;}
    return x;
}
    private:
    int head,tail;
    pp* array;
};

int main(){
    int n,p;
    cin>>n>>p;
    Que q(n);pp p_p[n];
    for(int i=0;i<n;i++){
        cin>>p_p[i].name>>p_p[i].time;
        q.enqueue(p_p[i]);
    }
    pp ans[n];
    int ans_time=0,now=0;
    while(! q.isEmpty()){
        pp tmp=q.dequeue();
        if(tmp.time<=p){
            ans_time+=tmp.time;
            ans[now].name=tmp.name;
            ans[now].time=ans_time;
            now++;
        }
        else{
            ans_time+=p;
            tmp.time-=p;
            q.enqueue(tmp);
        }
    }
    for(int j=0;j<n;j++){
        cout<<ans[j].name<<' '<<ans[j].time<<endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

#ifdef RED
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const int N = (int)1e6 + 5;

int n;
int a[N], b[N], c[N];
int dp[N][5];

int main() {
#ifdef RED
  freopen("a.in", "r", stdin);
#endif
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[1][1] = a[1];
  dp[1][2] = b[1];
  dp[1][3] = c[1];
  for (int i = 2; i <= n; ++i) {
    dp[i][1] = max(dp[i - 1][2], dp[i - 1][3]) + a[i];
    dp[i][2] = max(dp[i - 1][1], dp[i - 1][3]) + b[i];
    dp[i][3] = max(dp[i - 1][1], dp[i - 1][2]) + c[i];
  }
  cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
  return 0;
}


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

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

  int S, W;
  cin >> S >> W;

  if(S > W) cout << "safe" << endl;
  else cout << "unsafe" << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>

int main() {
  std::string s;
  std::cin >> s;

  int res = 0;
  for (size_t i = 0; i < s.length(); ++i) {
    if (i % 2 == 0) {
      if (s[i] == 'p') {
        --res;
      }
    } else {
      if (s[i] == 'g') {
        ++res;
      }
    }
  }
  std::cout << res << std::endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

typedef complex<double> P;

void pp(P x) { printf("%.8f %.8f\n", x.real(), x.imag()); }

void koch(int n, P b, P e)
{
	if (n-- == 0) {
		pp(b);
		return;
	}

	P p = (2.0 * b + e) / 3.0;
	P v[] = {b, p, p + (p - b) * P(cos(M_PI/3), sin(M_PI/3)), 2.0 * p - b, e};

	for (int i = 0; i < 4; i++)
		koch(n, v[i], v[i + 1]);
}

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

	P b = {0, 0}, e = {100, 0};
	koch(n, b, e);
	pp(e);
}


Measured memory_bytes: 2680
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
vector<int> each[200000+20];
int res[200000+20];
int c1=0,c2=0;
vector<int> v[3];
void dfs(int now,int col,int prev=-1){
	res[now]=col;
	if(col-1){
		c2++;
	}
	else{
		c1++;
	}
	v[col].PB(now);
	for(auto it:each[now]){
		if(it!=prev){
			dfs(it,1+((col-1)^1),now);
		}
	}
	
}
int main(){
	fastio;
	int n;
	cin>>n;
	rb(i,2,n)
		{
			int u,v;
			cin>>u>>v;
			each[u].PB(v);
			each[v].PB(u);
			
			
		}
	dfs(1,1);
	if(c1<=n/3||c2<=n/3){
		int used[200000+20]={0};
		memset(res,0,sizeof(res));
		if(c1<=n/3){
			int now=3;
			for(auto it:v[1]){
				used[now]=1;
				res[it]=now;
				now+=3;	
			}
			
		}
		else{
			
			int now=3;
			for(auto it:v[2]){
				used[now]=1;
				res[it]=now;
				now+=3;	
			}
		}
		int ii=1;
		rb(i,1,n){
			if(res[i]==0){
				while(used[ii]) ii++;
				res[i]=ii;
				ii++;
			}
		}
		rb(i,1,n){
			cout<<res[i]<<" ";
		}
		return 0;
	}
	int o,t,z;
	o=1,t=2,z=3;
	
	rb(i,1,n){
		if(res[i]==1){
			if(o<=n){
				res[i]=o;
				o+=3;
			}
			else{
				 res[i]=z;
				 z+=3;
				 
			}
		}
		else{
			if(t<=n){
				res[i]=t;
				t+=3;
			}
			else{
				 res[i]=z;
				 z+=3;
			}
		}
	}
		rb(i,1,n) cout<<res[i]<<" ";
//	}
	return 0;
}


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

const int maxn = 100 * 1000 + 20;
int n, m, dis[maxn];
vector <int> adj[maxn], adjexit[maxn];
bool vis[maxn];

void input() {
    cin >> n >> m;
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
}

void dfs(int v) {
    vis[v] = 1;
    for (int u : adj[v]) {
        if (!vis[u]) {
            dis[u] = dis[v] + 1;
            dfs(u);
            adjexit[u].size() % 2? adjexit[u].push_back(v): adjexit[v].push_back(u);
        }
        else if (dis[v] < dis[u])
            adjexit[v].push_back(u);
    }
}
void output() {
    for (int i = 1; i <= n; i++)
        for (int j : adjexit[i])
            cout << i << ' ' << j << endl;
}
int main() {    
    ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
    input();
    if (m % 2)
        return cout << -1 << endl, 0;
    dfs(1);
    output();
    return 0;    
}



Measured memory_bytes: 17536
#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 int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	string s, t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	int ans = inf;
	for(int i = 0; i + m - 1 < n; i++) {
		int cur = 0;
		for(int j = i; j < i + m; j++) {
			if(s[j] != t[j - i]) {
				cur++;
			}
		}
		ans = min(ans, cur);
	}
	cout << ans;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    vector<ll> zero(60), one(60);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        bitset<60> bit(A[i]);
        for(int u = 0; u < 60; u++) {
            if(bit.test(u)) one[u]++;
            else zero[u]++;
        }
    }
    ll ans = 0;
    for(int i = 59; i >= 0; i--) {
        ll cnt = zero[i] * one[i] % mod, two = (ll)pow(2, i) % mod;
        ll plus = cnt * two % mod;
        ans += plus;
        ans %= mod;
        if(ans < 0) ans += mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5564
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    A = LI()
    sub = [0]*n
    for a in A:
        sub[a-1] += 1
    for s in sub:
        print(s)

if __name__ == '__main__':
    main()

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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(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=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 205;

int mx = 0;
int nm[maxn];
bool cn[maxn][maxn];

int n;

void bfs(int at){
    queue<int> qq;
    qq.push(at); nm[at] = 1;
    while (!qq.empty()){
        int x = qq.front(); qq.pop();
        REP(i,n){
            if (cn[i][x]){
                if (!nm[i]) qq.push(i), nm[i] = nm[x]+1;
                else if (nm[i] == nm[x]) GG();
            }
        }
        MX(mx, nm[x]);
    }
}

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
     cin>>n;
    REP(i,n) REP(j,n){
        char x; cin>>x;
        cn[i][j] = (x=='1');
    }
    REP(i,n){
        fill(nm, nm+n,0);
        bfs(i);
    }
    cout<<mx<<endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n,j,sum=0;
    scanf("%d",&n);
    int d[n];
    for ( i = 0; i < n; i++)
    {
       scanf("%d",&d[i]); 
    }
    
    for ( i = 0; i < n; i++)
    {
        for ( j =i+1; j < n; j++)
        {
            sum=sum+(d[i]*d[j]);
        }
        
    }
    printf("%d\n",sum);
    
    
    

}

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

#define ll long long
#define rep(i, n) for (ll i = 0; i < n; i++)
#define CIN(params) cin >> params;
#define COUT(params) cout << params << endl;
#define mod 1000000007LL

using namespace std;

// 2 , 5
// 1 2 :  10 12 14
//

// 3, 7
// -100 : -10 -3 0 2 : 9 17
//

// 0 1 8  2  2
// 0 1 2  3  4

// 2, 4

// 3
// -10   -3  0 9 -100 2 17
// -100 -10 -3 0    2 9 17
//  0    90  7 3    2 7 8

// 90 8 7 7 3 2
// 0 1 7
//

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

  if (N >= M) {
    COUT(0);
    return 0;
  }

  int P[M];
  int diff[M - 1];
  int X[M];

  for (int i = 0; i < M; i++) {
    CIN(X[i]);
    P[i] = X[i];
  }

  sort(P, P + M);

  for (int i = 1; i < M; i++) {
    diff[i - 1] = abs(P[i - 1] - P[i]);
  }
  sort(diff, diff + M - 1, greater<>());

  // for (int i = 0; i < M - 1; i++) {
  //   COUT("diff: " << diff[i]);
  // }

  int c = 0;
  for (int i = 0; i < M - 1; i++) {
    if (i < N - 1) {

    } else {
      c += diff[i];
    }
  }
  COUT(c);

  return 0;
}


Measured memory_bytes: 1408