akhauriyash/Code-Regression huggingface dataset:
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
ll n,m,k;
ll A[N],B[N];
ll sum,pos1=0,pos2=0,v,ans;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),m=read(),k=read();
	for(register ll i=1;i<=n;i++)A[i]=read();
	for(register ll i=1;i<=m;i++)B[i]=read();
	for(register ll i=1;i<=n;i++)
	{
		if(sum+A[i]<=k)sum+=A[i],v++,pos1=i;
		else break;
	}
	for(register ll i=1;i<=m;i++)
	{
		if(sum+B[i]<=k)sum+=B[i],v++,pos2=i;
		else break;
	}
	ans=v;
	for(register ll i=pos1;i>=1;i--)
	{
		v--;sum-=A[i];
		while(pos2+1<=m&&sum+B[pos2+1]<=k)sum+=B[++pos2],v++;
		ans=max(ans,v);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6820
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool flag = false;
    for (int i = 1; i < b; i++) {
        if((a*i) % b == c) flag = true;
    }

    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,p; cin >> a >> p;
  p+=3*a;
  int ans = p/2;

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


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#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 all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll llINF=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  ll l,r;
  cin>>l>>r;
  if(r-l>=10000){
    cout<<0<<endl;
    return 0;
  }
  ll ans=llINF;
  for(ll i=l;i<r;i++){
    for(ll j=i+1;j<=r;j++){
      ll cnt=(i*j)%2019;
      mins(ans,cnt);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("caitui.inp", "r", stdin);
    long long int n, w;
    cin >> n >> w;
    long long int m[n + 10], v[n + 10];

    long long int tong = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> m[i] >> v[i];
        tong += v[i];
    }
    long long int f[tong + 10];
    for (int i = 1; i <= tong; i++)
    {
        f[i] = 1000000000;
    }
    f[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int t = tong; t >= v[i]; t--)
        {
            f[t] = min(m[i] + f[t - v[i]], f[t]);
        }
    }
    for (int t = tong; t >= v[1]; t--)
    {
        if (f[t] <= w)
        {
            cout << t;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define re register
#define LL long long
#define mp std::make_pair
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#pragma GCC optimize(3)
#pragma GCC optimize("-fcse-skip-blocks")
inline int read() {
	char c=getchar();int x=0;while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
}
const int maxn=1e5+5;
std::set<int> e[2][maxn];
std::set<int>::iterator it;
typedef std::pair<int,int> pii;
std::map<pii,int> ma[2];
int n,tot;
pii q[maxn<<1];
int fa[maxn];
inline int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
inline pii get(int x,int y) {if(x<y) std::swap(x,y);return mp(x,y);}
inline void merge(int x,int y) {
	x=find(x),y=find(y);
	if(x==y) return;
	if(e[0][x].size()+e[1][x].size()<e[0][y].size()+e[1][y].size()) 
		std::swap(x,y);
	//printf("%d %d\n",x,y);
	e[0][y].erase(x);e[0][x].erase(y);
	for(it=e[0][y].begin();it!=e[0][y].end();++it) {
		int now=(*it);
		ma[0][get(now,y)]=0;ma[0][get(x,now)]=1;
		if(ma[1][get(x,now)]) q[++tot]=mp(x,now);
		e[0][x].insert(now);e[0][now].erase(y);e[0][now].insert(x);
	}
	e[1][y].erase(x);e[1][x].erase(y);
	for(it=e[1][y].begin();it!=e[1][y].end();++it) {
		int now=(*it);
		ma[1][get(y,now)]=0;ma[1][get(x,now)]=1;
		if(ma[0][get(x,now)]) q[++tot]=mp(x,now);
		e[1][x].insert(now);e[1][now].erase(y);e[1][now].insert(x);
	}
	fa[y]=x;
}
int main() {
	n=read();
	for(re int i=1;i<=n;i++) fa[i]=i;
	for(re int x,y,i=1;i<n;i++) {
		x=read(),y=read();
		e[0][x].insert(y),e[0][y].insert(x);
		if(x<y) std::swap(x,y);
		ma[0][mp(x,y)]++;
	}
	for(re int x,y,i=1;i<n;i++) {
		x=read(),y=read();
		e[1][x].insert(y),e[1][y].insert(x);
		if(x<y) std::swap(x,y);
		if(ma[0][mp(x,y)]) q[++tot]=mp(x,y);
		ma[1][mp(x,y)]++;
	}
	for(re int i=1;i<=tot;i++) merge(q[i].first,q[i].second);
	for(re int i=1;i<=n;i++) fa[i]=find(i);
	for(re int i=2;i<=n;i++) if(fa[1]!=fa[i]) {puts("NO");return 0;}
	puts("YES");return 0;
	return 0;
}


Measured memory_bytes: 61952
#include <bits/stdc++.h>
using namespace std;
int main()
{
	static vector<int> g[200005];
	int N,M;
	scanf("%d %d",&N,&M);
	int a,b;
	for(int i = 0; i < M; i++){
		scanf("%d %d",&a,&b);
		g[a].push_back(b);
        g[b].push_back(a);
	}
	for(int i = 0; i <g[1].size();i++){
		int num = g[1][i];
		for(int j = 0; j <g[num].size();j++){
			if(N==g[num][j]){printf("POSSIBLE");return 0;}
		}
	}
	printf("IMPOSSIBLE");
	return 0;	
}

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

void solve() {
	long long n;
	cin >> n;
	string ans;
	while (n > 0){
		n--;
		ans.push_back(char('a' + n%26));
		n /= 26;
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans;
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 3108
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li.reverse()
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)




Measured memory_bytes: 24028
import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */

object Main extends App {
  val sc = new Scanner(System.in)
  val (n, m) = (sc.nextInt, sc.nextInt)

  val edges = for(i <- 0 until m) yield (sc.nextInt - 1, sc.nextInt - 1)

  val counts = new Array[Int](n)

  edges.foreach { case (x, y) => {
    counts(x) += 1
    counts(y) += 1
  }}
  if(counts.forall(_ % 2 == 0)) println("YES")
  else println("NO")
}


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

int main()
{
	int N, X[200001] = {0}, A[200001] = { 0 };

	cin >> N;

	for (int i = 1; i <= N; i++) {
		scanf("%d",&X[i]);
		A[i] = X[i];
	}

	sort(A,A + N+1);

	int j = A[N / 2];

	for (int i = 1; i <= N; i++) {
		if (X[i] <= j)cout << A[N / 2+1] << endl;
		else cout << A[N / 2] << endl;
	}


	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; cin >> A >> B;
  int result = (A-1) * (B-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
// 2019-04-18
// Accepted
// 00 : 48 sec
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
} ;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
    while (x->left != NIL) x = x->left;
    return x;
}

Node * treeSuccesor(Node *x) {
    if ( x->right != NIL ) return treeMinimum(x->right);
    Node *y = x->parent;
    while (y != NIL and x == y->right) {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node *z) {
    Node *y; // delete node
    Node *x; // y.childlen

    // determin delete node
    if ( z->left == NIL or z->right == NIL) y = z;
    else y = treeSuccesor(z);

    // determin y.childlen
    if (y->left != NIL) {
        x = y->left;
    }
    else {
        x = y->right;
    }

    if (x != NIL) {
        x->parent = y->parent;
    }

    if (y->parent == NIL) {
        root = x;
    }
    else {
        if (y == y->parent->left) {
            y->parent->left = x;
        }
        else {
            y->parent->right = x;
        }
    }

    if (y != z) {
        z->key = y->key;
    }
    free(y);
}

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while ( x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }
        else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    }
    else {
        if ( z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

Node * find(Node *u, int k) {
    while (u != NIL and k != u->key) {
        if ( k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}


void inorder (Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, x;
    string com;

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        }
        else if (com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if ( t != NIL) printf("yes\n");
            else printf("no\n");
        } 
        else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if (com == "delete") {
            scanf("%d", &x);
            treeDelete(find(root, x));
        }
    }
}



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

using namespace std;

int main(int argc, char *argv[]) {
    int A, B;
    cin >> A >> B;

    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }

    int sum = A;
    int ans = 1;
    for (int i = 0; i < 100; i++) {
        if (sum >= B) {
            break;
        }
        sum += A;
        sum--; 
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

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

int main() {
    int N, T, A;
    cin >> N >> T >> A;

    vector<int> Hs(N);
    rep(i, N){
        cin >> Hs.at(i);
    }

    vector<double> tmps(N);
    rep(i, N){
        tmps.at(i) = T - Hs.at(i)*0.006;
    }


    double min_diff = 100000;
    int point;
    rep(i, N){
        double diff = A - tmps.at(i);
        if(diff < 0) diff *= -1;
        if(diff < min_diff){
            min_diff = diff;
            point = i+1;
        }
    }
    cout << point << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jul  7 20:59:16 2019

@author: sp8783
"""
import math

n,d= map(int,input().split())
lst =[list(map(int,input().split())) for i in range(n)]

ans = 0

for i in range(n):
    for j in range(i+1,n):
        if i != j:          
            tmp = 0
            for k in range(d):
                tmp = tmp + (lst[i][k] - lst[j][k])**2
            dis = math.sqrt(tmp)
            if dis == math.floor(dis):
                ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc =new Scanner(System.in);
		int H=sc.nextInt();	//縦
		int W=sc.nextInt();	//横
		String s[]=new String[H];
		for(int i=0;i<H;i++) s[i] = sc.next();	//文字列を配列に格納

		for(int i=0;i<H;i++){
			System.out.println(s[i]);
			System.out.println(s[i]);
		}
	}
} 

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N, D, A;
    cin >> N >> D >> A;
    vector<pll> X(N);
    REP(i, N) cin >> X[i].first >> X[i].second;
    sort(X.begin(), X.end());
    REP(i, N) X[i].second = (X[i].second + (A-1))/A;

    queue<pll> qu;
    ll cum = 0;
    ll cnt = 0;
    REP(i, N){
    	while(!qu.empty()){
    		pll tmp = qu.front();
    		if(tmp.first+2*D<X[i].first){
    			cum -= tmp.second;
    			qu.pop();
    		}else{
    			break;
    		}
    	}

    	ll val = max(0ll, X[i].second - cum);
    	cum += val;
    	cnt += val;
    	qu.push({X[i].first, val});
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 6656
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        s: chars
    }
    let mut r = 0i64;
    for i in 0..4{
        if s[i] == '+' {
            r += 1;
        }
        else {
            r -= 1;
        }
    }
    println!("{}", r);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int n, h, w, ans;
template <typename T>inline void in(T &x){
	T ch = getchar(), f = 1; x = 0;
	while(!isdigit(ch)) f = ch == '-' ? -1 : f, ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}
signed main(){
	in(n), in(h), in(w);
	while(n--){
		int a, b;
		in(a), in(b);
		ans += (h <= a) & (w <= b);
	}
	cout<<ans;
	return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;
string s;

int main() {
  cin >> n >> s;
  map<pair<string, string>, int> a, b;
  range(i, 0, 1 << n) {
    string sa, sb;
    string ta, tb;
    range(j, 0, n) {
      if((i >> j) & 1) sa += s[j];
      else ta += s[j];
    }
    husk(j, n - 1, -1) {
      if((i >> j) & 1) sb += s[j + n];
      else tb += s[j + n];
    }
    b[make_pair(sb, tb)]++;
    a[make_pair(sa, ta)]++;
  }
  long long res = 0;
  for(auto it : a) {
    res += 1LL * it.second * b[it.first];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 108288
# In peace, in love, in war, everything is the same

import math

ar = [[0]*201 for i in range(201)]
for i in range(1, 201, 1):
	for j in range(1, 201, 1):
		ar[i][j] = math.gcd(i, j)
		
n, ans = int(input()), 0
for i in range(1, n+1, 1):
	for j in range(1, n+1, 1):
		for k in range(1, n+1, 1):
			ans += ar[ar[i][j]][k]
print(ans)

Measured memory_bytes: 9060
n, m, d = map(int, input().split())


count = 0
if d == 0:
    print (n * (m - 1) / (n ** 2))
elif n % 2 == 0:
    N = n // 2
    count += min(d, N)
    count += 2 * max(0, (N - d))
    count *= 2
    print (count * (m - 1) / (n ** 2))
else:
    N = n // 2
    count += min(d, N)
    count += 2 * max(0, (N - d))
    count *= 2
    if N + 1 > d:
        count += 2
    # print (count)
    print (count * (m - 1) / (n ** 2))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define MAX 100
#define INF 800000000

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  vector<vector<char>> s(H+2,vector<char>(W+2));
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cin>>s.at(i).at(j);
    }
  }
  vector<vector<int>> belong(H+2,vector<int>(W+2,-1));
  int k=1;
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(s.at(i).at(j)=='#'){
        belong.at(i).at(j)=k;
        k++;
      }else{
        belong.at(i).at(j)=belong.at(i).at(j-1);
      }
    }
    for(int j=W;j>0;j--){
      if(belong.at(i).at(j)==-1){
        belong.at(i).at(j)=belong.at(i).at(j+1);
      }
    }
    if(belong.at(i).at(1)==-1){
      for(int j=1;j<=W;j++){
        belong.at(i).at(j)=belong.at(i-1).at(j);
      }
    }
  }
  for(int i=H;i>0;i--){
    if(belong.at(i).at(1)==-1){
      for(int j=1;j<=W;j++){
        belong.at(i).at(j)=belong.at(i+1).at(j);
      }
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      cout<<belong.at(i).at(j)<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll h,w,k;
        cin>>h>>w>>k;
        vvc G(h,vc(w));
        vvl Ans(h,vl(w));
        set<ll> Y;
        rep(i,h){
            rep(j,w){
                cin>>G[i][j];
                if(G[i][j]=='#'){
                    Y.insert(i);
                }
            }
        }
        ll now=1;
        ll pre=0;
        for(ll n:Y){
            bool check=false;
            rep(i,w){
                if(check&&G[n][i]=='#'){
                    now++;
                }
                if(G[n][i]=='#')check=true;
                rep2(j,pre,n+1){
                    Ans[j][i]=now;
                }
                if(i==w-1)now++;
            }
            pre=n+1;
        }
        rep2(i,pre,h){
            rep(j,w)Ans[i][j]=Ans[pre-1][j];
        }
        rep(i,h){
            rep(j,w)cout<<Ans[i][j]<<' ';
            cout<<endl;
        }
    }

Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;




int main() {
    string s;
    cin >> s;
    int c = 0;
    vector<int> ans(s.size());
    for (int i = 0; i < s.size(); i++) {
       
        if (s.at(i) == 'R') c++;
        else {
            ans[i] += c / 2;
            ans[i - 1] += (c+1) / 2;
            c = 0;
        }


    }

    reverse(s.begin(), s.end());
    reverse(ans.begin(), ans.end());

    for (int i = 0; i < s.size(); i++) {

        if (s.at(i) == 'L') c++;
        else {
            ans[i] += c / 2;
            ans[i - 1] += (c+1) / 2;
            c = 0;
        }


    }
    reverse(s.begin(), s.end());
    reverse(ans.begin(), ans.end());

    rep(i,s.size())cout << ans[i] <<" ";
    
}



Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
	map<string,int> ma;
	ma["SAT"]=1;
	ma["FRI"]=2;
	ma["THU"]=3;
	ma["WED"]=4;
	ma["TUE"]=5;
	ma["MON"]=6;
	ma["SUN"]=7;
	string s;cin>>s;
	cout<<ma[s]<<"\n";
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll A, B, C, K;
priority_queue<int> que;

signed main()
{
    cin >> A >> B >> C >> K;
    que.push(A);
    que.push(B);
    que.push(C);
    REP(i, K) {
        ll tmp = que.top() * 2;
        que.pop();
        que.push(tmp);
    }
    ll ans = 0;
    while(!que.empty()) {
        ans += que.top();
        que.pop();
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin>>n;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==1&&i%2==0){
      ans++;
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3628
def a(s):
    count = 0
    test = s[0]
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] and test[i] != 'A':
            # s = s[:i + 1] + 'A' + s[i + 2:]
            test += 'A'
            count += 1
        else:
            test += s[i]
    return count


s = input()
k = int(input())
if s[0] != s[-1] or k == 1:
    print(a(s) * k)
elif k == 2:
    new_s = s * 2
    print(a(new_s))
elif len(s) == s.count(s[0]):
    new_s = s * 2
    count_2 = a(new_s)
    print(count_2 * (k // 2) + a(s) * (k % 2))
else:
    new_s = s * 2
    count_2 = a(new_s)
    count_3 = a(new_s + s)
    diff = count_3 - count_2
    print(count_3 + (k-3) * diff)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		executeCountBalls();
	}

	private static void execute() {

		Scanner in = new Scanner(System.in);

		try {
			String s1 = in.nextLine();
			String s2 = in.nextLine();
			String s3 = in.nextLine();

			int  a = Integer.parseInt(s1);
			String[] s2Array = s2.split(" ");
			int b = Integer.parseInt(s2Array[0]);
			int c = Integer.parseInt(s2Array[1]);

			int sum  = a + b + c;

//			System.out.println(a + "," + b + "," + c );

			System.out.println(sum + " " + s3);
		} catch (NumberFormatException e) {
			// TODO 自動生成された catch ブロック
			System.out.println("");
//			e.printStackTrace();
		}

	}

	public static void execute_product() {

		Scanner in = new Scanner(System.in);

		try {
			int a  = in.nextInt();
			int b  = in.nextInt();

			if( (a*b)%2 == 0 ) {
				System.out.println("Even");
			} else {
				System.out.println("Odd");
			}
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}

	public static void executeCountBalls() {
		Scanner in = new Scanner(System.in);

		try {
			long N = in.nextLong();
			long A = in.nextLong();
			long B = in.nextLong();

			long surplus = N%(A+B);
			long surplusA = surplus >= A ? A : surplus;

			 long countA = N/(A+B) * A + surplusA;

			System.out.println(countA);
		} catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 22604
#include <bits/stdc++.h>
#define fr first
#define sc second
#define ll long long

using namespace std;
const int MN = 1e6+7;
const int MD = 1e9+7;
const ll BIG_INF = 1e18+7;
const int INF = 2147483645;

int a[MN], n;
string s[2];

int main()
{
    ll a, b;
    cin >> a >> b;
    cout << a*b/__gcd(a, b);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
int main()
{
   long long  n,t;
   double sum=0;
    while(cin>>n>>t)
    {
        for(int i=0;i<n;i++)
        {
            long long x,y;
            scanf("%lld%lld",&x,&y);
            sum=max(y/(x*1.0),sum);
        }
        printf("%.6lf\n",t*sum);
    }
    return 0;
}







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

int Pz[3][3],tmp[3][3],Dx[4]={0,1,0,-1},Dy[4]={1,0,-1,0};

void emblem(int *a,int *b){
  
  int i,j;
  
  for(i = 0;i < 3;i++){
    for(j = 0;j < 3;j++){
      if(!Pz[i][j]){
	*a = j;
	*b=i;
      }
    }
  }
}

void swap(int *a,int *b){
  
  int tmp;
  
  tmp =*a;
  *a = *b;
  *b = tmp;
}

int check(){
  
  int i,a,b=0;
  
  for(i = 0;i < 9;i++){
    a = Pz[i/3][i%3];
    if(a){
      a--;
      b += abs(i/3 - a/3) + abs(i%3 - a%3);
    }
  }
  
  return b;
  
}

int defain(int a,int b,int P,int D,const int shin){
  
  int i,I,A,B,result;
  
  I = check();
  if(I == 0){
    return D;
  }
  if(D + I > shin){
    return -1;
  }

  for(i = 0;i < 4;i++){
    A = a + Dx[i];
    B = b + Dy[i];
    if(~P && i==(P+2)%4) continue;
    if(!(0 <= A && A < 3 && 0 <= B && B < 3)) continue;
    swap(&Pz[b][a],&Pz[B][A]);
    result = defain(A,B,i,D+1,shin);
    if(~result) return result;
    swap(&Pz[b][a],&Pz[B][A]);
  }
  
  return -1;
  
}

int main(){
  
  int i,j,a,b,c,d;

  for(i = 0;i < 3;i++){
    for(j = 0;j < 3;j++){
      scanf("%d",&Pz[i][j]);
    }
  }

  emblem(&a,&b);
  for(c = 0;c < 100;c++){
    for(i = 0;i < 3;i++){
      for(j = 0;j < 3;j++) tmp[i][j]=Pz[i][j];
    }
    d = defain(a,b,-1,0,c);
    if(d != -1){
      printf("%d\n",d);
      break;
    }

    for(i = 0;i < 3;i++){
      for(j = 0;j < 3;j++) Pz[i][j]=tmp[i][j];
    }

    d = -1;
    if(c == 99) printf("%d\n",d);
  }

  return 0;
  
}



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



int main(){
    string s;
    cin>>s;
    bool ok=false;
    if(s[2]==s[3] && s[4]==s[5]) ok=true;
    cout<<(ok?  "Yes": "No")<<endl;
}

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

int main(){
	int n,i,a[10],b,j;
	while(cin >> n && n){
		for(i=0;i<10;i++){
			a[i] = 0;
		}
		for(i=0;i<n;i++){
			cin >> b;
			a[b]++;
		}
		for(i=0;i<10;i++){
			if(a[i] == 0) cout << "-" << endl;
			else{
				for(j=0;j<a[i];j++){
					cout << "*";
				}
				cout << "\n";
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from sys import exit

import sys
sys.setrecursionlimit(1000000000)
mod = 998244353

#############
# Main Code #
#############

N, K = getNM()
que = [getList() for i in range(K)]

dp = [0] * (N + 1) # dp[i] iの時の通りの数
imos = [0] * (N + 1) # imos[i]: dp[1] ~ dp[i]までの累計
dp[1] = 1
imos[1] = 1

# 貰うdp
# dp += dp[l] - dp[r]

for i in range(2, N + 1):
    for l, r in que:
        if i - l >= 0:
            dp[i] += imos[i - l] - imos[max((i - r - 1), 0)]
            dp[i] %= mod
    imos[i] = dp[i]
    imos[i] += imos[i - 1]
    imos[i] %= mod

print(dp[N] % mod)

"""
# 配るdp

dp = [0] * (N + 1)
dp[1] = 1
dp[2] = -1

for i in range(1, N + 1):
    dp[i] += dp[i - 1]
    dp[i] %= mod
    for l, r in que:
        if i + l <= N:
            dp[i + l] += dp[i]
        if i + r + 1 <= N:
            dp[i + r + 1] -= dp[i]
print(dp[N] % mod)
"""

Measured memory_bytes: 76988
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] imos = new int[n + 1];
        for (int i = 0; i < m; i++) {
            imos[sc.nextInt() - 1]++;
            imos[sc.nextInt()]--;
        }
        int count = 0;
        for (int i = 1; i <= n; i++) {
            if (imos[i - 1] == m) {
                count++;
            }
            imos[i] += imos[i - 1];
        }
		System.out.println(count);
   }
}


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

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

#define loop(i, n) for(int i = 0;i < n;i++)

int main(void){

    string a, b;
    cin >> a >> b;

    b.pop_back();

    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    long long K; cin >> K;
    if (K % 2 == 0 || K % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    long long a = 7%K;
    int b = 7%K;
    if (b == 0) {
        cout << 1 << endl;
        return 0;
    }
    REP(i, K) {
        b = (b * 10) % K;
        a += b;
        a %= K;
        if (a == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
import sys
s = list(input())
t = list(input())

if not (1 <= len(s) <= 100 and 1 <= len(t) <= 100):
    sys.exit()

if s == t:
    print('No')
    sys.exit()

s.sort()
t.sort(reverse=True)
result = []
result.append(''.join(s))
result.append(''.join(t))
result.sort()

if result[0] == ''.join(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9072
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli N, in;
lli ans = 1, minus = 1;
int main(){
	cin.tie(0);
	std::ios::sync_with_stdio(false);
	cin >> N;
	for(int i = 0; i < N; i++){
		ans*=3;
		cin >> in;
		if(in % 2 == 0) minus*=2;
	}
	cout << ans-minus;
	return 0;
}


Measured memory_bytes: 256
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_6.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

YES = "Yes"  # type: str
NO = "No"  # type: str

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    s = list(next(tokens))  # type: str
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int

    # write code
    x_axis = []
    y_axis = []
    i = 0
    cntT = 0
    cntF = 0
    for i in range(len(s)):
        if s[i] == 'T':
            if cntT % 2 == 0:
                x_axis.append(cntF)
            else:
                y_axis.append(cntF)
            cntT += 1
            cntF = 0
            continue
        else:
            cntF += 1
            continue
    if cntT % 2 == 0:
        x_axis.append(cntF)
    else:
        y_axis.append(cntF)


    x -= x_axis[0]
    del x_axis[0]
    # print(x_axis, y_axis)
    x_set = {x}
    y_set = {y}
    for num in x_axis:
        x_set = {i + k for i in x_set for k in {-num, num} if - 8000 <= i <= 8000}
    for num in y_axis:
        y_set = {i+k for i in y_set for k in {-num,num} if -8000<=i<=8000}

    # print(x_set, y_set)
    if 0 in x_set and 0 in y_set:
        print(YES)
    else:
        print(NO)



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

int main(){
  int N,a[200];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  
  int flag = 1;
  int count = 0;
  
  while(flag == 1){
    for(int i = 0;i < N;i++) {
      if(a[i] % 2 == 1){
        flag = 0;
        break;
        }
    }
    if(flag == 0) break;
    for(int i = 0; i < N; i++) {
      a[i] /= 2;
    }
    count++;  
  }
  cout << count << endl;
    
}

Measured memory_bytes: 3572
import bisect
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0

for b in B:
  num_a = bisect.bisect_left(A, b)
  num_c = n - bisect.bisect_right(C, b)
  ans += num_a * num_c
print(ans)

Measured memory_bytes: 23092
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int a, b;
    cin >> a >> b;
    int diff = b - a;

    int ans = (1 + diff) * diff / 2;
    cout << ans - b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int a[N];
int count=0;

void swap(int *x,int *y){
  int t=*x;
  *x=*y;
  *y=t;
}

void bubblesort(int n){
  int flag=1;
  /* flag: ????????£??\????´?(?????????????????????
     ????????§????°??????????????????£??????????????£???????´?)????????????????????? 1:true,0:false */
  int i;
  for(i=0;i<n;i++){ // ??????????????¨???????????????????´???????
    while(flag){  // flag==1????????????  flag==0???break
      flag=0;
      int j;
      for(j=n-1;j>i;j--){
	if(a[j]<a[j-1]){
	  swap(&a[j],&a[j-1]);
	  flag=1;
	  count++;
	}
      }
    }
  }
}

int main()
{
  int n;
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  
  bubblesort(n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i<n-1) printf(" ");
  }
  printf("\n%d\n",count);
  
  return 0;
}

Measured memory_bytes: 604
n,a,b = map(int, input().split())
maxint = 0
minInt = 0
if a <= b:
  maxInt = a
  minInt = a - (n-b)
else:
  maxInt = b
  minInt = b - (n-a)

if a +b < n :
    minInt = 0
print(maxInt, minInt)

Measured memory_bytes: 2940
a = list(map(int, input().split()))
ans = 300

for i, j, k in [(0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)]:
    ans = min([ans, abs(a[j]-a[i])+abs(a[k]-a[j])])

print(ans)

Measured memory_bytes: 3064
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    if a > 0 and b > 0:
        print("Positive")
    elif a * b < 0 or a * b == 0:
        print("Zero")
    else:
        print("Negative" if (a - b + 1) % 2 != 0 else "Positive")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38324
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll M=2e5;

ll col[M+1];ll in[M+1],out[M+1],T=0,ans[M+1]={},sum[M+1]={},prev[M+1]={};
void dfs(vector<vector<ll>> &adj,bool vis[],ll src){
	vis[src]=true;
	in[src]=T++;
	ll su=0;
	for(auto it: adj[src]){
		if(!vis[it]){
			ll a=col[src],b=col[it];
			ll tt=ans[a];
			dfs(adj,vis,it);
			
			ll z=out[it]-in[it];

			z=(z+1)/2;
			ll x=z-(ans[a]-tt);

		//	if(a==2)
				//cout<<'x'<<ans[a]<<endl;
			//cout<<src<<" "<<x<<endl;
			//if(a!=b)
			sum[a]-=(x*(x+1))/2;
			su+=x;
			ans[a]+=x;
			//ans[a]=0;

		}
	}
	
	out[src]=T++;
	ans[col[src]]+=1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll i,j;
	
	for(i=1;i<=n;i++)
		cin>>col[i];
	vector<vector<ll>> adj(n+1);
	for(i=1;i<n;i++){
		ll a,b;cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	bool vis[n+1]={};
	dfs(adj,vis,1);
ll zz=(n*(n+1))/2;
//cout<<ans[3]<<endl;
for(i=1;i<=n;i++){
	//if(sum[i]==0)
		ll a=col[1],b=i;
			ll z=out[1]-in[1];
			z=(z+1)/2;
			ll x=z-ans[b];
			//cout<<src<<" "<<x<<endl;
			if(a!=b)
			sum[b]-=(x*(x+1))/2;
	cout<<zz+sum[i]<<endl;
}
	return 0;
} 

Measured memory_bytes: 40788
fun main() {
    val n = readLine()!!.toInt()
    val input = mutableListOf<String>()
    for (i in 0 until n) {
        input.add(readLine()!!)
    }
    val l = input.groupingBy { it }.eachCount().toList().sortedBy { it.first }.sortedByDescending { it.second }
    val maxPoll = l.first().second
    for(i in 0 until l.size) {
        if(l[i].second != maxPoll){
            break
        }
        println(l[i].first)
    }
}


Measured memory_bytes: 88640
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	long double ans, hoge = 0;
	vector<int> p;
	
	cin>>N>>K;
	
	p.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>p[i];
	}
	
	for(int i = 0, j = 0; i + K - 1 < N; i++){
		for(; j < N; j++){
			if(j >= i + K) break;
			hoge += ((long double)p[j] + 1)/2;
		}
		
		ans = max(hoge, ans);
		
		hoge -= ((long double)p[i] + 1)/2;
	}
	
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
/* S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
__gcd()　lower_bound(a+l,a+r,x)-a でindex
配列  -> min/max({}) 
vector-> *min_element(a.begin()+l,a.begin()+r)  *忘れず lとrで[l,r) 
reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
clock()/CLOCKS_PER_SEC で秒数 int ti=clock() ok
q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
<deque>(push/pop)_(front/back)/fornt/back/insert/
priority_queue 宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに*/
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define range(i, s, n) for (int i = (s); i < (n); ++(i))
#define lange(i, s, n) for (long long i = (s); i < long long (n); ++(i))
#define rrep(i,n) for(int (i)=(n)-1;(i)!=-1;--(i))
#define vep(i,v) for(auto (i)=v.begin();distance((i),(v.end()))>0;++(i))
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; }
template<class T> inline T GCD(T a, T b) { return b?GCD(b,a%b):a;}
template<class T> inline T LCM(T a, T b) { return a/GCD(a,b)*b;}
inline long long ceildiv(long long a, long long  b) { return (a+b-1)/b; }
template<class T> inline T modinv(T a, T M) { return (1-M*modinv(M%a,a))/a+M;}
typedef pair<long long,long long> P;
typedef pair<int,long long> Pil;

typedef pair<int,int> PI;
typedef std::vector<int> vi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<std::vector<long long>> vvl;
typedef std::vector<char> vc;
typedef std::vector<std::vector<char>> vvc;
typedef std::vector<long long> vl;
typedef std::vector<bool> vb;
typedef std::vector<std::vector<bool>> vvb;
using Graph = std::vector<std::vector<int> >;
const long long inf = 10e17;
const long long mod = 1000000007;
//int |x|<=2*10**9     long |x|<= 9*10**18
//printf(".(小数点以下の桁数)lf(double時、float ならf)")
#define ll long long
#define print(i) std::cout << (i) << '\n'
#define eb emplace_back
int main(){

int n,m,s,t;cin>>n>>m;
vvi e(3*n+3,vi{});
int x,y;
rep(i,m){cin>>x>>y;x*=3;y*=3;
e[x].eb(y+1);
e[x+1].eb(y+2);
e[x+2].eb(y);}
queue<pair<int,ll>> q;
cin>>s>>t;s*=3;t*=3;
vl dist(3*n+5,-1);
dist[s]=0;
q.push(Pil(s,0));
while(!q.empty()){
    auto p=q.front();q.pop();
    int now=p.first;ll cost=p.second;
    if (t==now){print(cost/3);return 0;}
  	++cost;
    for(auto next:e[now]){if (dist[next]==-1){q.push(Pil(next,cost));dist[next]=cost;}}

}
print(-1);}


Measured memory_bytes: 21940
from collections import defaultdict, deque

def main():
    n, m = map(int, input().split())
    edges = defaultdict(list)

    for _ in range(m):
        a, b = [int(s) - 1 for s in input().split()]
        edges[a].append(b)
        edges[b].append(a)
    
    visited = 1
    pos = 0
    mask = (1 << n) - 1
    print(solve(edges, pos, visited, mask))
    
def solve(edges, pos, visited, mask):
    if visited == mask:
        return 1

    s = 0
    for e in edges[pos]:
        if ((1 << e) & visited) == 0:
            s += solve(edges, e, visited | (1 << e), mask)
    
    return s

main()


Measured memory_bytes: 3316
#include<stdio.h>

int LinearSearch(int a[], int key, int N) {
	int i = 0;
	a[N] = key;
	while (a[i] != key)i++;
	if (i == N)return -1;
	else return i;
}

int main() {
	int n, q;
	int S[10000], T[500];
	int cnt = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d", &T[i]);
	}
	for (int j = 0; j < q; j++) {
		if (LinearSearch(S, T[j],n) != -1) {
			cnt++;
		}
	}
	printf("%d\n", cnt);


	return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	
	long long sum = 0;
	vector<long long> a(n);
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	
	long long tmp = 0;
	long long ans = 2*(*max_element(a.begin(), a.end()));
	for(int i = 0; i < n - 1; i++)
	{
		tmp += a[i];
		
		long long ttmp = sum - 2*tmp > 0 ? sum - 2*tmp : 2*tmp - sum;
		
		if(ans > ttmp)
		{
			ans = ttmp;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
s = input()
q = int(input())
turn = 1
start = []
end = []
for i in range(q):
    q_list = list(input().split())
    if q_list[0] == "1":
        turn *= -1
    else:
        if q_list[1] == "1":
            if turn == 1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])
        else:
            if turn == -1:
                start.append(q_list[2])
            else:
                end.append(q_list[2])

dum1 = "".join(start)
dum2 = "".join(end)
if turn == 1:
    print(dum1[::-1]+s+dum2)
else:
    print(dum2[::-1] + s[::-1] + dum1)

Measured memory_bytes: 5876