akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a%b) : a; }

template<typename T>
T lcm(T a, T b) { return a*(b/gcd(a,b)); }

template<typename T> 
vector<T> getFactor(T n) {
    vector<T> ret;

    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }

    sort(ret.begin(), ret.end());

    return ret;
}

map<ll, ll> PrimeFactorial(ll n) 
{
    map<ll,ll> ret;
    
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while (n % i == 0) {
                ret[i]++;
                n /= i;
            }
        }
    }

    if(n > 1) { ret[n]++; }

    return ret;
}

int main(void)
{
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a,b);
   
    auto f = PrimeFactorial(g);

    cout << f.size() + 1<< endl;

    return 0;
} /*atcoder*/



Measured memory_bytes: 3612
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int MOD = 1000000007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		long[][] dp = new long[N + 1][N + 1];
		dp[0][0] = 1;
		int idx = 0;
		for (int i = 0; i < N; ++i) {
			char v = sc.next().charAt(0);
			if (v == '-') continue;
			++idx;
			if (v == 'D') {
				for (int j = 0; j < idx; ++j) {
					dp[idx][j] += dp[idx - 1][j] * j % MOD;
					if (j > 0) dp[idx][j - 1] += dp[idx - 1][j] * j * j % MOD;
				}
			} else {
				for (int j = 0; j < idx; ++j) {
					dp[idx][j + 1] += dp[idx - 1][j];
					dp[idx][j] += dp[idx - 1][j] * j % MOD;
				}
			}
		}
		System.out.println(dp[idx][0] % MOD);
	}
}

Measured memory_bytes: 18636
s = list(map(str,input().split()))
dict = {}
for n in s:
    if n in dict:
        dict[n] += 1
    else:
        dict[n] = 1
long_word = ''
freq_word = ''
max_len = 0
max_fre = 0
for k,v in dict.items():
    if max_len < len(k):
        long_word = k
        max_len = len(k)
    if max_fre < v:
        freq_word = k
        max_fre = v
print(freq_word,long_word)


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    string A, B, C;
    cin >> A >> B >> C;

    A[0] -= 32;
    B[0] -= 32;
    C[0] -= 32;
    
    cout << A[0] << B[0] << C[0] << endl;

}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < H; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }

  cout << endl;

  for (int i = 0; i < H; i++) {
    cout << '#' << vec.at(i) << '#' << endl;
  }

  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }

  cout << endl;
 }


Measured memory_bytes: 256
class Dice
  attr_reader :pos

  def initialize(pos)
    @pos = pos
  end

  def roll(direction)
    case direction
    when :W
      @pos = [@pos[2], @pos[1], @pos[5], @pos[0], @pos[4], @pos[3]]
    when :S
      @pos = [@pos[4], @pos[0], @pos[2], @pos[3], @pos[5], @pos[1]]
    when :E
      @pos = [@pos[3], @pos[1], @pos[0], @pos[5], @pos[4], @pos[2]]
    when :N
      @pos = [@pos[1], @pos[5], @pos[2], @pos[3], @pos[0], @pos[4]]
    end
  end
end

pos  = gets.chomp.split.map(&:to_i)
dice = Dice.new(pos)
gets.chomp.split('').each{|d| dice.roll(d.to_sym)}

puts dice.pos[0]


Measured memory_bytes: 6876
cards = {}
["S","H","C","D"].each do |pattern|
  (1..13).each do |num|
    cards[pattern] ||= []
    cards[pattern] << num
  end
end

n = gets.to_i
n.times do
  pattern,num = gets.split
  cards[pattern].delete(num.to_i)
end
cards.each do |pattern,nums|
  nums.each {|num| puts pattern + " " + num.to_s}
end



Measured memory_bytes: 6848
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
class Node {
public:
	int key;
	Node *prev, *next;
};
Node *nil;
Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil&&cur->key != key) {
		cur = cur->next;
	}
	return cur;
}
void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}
void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while (true) {
		if (cur == nil)break;
		if (isf++ > 0)printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}
void deleteNode(Node *t) {
	if (t == nil)return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}
void deleteFirst() {
	deleteNode(nil->next);
}
void deleteLast() {
	deleteNode(nil->prev);
}
void deleteKey(int key) {
	deleteNode(listSearch(key));
}
void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->prev = nil;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
}
int main() {
	init();
	int n, key;
	char com[20];
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
		if (com[0] == 'i') {
			insert(key);
		}
		else if (com[0] == 'd') {
			if (strlen(com) > 6) {
				if (com[6] == 'F')deleteFirst();
				else if (com[6] == 'L')deleteLast();
			}
			else {
				deleteKey(key);
			}
		}
		
	}
	printList();
	return 0;
}

Measured memory_bytes: 32364
#include <stdio.h>

int main(){
  int i,j,n;
  int A[2000001],B[2000001],C[2000001];

  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  
  for(i = 0; i < 2000000; i++){
    C[i] = 0;
  }

  for(j = 0; j < n; j++){
    C[A[j]]++;
  }

  for(i = 1; i <= 2000000; i++){
    C[i] = C[i] + C[i-1];
  }
  
  for(j = n-1; j >= 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  
  for(i = 1; i <= n; i++){
    printf("%d",B[i]);
    if(i == n)printf("\n");
    else printf(" ");
  }
  
  return 0;
}



Measured memory_bytes: 25204
#include<bits/stdc++.h>
#include <complex>
#define ll long long
#define ld long double
#define F first
#define S second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
#define pi acos(-1)
#define X real()
#define Y imag()
#define angle(a) (atan2((a).imag(),(a).real()))
#define vec(a,b) ((b)-(a))
#define lenght(a) (hypot((a).imag(),(a).real()))
#define normalize(a) (a)/length(a)
#define point complex<long double>
#define dP(a,b)((conj(a)*(b)).real())
#define cP(a,b)((conj(a)*(b)).imag())
#define same(p1,p2)  (dP(vec(p1,p2),vec(p1,p2)) < EPS)
#define lengthsqr(p)   dP(p,p)
#define rotate0(p,ang)  ((p)*exp(point(0,ang)))
#define rotataA(p,ang,about) (rotate0(vec(about,p),ang)+about)
#define reflect0(v,m) (conj((v)/(m))*(m))
const ld EPS = (1e-10);
using namespace std;
const int N = 2e3+40, mod = 1e9+7;
ll fact[N], INV[N] ;
ll fp (ll b, ll p)
{
    if ( p == 0 )
        return 1 ;
    ll temp = fp(b,p/2)%mod ;
    temp = (temp*temp)%mod ;
    if ( p%2)
        temp = (temp *b )%mod ;
    return temp;
}
void pre()
{
    fact[0] = 1 ;
    INV[0] = 1 ;
    for ( int i = 1 ; i <= N ; i++)
    {
        fact[i] = (fact[i-1]*i)%mod ;
        INV[i] = fp(fact[i],mod-2);
    }
    return ;
}
ll nCr(ll n, ll r)
{
    if ( r > n)
            return 0 ;
    if ( n == r || r == 0 )
            return 1 ;
    return (((fact[n] * INV[n-r])%mod) * INV[r])%mod;
}
int main()
{
    Tsetso
    pre();
    int n, k ;
    cin >> n >> k ;
    for ( int i = 1 ; i <= k ; i++)
        cout << (nCr(n-k+1,i)*nCr(k-1,i-1))%mod << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int n, d, x;
vector<int> a;

void input(){
    cin >> n;
    cin >> d >> x;
    a.resize(n);
    for(int i=0;i<n;i++) cin >> a[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = x;
    for(int i=0;i<n;i++){
        ans += ((d-1) / a[i] + 1);
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
  string S, T, U;
  int A, B;
  cin >> S >> T >> A >> B >> U;
  if (S == U)
    cout << A - 1 << " " << B;
  else
    cout << A << " " << B - 1;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3+10;
int main()
{
	int n;
	int a[maxn][maxn]={};
bool vis[maxn]={};
int  now[maxn]={};
	scanf("%d",&n);
	for(int i=1;i<maxn;i++)now[i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n-1;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int day = 0;
    int round = n*(n-1)/2;
    while(round)
    {   for(int i=1;i<=n;i++)
        {
    	    if(now[i]<=n-1)
    	    {
    	    	int b=a[i][now[i]];
    	    	vis[i]=(a[b][now[b]]==i);
			}
	    }
	    int fn = 0;
	    for(int i=1;i<=n;i++)
	    {
	    	if(vis[i])
	    	{
	    		fn++;
	    		now[i]++;
			}
			vis[i]=false;
		}
		if(!fn)
		{
			day=-1;
			break;
		}
		else
		{
			round-=fn/2;
			day++;
		}
	}
	printf("%d\n",day);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
using namespace std;
typedef long long ll;
#define inf 1e8
int main() {
    int a, b, c; cin >> a >> b >> c;
    for (int i = a; i < a * b; i += a) {
        //c = a % b = ka % b = (ka + ba) % b = (k + b)a % b
        if (i % b == c) {
            cout << "YES" << endl;
            //cout << i << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int i=0;
  char a[11],b[11],c[11];
  scanf("%s%s%s",a,b,c);
  while (a[i]) i++;
  if (a[i-1]!=b[0]){
    printf("NO\n");
    return 0;
  }
  i=0;
  while (b[i]) i++;
  if (b[i-1]!=c[0]) printf("NO\n");
  else printf("YES\n");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){

    int elaps = 0;
    queue<pair<string,int>> Q;

    int n, q;
    cin >> n >> q;

    string s;
    int c;

    for(int i=0; i<n; ++i){
        cin >> s >> c;
        Q.push(make_pair(s,c));
    }
    while( !Q.empty()){
        s=Q.front().first;
        c=Q.front().second;
        Q.pop();
        int n = min(q,c);
        elaps += n;
        c = c-q;
        if( c>0 ){
            Q.push(make_pair(s,c));
        }else{
            cout << s << ' ' << elaps << endl;
        }
    }


    return 0;
}


Measured memory_bytes: 6324
from collections import defaultdict,Counter
N = int(input())
A = [int(c) for c in input().split()]
B = [c-i for i,c in enumerate(A)]
dic = defaultdict(int)
Cnt = Counter(B)
ans = 0
for i,c in enumerate(B):
  dic[c] += 1
  ans += Cnt[-2*i-c]-dic[-2*i-c]
print(ans)

Measured memory_bytes: 153444
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), a[] = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
        IntStream.rangeClosed(-100, 100).map(i -> Arrays.stream(a).map(j -> (j - i) * (j - i)).sum()).min().ifPresent(System.out::println);
    }
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if(c-b-a<=0){
      cout << "No" << endl;
      return 0;
  }
  if((c-b-a)*(c-b-a)>(4*a*b))cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int k,n,ar[1000000],br[1000000];
    cin >> k >> n;
    ar[0]=0;
    for(int i=1;i<=n;i++){
        cin >> ar[i];
        br[i]= ar[i]-ar[i-1];
    }
    br[0]=k-ar[n]+ar[1];
    sort(br,br+n+1);

    cout << k-br[n] << endl;
  return 0;
}


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

using namespace std;

int main() {
  char a[4];
  cin >> a ;
  if(a[0] == a[1] && a[1] == a[2])puts("Yes");
  else if(a[2] == a[3] && a[1] == a[2])puts("Yes");
  else puts("No");
  return 0;
}


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

#define int long long
template<class T> struct BinaryIndexTree{
    int n;
    vector<T> bit; 
    vector<T> org;

    BinaryIndexTree(int si): bit(si+1), org(si+1) { n = si; }; 

    void add(int idx, T v){
        org[++idx] += v;
        for(int i = idx;i <= n;i+=i&-i) bit[i] += v;
    }

    void update(int idx, T v){
        T vv = v - org[++idx];
        org[idx] = v;
        for(int i = idx;i <= n;i+=i&-i) bit[i] += vv;
    }

    T sum(int a){
        T ret = 0;
        for(int i = a;i > 0;i-=i&-i) ret += bit[i];
        return ret;
    }

    T sum(int l, int r) { return sum(r)-sum(l); }; 
};

signed main(){
	int n;
	cin >> n;
	
	vector<BinaryIndexTree<int>> seg(26, BinaryIndexTree<int>(n));

	string s;
	cin >> s;
	
	for(int i = 0;i < n;i++){
		seg[s[i]-'a'].update(i, 1);
	}

	int q;
	cin >> q;

	for(int i = 0;i < q;i++){
		int que;
		cin >> que;
		if(que == 1){
			int idx;
			char c;
			cin >> idx >> c;
			idx--;
			seg[s[idx]-'a'].update(idx, 0);
			s[idx] = c;
			seg[s[idx]-'a'].update(idx, 1);
		}else{
			int ans = 0;
			int l, r;
			cin >> l >> r;
			l--; r--;
			for(int j = 'a';j <= 'z';j++){
				if(seg[j-'a'].sum(l, r+1) > 0) ans++;
			}
			cout << ans << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 211328
N,A,B,C,D=map(int, input().split())
S=input()
if S.find("##", A, B)<0 and S.find("##", C, D)<0:
    if C<D:
        print("Yes")
    else:
        if S.find("...", B-2, D+1)>=0:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>> v(n);
	rep(i,n) cin >> v[i].first >> v[i].second;
	sort(ALL(v));
	ll p = 0;
	rep(i,n) {
		p += v[i].second;
		if (p >= k) {
			cout << v[i].first << endl;
			return;
		}
	}
}

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

Measured memory_bytes: 4760
#include <bits/stdc++.h>
using namespace std;
#define senor_SR ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef int32_t i32;

#define int long long
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pf push_front

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;

#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()

#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define farr(a,n) for(long long i=0;i<n;i++) cin>>a[i];
#define fvec(vec,n) for(long long i=0;i<n;i++) {ll tmp;cin>>tmp;vec.pb(tmp);}
#define parr(a,n) for(long long i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define prvec(v) for(long long i=v.size()-1;i>=0;i--) cout<<v[i]<<" "; cout<<endl;
#define pvecpair(v) for(long long i=0;i<v.size();i++) cout<<v[i].first<<" "<<v[i].second<<endl;

#define INF 1e17+4
#define MINF 
#define MAX_INT 100000
#define MOD 1000000007
ll mod(ll n) { n %= MOD; if (n < 0) return n + MOD; else return n;}
// vector<int> adj[1000002];
// int vis[1000002],dep[1000002],siz[1000002];

// void dfs(ll cur,ll par)
// {
//     vis[cur]=1;siz[cur]=1;
//     for(auto x:adj[cur])
//     {
//         if(vis[x]!=1)
//         {
//             dep[x]=dep[cur]+1;
//             dfs(x,cur);
//             siz[cur]+=siz[x];
//         }    
//     }
// }

// bool myfunc1(const pair<int,int> &a, const pair<int,int> &b) { return ;}

void solve()
{
    string s;cin>>s;
    int n=s.length();
    vector<int> a(2019);
    int num=0,sum=0,ans=0,ten=1;
    for(int i=n-1;i>=0;i--)
    {
        num=((s[i]-'0')*ten)%2019;
        sum=(sum+num)%2019;
        a[sum]++;
        ten=(ten*10)%2019;
    }
    for(int i=0;i<2019;i++)
        ans+=(a[i]*(a[i]-1))/2;
    ans+=a[0];
    cout<<ans<<endl;
}

signed main()
{
    senor_SR;
    
    // ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu
const int N=1010;
int n,m;
vector<int>st,cyc;
vector<int>g[N];
int vis[N];
//
void go(int x){
//cout<<x<<endl;
	if(vis[x]==2)return;
	if(vis[x]==1){
		while(1){
			if(!st.size())break;
			cyc.push_back(st.back());
			if(st.back()==x)break;
			st.pop_back();
		}
		return;
	}
	vis[x]=1;
	st.push_back(x);
	rep(i,g[x].size()){
		go(g[x][i]);
		if(cyc.size())break;
	}
	vis[x]=2;
	st.pop_back();
}
int main(){
	n=getint();m=getint();
	rep(i,m){
		int x=getint()-1,y=getint()-1;
		g[x].push_back(y);
	}
	rep(i,n)if(!vis[i]){
		go(i);
	//	cout<<i<<endl;
		if(cyc.size())break;
	}
//	rep(i,cyc.size())cout<<cyc[i]+1<<" ";
	if(!cyc.size())return !printf("%d\n",-1);
	reverse(cyc.begin(),cyc.end());
	memset(vis,0,sizeof(vis));
	rep(i,cyc.size())vis[cyc[i]]=true;
//	cout<<cyc.size()<<endl;
//	rep(i,cyc.size())cout<<cyca[i]<<endl;
	rep(ii,cyc.size()){
		int i=cyc[ii];
		rep(j,g[i].size())if(vis[g[i][j]]&&g[i][j]!=cyc[(ii+1)%cyc.size()]){
			int p=0,to=g[i][j];
		//	cout<<i<<" "<<to<<endl;
			rep(k,cyc.size())if(cyc[k]==g[i][j]){
				p=k;
				break;
			}
		//	cout<<p<<endl;
			if(p>ii){
				for(int k=ii+1;k<p;k++)vis[cyc[ii+1]]=false,cyc.erase(cyc.begin()+ii+1);
			}
			else{
				int c=cyc.size()-1-(ii+1)+1;
				rep(k,p)vis[cyc[0]]=false,cyc.erase(cyc.begin()),i--;
				while(c)vis[cyc.back()]=false,cyc.pop_back(),c--;
			}
			ii=-1;
		}
	}
	cout<<cyc.size()<<endl;
	rep(i,cyc.size())cout<<cyc[i]+1<<endl;
	return 0;
}


Measured memory_bytes: 384
def examA():
    X = SI()
    d = defaultdict(int)
    for s in X:
        if s=="T" and d["S"]>=1:
            d["S"] -=1
        else:
            d[s] += 1
    ans = d["S"] + d["T"]
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examA()

"""

"""

Measured memory_bytes: 5260
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>H>>W;
    mat a(H,vec(W));
    rep(i,H) rep(j,W) cin>>a[i][j];
    rep(i,H) rep(j,W) cin>>A, a[i][j] = abs(a[i][j] - A);
    vector<mat> dp(H,mat(W,vec(16000,false)));
    dp[0][0][a[0][0]] = true;
    reps(s,1,H + W - 1){//和がsなるindexの探索
        reps(i, max(s - W, 0LL), min(s + 1LL, H)){
            ll j = s - i;
            if(j < 0 || j >= W) continue;
            if(i != 0){
                rep(k, 16000){
                    if(dp[i-1][j][k]) dp[i][j][min(15999LL,k + a[i][j])] = dp[i][j][abs(k - a[i][j])] = true;
                }
            }
            if(j != 0){
                rep(k, 16000){
                    if(dp[i][j-1][k]) dp[i][j][min(15999LL,k + a[i][j])] = dp[i][j][abs(k - a[i][j])] = true;
                }
            }
        }
    }
    ll ans = INF;
    rep(i,16000){
        if(dp[H-1][W-1][i]) {
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 810624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

set<int> eratosthenes(int n){
  set<int> st;
  st.insert(2);
  for(int i = 3; i<=n ;i+=2) st.insert(i);
  for(auto it = st.begin(); it != st.end(); ++it){
    auto it2 = it;
    ++it2;
    for(; it2 != st.end(); ++it2){
      if((*it2)%(*it)==0){
        auto it3 = it2;
        --it3;
        st.erase(it2);
        it2 = it3;
      }
    }
  }
  return st;
}

int solve(){
  int N;cin >> N;
  if(N==3){
    cout << 2 SP 3 SP 25 << endl;
    return 0;
  }else if(N==4){
    cout << 2 SP 3 SP 5 SP 20 << endl;
    return 0;
  }else if(N==5){
    cout << 2 SP 3 SP 5 SP 6 SP 14 << endl;
    return 0;
  }
  set<int> st;
  st.insert(2);
  st.insert(3);
  N-=2;
  int x = 4;
  int sum = 5;
  rep(i,N){
    while((x%2)&&(x%3))++x;
    sum+=x;
    st.insert(x);
    ++x;
  }
  --x;
  if(sum%6==2){
    st.erase(8);
    st.insert(6*((x+6)/6));
  }else if(sum%6==3){
    st.erase(9);
    st.insert(6*((x+6)/6));
  }else if(sum%6==5){
    st.erase(9);
    st.insert(6*(x/6)+4);
  }

  for(const int &s : st)cout << s SPF;
  cout << endl;
  return 0;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  solve();
  return 0;
}



Measured memory_bytes: 1280
def get_gcd(a, b)
  rest = a % b
  return b if rest.zero? || rest == b
  get_gcd(b, rest)
end

STDIN.read.chomp.split("\n").each do |list|
  elems = list.split.map(&:to_i).sort_by(&:-@)
  gcd = get_gcd(*elems)
  lcm = elems.inject(:*) / gcd

  puts "#{gcd} #{lcm}"
end

Measured memory_bytes: 8580
$S = <>;
chomp $S;
$_=length($S);

$m=$n=0;
$f=0;

for(my$i=0;$i<$_;$i++){
    $f=1-$f;
    if(substr($S,$i,1)==$f){
        $m++;
    }else{
        $n++;
    }
}
$min = ($m>$n)?$n:$m;
print "$min";


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

int main() {
  int a, b, x;
  string y, ans = "";
  cin >> a >> b;
  
  if (a <= b) {
    x = b;
    y = to_string(a);
  } else {
    x = a;
    y = to_string(b);
  }
  
  for (int i = 0; i < x; i++) ans += y;

  cout << ans << endl;;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e6+5;
const ll mod =   1e9+7;
int k,n;ll ans;string s;
int fac[N],inv[N];
int po(int x , int y){
	int res=1;
	while(y){
		if(y&1)
		res=1ll*res*x%mod;
		y>>=1;
		x=1ll*x*x%mod;
	}
	return res%mod;
}
int ncr(int n,int r){
	if(r>n) return 0;
	return 1ll*fac[n]*inv[r]%mod*inv[n-r]%mod;
}
int main()
{  fast
   cin>>k>>s;
   fac[0]=1;
   for(int i=1;i<N;i++)
   fac[i]=1ll*i*fac[i-1]%mod;
   inv[N-1]=po(fac[N-1],mod-2);
   for(int i=N-2;i>=0;i--)
   inv[i]=1ll*(i+1)*(inv[i+1])%mod;
   n=s.size();
   for(int i=0;i<=k;i++){
   	ans=(ans+1ll*po(25,k-i)*po(26,i)%mod* ncr(n-1+k-i,n-1))%mod;
   }
   cout<<ans;
}

Measured memory_bytes: 19744
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <set>
#include <climits>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;

const int MAXN = 200002;

int n;
string s;

int memo[MAXN][4];
int dp(int i, int l) {
  if (i+1 >= n) return 0;
  if (!memo[i][l]) {
    memo[i][l] = INT_MIN;
    for (int r = 1; r <= 3; ++r) {
      if (i+r >= n) break;
      if (s.substr(i-l+1, l) == s.substr(i+1, r)) continue;
      memo[i][l] = max(memo[i][l], dp(i+r, r) + 1);
    }
  }
  return memo[i][l];
}

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = s.size();
  int ans = max(dp(0, 1), max(dp(1, 2), dp(2, 3))) + 1;
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 30868
import sys
 
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

m = 1000
for i in range(1, n):
    if a[i - 1] < a[i]:
        m = m % a[i-1] + m // a[i-1] * a[i];

print(m)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define in(s,x) s.find(x) != s.end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define SIZE(buff) (sizeof(buff)/sizeof(buff[0]))
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<pair<int,int>> VPII;
const ll mod=1000000007;
const ll INF= 1LL<<60-1;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << pair_var.first << " " << pair_var.second ;return os;}

// head


int m,n,k,res,tmp,tmp2,tmp3,h,w,x,y;
VI a;
deque<PII> que;
string s;
//VI b;
vector<PII> g[2100600];
int b[2100000];
int c[210] = {};
int rui[210000];
set<int> ch;
VI ab;
VI bb;

VI dfs(int x,int y,int z,VI gg){

  rep(i,1,x+1){
    if(z+c[i] > k || y+i > n-2) return gg;
    gg.pb(i);
    if (z+c[i] == k && y+i == n-2) {return ab = gg;}
    dfs(i,y+i,z+c[i],gg);
    gg.pop_back();
  }
  return ab;
}

signed main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  VPII ans;
  rep(i,1,n){
    ans.pb({1,i+1});
  }
  h = 2;
  w = 3;
  k = (n-1)*(n-2)/2-k;
  if(k<0){cout << -1 << '\n';exit(0);}
  while(k){
    if (w > n)break;
    ans.pb({h,w});
    w += 1;
    k-=1;
    if (w > n){
      h+=1;
      w= h+1;
      if (h>=n) break;
    }

  }
  if (k > 0) {cout << -1 << '\n';exit(0);}
  cout << ans.size() << '\n';
  rep(i,0,ans.size()){
    cout << ans[i] << '\n';
  }
}

Measured memory_bytes: 51456
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let _: usize = sc.read();
    let m: usize = sc.read();
    if m % 2 == 0 {
        for i in 0..(m / 2) {
            println!("{} {}", i + 1, m - i);
        }
        for i in 0..(m / 2) {
            println!("{} {}", m + 1 + i, 2 * m + 1 - i);
        }
    } else {
        for i in 0..((m + 1) / 2) {
            println!("{} {}", i + 1, m + 1 - i);
        }
        for i in 0..(m - (m + 1) / 2) {
            println!("{} {}", m + 2 + i, 2 * m + 1 - i);
        }
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2160
/**
 * Dictionary
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C
 */

#include<iostream>
#include<map>
using namespace std;

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

  string cmd, val;
  map<string, int> dic; // <key, value> と書くとkey型をキーとし、value型を値とする。
  for (int i = 0; i < n; i++) {
    cin >> cmd >> val;
    if (cmd == "insert") {
      dic[val] = 1;
    } else if (cmd == "find") {
	    cout << (dic.find(val) != dic.end() ? "yes" : "no") << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 36896
from collections import deque
n, m = map(int, input().split())


def find(x):
    if par[x] < 0:
        return x
    par[x] = find(par[x])
    return par[x]

def union(x, y):
    x, y = find(x), find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x

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

def size(x):
    return par[find(x)]

node_list = []
for i in range(m):
    node_list.append([int(x) for x in input().split()])

ans = 0
for i in range(m):
    par = [-1 for _ in range(n)]
    for j in range(m):
        if i == j:
            continue
        else:
            union(node_list[j][0]-1, node_list[j][1]-1)
    limit = 2
    flag = False
    for value in par:
        if value < 0:
            limit -= 1
        if not limit:
            flag = True
            break
    if flag:
        ans += 1
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <stack>

using namespace std;

int caseCnt, numbers[10], curNum;
stack<int> Left, Right;

bool used[10], result;

void clear_stack(){
    while( !Left.empty())  Left.pop();
    while(!Right.empty()) Right.pop();
}

bool dfs(int index, int left_or_right){
    if(!left_or_right){
        if(Left.empty() || numbers[index] > Left.top()){
            Left.push(numbers[index]);
        }else{
            //cout << "false\n";
            return false;
        }
    }else{
        if(Right.empty() || numbers[index] > Right.top()){
            Right.push(numbers[index]);
        }else{
            //cout << "false\n";
            return false;
        }
    }
    if(index == 9){
        //cout << "true\n";
        return true;
    }else if(dfs(index+1, 0)){
        //cout << "true\n";
        return true;
    }else if (dfs(index+1, 1)){
        //cout << "true\n";
        return true;
    }else{
        //cout << "false\n";
        return false;
    }
}

int main(){
    cin >> caseCnt;

    while(caseCnt--){
        result = false;
        clear_stack();

        for(int i=0; i<10; ++i) cin >> numbers[i];

        result = dfs(0, 0);
        if(result){
            cout << "YES\n";
            continue;
        }

        result = dfs(0, 1);
        if(result) cout << "YES\n";
        else       cout << "NO\n";
    }
    return 0;
}



Measured memory_bytes: 2948
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

string s;
ll ans;
void calc(int i, int j, ll sum) {
    if(i >= s.size())
        ans += (sum+stod(s.substr(j)));
    else {
        ll sub = stod(s.substr(j, i-j));
        calc(i+1, i, sum+sub); // +を入れる場合
        calc(i+1, j, sum);
    }
}

int main(){
    cin >> s;
    ans = 0;
    calc(1, 0, 0);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
    string s;
    cin >> s;
    list<char> ls;
    rep(i, s.size()) ls.push_back(s[i]);
    int Q; cin >> Q;
    bool inv = false;
    rep(i, Q) {
        int t; cin >> t;
        if(t == 1) {
            inv = !inv;
        } else {
            int f; cin >> f;
            char c; cin >> c;
            if(inv) {
                if(f == 1) ls.push_back(c);
                else ls.push_front(c);
            }else{
                if(f == 2) ls.push_back(c);
                else ls.push_front(c);
            }
        }
    }
    if(inv) {
        ls.reverse();
    }
    for_each(ls.cbegin(), ls.cend(), [](char x){
        cout << x;
    });
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];
vector<ll>v[N];
ll vis[N], d[N], par[N];
bool bfs (ll u)
{
	for (ll i = 1; i <= n; i++)
	{ vis[i] = d[i] = par[i] = 0; }
	vis[u] = 1;
	d[u] = 1;
	queue<ll>q;
	q.push (u);
	while (!q.empty())
	{
		ll x = q.front();
		q.pop();
		for (auto w : v[x])
		{
			if (!vis[w])
			{
				vis[w] = 1;
				par[w] = x;
				d[w] = d[x] + 1;
				q.push (w);
			}
			else
			{
				if (d[w] == d[x]) { return 0; }
			}
		}
	}
	return 1;
}
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	cin >> n;
	for (ll i = 1; i <= n; i++)
	{
		string str;
		cin >> str;
		str = " " + str;
		for (ll j = 1; j <= n; j++)
		{
			if (str[j] == '1') { v[i].pb (j); }
		}
	}
	ll mx = -1;
	for (ll i = 1; i <= n; i++)
	{
		if (bfs (i) != 0)
		{
			for (ll j = 1; j <= n; j++) { mx = max (mx, d[j]); }
		}
	}
	cout << mx;
	return 0;
}


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

int main(void)
{
    int n;
    cin >> n;

    ll s;
    vector<ll> a(n);

    rep(i, n)
    {
        cin >> a.at(i);
        if (i == 0)
            s = a.at(i);
        else
            s ^= a.at(i);
    }

    rep(i, n)
    {
        cout << (s ^ a.at(i)) << endl;
    }

    return 0;
}


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

using namespace std;
 
int main() {
  string u;
  double x, s=0.0;
  int N;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> x >> u;
    if (u == "JPY") s += x;
    else s += x*380000.0;
  }
  cout << s << endl;
  return 0;
}


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

using namespace std;

int main(){
    unsigned long long n, v[86] = {2, 1};
    cin >> n;

    for(int i=2; i<n+1; i++) {
        v[i] = v[i-1] + v[i-2];
    }
    cout << v[n] << endl;
}

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

const int MAXV=(int) 1e5+1;
const int INF= (int) 1e8;
 
struct edge{
    int to;
};
 
vector <edge> G[MAXV];
int relation[MAXV];
int relation_count[MAXV]={};
pair <int,int> block[MAXV];
int block_count[MAXV]={};

int DFS( int i, int count ){
    if( relation[i]<0 ){
        relation[i]=count;
        //cout << "i relation[i] " << i << " " << relation[i] << endl;
    }
    for( auto& e:G[i] ){
        if( relation[e.to] < 0 ){
            DFS(e.to, count);
        }
    }
    return 0;
}

int main(){
    int N,M,K;
    cin >> N >> M >> K;

    int a,b,c,d; 
    
    for(int i=0; i<M; i++){
        cin >> a >> b;
        edge e = { b };
        G[a].push_back(e);
        e = { a };
        G[b].push_back(e);
    }

    for(int i=1; i<=K; i++){
        cin >> c >> d;
        block[i]=make_pair(c,d);
    }

    for(int i=0; i<N+1; i++){
        relation[i]=-1;
    }

    for(int i=1; i<N+1; i++){
        DFS(i,i);
    }

    for(int i=1; i<=N; i++){
        relation_count[relation[i]]++;
    }

    for(int i=1; i<=K; i++){
        a = block[i].first;
        b = block[i].second;

        if(relation[a]==relation[b]){
            block_count[a]++;
            block_count[b]++;
        }
    }

    for(int i=1; i<=N; i++){
        int friends = (int) G[i].size();
        if(i!=1) cout << " ";
        cout << max(relation_count[relation[i]]-friends-block_count[i]-1,0); // -1 is for self
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 11888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <locale>
#include <cmath>
#include <iomanip>
#include <numeric>

using namespace std;

int main() {
    double L;
    cin >> L;
    double x,y,z;
    x = L / 3;
    y = L / 3;
    z = L / 3;
    double ans = x * y * z;
    // for(int i = 0; i < L-2; i++){
    //     x = i;
    //     for(double j = 0; j < L - i; j++) {
    //         y = j;
    //     }
    //     ans = max(ans, x*y*z);
    // }
    cout << setprecision(40) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x=0,y=0;
   
    for(int i=1; i<=3000;i++){
     cin>>x>>y;
    if(x==0&&y==0){
        break;
    }
     if(x>y){
                 cout<<y<<" "<<x<<endl;
    }
    else{
                cout<<x<<" "<<y<<endl;
    }
   
   }
}
    


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * 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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int counter(int x) {
    if (x==0) return 0;
    return counter(x >> 1) + (x & 1);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n+1);
    vector<vector<int>> x(n+1, vector<int>(n+1));
    vector<vector<int>> y(n+1, vector<int>(n+1));
    rep1(i, n) {
        cin >> a[i];
        for(int j=1; j<=a[i]; ++j) cin >> x[i][j] >> y[i][j];
    }
    int ans = 0;
    for (int bits=1; bits<(1<<n); bits++) {
        bool ok = true;
        rep1(i, n) {
            if (!(bits & (1 << (i-1)))) continue;
            rep1(j, a[i]) {
                // 矛盾していないか
                if (((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if (ok) chmax(ans, counter(bits));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;
const long long P = 1000000007;

int main() {
  int n;
  cin >> n;
  int s[n];
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s,s+n);
  int min = 0;
  for(int i = 0; i < n; i++) {
    if(s[i] % 10 != 0) {
      min = s[i];
      break;
    }
  }
  if(sum % 10 == 0) {
    sum -= min;
  }
  if(sum % 10 == 0) {
    sum = 0;
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

const ll MOD = (int) 1e9 + 7;

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> S(N);
    for (int i = 0; i < N; i++)cin >> S[i];
    sort(S.rbegin(), S.rend());

    vector<vector<ll>> dp(N + 1, vector<ll>(X + 1, 0));
    dp[0][X] = 1;

    for (int i = 0; i < N; i++) {
        for (int j = X; j >= 0; j--) {
            (dp[i + 1][j % S[i]] += dp[i][j]) %= MOD;
            (dp[i + 1][j] += dp[i][j] * (N - (i + 1)) % MOD) %= MOD;
        }
    }

    ll ans = 0;
    for (int i = 0; i <= X; i++) {
        (ans += (i*dp[N][i])%MOD) %= MOD;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 158592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    ll N;
    cin >> N;
    if (N % 2 != 0) {
        cout << 0;
        return 0;
    } else {
        ll k = N / 2;
        ll ans = 0;
        while (k) {
            ans += (k /= 5);
        }
        cout << ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;
 
void rec(const Graph &G, int v, int p, long long sum, vector<long long> &dist){
  dist[v] = sum;
  for(auto e : G[v]){
    if(e.first == p) continue;
    rec(G, e.first, v, sum+e.second, dist);
  }
}
 
int main(){
  int N; cin >> N;
  Graph G(N);
  for(int i=0; i<N-1; i++){
    int a, b; long long c;
    cin >> a >> b  >> c;
    --a, --b;
    G[a].push_back(Edge(b, c));
    G[b].push_back(Edge(a, c));
  }
  
  int Q, K; cin >> Q >> K;--K;
  vector<long long> dist(N, 0);
  rec(G, K, -1, 0, dist);
  
  for(int i=0; i<Q; i++){
    int x, y; cin >> x >> y; --x, --y;
    cout << dist[x] + dist[y] <<endl;
  }
}

Measured memory_bytes: 18688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
ll pos[105]={0};
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>pos[i];
  ll ans=1744174417441744;
  for(int i=0;i<=100;i++){
    ll kans=0;
    for(int j=0;j<n;j++){
      kans+=(pos[j]-i)*(pos[j]-i);
    }
    ans=min(ans,kans);
  }
  cout<<ans<<endl;
}


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

using namespace std;
const int INF = 1000000000;

int get_time(const string &s){
	stringstream ss(s);
	int h, m;
	ss >> h;
	ss.ignore();
	ss >> m;
	return h * 60 + m;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, t;
	cin >> n >> t;
	int prev = INF;
	vector<string> ans_name;
	vector<int> ans_time;
	for(int i = 0; i < n; ++i){
		string st_time, st_name, ar_time, ar_name;
		cin >> st_time >> st_name >> ar_time >> ar_name;
		const int cur = get_time(st_time);
		if(prev + t <= cur){
			ans_name.push_back(st_name);
			ans_time.push_back(cur - prev);
		}
		prev = get_time(ar_time);
	}
	cout << ans_name.size() << endl;
	for(int i = 0; i < ans_name.size(); ++i){
		cout << ans_name[i] << " " << ans_time[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1240