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

#define F first
#define S second
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}

const int N = 1e5 + 10;
ll a[N];
vi g[N];

void NO() {
	cout << "NO\n";
	exit(0);
}
void YES() {
	cout << "YES\n";
	exit(0);
}

ll dfs(int i, int p) {
	if (sz(g[i]) == 1) return a[i];

	ll sum = 0;
	int count = 0;
	ll mx = 0;
	for (int j : g[i]) {
		if (j == p) continue;
		ll now = dfs(j, i);
		if (now == -1) NO();
		sum += now;
		++count;
		mx = max(mx, now);
	}
	ll can = sum / 2;
	if (mx > sum - mx) can = sum - mx;
	if (a[i] >= sum - can and a[i] <= sum) return 2*a[i] - sum;
	return -1;
}

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

	int n; cin >> n;
	FOR (i, 0, n - 1) cin >> a[i];
	FOR (i, 1 ,n - 1) {
		int x, y; cin >> x >> y;
		--x, --y;
		g[x].push_back(y), g[y].push_back(x);
	}
	if (n == 2) {
		if (a[0] == a[1]) YES();
		else NO();

	}
	FOR (i, 0, n - 1) {
		if (sz(g[i]) - 1) {
			if (dfs(i, -1)) NO();
			YES();
		}
	}

	return 0;
}




Measured memory_bytes: 13184
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    S[0] = 2 + 48;
    S[1] = 0 + 48;
    S[2] = 1 + 48;
    S[3] = 8 + 48;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

def main():
	N = int(input())
	L = [input() for i in range(N)]
	print('AC x {0}'.format(L.count('AC')))
	print('WA x {0}'.format(L.count('WA')))
	print('TLE x {0}'.format(L.count('TLE')))
	print('RE x {0}'.format(L.count('RE')))
	

if __name__ == "__main__":
	main()




Measured memory_bytes: 16164
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

long long ans = 0;

void solve(string s) {
	for (int i = 1; i <= s.size(); i++) {
		string s1 = s.substr(0, i);
		if (i != s.size()) {
			ans += atoll(s1.data()) * (int)pow(2, s.size() - i -1);
		}
		else ans += atoll(s1.data());
		if (i != s.size()) {
			string s2 = s.substr(i);
			solve(s2);
		}
	}
}

int main()
{
	string s;
	cin >> s;
	solve(s);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#define ld long double
int main()
{
	int n,d,x,i,j;ld ans=0,s=0,k=0;
	scanf("%d%d%d",&n,&d,&x);d=2*d+x;x*=4;
	for(i=1;i<=n;++i,ans+=s)
		if(i<2)for(s=d,k=j=1;j<=n;++j)s+=((ld)x*(i+j-2)+d)/j,k+=1./j;
		else s+=k*x+(ld)d/i-((ld)x*n+d)/(n-i+2),k+=1./i-1./(n-i+2);
	printf("%.10lf",(double)ans/4);
}

Measured memory_bytes: 128
S = input()

num = len(S)

ans = 0

for bit in range(2**(num-1)):
  f = S[0]
  for i in range(num-1):
    if (bit >> i) & 1:
      f += '+'
    f += S[i+1]
  ans += sum(map(int,f.split('+')))

print(ans)


Measured memory_bytes: 9000
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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 a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  ll N,C,K; cin>>N>>C>>K;
  vector<ll> v(N);
  rep(i,0,N) cin >> v[i], v[i] += K;
  sort(all(v));
  ll now = v[0];
  ll ans = 0;
  rep(i,0,N){
    ll j = i;
    while(j<N && v[j]<=now+K && j-i<C){
      j++;
    }
    ans++;
    now = v[j];
    i = j - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4052
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X;
	cin >> X;
	int ans = 0;
	ans += X / 500 * 1000;
	X %= 500;
	ans += X / 5*5;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
n,m = map(int,input().split())
s = input()
t = input()
mx = max(n,m)
mn = min(n,m)
if mx / mn % 1 == 0:
    c = mx//mn
    if mn == len(s):
        if s == t[::c]:
            print(t[::c])
            print(mx)
        else:
            print(-1)
    else:
        if t == s[::c]:
            print(s[::c])
            print(mx)
        else:
            print(-1)
else:
    num = lcm(n,m)
    mmx = num // mx
    mmn = num // mn
    ber = lcm(mmx,mmn)
    if mn == len(s):
        if s[::ber//mmn] == t[::ber//mmx]:
            print(num)
        else:
            print(-1)
    else:
        if s[::ber//mmx] == t[::ber//mmn]:
            print(num)
        else:
            print(-1)

Measured memory_bytes: 9220
#include<iostream>
#include<iomanip>
using namespace std;
long long n, m, a[20];
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int main() {
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		for (int i = 0; i < m; i++)cin >> a[i];
		long long S = 0, L = 0;
		for (int i = 0; i < (1 << m); i++) {
			long long bit[20], cnt = 0, lcm = 1;
			for (int j = 0; j < m; j++) { bit[j] = (i / (1 << j)) % 2; }
			for (int j = 0; j < m; j++) { cnt += bit[j]; }
			for (int j = 0; j < m; j++) {
				if (bit[j] == 1) {
					lcm *= (a[j] / gcd(lcm, a[j]));
				}
			}
			long long K = ((n / lcm) + 1) *(n / lcm) / 2 * lcm;
			if (cnt % 2 == 0) { S += K; L += n / lcm; }
			if (cnt % 2 == 1) { S -= K; L -= n / lcm; }
		}
		if (L == 0)L = 1;
		cout << fixed << setprecision(15) << 1.0l*S / L << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
#include <string.h>
char s[200],t[200],s1[200],d,s2[200];
int main(){
	int i,j,k,l;
	scanf("%s%s",s,t);
	strcpy(s1,s);
	l=strlen(s);
    if(strcmp(s,t)==0){
    	printf("Yes");
    	return 0;
	}
	k=l;
	while(k--){
	strcpy(s2+1,s);
	s2[0]=s[l-1];
	s2[l]='\0';
	strcpy(s,s2);
	if(!strcmp(s,t)){
	 	printf("Yes");
    	return 0;
	}
	}
	printf("No");
    	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer i;
  for(i = nil; i->next != nil; i = i->next)
    {
      if(i->next->key == key)
	{
	  return i->next;
	}
    }
  return NULL;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->next->prev = t->prev;
  t->prev->next = t->next;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer i;
  i = nil->prev;
  deleteNode(i);
}

void delete(int key){
  NodePointer i;
  i = listSearch(key);
  if(i != NULL)
    {
      deleteNode(i);
    }
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

// 型定義
typedef long long ll;
// typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

ll N, K;

vector<ll> P;
vector<ll> C;

ll dist[5010][5010];
ll maxc[5010];
ll ldist[5010];
vector<bool> seen;  // 訪問済みの点

// BFSのための再帰関数
void dfs(const Graph &G, ll v, ll ini_v, ll counter) {
    seen[v] = true;
    maxc[ini_v] = counter;
    if(counter == 1) dist[ini_v][counter] = C[v];
    else dist[ini_v][counter] = dist[ini_v][counter-1] + C[v];
    ldist[ini_v] += C[v];
    // cout << v << endl;
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v, ini_v, counter+1); // 再帰的に値を追加していく
    }
}

int main()
{
    cout << fixed << setprecision(15);

    cin >> N >> K;

    P.assign(N, 0);
    C.assign(N, 0);

    Fill(dist , 0);
    Fill(maxc , 0);
    Fill(ldist , 0);
    REP(i, N){
        cin >> P[i];
    }
    REP(i, N){
        cin >> C[i];
    }

    // グラフ
    Graph G(N);

    REP(i, N){
        G[i].push_back(P[i]-1);
    }

    REP(i, N){
        seen.assign(N, false);
        dfs(G, P[i]-1, i, 1);
        // cout << "next" << endl;
    }

    // REP(i, N){
    //     for(ll j=1; j<=maxc[i]; j++){
    //         cout << "i:" << i << ", j:" << j << ", dist[i][j]:" << dist[i][j] << endl;
    //     }
    // }
    ll ans = -LINF;
    REP(i, N){
        // ループが正のとき
        if(ldist[i] > 0){
            // 1週以上できるとき
            if(K > maxc[i]){
                ll temp = ldist[i] * (K/maxc[i]);
                ll temp2 = 0;
                for(ll j=1; j<= K%maxc[i]; j++){
                    temp2 = max(temp2, dist[i][j]);
                }
                // cout << "hello" << endl;
                ans = max(ans, temp+temp2);

                temp = ldist[i] * ((K/maxc[i])-1);
                temp2 = 0;
                for(ll j=1; j<= maxc[i]; j++){
                    temp2 = max(temp2, dist[i][j]);
                }
                // cout << "hello" << endl;
                ans = max(ans, temp+temp2);
                
            }
            else{
                for(ll j=1; j<= min(K, maxc[i]); j++){
                    ans = max(ans, dist[i][j]);
                }
            }

        }
        else{
            // ループが負なので好きなときにとめて一番大きいところを答えにする
            for(ll j=1; j<= min(K, maxc[i]); j++){
                ans = max(ans, dist[i][j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 200456
#include <stdio.h>


int main(void) {
    int p, count, c, i;
    int coin[] = {500, 100, 50, 10, 5, 1};

    while (scanf("%d", &p) != EOF && p) {
        p = 1000 - p;
        for (i = 0, count = 0; p && i < 6; i++) {
            c = p / coin[i];
            count += c;
            p -= c * coin[i];
        }

        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 600
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int H;
  int W;
  int h;
  int w;
  rd(H);
  rd(W);
  rd(h);
  rd(w);
  wt_L((H-h)*(W-w));
  wt_L('\n');
  return 0;
}
// cLay varsion 20190925-1

// --- original code ---
// {
//   int H, W, h, w;
//   rd(H,W,h,w);
//   wt((H-h)*(W-w));
// }


Measured memory_bytes: 256
use std::io;

fn read_line()  -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).expect("Couldn't read standard input");
    buf.trim().to_owned()
}

fn main() {
    let _n: i32 = read_line().parse().unwrap();
    let a: Vec<i32> = read_line()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();

    let mut sum: i32 = 0;
    for n in a.iter() {
        sum = sum + n - 1;
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
set<int>s;
int main()
{
     int n;
     scanf("%d",&n);
     for(int i=0;i<n;i++)
     {
          int a;
          scanf("%d",&a);
          s.insert(a);
     }
     printf("%d\n",s.size());
}


Measured memory_bytes: 256
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
a = [0]*26

if len(s) != 26:
    for x in s:
        a[ord(x)-ord('a')] += 1
    for i in range(26):
        if a[i] == 0:
            tmp = i
            break
    ans = s + chr(ord('a')+tmp)
else:
    if s == "zyxwvutsrqponmlkjihgfedcba":
        ans = -1
    else:
        for i in range(len(s)-1, -1, -1):
            k = ord(s[i])-ord('a')
            j = 1
            while k + j < 26:
                if a[k+j] == 0:
                    j += 1
                else:
                    tmp = k + j
                    break
            else:
                a[k] += 1
                continue
            tmp2 = i
            break
        ans = s[:tmp2] + chr(tmp+ord('a'))
print(ans)

Measured memory_bytes: 10172
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;



int main() {
    string s;
    
    cin>>s;
    
    if(s=="ABC") s= "ARC";
    else s ="ABC";
    
    cout<<s<<endl;
    
    return 0;
}



Measured memory_bytes: 3592
# coding: utf-8
# Your code here!

A, B, C = map(int, input().split())

# print(A)
# print(B)
# print(C)

# print(A - B)

# print(C - (A - B))

x = C - (A - B)

if x > 0:
    print(x)
else:
    print(0)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner scanner = new FastScanner(System.in);
		String str = scanner.nextLine();
		StringBuilder strBuild = new StringBuilder();
		for (int i = 0; i < str.length(); i++) {
			if (i == 3) {
				strBuild.append("8");
			} else {
				strBuild.append(str.charAt(i));
			}
		}
		PrintWriter printWriter = new PrintWriter(System.out);
		printWriter.printf("%s\n", strBuild.toString());
		printWriter.close();
	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

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

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public long nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = (int) nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 24660
s=input()
if s=="SUN":
  print(7)
elif s=="MON":
  print(6)
elif s=="TUE":
  print(5)
elif s=="WED":
  print(4)
elif s=="THU":
  print(3)
elif s=="FRI":
  print(2)
elif s=="SAT":
  print(1)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  
  if (N <= 1)cout << 1 << endl;
  else if (N < 2)cout << 1 << endl;
  else if (N < 4)cout << 2 << endl;
  else if (N < 8)cout << 4 << endl;
  else if (N < 16)cout << 8 << endl;
  else if (N < 32)cout << 16 << endl;
  else if (N < 64)cout << 32 << endl;
  else cout << 64  << endl;
  
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
queue<long long>q;
long long a[100005];
int k;
void init()
{
    int cnt=0;
    for(int i=1;i<=9;i++)
        q.push(i);
    while(!q.empty())
    {
        long long ans=q.front();
        q.pop();
        a[++cnt]=ans;
        if(cnt>=100000) break;
        if(ans%10==0)
        {
            q.push(ans*10);
            q.push(ans*10+1);
        }
        else if(ans%10>=1&&ans%10<=8)
        {
            long long k=ans%10;
            q.push(ans*10+k-1);
            q.push(ans*10+k);
            q.push(ans*10+k+1);
        }
        else
        {
            long long k=ans%10;
            q.push(ans*10+k-1);
            q.push(ans*10+k);
        }
    }
}
int main()
{
    init();
    scanf("%d",&k);
    printf("%lld\n",a[k]);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
signed main(){
	int n,a,b,x[100000];
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)cin>>x[i];
	int ans=0;
	for(int i=0;i<n-1;i++){
		if(a*(x[i+1]-x[i])>=b)ans=ans+b;
		else ans=ans+a*(x[i+1]-x[i]);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
def main():
    n = int(input())

    while True:
        hund = n // 100
        ten = (n % 100) // 10
        one = n % 10
        if hund == ten and hund == one:
            print(n)
            break
        else:
            n += 1

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int toint(iv v)
{
	int ret = 0;
	int x = 1;
	for(int i = v.size()-1;i >= 0;i--)
	{
		ret += v[i] * x;
		x *= 10;
	}
//	cout << ret << endl;
	return ret;
}

iv toiv(int n,int l)
{
	iv ret;
	REP(i,l)
	{
		ret.PB(n%10);
		n /= 10;
	}
//	SHOW1d(ret,ret.size());
	
	return ret;
	
}

int main()
{
	int a,l;
	
	while(cin >> a >> l,a|l)
	{
		int _list[21] = {};
		_list[0] = a;
		
		bool flag = false;

		
		REP(i,21)
		{
			iv tmp = toiv(_list[i],l);
			sort(ALL(tmp));
			int _min = toint(tmp);
			sort(ALL(tmp),greater<int>());
			int _max = toint(tmp);
			int lis = _max -_min;
			
	//		cout << _max << ' ' << _min << endl;
			
			REP(j,i+1)
			{
				if(_list[j] == lis)
				{
					cout << j << ' ' << _list[j] << ' ' << i - j + 1 << endl;
					flag = true;
				}
				if(flag)break;
			}
			
			_list[i+1] = lis;
			if(flag)break;
		}
		
		int listmp = _list[20],_cou = 21;
		
		while(1)
		{
			if(flag)break;
			iv tmp = toiv(listmp,l);
			sort(ALL(tmp));
			int _min = toint(tmp);
			sort(ALL(tmp),greater<int>());
			int _max = toint(tmp);
			int lis = _max -_min;
			REP(j,21)
			{
				if(_list[j] == lis)
				{
					cout << j << ' ' << _list[j] << ' ' << _cou - j + 1 << endl;
					flag = true;
				}
			}
			
			listmp = lis;
			_cou++;
		}	
		
		
		NEXT:;
		
	}
		
	
	return 0;
}

Measured memory_bytes: 3172
import math
ans=int(input().strip('\n'))
if ans!=2:
    flag=True
    while flag:
        for i in range(2,math.ceil(math.sqrt(ans))+1):
            if ans%i==0:
                flag=False
                break
        if flag:
            break
        else:
            flag=True
            ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=410,mod=998244353;
int n,sa,sb,ans;
int a[N],b[N],fac[N],ifac[N],dp[N][N][N];
inline int pw(int x,int y){
	int res=1;
	for(;y;x=x*x%mod,y>>=1) if(y&1) res=res*x%mod;
	return res;
}
void pre(){
	fac[0]=1; for(int i=1;i<=N-10;i++) fac[i]=fac[i-1]*i%mod;
	ifac[N-10]=pw(fac[N-10],mod-2);
	for(int i=N-10-1;i>=0;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
} 
signed main(){
	scanf("%lld",&n); pre();
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]),sa+=a[i],sb+=(b[i]-1);
	dp[0][0][0]=-1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=sa;j++)
			for(int k=0;k<=sb;k++){
				if(!dp[i-1][j][k]) continue; 
				dp[i][j][k]+=dp[i-1][j][k],dp[i][j][k]%=mod;
				for(int c=0,mul=1;c<b[i];c++,mul=mul*a[i]%mod) 
					dp[i][j+a[i]][k+c]+=-1ll*dp[i-1][j][k]*mul%mod*ifac[c]%mod,dp[i][j+a[i]][k+c]%=mod;
			}
			
	for(int i=0;i<=sa;i++)
		for(int j=0,mul=pw(i,mod-2),tp=mul;j<=sb;j++,mul=mul*tp%mod){
			ans=(ans+dp[n][i][j]*sa%mod*fac[j]%mod*mul%mod)%mod;
		}
	printf("%lld",(ans+mod)%mod);
} 

Measured memory_bytes: 262200
#include "bits/stdc++.h"
using namespace std;

typedef pair<long long, long long> P;

int main() {
	long long H, W, N, a, b, ans[10] = {};
	map<P, bool> mp1, mp2;
	cin >> H >> W >> N;
	ans[0] = (H - 2) * (W - 2);
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		a--, b--;
		mp2[P(a, b)] = true;
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (0 <= a - j && a - j <= H - 3 && 0 <= b - k && b - k <= W - 3) {
					mp1[P(a - j, b - k)] = true;
				}
			}
		}
	}
	for (auto it = mp1.begin(); it != mp1.end(); it++) {
		int x = it->first.first, y = it->first.second;
		int count = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (mp2[P(x + i, y + j)]) count++;
			}
		}
		ans[0]--;
		ans[count]++;
	}
	for (int i = 0; i < 10; i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 212736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
	string t;

	cin >> t;

	for(int i=0; i<t.size(); i++){
		if(t[i] == '?'){
			t[i] = 'D';
		}
	}

	cout << t << endl;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
bool is_prime(const unsigned int n)
{
  if (n < 2)
    return false;
  if (n == 2 || n == 3)
    return true;
  if (n % 2 == 0 || n % 3 == 0)
    return false;
  for (unsigned int i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return false;
  return true;
}
int main()
{
  int x;
  cin >> x;
  while (not is_prime(x))
    x++;
  cout << x << endl;
  return 0;
}


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

if n < 10:
  print(n)

elif n < 10**2:
  print(9)
  
elif n < 10**3:
  print(9+n-100+1)
  
elif n < 10**4:
  print(909)
  
elif n < 10**5:
  print(909+n-10000+1)

else:
  print(90909)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9+7;
ll const inf = 1e6+2;
ll fact[inf];
void factfill()
{
    fact[0]=1;
    for(ll i=1; i<inf; i++)
        fact[i] = ( fact[i-1]*i ) % mod;
}

ll powmod(ll a, ll b)
{
    ll res = 1;
    while(b){
        if(b%2) res = ( res*a )%mod;
        a = (a*a)%mod;
        b/=2;
    }
    return res;
}

ll inv(ll x)
{
    return powmod(x,mod-2) % mod;
}

ll choose(ll n, ll r)
{
    return ( (fact[n]* inv(fact[n-r] ) )%mod *inv(fact[r]))%mod;
}
void solve()
{   

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


   

   ll mincost = LLONG_MAX;
   for(ll i=-100; i<=100; i++)
   {
        ll curr=0;
        for(ll j=0; j<n; j++){

            curr += (a[j]-i)*(a[j]-i);

        }
       
        mincost = min( mincost, curr );


   }
   cout << mincost;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        //factfill();
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return a;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }

int main() {
  int H,W; cin >>H >>W;
  vector<string> maze(H);
  for (int i=0; i<H; i++) cin >>maze.at(i);

  vector<int> dx = {0, 1, 0, -1};
  vector<int> dy = {1, 0, -1, 0};
  
  int realans = 0;

  for (int roadi=0; roadi<H; roadi++){
    for (int roadj=0; roadj<W; roadj++){
      if (maze.at(roadi).at(roadj) == '#') continue;
      // maze.at(roadi).at(roadj)から幅優先探索すれば最大移動回数になるはず
      vector<vector<int>> dist = vector<vector<int>>(H, vector<int>(W, -1)); //全頂点を未訪問に
      queue<pair<int,int>> que;

      dist.at(roadi).at(roadj) = 0;
      que.push(make_pair(roadi, roadj));

      while(!que.empty()){
        pair<int, int> v = que.front(); que.pop();
        for (int i=0; i<4; i++){
          int y = v.first + dy.at(i), x = v.second + dx.at(i);
          if (y < 0 || y >= H || x < 0 || x >= W) continue;
          if (maze.at(y).at(x) == '#') continue;
          if (dist.at(y).at(x) != -1) continue;
          dist.at(y).at(x) = dist.at(v.first).at(v.second) + 1;
          que.push(make_pair(y, x));
        }
      }
      int ans = 0;
      for (int i=0; i<H; i++){
        for (int j=0; j<W; j++){
          if (maze.at(i).at(j) == '#') continue;
          int tmp = dist.at(i).at(j);
          if (tmp > ans) ans = tmp;
        }
      }
      realans = max(realans, ans);
    }
  }

  

  cout <<realans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int n = s.size();
    string t = "";
    rep(i, n) t += 'x';
    cout << t << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long int lli;

int main(){
    string s;
    cin >> s;
    lli ans = 0, tail = s.length() - 1;
    for(lli i = s.length() - 1; i > -1; i--){
        //printf("i = %lld, tail = %lld, ans = %lld\n", i, tail, ans);
        if(s[i] == 'B'){
            //printf("found B\n");
            ans += tail - i;
            tail--;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		

		while(sc.hasNext()) {
			int[] a = new int[4];
			int[] b = new int[4];
			
			for(int i=0; i<4;i++) {
				a[i] = sc.nextInt();
			}
			for(int i=0; i<4; i++) {
				b[i] = sc.nextInt();
			}
			
			int hit = 0;
			int blow = 0;
			
			for(int i=0; i<4;i++) {
				if (a[i] == b[i]) {
					hit++;
				}else {
					for(int j=0; j<4; j++) {
						if(a[i] == b[j]) {
							blow++;
						}
					}
				}
			}
			System.out.print(hit +" ");
			System.out.println(blow);
			
		}	
	}
}



Measured memory_bytes: 25896
n,k,l=map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
uf1=UnionFind(n)
uf2=UnionFind(n)
d=dict()
a,b=[0]*n,[0]*n
for i in range(k):
  p,q=map(int,input().split())
  uf1.union(p-1,q-1)
ans=[0]*n
for i in range(l):
  r,s=map(int,input().split())
  uf2.union(r-1,s-1)
for i in range(n):
  a[i]=uf1.find(i)
  b[i]=uf2.find(i)
  if (a[i],b[i]) not in d:
    d[(a[i],b[i])]=1
  else:
    d[(a[i],b[i])]+=1
for i in range(n):
  ans[i]=d[(a[i],b[i])]
print(*ans)

Measured memory_bytes: 110432
#include<cstdio>
#include<algorithm>
using namespace std;
int n,m;
long long sum;
int main() {
	scanf("%d %d",&n,&m);
	sum=(long long)(n-2)*(m-2);
	if(sum>0) printf("%lld\n",sum);
	else printf("%lld\n",-sum);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <stack>
#include <cstdio>
#include <string>
#include <bitset>
#include <list>
#include <set>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <functional>
#include <queue>
#include <regex>
#include <cassert>
#include <map>
// #include "bits/stdc++.h"

using namespace std;
//debug

#define rep(i, N, M) for (ll i = N; i < M; ++i)
#define rrep(i, N, M) for (ll i = N; i < M; --i)
#define pb push_back


typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef priority_queue<ll> pqll;
typedef priority_queue<pll, vector<pll>> pqpll;
typedef priority_queue<ll, vll, greater<ll>> pqll_greater;
typedef priority_queue<pll, vector<pll>, greater<pll>> pqpll_greater;


#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define vec(a) vector<a>
#define _CRT_SECURE_NO_WARNINGS

template<class T, class S>
T atbit(T n, S i) {
	return (n >> i) % i;
}

template<class T>
T getbit(T i) {
	return 1LL << i;
}

//#define TRANSFORM(v,w,func) decltype(v) w ; transform((v).begin(),(v).end(),back_inserter(w),func);

using namespace std;


int main() {
	ll N, M;
	cin >> N >> M;
	vll A(N+1,0),B(N);
	rep(i, 0, N) {
		cin >> B[i];
		B[i] = B[i] % M;
	}
	rep(i, 1, N+1) {
		A[i] += A[i - 1] + B[i - 1];
		A[i] %= M;
	}
	sort(all(A));
	map<ll, ll> f;
	while (!A.empty()) {
		auto i = A.back();
		f.insert({ i,0 });
		while (!A.empty()&&i == A.back()) {
			A.pop_back();
			++f.at(i);
		}

	}
	
	ll cnt=0LL ;
	for (auto x : f) {
		cnt+= x.second *(x.second - 1) / 2;
	}

	cout<<cnt;

	
}


Measured memory_bytes: 5760
#include<stdio.h>
int main(void){
  int i,ans=0;
	char s[4];
	scanf("%s",s);


	if(s[0]=='a'&&s[1]=='b'&&s[2]=='c'){
    ans=1;
  }
  else if(s[0]=='a'&&s[1]=='c'&&s[2]=='b'){
    ans=1;
  }
  else if(s[0]=='b'&&s[1]=='a'&&s[2]=='c'){
    ans=1;
  }
  else if(s[0]=='b'&&s[1]=='c'&&s[2]=='a'){
    ans=1;
  }
  else if(s[0]=='c'&&s[1]=='b'&&s[2]=='a'){
    ans=1;
  }
  else if(s[0]=='c'&&s[1]=='a'&&s[2]=='b'){
    ans=1;
  }

  if(ans==1){
    printf("Yes\n");
  }
	else {
    printf("No\n");
  }

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<string,int> a;
  map<string,int>::iterator itr;
  int n,max=0;
  string s;
  cin>>n;
  for(int i;i<n;i++){
    cin>>s;
    a[s]++;
  }
  for(itr=a.begin();itr!=a.end();itr++){
    if(itr->second>max){
      max=itr->second;
    }
  }
  for(itr=a.begin();itr!=a.end();itr++){
    if(itr->second==max){
      cout<<itr->first<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>

using namespace std;

vector<int>dp;

int fib_dp(int n) {
    if (dp[n] != -1) return dp[n];
    dp[n] = fib_dp(n-1) + fib_dp(n-2);
    return dp[n];
}

int main() {
    int n;
    cin >> n;
    dp.resize(n+1);
    for (int i = 0; i <= n; ++i) dp[i] = -1;
    dp[0] = 1;
    dp[1] = 1;
    cout << fib_dp(n) << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

struct LowLink {
    
    vector < vector < int > > G;
    vector < int > ord, low;
    vector < bool > used;
    vector < pair < int, int > > bridge;
    vector < int > articulation_point;
    const int INF = 1145141919;
    
    LowLink (int n) : G(n), ord(n), low(n), used(n) {}
    
    void add_edge(int a, int b) {
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    void build(int root) {
        fill(low.begin(), low.end(), INF);
        fill(used.begin(), used.end(), false);
        dfs(root, -1, 1);
    }
    
    int dfs(int v, int prev, int cnt) {
        used[v] = true;
        low[v] = ord[v] = cnt;
        int min_low = cnt;
        int route = 0;
        bool isArticulation = false;
        for (int i = 0; i < G[v].size(); i++) {
            if (!used[G[v][i]]) {
                route++;
                int low_nxt = dfs(G[v][i], v, cnt + 1);
                if (ord[v] < low_nxt) {
                    bridge.push_back(make_pair(v, G[v][i]));
                }
                if (prev != -1 && G[v].size() >= 2 && low_nxt >= cnt) {
                    isArticulation = true;
                }
                min_low = min(min_low, low_nxt);
            } else if (G[v][i] != prev) {
                min_low = min(min_low, low[G[v][i]]);
            }
        }
        if (prev == -1 && route > 1) isArticulation = true;
        if (isArticulation) articulation_point.push_back(v);
        return low[v] = min_low;
    }
    
};


int main() {
    
    int V,E; cin >> V >> E;
    LowLink inst(100010);
    
    REP(i,E) {
        int a,b; cin >> a >> b;
        inst.add_edge(a, b);
    }
    
    inst.build(0);
    
    vector < pair < int, int > > ans;
    
    REP(i,inst.bridge.size()) {
        int a = min(inst.bridge[i].first, inst.bridge[i].second);
        int b = max(inst.bridge[i].first, inst.bridge[i].second);
        ans.push_back(make_pair(a, b));
    }
    
    sort(ans.begin(), ans.end());
    REP(i,ans.size()) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    
    return 0;
}

Measured memory_bytes: 7324
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
#include <chrono>
#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

string s;

void hora(int tc) {
	cin>>s;
	int len = s.length();
	for(int i = 0;i < len;i++) {
		if(s[i] == '?') {
			if(i != 0 && s[i - 1] == 'P') s[i] = 'D';
			else if(i != len - 1 && s[i + 1] == 'D') s[i] = 'P';
			else if(i != len - 1 && s[i + 1] == '?') {
				s[i] = 'P';
				s[i + 1] = 'D';
			} else s[i] = 'D';
		}
	}
	cout<<s<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 3772
s = input().replace('><','> <').split()
ans = 0
#print(list(s))
for st in s:
    lt = st.count('<')
    gt = len(st) - lt
    if lt > gt:
        gt -= 1
    else:
        lt -= 1
    ans += (lt*lt+lt)//2 + (gt*gt+gt)//2
print(ans)

Measured memory_bytes: 12468
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
ch = ["z"]+[chr(i) for i in range(ord("a"), ord("a")+25)]

ans = ""
while n>0:
    if n%26: ans = ch[n%26] + ans; n //= 26
    else: ans = ch[n%26] + ans; n //= 26; n -= 1
print(ans)


Measured memory_bytes: 37692
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int comp[maxN], szz[maxN], n, m, k, ans[maxN];

int get(int u) {
	if(u != comp[u]) return comp[u] = get(comp[u]);
	return comp[u];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	cin >> n >> m >> k;
	iota(comp, comp + n, 0);
	for(int i = 0, u, v; i < m; i++) {
		cin >> u >> v, u--, v--;
		ans[u]--, ans[v]--;
		comp[get(u)] = get(v);
	}
	for(int i = 0; i < n; i++) szz[get(i)]++;
	for(int i = 0; i < n; i++) ans[i] += szz[get(i)];

	for(int i = 0, u, v; i < k; i++) {
		cin >> u >> v, u--, v--;
		if(get(u) == get(v)) ans[u]--, ans[v]--;
	}
	for(int i = 0; i < n; i++) cout << ans[i] - 1 << ' '; cout << '\n';
}


Measured memory_bytes: 2304
def Gcd(a,b):
    if a < b:
        return Gcd(b,a)
    else:
        if a%b:
            return Gcd(b,a%b)
        else:
            return b

N = int(input())
arr = list(map(int,input().split()))
gcd = arr[0]
for i in arr:
    gcd = Gcd(gcd,i)
print(gcd)

Measured memory_bytes: 14224
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1e9;
const int MAX_N = 2510;

vector<int> to[MAX_N];
vector<int> rto[MAX_N];
bool reachableFrom1[MAX_N];
bool reachableToN[MAX_N];
bool ok[MAX_N];

void dfs(int v) {

    if(reachableFrom1[v]) {
        return;
    }

    reachableFrom1[v] = true;
    
    for(int u : to[v]) {
        dfs(u);
    }
}

void rdfs(int v) {

    if(reachableToN[v]) {
        return;
    }

    reachableToN[v] = true;
    
    for(int u : rto[v]) {
        rdfs(u);
    }
}

int main() {
    int n, m, p;
    cin >> n >> m >> p;

    vector<tuple<int, int, int>> edges;
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;  b--;
        c -= p;
        c *= -1;
        edges.emplace_back(a, b, c);
        to[a].push_back(b);
        rto[b].push_back(a);
    }

    dfs(0);
    rdfs(n-1);

    rep(i, n) {
        ok[i] = reachableFrom1[i] && reachableToN[i];
    }

    vector<int> dist(n, INF);

    dist[0] = 0;
    bool upd = true;
    int step = 0;
    while(upd) {

        upd = false;
        
        rep(i, m) {
            int a, b, c;
            tie(a, b, c) = edges[i];

            if(!ok[a] || !ok[b]) {
                continue;
            }

            int newD = dist[a] + c;
            if(newD < dist[b]) {
                upd = true;
                dist[b] = newD;
            }
        }

        step++;

        if(step > n) {
            cout << -1 << endl;
            return 0;
        }

    }

    int ans = max(0, -dist[n-1]);

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

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

using namespace std;

#define ll long long

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

    return 0;
}

Measured memory_bytes: 3632