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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;

/* [💭] [💡] [🎈] */

const ll mod = 1000000007;

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

    int n, k;
    cin >> n >> k;

    priority_queue<int> pos, neg;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x < 0) neg.emplace(-x);
        if (x > 0) pos.emplace(x);
    }

    // has excess 0s
    if (k > (pos.size() + neg.size())) {
        cout << 0;
        return 0;
    }

    // has no positives and odd k
    if (!pos.size() && (k & 1)) {
        // has 0s
        if (n > (pos.size() + neg.size())) {
            cout << 0;
            return 0;
        }

        // has no 0s
        ll p = 1;
        priority_queue<int> revneg;
        while (neg.size()) {
            revneg.emplace(-neg.top());
            neg.pop();
        }
        while (k--) {
            p = p * (mod + revneg.top()) % mod;
            revneg.pop();
        }

        cout << p;
        return 0;
    }

    
    if (pos.size() + neg.size() == k && (neg.size() & 1) && n > (pos.size() + neg.size())) {
        cout << 0;
        return 0;
    }

    ll p = 1;
    int l = k;
    while (l >= 1) {
        if (pos.size() >= 2 && neg.size() >= 2 && l >= 2) {
            ll p1 = pos.top();
            pos.pop();
            ll p2 = pos.top();
            pos.emplace(p1);
            ll n1 = neg.top();
            neg.pop();
            ll n2 = neg.top();
            neg.emplace(n1);
            if (p1 * p2 > n1 * n2) {
                p = ((p * p1) % mod * p2) % mod;
                pos.pop();
                pos.pop();
            } else {
                p = ((p * n1) % mod * n2) % mod;
                neg.pop();
                neg.pop();
            }
            l -= 2;
        } else if (neg.size() >= 2 && l >= 2) {
            ll n1 = neg.top();
            neg.pop();
            ll n2 = neg.top();
            neg.emplace(n1);
            p = ((p * n1) % mod * n2) % mod;
            neg.pop();
            neg.pop();
            l -= 2;
        } else if (pos.size()) {
            p = (p * pos.top()) % mod;
            pos.pop();
            l--;
        } else {
            p = (-p * neg.top()) % mod;
            neg.pop();
            l--;
        }
    }

    p = ((p % mod) + mod) % mod;
    cout << p;

    return 0;
}

Measured memory_bytes: 4380
import collections

N = int(input())
D = list(map(int, input().split()))

ans = 1
m = max(D)
c = collections.Counter(D)

if 0 not in c.keys() or (c[0] != 1 or D[0] != 0):
    print(0)
    exit()

temp = 1
for i in range(1, m+1):
    if i not in c.keys():
        print(0)
        exit()
    ans *= temp**c[i]
    temp = c[i]
    if ans > 998244353:
        ans %= 998244353  

print(ans % 998244353)

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e5+9;
 
int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    char s;
    cin>>s;
    cout<<(islower(s)?'a':'A');
    
    
    
    
}


Measured memory_bytes: 3644
ABCD = list(input())

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

AA = ABCD[0]
BB = ABCD[1]
CC = ABCD[2]
DD = ABCD[3]

if A+B+C+D==7:
    print(AA+'+'+BB+'+'+CC+'+'+DD+'=7')
elif A+B+C-D==7:
    print(AA+'+'+BB+'+'+CC+'-'+DD+'=7')
elif A+B-C+D==7:
    print(AA+'+'+BB+'-'+CC+'+'+DD+'=7')
elif A+B-C-D==7:
    print(AA+'+'+BB+'-'+CC+'-'+DD+'=7')
elif A-B+C+D==7:
    print(AA+'-'+BB+'+'+CC+'+'+DD+'=7')
elif A-B+C-D==7:
    print(AA+'-'+BB+'+'+CC+'-'+DD+'=7')
elif A-B-C+D==7:
    print(AA+'-'+BB+'-'+CC+'+'+DD+'=7')
elif A-B-C-D==7:
    print(AA+'-'+BB+'-'+CC+'-'+DD+'=7')

Measured memory_bytes: 62040
#include<cstdio>
#include<cmath>
#include<iostream>
#define PI 3.14159265358979
double rad(double a){
  return a*PI/180.0;
}

int main(){
  int a,b;
  int th=0;
  double x = 0, y = 0;
  while(scanf("%d,%d",&a,&b)){
    if(a==0&&b==0)break;
    x+=(double)a*sin(rad(th));
    y+=(double)a*cos(rad(th));
    th+=b;
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    char x, y;
    cin >> x >> y;
    if(x < y) cout << "<" << "\n";
    else if(x > y) cout << "> " << "\n";
    else cout << "=" << "\n";

    return 0;
}


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

using namespace std;

bool chk(int x) {
    if (x <= 3) return (x >= 2);
    if (x % 2 == 0 || x % 3 == 0) return false;
    for (int i = 5; i * i <= x; i += 6) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
    }
    return true;
}

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

    int x;
    cin >> x;
    while (1) {
        if (chk(x)) {
            cout << x << '\n';
            return 0;
        }
        x++;
    }
}

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

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    int i = 1;
    bool judge = true;
    
    do {
        if(i%2 != 0) c = c - b;
        else a = a - d;

        if (a<=0 || c<=0) judge = false;
        i++;
    } while(judge);

    if(i%2 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3560
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_B
# Rooted Trees
# Result:
import sys

class Node(object):
    def __init__(self, id_):
        super(Node, self).__init__()
        self.id_ = id_
        self.parent = None
        self.left = None
        self.right = None

    def set_child(self, left, right):
        self.left = left
        self.right = right

    def set_parent(self, parent):
        assert self.parent == None
        self.parent = parent

    def sibling(self):
        if self.parent == None: return None
        if self.parent.left == self:
            return self.parent.right
        else:
            return self.parent.left

    def degree(self):
        degree = 0
        if self.left != None: degree += 1
        if self.right != None: degree += 1
        return degree

    def depth(self):
        depth = 0
        p = self.parent
        while p != None:
            depth += 1
            p = p.parent
        return depth

    def height(self):
        return self._height(self)

    def _height(self, n):
        assert n != None
        if n.left == None and n.right == None: return 0
        hl = self._height(n.left) + 1 if n.left != None else 0
        hr = self._height(n.right) + 1 if n.right != None else 0
        return hl if hl > hr else hr

    def __str__(self):
        str_ = 'node %d: ' % (self.id_)
        parent_id = self.parent.id_ if self.parent != None else -1
        str_ += 'parent = %d, ' % (parent_id)
        sibling_id = self.sibling().id_ if self.sibling() != None else -1
        str_ += 'sibling = %d, ' % (sibling_id)
        str_ += 'degree = %d, ' % (self.degree())
        str_ += 'depth = %d, ' % (self.depth())
        str_ += 'height = %d, ' % (self.height())
        if self.depth() == 0:
            str_ += 'root'
        elif self.degree() != 0:
            str_ += 'internal node'
        else:
            str_ += 'leaf'
        return str_


nnodes = int(sys.stdin.readline())
nodes = []
for i in range(0, nnodes):
    nodes.append(Node(i))

# set parent and child
for _ in range(0, nnodes):
    vals = sys.stdin.readline().rstrip().split(' ')
    node_id = int(vals[0])
    left_id_ = int(vals[1])
    right_id_ = int(vals[2])
    node = nodes[node_id]
    left_ = nodes[left_id_] if left_id_ != -1 else None
    right_ = nodes[right_id_] if right_id_ != -1 else None
    node.set_child(left_, right_)
    if left_ != None:
        left_.set_parent(node)
    if right_ != None:
        right_.set_parent(node)

for node in nodes:
    print node

Measured memory_bytes: 4384
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    readln.chomp.map!(ch => ch == 'A' || ch == 'G' || ch == 'C' || ch == 'T')
                .group
                .map!(pair => pair[0] ? pair[1] : 0)
                .reduce!max
                .writeln;
}


























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(a) for(int i = 0; i < a; ++i)
int main(){
  int N;
  cin >> N;
  int t[110000], x[110000], y[110000];
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep(N) cin >> t[i+1] >> x[i+1] >> y[i+1];
  
  bool can = true;
  rep(N){
    int dt = t[i+1] - t[i];
    int dst = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if(dt < dst || dt%2 != dst%2) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include<stdio.h>

int main(){
  int sx,sy,tx,ty;
  scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
  int a = tx - sx;
  int b = ty - sy;
  int i;
  for(i=0;i<=b-1;i++)
    printf("U");
  for(i=0;i<=a-1;i++)
    printf("R");

  for(i=0;i<=b-1;i++)
    printf("D");
  for(i=0;i<=a-1;i++)
    printf("L");

  printf("D");
  for(i=0;i<=a;i++)
    printf("R");
  for(i=0;i<=b;i++)
    printf("U");
  printf("L");

  printf("U");
  for(i=0;i<=a;i++)
    printf("L");
  for(i=0;i<=b;i++)
    printf("D");
  printf("R");
}

Measured memory_bytes: 128
(defn make-vec
  [n]
  (->>
    (clojure.string/split (str n) #" ")
    (map #(Integer/parseInt %))))

(defn abc-125a
  []
  (let [v (make-vec (read-line))
        a (nth v 0)
        b (nth v 1)
        t (+ 0.5 (nth v 2))]
    (loop [cnt 0
           idx 1]
      (if (< t (* idx a))
        cnt
        (recur
          (+ cnt b)
          (inc idx))))))

(prn (abc-125a))

Measured memory_bytes: 66556
#include <bits/stdc++.h>
using namespace std;
const char s[5]="RYGB";
int h,w,d;
char res[505][505];
int main()
{
    scanf("%d%d%d",&h,&w,&d);
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j) {
            int x=(i+j)/d,y=(i-j+w-1)/d;
            res[i][j]=s[(x&1)*2+(y&1)];
        }
    for (int i=0;i<h;++i)
        puts(res[i]);
    return 0;
}


Measured memory_bytes: 768
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



int main()
{
    int x,y;
    cin>>x>>y;
    if(x<=y)
    cout<<x;
    else
    cout<<x-1;

    return 0;
} 

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;
template<class T> using V = vector<T>;
using I = int;
using VI = V<I>;
const int INF = 2e9;
const int64 MOD = 1e9 + 7;

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

int gcd(int a, int b) {
    if(a<b) swap(a,b);
    return b ? gcd(b, a%b) : a;
}

int tri_gcd(int a , int b , int c){
    int d = gcd(a , b);
    return gcd( c , d);
}

int main(){
    int k; cin >> k;
    uint64 sum = 0;
    for(int a=1 ; a <= k ; ++a){
        for(int b=1 ; b <= k; ++b){
            for(int c=1 ; c <= k ; ++c){
                sum+=tri_gcd( a , b , c);
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  string S;
  cin >> S;

  stack<int> A;
  REP(i,S.size()){
    if(S.at(i)=='0'){
      A.push(0);
    }else if(S.at(i)=='1'){
      A.push(1);
    }else{
      if(!A.empty()){
        A.pop();
      }
    }
  }
  stack<int> B;
  while(!A.empty()){
    B.push(A.top());
    A.pop();
  }

  while(!B.empty()){
    cout << B.top();
    B.pop();
  }
  cout << endl;
}

Measured memory_bytes: 256
import           Control.Applicative()
import           Data.List

main :: IO ()
main = do
    s <- getLine
    let t = sort s
    putStrLn $ if t !! 0 == t !! 1 && t !! 2 == t !! 3 && t !! 1 /= t !! 2
        then "Yes"
        else "No"
    



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


int main(){
    int64_t A,B,N;
    cin >> A >>B >> N;


    int64_t x;
    
    x = B-1;

    if(x > N){
        x = N;
    }

    int ans;
    ans =  (A*x)/B;
    
    cout << ans << endl;

}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int MAX = 1e5 + 100;
vector<int> adj[MAX];

map<pair<int,int>,int> m;

void dfs(int cur, int par, int prev){
	int cnt = 1;
	for(auto x : adj[cur]){
		if(x != par){
			if(cnt == prev){
				cnt++;
			}
			m[{cur,x}] = cnt;
			m[{x,cur}] = cnt;
			dfs(x,cur,cnt);
			cnt++;
		}
	}
}


int32_t main(){
	int n;
	cin >> n;
	vector<pair<int,int>> v;
	for(int i = 0; i < n-1; i++){
		int x, y;
		cin >> x >> y;
		v.push_back({x,y});
		adj[x].push_back(y);
		adj[y].push_back(x);		
	}
	int start, maxDeg = 0;
	for(int i = 1; i <= n; i++){
		if(adj[i].size() == 1){
			start = i;
		}
		maxDeg = max(maxDeg,(int)adj[i].size());
	}
	dfs(start,-1,-1);
	
	cout << maxDeg << endl;
	for(int i = 0; i < n; i++){
		if(m.count({v[i].F,v[i].S})){
			cout << m[{v[i].F,v[i].S}] << endl;
		}
		else if(m.count({v[i].S,v[i].F})){
			cout << m[{v[i].S,v[i].F}] << endl;
		}
	}

	return 0;
}



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

using namespace std;

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

    vector <int> c(N);
    vector <int> t(N);

    for(int i = 0; i < N; i++){
        cin >> c[i] >> t[i];
    }

    int min = *max_element(c.begin(), c.end()) + 1;
    int o_min = min;
    for(int i = 0; i < N; i++){
        if (t[i] <= T) {
            if (min >= c[i]) {
                min = c[i];
            }
        }
    }
    if (min != o_min) {
        cout << min << endl;
    }else{
        cout << "TLE" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cctype>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<set>
#define LL long long
#define ULL unsigned  long long
#define maxn (LL)1e5
#define INF 0x3f3f3f3f
#define inf 0x7fffffff
#define PI  acos(-1.0)
#define pb push_back
#define re register LL
const double eps = 0.0000001;
using namespace std;
typedef pair<LL,LL> pii;
inline LL sgn(double x)
{
    return (x > eps) - (x < -eps);
}
const LL N=1e6+2;
const LL mod=1e9+7;
int f[2010];
LL mul(LL a,LL b,LL mod)
{
    LL ans=0;
    for(;b;b>>=1)
    {
        if(b&1)
        {
            ans=ans+a%mod;
        }
        a=a*2%mod;
    }
    return ans%mod;
}
int main()
{
   int n;
   LL k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
       cin>>f[i];
   int num1=0;
   for(int i=1;i<=n;i++)
       for(int j=1;j<=n;j++)
           if(f[i]>f[j]) num1++;
   int num=0;
   for(int i=1;i+1<=n;i++)
       for(int j=i+1;j<=n;j++)
       if(f[j]<f[i]) num++;
   cout<<(LL)(mul((LL)num,k,mod)+mul(k*(k-1)/2,(LL)num1,mod))%mod;
}
 

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

int main() {
   long long N,A,B;
   cin >> N >> A >> B;
   if ((A-B)%2==0) cout << abs(A-B)/2 << endl;
   else cout << min(A-1,N-B)+abs(A-B)/2+1 << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
#define ll long long
ll mod = 1000000000+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    ll T;
    T=1;
    //cin>>T;
    start:
    while(T--)
    {
        map<string,int> m;
        m["AC"] = 0;
        m["WA"] = 0;
        m["TLE"] = 0;
        m["RE"] = 0;
        ll n;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            string s;
            cin>>s;
            m[s]++;
        }
        cout<<"AC"<<" x "<<m["AC"]<<endl;
        cout<<"WA"<<" x "<<m["WA"]<<endl;
        cout<<"TLE"<<" x "<<m["TLE"]<<endl;
        cout<<"RE"<<" x "<<m["RE"]<<endl;
        
    }
    return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define MEM 100001
#define sanic ios_base::sync_with_stdio(0)
using namespace std;
const long long MOD = 1e9+9;
long long a,b,t;
long long p[MEM];
long long f(long long a){
    if(a==1) return 1;
    return 2*f(a/2)+1;
}
int main() {
    cin >> a;
    cout << f(a);
}


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

double dp[AMAX][AMAX][AMAX];
int n;

double f(int a, int b, int c) {
  if(dp[a][b][c] != 0) return dp[a][b][c];
  double nu = 1 - (double)(n - a - b - c) / n, ret = 1 / nu;
  if(a > 0) ret += f(a - 1, b, c) * a / n / nu;
  if(b > 0) ret += f(a + 1, b - 1, c) * b / n / nu;
  if(c > 0) ret += f(a, b + 1, c - 1) * c / n / nu;
  dp[a][b][c] = ret;
  return ret;
}

int main() {
  int a[3] = {0, 0, 0}, A;
  scanf("%d", &n);
  dp[1][0][0] = n;
  for(int i = 0; i < n; i++) {
    scanf("%d", &A);
    a[A - 1]++;
  }
  printf("%.10lf\n", f(a[0], a[1], a[2]));
}

Measured memory_bytes: 213248
#include <bits/stdc++.h>
using namespace std;
const long long INF = -1e18;
const int MAX = 3000;
int n, m;
struct edge {
	int from , to;
	long long cost;
};
edge e[MAX];
long long d[MAX];
void bellmanford() {
	fill(d, d + MAX, INF);
	d[0] = 0;
	for(int i = 0; i < n; i++) {
		bool flag = false;
		for(int j = 0; j < m; j++) {
			edge tmp = e[j];
			if(d[tmp.from] != INF && d[tmp.to] < d[tmp.from] + tmp.cost) {
				d[tmp.to] = d[tmp.from] + tmp.cost;
				if(tmp.to == n - 1) {
					flag = true;
				}
			}
		}
		if(i == n - 1 && flag) {
			cout << "inf" << endl;
			exit(0);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		e[i] = edge{a, b, c};
	}
	bellmanford();
	cout << d[n - 1] << endl;
	return 0;	
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0, k) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)#n
c=list(set(b))
c.sort()
kosuu_list=[]
kosuu=1
for i in range(len(b)-1):
    #kosuu=0
    #print(b[i])
    if b[i]==b[i+1]:
        kosuu+=1
    else:
        kosuu_list.append(kosuu)
        kosuu=1
kosuu_list.append(b.count(b[-1]))
#print(kosuu_list)
count=0
#print(c)
for i in range(len(c)):
    if kosuu_list[i]==c[i]:
        count+=0
    elif kosuu_list[i]>=c[i]:
        count+=kosuu_list[i]-c[i]
    else:
        count+=kosuu_list[i]
print(count)

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

string s;
int n,q;
vector<int> l(200000);
vector<int> r(200000);
vector<int> a(200000);
vector<int> ans(200000);

int main() {
    cin >> n >> q >> s;

    int counts = 0;

    for (int i = 0; i < q; ++i) {
        cin >> l.at(i) >> r.at(i);
    }

    for (int i = 0; i < n; ++i)
    {
        if (i == n-1)
        {
            a.at(i) = counts;
            break;
        }

        if (s.at(i) == 'A' && s.at(i+1) == 'C') {
            a.at(i) = counts;
            counts++;
            a.at(i+1) = counts;
        } else {
            a.at(i) = counts;
        }
    }

    for (int i = 0; i < q; ++i)
    {
        ans.at(i) = a.at(r.at(i)-1) - a.at(l.at(i)-1);
    }



    for (int i = 0; i < q; ++i) cout << ans.at(i) << endl;

}

Measured memory_bytes: 4224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e18;

ll N,A,B,C,D;
string ans;
int main(){
    cin >> N >> A >> B >> C >> D;
    ans="NO";
    REP(i, 0, N){
        if(CK(B-A,-D*(N-i-1)+C*i, -C*(N-i-1)+D*i+1)){
            ans="YES";
            break;
        }
    }
    p(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, m, k;
    cin >> n >> m >> k;
    ll a[n+1], b[m+1], prefix_sum[n+1], prefix_sum1[m+1];
    prefix_sum[0] = 0;
    prefix_sum1[0] = 0;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        prefix_sum[i] = prefix_sum[i-1] + a[i];
    }
    for(int i = 1; i <= m; ++i){
        cin >> b[i];
        prefix_sum1[i] = prefix_sum1[i-1] + b[i];
    }
    ll mx = 0;
    for(int i = 0; i <= n; ++i){
        ll diff = k - prefix_sum[i], ans = 0;
        if(diff < 0)
            break;
        ll low = 1, high = m;
        while(low <= high){
            ll mid = (low + high)/2;
            if(prefix_sum1[mid] <= diff){
                ans = mid;
                low = mid + 1; 
            }
            else
                high = mid - 1;
        }
        mx = max(mx, i+ans);  
    }
    cout << mx;
    return 0;
}


Measured memory_bytes: 9896
import collections


def main():
    N = int(input())
    S = [input()for n in range(N)]
    counter = [100] * 26
    for s in S:
        S_count = collections.Counter(s)
        for i in range(26):
            counter[i] = min(counter[i], S_count[chr(i + 97)])

    ans = ''
    for i in range(26):
        ans = ans + (chr(i + 97) * counter[i])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9336
import java.util.*;

class Main{
    public static final int MAX_NUM = 1000000;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int q = sc.nextInt();
        sc.nextLine();

        LinkedList<Integer> List = new LinkedList<Integer>();
        ListIterator<Integer> it = List.listIterator();

        for(int i=0;i<q;i++){
            int order = sc.nextInt();
            switch(order){
                case 0:
                    int x = sc.nextInt();
                    it.add(x);
                    it.previous();
                    break;
                case 1:
                    int d = sc.nextInt();
                    if(d > 0){
                        for(int j=0;j<d;j++)it.next();
                    }else{
                        for(int j=0;j<-d;j++)it.previous();
                    }
                    break;
                case 2:
                    it.next();
                    it.remove();
                    break;
            }
        }
        for(Integer i:List) System.out.println(i);
    }
}


Measured memory_bytes: 309376
#include<iostream>
using namespace std;
int main() {
    int number1;
    int number2;
    int answer = 0;

    cin >> number1;
    cin >> number1;
    cin >> number2;
    cin >> number2;
    if((number1+1) != number2) {
        answer = 1;
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

double abs(double a);
int main(void) {
	int n, t, a;
	scanf("%d %d %d", &n, &t, &a);
	int h[n], ans;
	double tmp = 1e9;
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		double cmp = (double)t - (double)h[i] * 0.006;
		if(abs(cmp - a) < tmp) tmp = abs(cmp - a), ans = i + 1;
	}
	printf("%d\n", ans);
	return 0;
}

double abs(double a) {
	if(a < 0) return -a;
	else return a;
}



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

#define int long long

using namespace std;

vector <int> vec[26];
string s, t;
int ptr[26];

bool calc (int x, int num, long long start) {
    if (start % (int)s.length() == 0) return true;
    return (vec[num][x] - 1) % (int)s.length() > (start - 1) % (int)s.length();
}

void solve (long long start, int pos) {
    if (pos == t.length()) {
        cout << start;
        exit(0);
    }

    int num = t[pos] - 'a';
    if (vec[num].size() == 0) {
        cout << -1;
        exit(0);
    }

    int l = 0, r = vec[num].size() - 1;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (calc(mid, num, start)) r = mid - 1;
        else l = mid + 1;
    }

    if (l == vec[num].size()) l = 0;
    int fpos = vec[num][l];
    long long cur = fpos;
    if (fpos <= start) {
        long long temp = start - fpos;
        temp = temp / (int)s.length() + 1;
        cur += 1LL * temp * (int)s.length();
    }

    solve(cur, pos + 1);
}

int32_t main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++) vec[s[i] - 'a'].push_back(i + 1);
    solve(0, 0);
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string str;
    int ans=0;
    cin>>str;
    for(int i=0;i<str.size()-1;i++){
        if(str[i]=='B'&&str[i+1]=='W'){
            ans++;
        }else if(str[i]=='W'&&str[i+1]=='B'){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,weight; cin >> n >> weight;
    vi v(n), w(n);
    rep(i,n) cin >> v[i] >> w[i];

    vi dp(1e4+1100);  // 添え字:重さ, 中身:価値の合計
    for(int i = 0; i <= 1e4; ++i) {
        for(int j = 0; j < n; ++j) {
            /*if(i+w[i] <= 1e4)*/ chmax(dp[i+w[j]], dp[i] + v[j]);
        }
    }
    cout << dp[weight] << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3228
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
using namespace std;

long long mod_prod(long long a, long long b) {
	long long ret;
	ret = (a * b) % 1000000007;
	return ret;
}

long long N, cnt[26];
long long ans;
char S[100001];

int main(void) {
	scanf("%lld", &N);
	scanf("%s", S);

	for (int i = 0; i < 26; i++) {
		cnt[i] = 0;
	}

	for (int i = 0; i < N; i++) {
		cnt[S[i] - 'a'] += 1;
	}

	ans = 1;
	for (int i = 0; i < 26; i++) {
		ans = mod_prod(ans, cnt[i] + 1);
	}
	ans = (ans - 1 + 1000000007) % 1000000007;

	printf("%lld\n", ans);
}

Measured memory_bytes: 384
import java.util.*;
import java.io.*;
public class Main {
    static ArrayList<Integer> adj_lst[];
    static long dp[][],mod=1000000007L;
    public static void main(String args[]){
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        adj_lst=new ArrayList[n];
        for(int i=0;i<adj_lst.length;i++) {
            adj_lst[i]=new ArrayList<Integer>();
        }
        for(int i=0;i<n-1;i++) {
            int u=input.nextInt()-1;
            int v=input.nextInt()-1;
            adj_lst[u].add(v);
            adj_lst[v].add(u);
        }
//        for(int i=0;i<adj_lst.length;i++) {
//            System.out.print(i+"->");
//            for(int j=0;j<adj_lst[i].size();j++) {
//                System.out.print(adj_lst[i].get(j)+" ");
//            }
//            System.out.println();
//        }
        dp=new long[n][2];
        for(int i=0;i<n;i++) {
            for(int j=0;j<2;j++) {
                dp[i][j]=-1L;
            }
        }
        System.out.println(BFS(0,-1,1));
    }
    //color     0->black    1->white
    static long BFS(int root, int parent,int parent_clr) {
//        System.out.println(source+" "+parent+" "+parent_clr);
        if(adj_lst[root].size()==1 && adj_lst[root].get(0)==parent) {
            if(parent_clr==0) {
                return 1;
            }
            return 2;
        }
        if(dp[root][parent_clr]!=-1) {
            return dp[root][parent_clr];
        } 
        long ways=1,ways1=1,ways2=1;
        for(int i=0;i<adj_lst[root].size();i++) {
            if(adj_lst[root].get(i)==parent) {
                continue;
            }
            if(parent_clr==0) {
                ways*=BFS(adj_lst[root].get(i),root,1);
                ways%=mod;
            }
            else {
                ways1*=BFS(adj_lst[root].get(i),root,0);
                ways2*=BFS(adj_lst[root].get(i),root,1);
                ways1%=mod;
                ways2%=mod;
            }
        }
        if(parent_clr==0) {
            dp[root][parent_clr]=ways;
            return dp[root][parent_clr];
        }
        dp[root][parent_clr]=(ways1+ways2)%mod;
        return dp[root][parent_clr];
    }
}


Measured memory_bytes: 123516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map> 
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)



int main(){
  string s;
  cin >> s;
  int S = 0,T = 0;
  int ans = s.size();
  rep(i,s.size()){
     if (s[i] == 'S') S++;
     if (s[i] == 'T'){
        if (S > 0){
           S--;
           ans -=2;
        }
     }
  }
  cout << ans << endl;

   return 0;
}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	
	ll N, K; cin >> N >> K;
	vector<ll> H(N);
	REP(i,N) cin >> H[i];

	SORT(H);

	ll ans = 0;
	REP(i,N-K){
		ans += H[i];
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1920
#include<iostream>
#include<cmath>
#include<algorithm>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

int N, A[200005];

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

    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);

    int b = A[N / 2];

    int ans = 0;
    REP(i, N) { ans += abs(A[i] - b); }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int ab(int a)
{
    if(a>=0) return a;
    else return -a;
}

int main()
{
    int n,l;
    cin >> n >> l;
    int sum=0;
    for(int i=0;i<n;i++) sum+=(l+i);
    int best=1000000;
    int idx;
    for(int i=0;i<n;i++)
    {
        if(ab(l+i)<best)
        {
            best=ab(l+i);
            idx=i;
        }
    }
    cout << sum-(l+idx) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cout << x << endl;
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;
int MAX_K = 150;

map<ll, int> factorize(ll x)
{
    map<ll, int> ret;
    for(ll i = 2; i*i <= x; i++)
    {
        while(x%i == 0)
        {
            ret[i]++;
            x/=i;
        }
    }
    if(x != 1) ret[x]++;
    return ret;
}

int main()
{
    ll N;
    cin >> N;
    if(N == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    vector<ll> M;
    auto fac = factorize(N);
    for(auto [p,e]:fac)
    {
        ll m = 1;
        rep(i,e) m *= p;
        if(p == 2) m *= 2LL;
        M.push_back(m);
    }
    int n = M.size();
    ll ans = LINF;
    for(ll S = 0; S < (1 << n); S++)
    {
        vector<ll> R;
        rep(i,n)
        {
            if((S >> i) & 1) R.push_back(M[i] - 1);
            else R.push_back(0);
        }
        auto tmp = crt(R, M);
        if(tmp.first != 0) chmin(ans, tmp.first);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A[5], max_v=0, ans = 0;

void solve(){

}

int main(){
    rep(i,5){
        cin >> A[i];
        if(A[i] % 10 == 0) ans += A[i];
        else {
            ans += ((A[i] / 10)+1)*10;
            max_v = max(max_v, 10 - (A[i]%10));
        }
    }        

    cout << ans - max_v << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    l[a-1].append(b-1)
    l[b-1].append(a-1)

from collections import deque

p=[0]*n
ans=[0]*n
d=deque()
d.append(0)
while len(d)!=0:
    now=d.popleft()
    for to in l[now]:
        if p[to]==0:
            p[to]=p[now]+1
            d.append(to)
            ans[to]=now
print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Measured memory_bytes: 34728
#include <iostream>
#include <complex>
#include <cmath>
#include <string>
using namespace std;
typedef complex<double> C;
#define EPS (1e-8)
#define EQ(a,b) (abs((a)-(b)) < EPS)
const string mes[2] = {"YES","NO"};
double cross(C a, C b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

bool is_paralelle(C a, C b) {
  return EQ(cross(a,b), 0.0);
}

void solve() {
  double x1, y1, x2, y2, x3, y3, x4, y4;
  cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
  
  C a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
    
  int res = (is_paralelle(a-b, c-d))?0:1;
  cout<<mes[res]<<endl;
}

int main (int argc, char const* argv[]) {
  int n; cin>>n;
  for(int i=0;i<n;i++) solve();
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;

// bit全探索的なDP
int main() {
    int N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
    }
    int min = N + 1;
    vector<int> res;
    rep(i, 0, N) {
        vector<int> d(N, -1);
        vector<int> pre(N, -1);
        queue<int> q;
        q.push(i);
        d[i] = 0;
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(auto n : G[v]) {
                if(d[n] == -1) {
                    d[n] = d[v] + 1;
                    pre[n] = v;
                    q.push(n);
                }
            }
        }
        rep(j, 0, N) {
            if(i == j || d[j] == -1) {
                continue;
            }
            for(auto n : G[j]) {
                if(n == i) {
                    vector<int> tmp;
                    tmp.push_back(i);
                    int cur = j;
                    while(cur != i) {
                        tmp.push_back(cur);
                        cur = pre[cur];
                    }
                    if(min > tmp.size()) {
                        min = tmp.size();
                        res = tmp;
                    }
                }
            }
        }
    }
    if(min == N + 1) {
        cout << -1 << endl;
    } else {
        cout << res.size() << endl;
        for(auto v : res) {
            cout << v + 1 << endl;
        }
    }
}

Measured memory_bytes: 384
n,k=list(map(int,input().split()))
S=input()
c,row_count=S[0],1

for s in S:
  if c != s:
    c = s
    row_count += 1

if row_count-k*2 <= 1:
  row_count = 1
else:
  row_count -= k*2
  
print(n-row_count)

Measured memory_bytes: 9292
s = input()
t = input()
slist = []
tlist = []
for i in s:
    slist.append(ord(i))
for i in t:
    tlist.append(ord(i))

slist.sort()
tlist.sort(reverse=True)

while True:
    if not slist and not tlist:
        print('No')
        exit(0)
    elif not tlist:
        print('No')
        exit(0)
    elif not slist:
        print('Yes')
        exit(0)

    spop = slist.pop(0)
    tpop = tlist.pop(0)

    if spop == tpop:
        pass
    elif spop > tpop:
        print('No')
        exit(0)
    else:
        print('Yes')
        exit(0)


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

using namespace std;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < d; ++j) {
      cin >> x[i][j];
    }
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int sq = 0;
      for (int k = 0; k < d; ++k) {
        int dif = x[i][k] - x[j][k];
        sq += dif * dif;
      }
      int s = sqrt(sq) + 0.5;
      if (s * s == sq) ++res;
    }
  }
  cout << res << endl;
}

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

using ll = long long;

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

	ll n, a, b;
	cin >> n >> a >> b;
	ll c = a + b;
	ll result = a * (n / c) + min((n % c), a);
	cout << result << endl;
}


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

struct union_find{
    vector<int> par;
    vector<int> rank;
    union_find(int sz){
        par.resize(sz);
        rank.assign(sz,0);
        for(int i = 0;i < sz;++i) par[i]=i;
    }
    int find(int a){
        if(par[a]==a) return a;
        else return par[a] = find(par[a]);
    }
    void unite(int a,int b){
        int root_a,root_b;
        root_a = find(a),root_b = find(b);
        if(rank[root_a]>rank[root_b]){
            par[root_b] = root_a;
        }else if(rank[root_a]<rank[root_b]){
            par[root_a] = root_b;
        }else{
            rank[root_a]++;
            par[root_b] = root_a;
        }
    }
    bool same(int a,int b){return find(a)==find(b);}
};

typedef int Weight;
struct Edge {  
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : 
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

pair<Weight,Edges> kruskal(const Graph &g) {
  int n = g.size();
  union_find tree(n);
  priority_queue<Edge> Q;
  for(int u=0;u<n;u++){
    for(auto e : g[u]){
      if (u < e.dst) Q.push(e);
    }
  }
  Weight total = 0;
  Edges F;
  while ((int)F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (!tree.same(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
      tree.unite(e.src, e.dst);
    }
  }
  return pair<Weight, Edges>(total, F);
}

int main(){
	int  v, e; cin >> v >> e;
    Graph g(v);
    int s, t, w;
    for(int i=0; i<e; i++){
        cin >> s >> t >> w;
        g[s].push_back({s, t, w});
        g[t].push_back({t, s, w});
    }

    cout << kruskal(g).first << endl;
}


Measured memory_bytes: 8796
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
for i in range(1, N):
    a = A[i - 1]
    b = A[i]
    if a + b <= x:
        continue
    over = (a + b) - x
    ans += over
    A[i] = max(0, b - over)

print (ans)



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

vi g[114514];
bool used[114514];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, m, a, b;
	cin>>n>>m;
	REP(i, m){
		cin>>a>>b;
		--a;
		--b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	deque<int> ans;
	ans.push_front(0);
	ans.push_back(g[0][0]);
	if(g[0].size()==1 && g[g[0][0]].size()==1){
		cout<<2<<'\n';
		REP(i, 2){
			cout<<ans[i]+1<<" \n"[i==1];
		}
		return 0;
	}
	used[0]=used[g[0][0]]=true;
	bool can1=false, can2=false;
	FOR(i, 2, n){
		bool ok1=true;
		if(!can1){
			for(int x : g[ans.front()]){
				if(used[x]){
					continue;
				}
				ok1=false;
				ans.push_front(x);
				used[x]=true;
				break;
			}
			if(ok1){
				can1=true;
			}
		}
		bool ok2=true;
		if(!can2){
			for(int x : g[ans.back()]){
				if(used[x]){
					continue;
				}
				ok2=false;
				ans.push_back(x);
				used[x]=true;
				break;
			}
			if(ok2){
				can2=true;
			}
		}
		if(ok1 && ok2){
			break;
		}
	}
	int sz=ans.size();
	cout<<sz<<'\n';
	REP(i, sz){
		cout<<ans[i]+1<<" \n"[i==sz-1];
	}
	return 0;
}


Measured memory_bytes: 7168
s = gets.chomp
len = s.length
x = (len -1 )/2
y = (len + 3)/2
a = s.slice(0,x)
b = s.slice(y-1,len)
if s == s.reverse
  if a == a.reverse && b == b.reverse
    puts "Yes"
  else
    puts "No"
  end
else
  puts"No"
end
  

Measured memory_bytes: 1788
n = int(input())
 
ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

Measured memory_bytes: 9132
import collections

N = int(input())
S = []

for _ in range(N):
    S.append(input())

c = collections.Counter(S)
print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))



Measured memory_bytes: 82260
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in= new Scanner(System.in);
		int n = in.nextInt();
		double [] dp = new double[n+1];
		dp[0] =1;
		
		for( int i=0; i<n; i++) {
			Double k =in.nextDouble();
			for(int j = i+1 ;j>=0; j--) {
				if( j== 0)
					dp[j] = dp[j]* (1-k);
				else
				dp[j] = dp[j-1]* k + dp[j]* ((double)1-k);
				//System.out.print(dp[j] + " ");
			}
			//System.out.println();
		}
		
		/*for(int i=1; i<=n; i++)
			System.out.print(dp[i] + " ");
		    System.out.println();*/
		double ans= 0;
		for(int i=n/2 + 1; i<=n; i++)
			ans+= dp[i];
		System.out.printf("%.18f",ans);
	       
	}
	
	

}


Measured memory_bytes: 41172