akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()

//use (__int128)to extend ll range
double doINF = 1.0/0.0 ;
ostream_iterator <int> outp(cout," ");
inline ll modadd(ll n,ll m,ll mod){
    ll sum = ((n+m)%mod+mod)%mod;
    return sum;
} 
inline ll modsub(ll n,ll m, ll mod){
    ll diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}
inline ll modpro(ll n,ll m,ll mod){
    ll pro = ((n*m)%mod+mod)%mod;
    return pro;
}
inline ll pow(int x,int y){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}
inline ll powmod(ll x,ll y,ll mod){
    ll res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}
ll min(ll a, ll b){
   if(a>b){
       return b;
   }
   return a;
}

ll max(ll a, ll b){
   if(a>b){
       return a;
   }else return b;
}
 
bool pairdec(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 		if(a.fi!=b.fi)
       	return (a.fi> b.fi);
		else return a.se>b.se;  
} 
ll power(ll x, ll y, ll mod) 
{ 
    ll res = 1; 
    x = x%mod; 
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % mod; 
  
        y = y >> 1;
        x = (x * x) % mod; 
    } 
    return res; 
} 
ll modInverse(ll a, ll mod) 
{ 
    return  powmod(a, mod - 2, mod); 
} 
ll modFact(ll n, ll mod) 
{ 
    if (n >=mod) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) %mod; 
  
    return result; 
} 
//cout<<setprecision(9)<<fixed<<sum<<endl; --- precision for double numbers
//copy(v.beg,v.en,outp);
//-----comparision for pairs------
 
bool comp(const pair<int,int>pia,const pair<int,int>pib)
{
	if(pia.fi==pib.fi) return pia.se>pib.se;
	else return pia.fi>pib.fi;
}

const ll N=1e9+7;
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    forl(i,0,n) cin>>arr[i];
    map<ll,ll>mp;
    set<ll>thr;
    forl(i,0,n)
    {
        if(mp.find(arr[i])!=mp.en) mp[arr[i]]++;
        else mp[arr[i]]=1;

    }
    for(auto x:mp)
    {
        if(x.se>=2)thr.insert(x.fi);
       // cout<<x.fi<<" "<<x.se<<endl;
    }
    ll sum=0;
    for(ll x:thr)
    {
        sum+=(mp[x]*(mp[x]-1))/2;
    }
    forl(i,0,n)
    {
        ll val=sum;
        if(thr.find(arr[i])!=thr.en)
        {
            val=sum-mp[arr[i]]+1;
        }
        cout<<val<<endl;
    }
    
}


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

using namespace std;
int main() {
	int n;
	cin >> n;
	int sum, tmp;
	tmp = n;
	while(tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}
	if (n % sum == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define M 1001

int n;

char x[M],y[M];
 
void lcs(void){
  int i,j;
  int len_x, len_y,graph[M][M];

  len_x=strlen(x);
  len_y=strlen(y);
  for(i=1;i<M;i++){
    for(j=1;j<M;j++){
      graph[i][j]=0;
    }
  }
  for(i=1;i<=len_x;i++){
    for(j=1;j<=len_y;j++){
      if(x[i-1]==y[j-1]) graph[i][j]=graph[i-1][j-1]+1;

      else{
        if(graph[i-1][j]>=graph[i][j-1]) graph[i][j]=graph[i-1][j];
        else graph[i][j]=graph[i][j-1];
      }
    }
  }
  printf("%d\n",graph[len_x][len_y]);
}
     
int main()
{
  int i;
   
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%s",x);
    scanf("%s",y);
    lcs();
  }
  return 0;
}

Measured memory_bytes: 6592
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,Y = MI()

for i in range(N+1):
    for j in range(N+1-i):
        k = N-i-j if N-i-j>=1 else 0
        total = 10000*i + 5000*j + 1000*k
        if total == Y:
            print(i,j,k)
            break
    else:
        continue
    break
else:
    print(-1,-1,-1)


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

#define lpsbd(i, s, b, d) for(size_t i = s; i < b; i+=d)
#define lpsb(i, s, b) for(size_t i = s; i < b; i++)
#define lpn(i, n) for(size_t i = 0; i < n; i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)

using namespace std;
using ull = unsigned long long;
using p = pair<pair<string,int>,int>;

const ull MOD = 1000000007;

int main(void)
{
    int N, P;
    cin >> N;
    auto R = vc(p, N);
    fa(i, R)
    {
        cin >> i.first.first >> P;
        i.first.second = -P;
    }
    lpn(i, N) R[i].second = i + 1;
    sort(R.begin(), R.end());
    fa(i, R) cout << i.second << endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

ll maxn = 1e18;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n;
	cin>>n;
	vll v(n);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	sort(all(v));
	ll ans=1;
	for(int i=0;i<n;++i){
		if(ans*v[i]>maxn || (v[i]!=0 && ans*v[i] < ans)){
			cout<<-1<<endl;
			return 0;
		}
		ans*=v[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  map<ll,ll> m;
  ll ans = 0;
  rep(i,n){
    ll x;cin >> x;
    ans += x;
    m[x]++;
  }
  ll q;cin >> q;
  rep(i,q){
    ll b,c;cin >>b >> c;
    ans -= b * m[b];
    ans += c * m[b];
    m[c] += m[b];
    m[b] = 0;
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 9404
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //??\???????????°????±?????????´??°
        Integer num = 0;
        //????¨???????????´?????????´??°
        long sum = 0;
        
        //??´??°num?????\???
        num = Integer.parseInt(br.readLine());
        
        //?????????????????§??°?????\???
        String str = br.readLine();
        
        String[] ar = str.split(" ");
        
        int[] AL = new int[num];
        
        //????¨????????¨????
        for (int i=0; i < ar.length; i++) {
            sum+=Integer.parseInt(ar[i]);
            
            AL[i] = Integer.parseInt(ar[i]);
            
            
        }
    
        Arrays.sort(AL);
        
        //????°?????????¨???
        System.out.print(AL[0]);
        System.out.print(" ");
        //?????§????????¨???
        System.out.print(AL[AL.length-1]);
        System.out.print(" ");
        //????¨?????????¨???
        System.out.print(sum);
        System.out.print("\n");
        
        
    }
    
}

Measured memory_bytes: 28864
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxd = 1e5+10;
int n,arr[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
    sort(arr+1,arr+1+n);
    long double x = arr[1];
    for(int i=2;i<=n;i++) x = (x+arr[i])/2;
    printf("%.6Lf",x);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
/*
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
*/
int main(){
	int N;
	int A[10000];
	cin>>N;
	ll ans=0;
	FOR(i,0,N){
		cin>>A[i];
		while(A[i]%2==0){
			ans++;
			A[i]/=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
// Code by H~$~C
#include <bits/stdc++.h>
using namespace std;

static const int Maxn = 100005;

#define int long long

int n;
long long T, E;
long long a[Maxn];
long long dp[Maxn];
// dp[i] = min { dp[j] + a[i] - a[j] + max(T, 2 * (a[i] - a[j + 1]) }
// dpt[i] = min { dpt[j] + max(T, 2 * (a[i] - a[j + 1])) }
// dp[i] = dpt[i] + a[i]
// Ans = dp[n] + (E - a[n]) = dpt[n] + E

namespace sgt1 {
  #define ls (p * 2 + 1)
  #define rs (p * 2 + 2)
  #define mid (l + r >> 1)
  long long tr[Maxn << 2];
  inline void init() {
    memset(tr, 0x3f, sizeof(tr));
  }
  inline void pushup(int p) {
    tr[p] = min(tr[ls], tr[rs]);
  }
  void modify(int p, int l, int r, int pos, long long val) {
    if (l == r) {
      tr[p] = min(tr[p], val);
      return ;
    }
    if (pos <= mid) {
      modify(ls, l, mid, pos, val);
    }
    else {
      modify(rs, mid + 1, r, pos, val);
    }
    pushup(p);
  }
  long long query(int p, int l, int r, int L, int R) {
    if (L > r || l > R) return 1e18;
    if (L <= l && r <= R) {
      return tr[p];
    }
    long long left = query(ls, l, mid, L, R);
    long long right = query(rs, mid + 1, r, L, R);
    return min(left, right);
  }
  #undef ls
  #undef rs
  #undef mid
}
namespace sgt2 {
  #define ls (p * 2 + 1)
  #define rs (p * 2 + 2)
  #define mid (l + r >> 1)
  long long tr[Maxn << 2];
  inline void init() {
    memset(tr, 0x3f, sizeof(tr));
  }
  inline void pushup(int p) {
    tr[p] = min(tr[ls], tr[rs]);
  }
  void modify(int p, int l, int r, int pos, long long val) {
    if (l == r) {
      tr[p] = min(tr[p], val);
      return ;
    }
    if (pos <= mid) {
      modify(ls, l, mid, pos, val);
    }
    else {
      modify(rs, mid + 1, r, pos, val);
    }
    pushup(p);
  }
  long long query(int p, int l, int r, int L, int R) {
    if (L > r || l > R) return 1e18;
    if (L <= l && r <= R) {
      return tr[p];
    }
    long long left = query(ls, l, mid, L, R);
    long long right = query(rs, mid + 1, r, L, R);
    return min(left, right);
  }
  #undef ls
  #undef rs
  #undef mid
}

signed main() {
  scanf("%lld%lld%lld", &n, &E, &T);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
  }
  
  memset(dp, 63, sizeof(dp));
  dp[0] = 0;
  sgt1::init();
  sgt2::init();
  sgt1::modify(0, 0, n, 0, dp[0]);
  sgt2::modify(0, 0, n, 0, dp[0] - 2 * a[1]);
  for (int i = 1; i <= n; ++i) {
    int low = 0, high = n;
    while (high - low > 1) {
      int mid = low + high >> 1;
      if ((a[i] - a[mid]) * 2 >= T) low = mid;
      else high = mid;
    }
    int pos = low;
    if (pos < i) {
      dp[i] = min(dp[i], sgt1::query(0, 0, n, pos, i - 1) + T);
    }
    if (pos > 0) {
      dp[i] = min(dp[i], sgt2::query(0, 0, n, 0, pos - 1) + 2 * a[i]);
    }
    sgt1::modify(0, 0, n, i, dp[i]);
    sgt2::modify(0, 0, n, i, dp[i] - 2 * a[i + 1]);
  }
  printf("%lld\n", dp[n] + E);
  return 0;
}


Measured memory_bytes: 8064
import java.util.*;
import java.text.DecimalFormat;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        DecimalFormat df = new DecimalFormat("#0.00000");
        int a = input.nextInt();
        int b = input.nextInt();
        double aa = a;
        double bb = b;
        double s = aa/bb;
        String ss = df.format(s);
        System.out.println((a / b) + " " + (a % b) + " " + ss);
    }
}


Measured memory_bytes: 26400
def actual(N, S, M, T):
    points = [S.count(word) - T.count(word) for word in set(S)]

    return max(0, max(points))

N = int(input())
S = [input() for _ in range(N)]

M = int(input())
T = [input() for _ in range(M)]

print(actual(N, S, M, T))


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;

    int digit = 0;
    string ans = "";
    while(N != 0){
        if(N % 2 == 0){
            ans = '0' + ans;
        }else{
            ans = '1' + ans;
            if(digit % 2 == 0){
                N--;
            }else{
                N++;
            }
        }
        N /= 2;
        digit++;
    }
    if(ans == "") ans = "0";
    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
/**
*    created: 01.07.2020 21:04:51
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const int MOD = 1000000007;
// const int MOD = 998244353;
const long double pi = acos(-1.0);
const int INF = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    int cnt = 0;
    for (int i = a; i <= b; i++) {
        string s = to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3704
from bisect import bisect_left, bisect_right

N = int(input())
a = sorted(list(map(int, input().split())))

ans = 1
for i in range(N):
    X = a[i]
    res = bisect_right(a, X+1) - bisect_left(a, X-1)
    ans = max(res, ans)

print(ans)


Measured memory_bytes: 13964
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int c=0;
		for(int i=1;i<=n;i++)
		{
			if((((int)Math.log10(i)+1) & 1) == 1)
				++c;
		}
		
		System.out.println(c);		
	}
}




Measured memory_bytes: 22484
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

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

typedef long long ll;

using namespace std;



/*
class TheKingsArmyDiv2
{
public:
	int getNumber(vector <string> state)
	{

	}
};
*/




int main()
{
	int N;
	
	while (cin >> N, N)
	{
		string str;
		char c;
		int co;
		
		cin >> str;
		while (N > 0)
		{
			N--;
			string t;
			co = 1;
			c = str[0];
			for (int i=1; i<str.size(); i++)
			{
				if (str[i] == c)
				{
					co++;
				} else {
					char s[10];
					sprintf(s, "%d", co);
					t += s;
					t.push_back(c);
					
					c = str[i];
					co = 1;
				}
			}
			char s[10];
			sprintf(s, "%d", co);
			t += s;
			t.push_back(c);
			str = t;
		}
		cout << str.c_str() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1376
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   bool flag = true;
   std::string W[N];
   std::cin >> W[0];
   char tail = W[0][W[0].size()-1];
   for(int i=1; i<N; ++i){
      std::cin >> W[i];
      if(tail!=W[i][0]) flag = false;
      tail = W[i][W[i].size()-1];
      for(int j=0; j<i; ++j)
	 if(W[i]==W[j]) flag = false;
   }
   if(flag) std::cout << "Yes" << std::endl;
   else std::cout << "No" << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;

int main()
{

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

}


Measured memory_bytes: 3616
from itertools import product
H,W,K=map(int, input().split())
C=[input()for _ in range(H)]
ans=0
for hp in product([True,False], repeat=H):
    for wp in product([True,False], repeat=W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if C[h][w]=="#" and not hp[h] and not wp[w]:
                    cnt += 1
        if cnt==K:
            ans+=1
print(ans)

Measured memory_bytes: 68480
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#define XA 0
#define YA 1
#define RES 8000

using namespace std;

int main() {
  bool DP[2][RES][2*RES]={};
  string s;
  int step;
  int x,y;
  int isY;
  vector<int> list[2];
  
  cin >> s;
  cin>>x>>y;
  step=0;
  isY=0;
  
  for(char& c : s){
    if(c=='F'){
      step++;
    }else{
      list[isY].push_back(step);
      step=0;
      isY=1-isY;
    }
  }

  list[isY].push_back(step);
  DP[XA][0][0+RES]=true;
  DP[XA][1][list[XA][0]+RES]=true;
  DP[YA][0][0+RES]=true;
  for(int i=1;i<list[XA].size();++i){
    for(int j=0;j<2*RES;j++){
      if(DP[XA][i][j]){
        DP[XA][i+1][j+list[XA][i]]=true;
        DP[XA][i+1][j-list[XA][i]]=true;
      }	
    }
  }
  for(int i=0;i<list[YA].size();++i){
    for(int j=0;j<2*RES;j++){
      if(DP[YA][i][j]){
        DP[YA][i+1][j+list[YA][i]]=true;
        DP[YA][i+1][j-list[YA][i]]=true;
      }	
    }
  }
  if((DP[XA][list[XA].size()][x+RES])&&(DP[YA][list[YA].size()][y+RES])){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 250240
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
typedef pair<int,int> P;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
//#define int ll

signed main(void){
    int N;
    string S;
    cin >> N >> S;
    int Ans=0;
    REP(i,N){
        int num=0;
        string T,U;
        T=S.substr(0,i);
        U=S.substr(i);
       // cout << T << " " << U << endl;
        REP(j,26){
            if(T.find((char)('a'+j))!=std::string::npos && U.find((char)('a'+j))!=std::string::npos){
                num++;
            }
        Ans=max(Ans,num);
        }
    }
    cout << Ans << endl;
  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int MAXN = 1005;
const int MAXV = MAXN * (MAXN - 1) / 2;
vector<int> to[MAXV];
int id[MAXN][MAXN];

int toID(int i, int j) {
    if (i > j) swap(i, j);
    return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];

int dfs(int v) {
    if (visited[v]) {
        if (!calculated[v]) {
            return -1;
        }
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for (int u : to[v]) {
        int res = dfs(u);
        if (res == -1) {
            return -1;
        }
        dp[v] = max(dp[v], res + 1);
    }
    calculated[v] = true;
    return dp[v];
}

int main() {

    int n;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(n - 1));

    rep(i, n) {
        rep(j, n - 1) {
            int c;
            cin >> c;
            c--;
            a[i][j] = c;
        }
    }

    int V = 0;
    rep(i, n)rep(j, n) {
            if (i < j) {
                id[i][j] = V++;
            }
        }

    rep(i, n) {
        rep(j, n - 1) {
            a[i][j] = toID(i, a[i][j]);
        }
        rep(j, n - 2) {
            to[a[i][j + 1]].push_back(a[i][j]);
        }
    }

    int ans = 0;

    rep(i, V) {
        int res = dfs(i);
        if (res == -1) {
            puts("-1");
            return 0;
        }
    }

    rep(i, V) {
        ans = max(ans, dfs(i));
    }

    cout << ans << endl;

}


Measured memory_bytes: 38528
#include <stdio.h>

int hantei(int x){
  int i;
  if(x<2)return 0;
  else if(x==2)return 1;
  if(x%2==0)return 0;
  for(i=3;i*i<=x;i+=2){
    if(x%i==0)return 0;
  }
  return 1;
}

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



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

int main(){
  int d,n;
  cin>>d>>n;
  if(d==0){
    if(n==100){
      cout<<101<<endl;
    }else{
      cout<<n<<endl;
    }
  }else if(d==1){
    if(n==100){
      cout<<10100<<endl;
    }else{
      cout<<100*n<<endl;
    }
  }else{
    if(n==100){
      cout<<1010000<<endl;
    }else{
      cout<<10000*n<<endl;
    }
  }
}


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

//Dijkstra shortest path using priority queue

#define ipair pair<int,int>
#define inf 0x3f3f3f3f
const int N=100005;
vector<ipair>adj[N];
vector<int>parent(N);
void addEdge(int u,int v,int w)
{
    adj[u].push_back({w,v});
    adj[v].push_back({w,u});
}
bool f=0;
vector<int>ans;
void shortestPath(int V,int src)
{
    set<pair<int,int>>st;    
    vector<int>dist(V+1,inf);
    dist[src]=0;
    parent[src]=-1;
    st.insert({dist[src],src});
    while(!st.empty())
    {
        pair<int,int>tmp=*(st.begin());
        st.erase(st.begin());
        for(auto it:adj[tmp.second])
        {
            int v=it.second;
            if(dist[v]>(dist[tmp.second]+it.first))
            {
                if(dist[v]!=inf)
                st.erase(st.find({dist[v],v}));
                dist[v]=dist[tmp.second]+it.first;
                parent[v]=tmp.second;
                st.insert({dist[v],v});
            }
        }
        
    }
    for(int i=2;i<=V;i++)
    {
        if(dist[i]==inf)
        {
            f=1;
            break;
        }
        ans.push_back(parent[i]);
    }
    
    
}



int main() {
    int n,m;
   cin>>n>>m;
   for(int i=0;i<m;i++)
   {
       int x,y;
       cin>>x>>y;
       addEdge(x,y,1);
   }
 
    shortestPath(n,1); 
    if(f==1)
    {
        cout<<"No\n";
        return 0;
    }
    cout<<"Yes\n";
    for(auto it:ans)
    cout<<it<<endl;
	return 0;
}

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


int G[100][100];
int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int k,n,u;
    cin >> n;
    for(int i = 0; i < n ; i++){
        cin >> u;
        cin >> k;
        for(int i2 = 0; i2 < k ; i2++){
            int j;
            cin >> j;
            G[i][j-1] = 1;
        }
    }

    for(int i = 0; i < n ; i++){
        for(int j = 0; j < n ; j++){
            printf("%d",G[i][j]);
            if(j<n-1){
                printf(" ");
            }
        }
        
            printf("\n");
        
    }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "Yes\n"
#define N cout << "No\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)

long long mod = 1000000007 , ans = 1 ;
int p(long long a , long long b)
{
    while(b)
    {
        if(b%2)
        {
            ans = ( (ans%mod)*(a%mod) ) %mod ;
        }
        a = ((a%mod)*(a%mod))%mod ;
        b /= 2 ;
    }
    return ans ;
}


int prime[1000010] ;
void fun()
{
	for (int i = 2; i < 1000001; i++)
	{
		if (prime[i] == 0)
		{
			for (int j = i + i; j < 1000001; j += i)
			{
				prime[j] = 1;
			}
		}
	}
}
int gcd(ll a,ll b)
{
     if(b == 0)
     {
          return a ;
     }
     return gcd(b,a%b) ;
}
int main()
{
     // ios_base::sync_with_stdio(false);
     // cin.tie(NULL);
     string s , t ;
     cin >> s >> t ;
     int l , m ;
     l = s.size() ;
     m = t.size() ;
     int cnt = 0 , min  = 10000 ;
     for(int i = 0 ; i <= l-m ; i++)
     {
          cnt = 0 ;
          for(int j = 0 ; j < m ; j++ )
          {
               if(s[i+j] != t[j])
               {
                    cnt++ ;
               }
          }
          if(cnt < min)
          {
               min = cnt ;
          }
     }
     cout << min << endl ;
}


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

typedef int state_t;

const int Mod = 1e9 + 7, MaxN = 41, StateLen = 5 + 7 + 5;
int N, X, Y, Z, p[MaxN], f[MaxN][1 << StateLen];
state_t end_state;

state_t dp(int i, int j) {
  if (i == N) {
    return 0;
  }
  if (~f[i][j]) {
    return f[i][j];
  }
  long long res = 0;
  for (int k = 1; k <= 10; ++k) {
    int next_state = (j << k) | 1;
    if ((next_state & end_state) == end_state) {
      res += p[N - 1 - i];
    } else {
      res += dp(i + 1, next_state & ((1 << 17) - 1));
    }
  }
  return f[i][j] = res % Mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  memset(f, 0xff, sizeof f);
  cin.tie(0);
  cin >> N >> X >> Y >> Z;
  p[0] = 1;
  for (int i = 1; i < MaxN; ++i) {
    p[i] = p[i - 1] * 10LL % Mod;
  }
  end_state = (1 << X) | (1 << (X + Y)) | (1 << (X + Y + Z));
  cout << dp(0, 1) << endl;
  return 0;
}


Measured memory_bytes: 21248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

//string N;ll K,n;
string S;ll N,K;
ll nCr(ll nn,ll r){
    if(r>N)return 0;
    if(r==1)return nn;
    if(r==2)return nn*(nn-1)/2;
    if(r==3)return nn*(nn-1)*(nn-2)/6;
    return 0;
}

long long dp(int i, int k, int smaller) {
	 if (k == 0) return 1;
 	 else if (i == N) return 0;

    
    if (smaller) return nCr(N-i, k) * pow(9, k);
    else {
        if (S[i] == '0') return dp(i+1, k, false);
        else {
            long long zero = dp(i+1, k, true);
            long long aida = dp(i+1, k-1, true) * (S[i] - '1');
            long long icchi = dp(i+1, k-1, false);
            return zero + aida + icchi;
        }
    }
}


void solve() 
{
    cin>>S>>K;
    N=S.size();
    cout<<dp(0,K,0)<<endl;
}

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


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

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

    ll r=0, g=0, b=0;
    rep(i, n) {
        if (s[i] == 'R') r++;
        if (s[i] == 'G') g++;
        if (s[i] == 'B') b++;
    }
    ll ans = r*g*b;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            int k = 2 * j - i;
            if (k >= n) continue;
            if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


ABC = list(map(int, sys.stdin.buffer.readline().split()))
K = int(sys.stdin.buffer.readline())

ABC.sort()
ABC[-1] *= 2 ** K
print(sum(ABC))


Measured memory_bytes: 14632
#include <iostream>
#include <string.h>
using namespace std;
#include <queue>
int main (){
    long D[100000];
    for(int i=0;i<100000;i++){
        D[i]=1000000000;
    }
    int V,E,r;
    cin>>V>>E>>r;
    int head[100000],next[500000]={},to[500000]={},D2[500000]={};
    memset(head,-1,sizeof(head));
    for(int i=0;i<E;i++){
        int s,t,d;
        cin>>s>>t>>d;
        next[i]=head[s];
        head[s]=i;
        to[i]=t;
        D2[i]=d;
    }
    queue<int> Q;
    Q.push(r);
    D[r]=0;
    while(! Q.empty()){
        int x=Q.front();
        Q.pop();
        for(int i=head[x];i!=-1;i=next[i]){
            if(D[to[i]]>D[x]+D2[i]){
                D[to[i]]=D[x]+D2[i];
                Q.push(to[i]);
            }
        }
    }
    for(int i=0;i<V;i++){
        if(D[i]==1000000000) cout<<"INF"<<endl;
        else cout<<D[i]<<endl;
    }
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> a(n);
  vector<int> b(n);

  REP (i, n) {
    cin >> a[i];
  }
  REP (i, n) {
    cin >> b[i];
  }

  int ans = 0;
  REP (i, n) {
    int sum = 0;
    REP (j, n) {
      if (j <= i) sum += a[j];
      if (i <= j) sum += b[j];
    }
    ans = max(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
    ll n,i,ans=1,p=1e18;
    cin>>n;
    ll ara[n+1];
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&ara[i]);
    }
    sort(ara+1,ara+n+1);
    if(ara[1]==0)
    {
        printf("0\n");
        return 0;
    }
    for(i=1;i<=n;i++)
    {
        if(ara[i]>(p/ans))
        {
            printf("-1\n");
            return 0;
        }
        ans*=ara[i];
    }
    printf("%lld\n",ans);
}



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

int calc(int x){
    int ret=0;
    while(x%100==0){
        x/=100;
        ++ret;
    }
    return ret;
}
 
int main()
{   
    int D,N;
    cin>>D>>N;
    int cnt=0,val=0;
    while(cnt<N){
        ++val;
        if(calc(val)==D) ++cnt;
    }
    cout<<val<<endl;
    
    
}

Measured memory_bytes: 256
#include <stdio.h>

#define MaxValue 200000
int s[MaxValue];

int main(void) {
  int n, a, b;
  scanf("%i %i %i", &n, &a, &b);
  
  for (int i = 0; i < n; i++) {
    scanf("%i", &s[i]);
  }
  
  int lo = 0, hi = 1<<30, ans = -1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    
    long long req = 0;
    for (int i = 0; i < n; i++) {
      long long h = s[i] - (long long)b * mid;
      if (h > 0) {
        req += (h+(a-b)-1) / (a-b);
      }
    }
    
    if (req <= mid) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  
  printf("%i\n", ans);
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

double dist (double a, double b,  double c, double d){
    
    return sqrt((a-c)*(a-c) + (b-d)*(b-d));
    
}

bool check(int x,int y,vector<string> a,vector<string> b ){
    for(auto i = 0; i<b.size();i++){
        for(auto j =0; j<b.size();j++){
            if(a[x+i][y+j]!= b[i][j]) return false;
        }
    }
    return true;
}

int dist(pii a, pii b){
    return abs(a.first-b.first) + abs(a.second-b.second);
}


int main() {
    int n;cin>>n;
    ll v = 0;
    while(v*v<n) v++;
    if(n ==v*v) {cout<<n<<endl;return 0;}
    else v--;
    cout<<v*v<<endl;
    return 0;
}







Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def bitr(x): return format(x, 'b')
def bitlen(x): 
    if x: return int(math.log2(x))+1 
    else: return 1;
def popcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    print("ACL"*N)



if __name__ == "__main__":
    main()

Measured memory_bytes: 72696
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long N){
    if(N % 2 == 1){
        cout << 0 << endl;
        return;
    }
    ll cnt = 0;
    ll dvd = 10;
    while(dvd <= N){
        cnt += N / dvd;
        dvd *= 5;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll v[100001];
vector<pair<ll, ll>> e[100001];
ll n, m;

void dfs(ll i, ll x) {
	v[i] = x;

	rep(p, 0, e[i].size()) {
		ll nextID = e[i][p].first;
		ll nextDistance = e[i][p].second;
		if (v[nextID]) {
			//visited
			if (v[i] + nextDistance != v[nextID]) {
				cout << "No";
				exit(0);
			}
		}
		else {
			//not visited
			dfs(nextID, v[i] + nextDistance);
		}
	}
}

int main() {
	cin >> n >> m;
	rep(i, 0, m) {
		ll l, r, d; cin >> l >> r >> d;
		e[l].push_back({ r,d });
		e[r].push_back({ l,-d });
	}

	repe(i, 1, n) {
		if (!v[i]) {
			dfs(i, 1e9 + 1);
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

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

    int minimum = 3e5;
    int ans = 0;
    vector<int> P(N);
    for (int &p : P)
    {
        cin >> p;
        if (p < minimum)
        {
            ans++;
            minimum = p;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;

int main(){
	int q=1;
	//cin>>q;
	while(q--){
		int n;
		cin>>n;

		cout<<setprecision(4)<<(44/(float)7)*n<<endl;
	}
   
}

Measured memory_bytes: 3784
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    for (int ii = 0; ii < n; ii++) {
      int f = scanner.nextInt();
      int t = scanner.nextInt();
      if (f < t) {
        for (int jj = f; jj <= t; jj++) {
          System.out.print(jj);
          if (jj != t) {
            System.out.print(" ");
          } else {
            System.out.print("\n");
          }
        }
      } else if (f > t) {
        if (f <= 5 && t <= 5) {
          for (int jj = f; jj >= t; jj--) {
            System.out.print(jj);
            if (jj != t) {
              System.out.print(" ");
            } else {
              System.out.print("\n");
            }
          }
          continue;
        }
        String out = "";
        for (int jj = f;;) {
          out += jj + " ";
          if (jj == t) {
            break;
          }
          if (5 < jj) {
            jj++;
          } else {
            jj--;
            if (jj < 0) {
              for (int kk = 0; kk < 7; kk++) {
                jj++;
                if (jj != 0 && jj != 6) {
                  out += jj + " ";
                }
              }
            }
          }
          if (jj == 10) {
            jj = 5;
          }
        }
        System.out.print(out.trim() + "\n");
      }
    }
  }
}

Measured memory_bytes: 17180
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll L,A,B,M;
mat mult(mat &A,mat &B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();i++){
		for(int k=0;k<B.size();k++){
			for(int j=0;j<B[0].size();j++){
				(C[i][j] += A[i][k]*B[k][j]%M)%=M;
			}
		}
	}
	return C;
}

mat pow(mat A, ll n){
	if(n==1) return A;
	else if(n%2==0){
		mat B = pow(A,n/2);
		return mult(B,B);
	}else{
		mat B = pow(A,n-1);
		return mult(A,B);
	}
}

ll cnt[20] = {};
ll cnt2[20] = {};
ll p[19] = {1};

int main(){
    cin >> L >> A >> B >> M;
    for(int i=1;i<=18;i++) p[i] = 10*p[i-1];
    for(int i=1;i<=18;i++){
        if(p[i]-1<A) continue;
        if(A+(L-1)*B<p[i-1]) continue;
        cnt[i] = (min(p[i]-1,A+(L-1)*B)-A)/B+1;
        if(i>1 && p[i-1]-1>A) cnt[i] -= max((p[i-1]-1-A)/B+1,0LL);
    }
    ll ans = 0;
    mat res(3,vec(3,0));
    res[0][0] = res[1][1] = res[2][2] = 1;
    for(int i=1;i<=18;i++){
        if(cnt[i]==0) continue;
        mat A(3,vec(3,0));
        A[0][0] = p[i]%M; A[0][1] = A[1][1] = A[2][2] = 1;
        A[1][2] = B;
        mat a = pow(A,cnt[i]);
        res = mult(a,res);
    }
    cout << (res[0][2]+A%M*res[0][1]%M)%M << endl;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int GCD(int a, int b)
{
	for (; b; a %= b, swap(a, b));
	return a;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, M, dn, dm;
	long long lcm, gcd;
	string S, T;
	cin >> N >> M >> S >> T;
	lcm = 1LL * N*M / (gcd = GCD(N, M));
	dn = N / gcd;
	dm = M / gcd;
	for (int i = 0; i < gcd; i++) {
		if (S[dn*i] != T[dm*i]) {
			cout << "-1\n";
			return 0;
		}
	}
	cout << lcm << '\n';
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

string s;
int N;
int mp[30];

int mod_pow(int x, int n, int MOD) {
  if (n == 0)
    return 1;
  int res = mod_pow(x * x % MOD, n / 2, MOD);
  if (n % 2 == 1)
    res = res * x % MOD;
  return res;
}

int rec(int now, bool flag) {
  if (now >= 26) {
    if (flag) return 1;
    return 0;
  }
  if (!mp[now]) return rec(now + 1, flag);

  int l = mp[now] * rec(now + 1, true) % MOD;
  int r = rec(now + 1, flag) % MOD;
  return (l + r) % MOD;
}

signed main() {
  cin >> N >> s;
  for (int i = 0; i < N; i++) {
    mp[s[i] - 'a']++;
  }

  cout << rec(0, false) << endl;
  return 0;
}


Measured memory_bytes: 512