akhauriyash/Code-Regression huggingface dataset:
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=1e17;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
// double dp[100005];
 
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main()
{
 
 IO;
 OS;
cin>>k>>n;
lli a[n+1];
lli mx=0;
for(int i=1;i<=n;i++)
{
    cin>>a[i];
    
}

for(int i=1;i<=n;i++)
{
    if(i==1)
        mx=max(mx,a[1]+k-a[n]);
    else
        mx=max(mx,a[i]-a[i-1]);
}


cout<<k-mx;

 
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    char s[11];

    scanf("%s", s);

    int cnt = 0;
    int maxdata = 0;
    for (int i = 0; i < strlen(s); i++) {
        char c = s[i];
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
            cnt++;
        } else {
            maxdata = maxdata < cnt ? cnt : maxdata;
            cnt = 0;
        }

    }
    maxdata = maxdata < cnt ? cnt : maxdata;
    printf("%d",maxdata);

    return 0;
} 

Measured memory_bytes: 128
def ReadMap(n, m):
  Map = [0] * m
  for i in range(m):
    a = raw_input()
    b = list(a)
    if a.count('&')>0:
      j = a.index('&')
      PosCas = [j, i]
      b[j] = '.'
    Map[i] = b
  return Map, PosCas

def fill(SP, c1, c2):
  for x, y in SP:
    if not (0 <= x < n and 0 <= y < m):
      continue
    if Map[y][x]!=c1:
      continue
    if x in [0, n-1] or y in [0, m-1]:
      return 1
    Map[y][x] = c2
    SP += ([[x+1, y] , [x-1, y], [x, y+1], [x, y-1]])
  return 0

def PrintMap():
  for e in Map:
    print "".join(e)
  print
  return

while 1:
  n, m = map(int,raw_input().split())
  if n == m == 0: break
  Map, PosCas = ReadMap(n, m)
  c = 0
#  PrintMap()
  while 1:
    SP = [PosCas]
    if fill(SP, '.', '#'): break
#    PrintMap()
    c += 1
    if fill(SP, '#', '.'): break
#    PrintMap()
  print c

Measured memory_bytes: 12484
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace debug
{
    class ProgramD
    {
        static void Main(string[] args)
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            long[] m = new long[5];
            m[0] = long.Parse(Console.ReadLine());
            m[1] = long.Parse(Console.ReadLine());
            m[2] = long.Parse(Console.ReadLine());
            m[3] = long.Parse(Console.ReadLine());
            m[4] = long.Parse(Console.ReadLine());


            Console.WriteLine((n + m.Min() -1)/ m.Min() + 4);

        }

        
    }

}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main(){
  	int k,a,b;
  	cin>>k>>a>>b;
  	bool res=false;
  	for(int i=a;i<=b;i++){
      if(i%k == 0){
		res=true;
        break;
      }
    }
    if(res)
      cout<<"OK";
  	else
      cout<<"NG";
}

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


int main()
{
	int n,m,a;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i) {scanf("%d",&a);n-=a;}
	if(n>=0) printf("%d",n);
	else puts("-1");
}

Measured memory_bytes: 3760
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long

using namespace std;
LL a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	
	if(d&1)
	{
		cout<<b-a;
	}
	else
	{
		cout<<a-b;
	}
	
	
	
	return 0;
}


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

int main() {
	int N, count = 0;
	cin >> N;
	if (N == 1 || N == 2 || N == 4) cout << 4 << endl;
	else {
		while (N != 1) {
			if (N % 2 == 0) N /= 2;
			else  N = N * 3 + 1;
			count++;
		}
		cout << count + 2 << endl;
	}
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll odd=0;
    ll feven = 0;
    rp(i,n){
      ll x;
      cin >> x;
      if(x %2 == 1) odd++;
      if(x %4 == 0) feven++;
    }
    if(n%2 == 1 && odd == (n+1)/2 && feven == n/2) {
      cout << "Yes" <<endl;
      return 0;
    }
    if(odd <= feven){
      cout << "Yes" <<endl;
      return 0;
    }
    cout << "No"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define ms(x, v) memset(x, v, sizeof(x))
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
queue<pair<int, int> > q;
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    rep1(i, m)
    {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int f = 0;
    set<int> se;
    q.push({1, 0});
    while(!q.empty() && !f)
    {
        pair<int, int> cur = q.front(); q.pop();
        if(cur.second > 2) continue;
        if(cur.second == 2 && cur.first == n) f = 1;
        for(auto v : g[cur.first])
        {
            if(!se.count(v))
            {
                se.insert(v);
                q.push({v, cur.second + 1});
            }
        }
    }
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 22128
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let n: i32 = input.trim().parse().unwrap();

    if n % 2 == 0 {
        println!("0.5");
    } else {
        println!("{}", ((n + 1) as f64) / ((2 * n) as f64));
    }
}


Measured memory_bytes: 4352
n = int(input())

c = [0] * n
s = [0] * n
f = [0] * n

for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

for i in range(n):
	t = 0
	for j in range(i,n-1):
		if t < s[j]: t = s[j]
		elif t % f[j] == 0: pass
		else: t = t + f[j] - t%f[j]
		t += c[j]

	print(t)


Measured memory_bytes: 41708
#include<bits/stdc++.h>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0;i < (ll)(n);i++)
#define INF (1e9 + 1)
#define MAXN
#define MAXM
int main()
{
    int N;
    cin >> N;
        cout << N / 3 << endl;


    return 0;
}
/*
    REP(i,a){
        REP(j,b){

        }
    }
    */


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

using namespace std;

int vet[200005];

int main()
{
    int k, n; cin >> k >> n;
    for (int i = 1; i <= n; i++)
        cin >> vet[i];

    int minimo = (vet[n] - vet[1]);

    for (int i = 2; i <= n; i++)
        minimo = min(minimo, vet[i-1]+k - vet[i]);

    cout << minimo << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
 
#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
 
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define f first 
#define s second 
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define mp make_pair    
#define endl "\n"
 
#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = b - 1; i >= a; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define trans(a,b) trasform(a.begin(),a.end(),a.begin(),b)
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)
 
#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-10

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

ld dp[301][301][301];
ld n;

ld solve(int a,int b,int c){
    if(a+b+c == 0)return 1;
    ld &r = dp[a][b][c];
    if(r > 0)return r;
    r = n /(ld)(a+b+c);
    ld u = a+b+c;

    if(a)r+= ((ld)a/u) * solve(a-1,b,c);
    if(b)r+= ((ld)b/u) * solve(a+1,b-1,c);
    if(c)r+= ((ld)c/u) * solve(a,b+1,c-1);
    return r;
}


int32_t main(int32_t argc, char const *argv[]){
    FIN;
    fore(i,0,301)fore(j,0,301)fore(k,0,301)dp[i][j][k]=-1;

    int j; cin>>j;
    n = j;
    int a=0,b=0,c=0;

    fore(i,0,j){
        int u;cin>>u;
        a += (u ==1);
        b += (u ==2);
        c += (u ==3);
    }
    cout<<setprecision(15)<<solve(a,b,c)- (ld)1;


    return 0;
}







































































































































































































































































































































































//formulas 
//cero = r/k  -(l/k + (l%k!=0)) +1; cantidad de numeros divisibles por k en el intervalo [l r]
//upper_bound primer elemento mayot estricto
//lower_bound primer elemento mayo o igual
//al hacer bfs con distancia recordar simpre antes de visitar preguntar si ya llegue antes co
//un peso menor




//PROGRAMADO POR xXLucarioXx    


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

int arr[101];

int main(void) {
    int n;
    scanf("%d",&n);
    int ret=0;
    for(int i=1;i<=n;i++) {
        scanf("%d",&arr[i]);
        if (i%2==1&&arr[i]%2==1) {
            ret++;
        }
    }
    printf("%d",ret);
}

Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

// ref : https://img.atcoder.jp/arc101/editorial.pdf
using ll = long long;

int main(){
    int n, k;
    std::cin >> n >> k;
    std::vector<ll> x(n);
    for(int i = 0; i < n; i++){
        std::cin >> x[i];
    }


    // n - k + 1通りを全探索
    ll minCost = (x[n - 1] - x[0]) * 2;
    for(int start = 0; start <= n - k; start++){
        int l = start;
        int r = start + k - 1;
        ll cost = std::min(std::abs(x[l]), std::abs(x[r])) + std::abs(x[l] - x[r]);
        minCost = std::min(cost, minCost);
    }

    std::cout << minCost << std::endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()
T = input()

MOD = 10 ** 9 + 7

ptn = []
i = 0
while i < N:
    if S[i] == T[i]:
        ptn.append(1)
        i += 1
    else:
        ptn.append(2)
        i += 2

if ptn[0] == 1:
    ans = 3
else:
    ans = 6

for s, t in zip(ptn[:], ptn[1:]):
    if s == 1 and t == 1:
        ans *= 2
    elif s == 1 and t == 2:
        ans *= 2
    elif s == 2 and t == 1:
        ans *= 1
    elif s == 2 and t == 2:
        ans *= 3
    ans %= MOD

print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

#ifndef INTERACTIVE
[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}
#endif // INTERACTIVE

std::pair<int, int> find_centers(const std::vector<long long>& pref, int l, int r, int d) {
    auto s = pref[r] - pref[l];
    int cl = -1, cr = -1;

    auto base = pref.begin() + 1;
    auto first = pref.begin() + l + 1;
    auto last = pref.begin() + r + 1;

    int delta = 5;

    cl = std::lower_bound(first, last, s/2 + pref[l]) - base - 1;
    cr = std::upper_bound(first, last, s/2 + pref[l]) - base;

    cl -= delta;
    cr += delta;

    cl = std::max(cl, l + d - 1);
    cr = std::min(cr, r - d);
    assert(cl <= cr);

    return {cl + 1, cr + 1};
}

int main() {
    int n; cin >> n;
    std::vector<long long> a(n);
    for (auto& x: a) cin >> x;
    std::vector<long long> pref(n + 1);
    for (int i = 0; i < n; ++i) {
        pref[i + 1] = pref[i] + a[i];
    }
    int cl = -1, cr = -1;
    std::tie(cl, cr) = find_centers(pref, 0, n, 2);
    long long ans = LLONG_MAX;
    for (int c = 2; c <= n - 2; ++c) {
        auto ls = find_centers(pref, 0, c, 1);
        auto rs = find_centers(pref, c, n, 1);
        for (int l = ls.first; l <= ls.second; ++l) {
            for (int r = rs.first; r <= rs.second; ++r) {
                std::vector<long long> b = {pref[l] - pref[0], pref[c] - pref[l], pref[r] - pref[c], pref[n] - pref[r]};
                auto mm = std::minmax_element(b.begin(), b.end());
                ans = std::min(ans, *mm.second - *mm.first);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int xor128(void) { 
  static int x = 123456789;
  static int y = 362436069;
  static int z = 521288629;
  static int w = 88675123; 
  int t;
 
  t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

struct Node {
  int Value;
  int SubTreeSize;
  Node *Lch, *Rch;

  int RMQ;

  Node(int V):Value(V), SubTreeSize(1), RMQ(V) {
    Lch = (Node *)NULL;
    Rch = (Node *)NULL;
  };
};
inline int Count(Node *t)
{
  if(t == (Node *)NULL) return(0);
  else return(t -> SubTreeSize);
}
inline int Sum(Node *t)
{
  if(t == (Node *)NULL) return(INF);
  else return(t -> RMQ);
}

inline Node *Update(Node *t)
{
  t -> SubTreeSize = Count(t -> Lch) + Count(t -> Rch) + 1;
  t -> RMQ = min(Sum(t -> Lch), min(Sum(t -> Rch), t -> Value));
  return(t);
}
inline void Push(Node *t) 
{
}

inline Node *MakeRoot(int value)
{
  return(new Node(value));
}

Node *Merge(Node *l, Node *r)
{
  Push(l), Push(r);
  if(l == (Node *)NULL) return(r);
  if(r == (Node *)NULL) return(l);
  int Left  = l -> SubTreeSize;
  int Right = r -> SubTreeSize;
  if(xor128() % (Left + Right) < Left) { // ???(left)??????
    l -> Rch = Merge(l -> Rch, r);
    return(Update(l));
  } else {                              // ???(right)??????
    r -> Lch = Merge(l, r -> Lch);
    return(Update(r));
  }
}
  
pair< Node*, Node* > Split(Node *t, int k) // [0, k), [k, n)
{
  if(t == (Node *)NULL) return(make_pair((Node *)NULL, (Node *)NULL));
  Push(t);
  if(k <= Count(t -> Lch)) { // ?????´?????????
    pair< Node *, Node *> s = Split(t -> Lch, k);
    t -> Lch = s.second;
    return(make_pair(s.first, Update(t)));
  } else {                   // ?????´?????????
    pair< Node *, Node *> s = Split(t -> Rch, k - Count(t -> Lch) - 1);
    t -> Rch = s.first;
    return(make_pair(Update(t), s.second));
  }
}

Node *Insert(Node *root, int pos, int value)
{
  Node *p = MakeRoot(value);
  pair< Node *, Node *> s = Split(root, pos);
  return(Merge(Merge(s.first, p), s.second));
}
Node *Erase(Node *root, int pos)
{
  pair< Node *, Node *> s = Split(root, pos);
  pair< Node *, Node *> t = Split(s.second, 1);
  delete t.first;
  return(Merge(s.first, t.second));
}

void Dump(Node *root)
{
  if(root == (Node *)NULL) return;
  cout << "(";
  Dump(root -> Lch);
  cout << "" << root -> Value << "";
  Dump(root -> Rch);
  cout << ")";
}

int main()
{
  Node *root = NULL;
  int n, q, a, x, y, z;
  scanf("%d %d", &n, &q);
  for(int i = 0; i < n; i++) {
    scanf("%d", &a);
    root = Insert(root, i, a);
  }
  while(q--) {
    scanf("%d %d %d", &x, &y, &z);
    if(x == 0) {
      ++z;
      pair< Node *, Node *> a, b, c;
      c = Split(root, z);
      b = Split(c.first, z - 1);
      a = Split(b.first, y);
      root = Merge(Merge(Merge(a.first, b.second), a.second), c.second);
    } else if(x == 1) { 
      ++z;
      pair< Node *, Node *> p, q;
      p = Split(root, y);
      q = Split(p.second, z - y);
      printf("%d\n", Sum(q.first));
      root = Merge(p.first, Merge(q.first, q.second));
    } else {
      root = Erase(root, y);
      root = Insert(root, y, z);
    }
  }
}

Measured memory_bytes: 10568
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX 1000000

int N, R, L;
long long S[MAX+1], T[MAX+1];
int H[MAX+1], P[MAX+1]; // heap

bool isGreater(int a, int b){
  if ( S[a] == S[b] ) return a > b;
  return S[a] < S[b];
}

void swp(int a, int b){
  int i1 = H[a];
  int i2 = H[b];
  swap(H[a], H[b]);
  P[i1] = b;
  P[i2] = a;
}

void downHeap(int i){
  int l, r, largest;
  l = 2*i;
  r = 2*i+1;
  if ( l <= N && isGreater(H[i], H[l]) ) largest = l;
  else largest = i;
  if ( r <= N && isGreater(H[largest], H[r]) ) largest = r;
  if ( largest != i ){
    swp(i, largest);
    downHeap(largest);
  }
}

void upHeap(int i){
  while ( i > 1 && isGreater(H[i/2], H[i]) ){
    swp(i, i/2);
    i = i/2;
  }
}

void update(int d, int t, int x){
  S[d] += x;
  if ( x > 0 ){
    upHeap(P[d]);
  } else if( x < 0 ){
    downHeap(P[d]);
  }
}

void init(){
  for ( int i = 0; i <= N; i++ ){
    S[i] = 0;
    T[i] = 0;
    H[i] = i;
    P[i] = i;
  }

  // build heap
  for ( int i = N/2; i >= 1; i-- ) downHeap(i);
}

main(){
  cin >> N >> R >> L;
  init();
  int d, t, x;
  int pret = 0;
  int pred = 1;
  for ( int i = 0; i < R; i++ ){
    scanf("%d %d %d", &d, &t, &x);
    T[pred] += t - pret;
    update(d, t, x);
    pred = H[1];
    pret = t;
  }

  T[pred] += L - pret;

  int maxv = -2000000000;
  int ans = -1;
  for ( int i = 1; i <= N; i++ ){
    if ( maxv < T[i] ){
      maxv = T[i];
      ans = i;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 13924
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  stack<int>st[1000];
  int n,tc,q,t;
  ll x;
  cin>>n>>tc;
  while(tc--)
  {
    cin>>q;
    if(q==0)
    {
      cin>>t>>x;
      st[t].push(x);
    }
    else if(q==1)
    {
      cin>>t;
      if(!st[t].empty())
      {
        cout<<st[t].top()<<endl;
      }
    }
    else if(q==2)
    {
      cin>>t;
      if(!st[t].empty())
      {
        st[t].pop();
      }
    }
  }
}



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

int main() {
  int x;
  cin >> x;
  if(x == 1) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 3596
def check_valid(flag):
    for i, m in mentions.items():
        if not (flag & (1 << i)):
            continue
        for j, honest in m.items():
            if honest and flag & (1 << j):
                continue
            if not honest and not (flag & (1 << j)):
                continue
            return False
    return True


n = int(input())
mentions = {}
for i in range(1, n + 1):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        if i not in mentions:
            mentions[i] = {x: y}
        else:
            mentions[i][x] = y
res = 0
for i in range(1, 1 << n + 1):
    if check_valid(i):
        temp = 0
        for j in range(1, n + 1):
            if i & (1 << j):
                temp += 1
            res = max(res, temp)
print(res)

Measured memory_bytes: 44508
import java.util.Scanner;

public class Main {

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

		int H[]=new int[256];
		int W[]=new int[256];

		int i=0;
		while(true){
			H[i]=sc.nextInt();
			W[i]=sc.nextInt();

			if(H[i]==0&&W[i]==0)	break;
			i++;
		}

		for(int x=0;x<i;x++){
			for(int j=0;j<H[x];j++){
				for(int k=0;k<W[x];k++){
					if((j%2==0&&k%2==0)||(j%2==1&&k%2==1))	System.out.print("#");
					else	System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 37896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;
  cin >> N;
  int total = 0;
  
  for (int i=0; i < N; i++) {
    cin >> l >> r;
    total += r - l + 1;
  }
  
  cout << total << endl;
  
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    a[i]=x%4;
  }
  int c1=0,c2=0,c0=0;
  for (int i=0;i<N;i++){
    if (a[i]==0){
      c0++;
    }
    else if (a[i]==1||a[i]==3){
      c1++;
    }
    else {
      c2++;
    }
  }
  bool ans=true;
  if (c2>0&&c0<c1){
    ans=false;
  }
  else if(c2==0&&c0+1<c1){
    ans=false;
  }
  if (ans){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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


using namespace std;


typedef long long LL;
typedef pair<LL,LL> pp;

int main()
{
	int A, B, C, D;
	cin >> A >> B;
	cin >> C >> D;
	int t = 0;
	for (int i = 0; i <= 100; i++) {
		if (i >= A && i < B && i >= C && i < D) {
			t++;
		}
	}
	cout << t << endl;
	exit(0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int N, K; cin >> N >> K;
    if (N%K==0) cout << 0 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;


public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		nPoint = in.nextInt();
		
		lEdge = new List[nPoint];
		for (int i=0;i<nPoint;i++) {
			lEdge[i] = new ArrayList<P>();
			for (int j=0;j<nPoint;j++) {
				int d = in.nextInt();
				if (d>=0) lEdge[i].add(new P(j, d));
			}
		}
		
		System.out.println(prim(0));
	}

	static int nPoint;
	static List<P>[] lEdge;
	
	// s is index of start point
	static long prim(int s) {
		PriorityQueue<P> q = new PriorityQueue<P>();
		q.add(new P(s, 0));
		Set<Integer> already = new HashSet<Integer>();
		already.add(s);
		
		long res=0;
		while (already.size() != nPoint) {
			P next = q.poll();
			if (already.size() != 1 && already.contains(next.index)) {
				continue;
			}
			already.add(next.index);
			res += next.dist;
			for (int i=0;i<lEdge[next.index].size();i++) {
				int ind = lEdge[next.index].get(i).index;
				if (already.contains(ind)) continue;
				q.add(new P(ind, lEdge[next.index].get(i).dist));
			}
		}
		return res;
	}
	
	static class P implements Comparable<P> {
		int index; int dist;
		public P(int index, int dist) {this.dist=dist; this.index=index;}
		public int compareTo(P p) {return this.dist - p.dist;}
	}
}

Measured memory_bytes: 41184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+7;
ll dp[N][2];
ll arr[N];
int main(){
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)  cin>>arr[i];
	dp[2][0]=arr[1];
	dp[2][1]=arr[2];
	for(ll i=3;i<=n;i++){
		if(i&1){
			dp[i][1]=max({dp[i-2][1],dp[i-2][0],dp[i-3][1],dp[i-3][0]})+arr[i];
			dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
		}
		else {
			dp[i][1]=max(dp[i-2][1],dp[i-2][0])+arr[i];
			dp[i][0]=arr[i-1]+dp[i-2][0];
		}
	}
	cout<<max(dp[n][0],dp[n][1])<<endl;
	return 0;
}

Measured memory_bytes: 8284
#include <stdio.h>
    int main(void){
    	int N;
    	int a[100];
    	int b[100];
    	int c[100];
    	int d[100];
    	int ans = 0;
    	scanf("%d",&N);
    	int i,j;
    	for(i=0;i<N;i++){
    		scanf("%d %d",&a[i],&b[i]);
    	}
    	for(i=0;i<N;i++){
    		scanf("%d %d",&c[i],&d[i]);
    	}
    	//まずBについてx座標の小さい順にソートしていく。
    	//バブルソートの場合は、
    	for(i=0;i<N;i++){
    		for(j=i+1;j<N;j++){
    			if(c[i]>c[j]){
    				int temp1;
    				int temp2;
    				temp1 = c[i];
    				temp2 = d[i];
    				c[i] = c[j];
    				d[i] = d[j];
    				c[j] = temp1;
    				d[j] = temp2;
    			}
    		}
    	}
    	//上の操作をするとc[0]は最小のx座標になっている。これは昇り順って言う？
    	//次にRedをy座標について降り順ににソートする
    	for(i=0;i<N;i++){
    		for(j=i+1;j<N;j++){
    			if(b[i]<b[j]){
    				int temp1;
    				int temp2;
    				temp1 = a[i];
    				temp2 = b[i];
    				a[i] = a[j];
    				b[i] = b[j];
    				a[j] = temp1;
    				b[j] = temp2;
    			}
    		}
    	}
    	//上の操作でRedがy座標について下り順ソートされた。
    	//次にマッチングさせていく。Blueのxが一番小さいヤツとRedのy座標が一番大きいやつでペアを作る。
    	//ペアを作ったらその2つの点は捨てていく。ansを加算する。
    	//ええとまずBlueの数分だけループを回せばいいのか？
    	for(i=0;i<N;i++){
    		//Blueの点c[i],d[i]について
    		//Redを見ていく、Redはもうy順でソートされているのでRed[0]から条件を満たすかどうかチェックする。
    		for(j=0;j<N;j++){
    			if(d[i]>b[j]){//もしもBのy座標がAより大きかったら
    				if(c[i]>a[j]){//x座標B>Aをチェックする。
    					//printf("(%d,%d) matched (%d,%d)\n",a[j],b[j],c[i],d[i]);
    					a[j]=1e9;
    					b[j]=1e9;
    					ans++;
    					break;
    				}
    			}
    		}
    	}
    	
    	printf("%d",ans);
    	return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
int main(){
  int N, K; std::cin >> N >> K;
  std::vector<int> vec(N);
  for (int &x: vec) std::cin >> x;
  int count = 0;
  for (int x: vec){
    if (x >= K){
      count++;
    }
  }
  std::cout << count << "\n";
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

n, l, t = map(int, input().split())
XW = [list(map(int, input().split())) for _ in range(n)]
L = []
cnt = 0
for i, xw in enumerate(XW):
  x, w = xw
  L.append((x+t*(3-2*w))%l)
  cnt += (x+t*(3-2*w))//l
L.sort()
for i in range(cnt, cnt+n):
  print(L[i%n])

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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend()
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   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 (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (b % 2 == 0) return (pow(a * a, b / 2, m) % m); else return (pow(a * a, b / 2) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

   ll dx[4]={1,0,-1,0};
   ll dy[4]={0,1,0,-1};

int main(){
  ll D; cin >> D;
  switch(D){
    case 22:
      cout << "Christmas Eve Eve Eve\n";
      break;
    case 23:
      cout << "Christmas Eve Eve\n";
      break;
    case 24:
      cout << "Christmas Eve\n";
      break;
    case 25:
      cout << "Christmas\n";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;









int main() {
	vector<int> v(4);
	
	rep(i, 0, 3) {
		int a, b;
		cin >> a >> b;
		v[a-1]++;
		v[b-1]++;
	}


	int cnt1=0;
	int cnt2=0;

	rep(i, 0, 4) {
		if (v[i] == 1)cnt1++;
		if (v[i] == 2)cnt2++;
	}

	if (cnt1 == 2 && cnt2 == 2)cout << "YES" << endl;
	else cout << "NO" << endl;



	return 0;
}


Measured memory_bytes: 256
s = list(input())
length = len(s)
ans = 0

if length % 2 == 0:
    for i in range(int(length/2)):
        if  s[i] != s[length - i -1]:
            ans += 1
else:
    for i in  range(int((length-1)/2)):
        if s[i] != s[length - i -1]:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	int cnt[51] = {};
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	for(int i = 1; i <= n; i++){
		cout << cnt[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

void solve()
{
 
 int n;
 cin >> n;
 int a[n];

 forf(i,0,n) cin >> a[i];


 map<int,int>mp;
 
 forf(i,0,n)
 {
    if(mp[a[i]])
    {
        cout<<"NO\n";
        return ;
    }
    mp[a[i]]=1;
 }


 cout<<"YES\n";


}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 17644
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
min(a,b,c,d)==min({a,b,c,d});
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll             long long int
#define endl           '\n'
#define mod            1000000007
#define fo(i,n)        for(int i=1;i<=n;i++)
#define tol(s)         transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s)         transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x)         (x).begin(), (x).end()
#define pb             push_back
#define lb             lower_bound
#define ub             upper_bound
#define tr(it, a)      for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b)       __gcd(a,b)
#define pq             priority_queue
#define fr             first
#define sc             second
#define sz(x)          x.size()
#define T              ll t=0;cin>>t;for(ll test=0;test<t;test++)
 
const int inf=0x3f3f3f3f;
bool ispalindrome(string s) 
{ 
    ll len=s.length(); 
    for(ll i=0;i<len;i++){ 
        if(s[i]!=s[len-i-1]) 
        return false; 
    } 
    return true; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res*a;
        a = a*a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif


string s;
cin>>s;
if(s[0]=='R' && s[1]=='R' && s[2]=='R')cout<<3<<endl;
else if(s[1]=='R' && s[2]=='R' || s[0]=='R' && s[1]=='R')cout<<2<<endl;
else if(s[2]=='R' || s[0]=='R' || s[1]=='R')cout<<1<<endl;
else
cout<<0<<endl;








return 0;
}  

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

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

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100000), 100000000)
}

func main() {
	s, t := scanString(), scanString()
	ans := 0
	for i := range s {
		if s[i] != t[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2884
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
#define maxn 100001

typedef struct {
    std::vector<int> nextnode;
    int weight;
} tree;

int seek(std::vector<tree> &a,int now){
    if(a[now].nextnode.size() == 0) return 0;
    std::vector<int> t;
    for(int i = 0; i < a[now].nextnode.size(); i++){
        t.push_back(seek(a,a[now].nextnode[i]));
    }
    std::sort(t.begin(),t.end());
    int w = t[0];
    for(int i = 0; i < t.size();i++){
        w = max(w + 1, t[i] + 1);
    }
    return w;
}


signed main()
{
int n;
std::cin >> n;
std::vector<tree> a(n);
a[0].weight = 0;
for(int i = 1; i < n; i++){
    int temp;
    a[i].weight = 0;
    std::cin >> temp;
    temp--;
    a[temp].nextnode.push_back(i);
}
int out = seek(a,0);
std::cout << out << std::endl;

return 0;
}

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

int main() {
    int N;
    int A[210];
    cin >> N;
    rep(i, N) {
        cin >> A[i];
    }

    int res = 0;

    while (true)
    {
        /* code */
        bool is_odd = false;

        rep(i, N) {
            if(A[i] % 2 != 0) is_odd = true;
        }

        if (is_odd) break;

        rep(i, N) {
            A[i] /= 2;
        }

        res++;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc068
// status:

#define SUBMIT
//#define DEBUG

#include <bits/stdc++.h>
using namespace std;
using ui64 = uint64_t;

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(50
)");
#endif
    ui64 K, N;
    stream >> K;

    if (K == 0) {
        cout << "2" << endl;
        cout << "0 0" << endl;
        exit(0);
    }
    if (K == 1) {
        cout << "2" << endl;
        cout << "0 2" << endl;
        exit(0);
    }

    const ui64 MAX_N = 50;
    N = min(K, MAX_N);

    ui64 r = K / N;
    ui64 rest = K - r * N;

    cout << N << endl;
    vector<ui64> d;
    for (int i = 1; i <= N; ++i) {
        ui64 a = r + (i - 1);
        if (N - i < rest) a++;

        d.push_back(a);
        cout << a;
        if (i != N) cout << " ";
        else cout << endl;
    }
#ifdef DEBUG
    ui64 actual = 0;
    while (true) {
        auto found = max_element(d.begin(), d.end());
        if (*found < N) break;

        actual++;
        for (int i = 0; i < N; ++i) d[i]++;
        *found -= N + 1;
    }
    cout << actual << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;


int main() {
    string str;
    int sum;

    while (getline(cin, str)) {
        sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum += (int) str[i] - '0';
        }
        if (sum != 0) { cout << sum << endl; }
    }
}


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

int n,m; //input intergers:n,m
vector<pair<int,int> > e[100010]; //the vector array of DFS
long long pos[100010]; //the positions of each person 
bool vis[100010]; //the bool array of DFS to know each person has visited or not

inline void dfs(int x) //DFS
{
	vis[x]=1; //visited this person(x)
	for(int i=0;i<e[x].size();i++) //visit the person who has relation of this person(x)
	{
		pair<int,int> cur=e[x][i];
		if(vis[cur.first]) //if(this person(e[x][i])'s position has known)
		{
			if(pos[cur.first]-pos[x]!=cur.second) {cout<<"No";exit(0);} //if this person(e[x][i]) is wrongful then exit
		}
		else //if this person(e[x][i])'s position hasn't known then take notes and DFS
		{
			pos[cur.first]=pos[x]+cur.second;
			dfs(cur.first);
		}
	}
}

int main()
{
	cin>>n>>m; //input
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d; //input
		e[l].push_back({r,d}); //take notes
		e[r].push_back({l,-d}); //take notes
	}
	
	for(int i=0;i<n;i++) if(!vis[i]) dfs(i); //DFS
	
	cout<<"Yes"; //if every one isn't wrongful then print 'Yes'
	
	return 0; //END
}

Measured memory_bytes: 11648
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
const int N=100100;
vector<int> head[N];
int n,l[N],len;
pair<bool,int> dfs(int x,int fa,int c)
{
    int size=1;
    bool f=false;
    for(int i=0;i<head[x].size();++i)
    {
        int y=head[x][i];
        pair<bool,int> t;
        if(y!=fa)
        {
            t=dfs(y,x,c+1);
            f=f||t.first;
            if(!t.first) size+=t.second;
        }
    }
    if(f||x==n) 
    {
        if(x==n) len=c;
        l[c]=size-1;
        return make_pair(true,size);
    }
    else return make_pair(false,size);
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<n;++i)
    {
        int x,y;
        cin>>x>>y;
        head[x].push_back(y);
        head[y].push_back(x);
    }
    dfs(1,0,1);
    int a=0,b=0;
    for(int i=1;i<=(1+len)>>1;++i)
        a+=l[i];
    for(int i=(3+len)>>1;i<=len;++i)
        b+=l[i];
    if(a>b||(a==b&&len%2==1))
        cout<<"Fennec"<<endl;
    else
        cout<<"Snuke"<<endl;
    return 0;
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i=0;i<N;i++)  cin >> A.at(i);

  ll ans=0;
  map<ll,ll> mp;
  for(ll i=0;i<N;i++){
    ll tmp=i-A.at(i);
    if(mp.count(tmp)) ans+=mp.at(tmp);
    tmp=A.at(i)+i;
    mp[tmp]++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 17164
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

#define MAX_N 100000

int main()
{
    int N, A[MAX_N + 2], sum = 0;

    scanf("%d", &N);

    A[0] = 0;
    A[N + 1] = 0;

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

    sum += abs(A[N] - A[N + 1]);

    for (int i = 1; i <= N; i++)
    {
        printf("%d\n", sum - abs(A[i - 1] - A[i]) - abs(A[i] - A[i + 1]) + abs(A[i - 1] - A[i + 1]));
    }

    return 0;
}


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

int main(){
	int n,a,b,c;
	cin>>n;
	while(n--){
	 cin>>a>>b>>c;
	 a=a*a;b=b*b;c=c*c;
	 if(a+b==c || b+c==a || c+a==b){cout<<"YES";}else{cout<<"NO";}
	 cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    string s;
    cin >> s;

    bool containA = false;
    bool containB = false;

    for (char ch : s) {
        if (ch == 'A') containA = true;
        if (ch == 'B') containB = true;
    }

    if (containA and containB) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n; cin >> n;
string s; cin >> s;

stack<char> st;
rep(i,n) {
    if(!st.empty() && st.top() == '(') {
        if(s[i] == ')') {
            st.pop();
        }
        else {
            st.push(s[i]);
        }
    }
    else st.push(s[i]);
}

int cntl = 0, cntr = 0;
while(!st.empty()) {
    char c = st.top();
    if(c == '(') cntl++;
    if(c == ')') cntr++;
    st.pop();
}

rep(i,cntr) {
    s = '(' + s;
}
rep(i,cntl) {
    s = s + ')';
}
cout << s << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n,c=0,p=0; cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	while(1){ c=0;
        for(int i=0;i<n;i++){
            if(arr[i]%2==0)c++;
        }
        if(c==n){
            for(int i=0;i<n;i++){
                arr[i]=arr[i]/2;
            }p++;
        }
        else break;
	}
	cout<<p;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, a;
  cin >> n >> a;
  dump(n*n-a);
  return 0;
}


Measured memory_bytes: 256
def s2int(a):
    dot_idx = -1
    for j in range(len(a)):
        if a[j] == '.':
            dot_idx = j
            break
    # .がないので末尾につける
    if dot_idx == -1:
        a += ".000000000"
    # .の場所に応じて後ろにつける
    else:
        while len(a) < 10+dot_idx:
            a += "0"
    tmps = ""
    for j in range(len(a)):
        if a[j] == '.':continue
        tmps += a[j]
    return int(tmps)

def Count_two_five(x):
    c2 = 0
    c5 = 0
    while x > 0 and x % 2 == 0:
        x //= 2
        c2 += 1
    while x > 0 and x % 5 == 0:
        x //= 5
        c5 += 1
    c2 = min(c2, 18)
    c5 = min(c5, 18)
    return c2, c5

def main():
    N = int(input())

    C2 = [0] * N
    C5 = [0] * N

    for i in range(N):
        C2[i], C5[i] = Count_two_five(s2int(str(input())))

    Cc = [[0] * 19 for _ in range(19)]

    for i in range(N):
        Cc[C2[i]][C5[i]] += 1

    ans = 0
    for i in range(N):
        Cc[C2[i]][C5[i]] -= 1
        l2 = max(0, 18 - C2[i])
        l5 = max(0, 18 - C5[i])
        for j in range(l2, 19):
            for k in range(l5, 19):
                ans += Cc[j][k]
        Cc[C2[i]][C5[i]] += 1

    print(ans//2)

main()

Measured memory_bytes: 80100