akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;

int route[15] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };

void solve( int s, int t )
{
    if ( s >= 0 && s <= 5 && t >= 0 && t <= 5 )
    {
        if ( s > t )
        {
            for ( int i = s; i >= t; i-- )
            {
                cout << i;
                if ( i == t ) cout << endl; else cout << " ";
            }
            return;
        }
        else
        {
            for ( int i = s; i <= t; i++ )
            {
                cout << i;
                if ( i == t ) cout << endl; else cout << " ";
            }
            return;
        }
    }

    int k = 0;
    for ( k = 0; k < 15; k++ ) if ( route[k] == s ) break;
    while ( route[k] != t )
    {
        cout << route[k] << " ";
        k = ( k + 1 ) % 15;
    }
    cout << route[k] << endl;;
}

int main( void )
{

    int n;
    cin >> n;

    for ( int i = 0; i < n; i++ )
    {
        int s, t;
        cin >> s >> t;
        solve( s, t );
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    ll ans = 1e18;
    for(int i = -100; i <= 100; i++){
        ll res = 0;
        for(int j = 0; j < n; j++){
            res += abs(a[j]-i)*abs(a[j]-i);
        }
        ans = min(ans,res);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
edges = [[] for _ in range(N+1)]


for i in range(N-1):
  a, b = map(int, input().split())
  if i == 0:
    root = a
  edges[a].append((b, i))
  edges[b].append((a, i))

ans = [-1 for i in range(N-1)]
def dfs(u):
  flag = ["white"] * (N + 1)
  stack = [(u, -1, -1)]

  while stack:
    u, parent, color = stack.pop()
    flag[u] = "black"

    nextColor = 1
    for (next, index) in edges[u]:
      if next != parent and flag[next] != "black":
        if nextColor == color:
          nextColor += 1
        stack.append((next, u, nextColor))
        ans[index] = nextColor
        nextColor += 1

dfs(root)

print(max(ans))

for a in ans:
  print(a)

Measured memory_bytes: 38900
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) {
  os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}';
  return os;
}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int64 INF64 = numeric_limits<int64>::max() / 2;
constexpr int MOD = 1000000007;
const double PI = acos(-1);

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

  int n; cin >> n;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      if (i * j == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//void mysort(vector<int> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<int> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll d,g ;
	cin >> d >> g ;
	vll p(d),c(d) ;
	for(int i=0;i<d;i++) cin >> p.at(i) >> c.at(i) ;
	ll mn = 100000 ;
	for(int i=0;i<(1<<d);i++){
		bitset<12> bit(i) ;
		ll sum = 0 ;
		ll cnt = 0 ;
		for(int j=0;j<d;j++){
			if(bit[j]){
				sum += p.at(j)*100*(j+1)+c.at(j) ;
				cnt += p.at(j) ;
			}
		}
		int j = d-1 ;
		while(j>=0&&sum<g){
			if(bit[j]){
				j-- ;
			}else{
				ll sub = (p.at(j)-1)*100*(j+1) ;
				if(sub<=g-sum){
					sum += sub ;
					cnt += p.at(j)-1 ;
				}else{
					ll subcnt = (g-sum+100*(j+1)-1)/(100*(j+1)) ;
					cnt += subcnt ;
					sum += subcnt*100*(j+1) ;
				}
				j-- ;
			}
		}
		if(sum<g) cnt = 100000 ;
		if(cnt<mn) mn = cnt ;
	}
	cout << mn << endl ;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  s <- getIntList
 
  let result = (length $ fst $ break (0 ==) s) + 1

  print result

Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <vector>

#define rep(i, s, N) for(int i = s; i < N; i++)
#define YesNo(result) do {if (result) std::cout << "Yes" << '\n'; else std::cout << "No" << '\n';} while(0)
#define resetarr(arr, val) for(int i = 0; i < sizeof(arr) / 4; i++){ arr[i] = val; }

int main(int argc, char const *argv[]) {
  int n = 0, x = 0;
  std::cin >> n >> x;
  int sum = 0;
  int min = 100000;
  rep(i, 0, n) {
    int t = 0;
    std::cin >> t;
    sum += t;
    if(min > t) min = t;
  }
  int ans = n;
  while(x >= sum+min) {
      sum += min;
      ans++;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define fint register int
#define h 5001
#define p 4759084
using namespace std;
char a[p],b[p];
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	int lena=strlen(a);
	int lenb=strlen(b);
	int ans=INT_MAX;
	for(fint i=0;i<lena-lenb+1;i++)
	{
		int now=0;
		for(fint j=0;j<lenb;j++)
		if(a[i+j]!=b[j])
		now++;
		ans=min(ans,now);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3764
#define rep(i,N) for(int i=0;i<(int)N;i++)
#include <bits/stdc++.h>
using namespace std;
typedef int64_t LL;
const LL MOD=pow(10,9)+7;
LL Cmb(int n,int k,LL mod)
{
  LL coef=1;
  vector<LL> sieve(n+1,0);
  if(n<k){coef=0;return coef;}
  if(n==k||k==0){coef=1;return coef;}
  k=min(k,n-k);
  for(LL p=2;p<=n;p++)
  {
    if(sieve.at(p)==0)
    {
      //エラトステネスの篩
      for(LL i=p*p;i<=n;i+=p)
      {
        sieve.at(i)=1;
      }
      //素因数分解された各項の冪乗prime
      for(LL prime=p;prime<=n;prime*=p)
      {
        LL cnt=n/prime-k/prime-(n-k)/prime;
        rep(j,cnt)
        {
          coef*=p;
          coef%=mod;
        }
      }
    }
  }
  return coef;
}
int main()
{
  int x,y,l,m,n;
  cin>>x>>y;
  if((x+y)%3>0){cout<<0<<endl;return 0;}
  l=(x+y)/3;
  m=x-l;
  n=y-l;
  if(m<0||n<0){cout<<0<<endl;return 0;}
  cout<<Cmb(m+n,m,MOD)<<endl;
}

Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;


int main()
{
	string S;
	cin >> S ;

	int u_len = 0;
	int start = 0;
	int len = 0;

	for (int si = 0; si < S.length(); si++) {
		if (S[si] == 'A' || S[si] == 'C' || S[si] == 'G' || S[si] == 'T') {
			len++;
			if (len > u_len) u_len = len;
		}
		else {
			len = 0;
		}
	}
	
	cout << u_len;

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,x,y; cin >> n >> x >> y; x--; y--;
	vvl G(n);
	rep(i,n-1){
		G[i].push_back(i+1);
		G[i+1].push_back(i);
	}
	G[x].push_back(y);
	G[y].push_back(x);
	vvl d(n,vl(n,inf));
	vl ans(n+1,0);
	rep(i,n){
		d[i][i] = 0;
		queue<ll> q;
		q.push(i);
		while(!q.empty()){
			ll u = q.front(); q.pop();
			for(auto v : G[u]){
				if(d[i][v] != inf) continue;
				d[i][v] = d[i][u] + 1; 
				q.push(v);
			}
		}
		rep(j,n){
			ans[d[i][j]]++;
		}
	}
	REP(i,1,n){
		cout << ans[i]/2 << endl;
	}
}


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

int main(){
    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<char> c(n);
        for(int i = 0; i < n; i++){
            cin >> c[i];
        }
        vector<int> vote(30, 0);
        int MAX = 0, NEXT = 0;
        char MAX_ans;
        int ans_i = 0;
        char ans;
        for(int i = 0; i < n; i++){
            vote[(int)c[i] - 'A']++;
            if(vote[(int)c[i] - 'A'] > MAX){
                MAX = vote[(int)c[i] - 'A'];
                MAX_ans = c[i];
            }else if(vote[(int)c[i] - 'A'] > NEXT){
                NEXT = vote[(int)c[i] - 'A'];
            }

            //????????????
            if(MAX > NEXT + n - 1 - i){
                ans_i = i + 1;
                ans = MAX_ans;
                break;
            }
        }   
        if(ans_i == 0) cout << "TIE" << endl;
        else cout << ans << " " << ans_i << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 100000000;

int gcd(int a, int b) {

    if (a%b==0) {
        return b;
    }
    else {
        return gcd(b,a%b);
    }

}

int main() {
    int K;
    cin >> K;
    int ans = 0;
    for (int i=1;i<=K;i++) {
        for (int j=1;j<=K;j++) {
            for (int k=1;k<=K;k++) {
                ans += gcd(i,gcd(j,k));
            }
        }
    }
    cout << ans << endl;}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;


ll gcd(ll a,ll b)
{
    if(a!=0 && b==0)
    {
        return a;
    }
    if(a%b==0)
    {
        return b;
    }
    else
    {
        return(gcd(b,a%b));
    }
    
}
int main(void)
{

    ll n;
    cin>>n;
    ll a[n+1];
    ll min=mod;
    vector<ll> yaku;
    rep(i,n)
    {
        cin>>a[i];
    }
    ll L[n+1]={0};
    ll R[n+1]={0};
    L[0]=0;
    R[n]=0;
    for(int i=0;i<=n;i++)
    {
        L[i+1]=gcd(L[i],a[i]);
        R[n-1-i]=gcd(R[n-i],a[n-i-1]);
    }
    ll ans=0;
    rep(i,n)
    {
        ll temp=gcd(L[i],R[i+1]);
        if(ans<temp)ans=temp;
    }
    cout<<ans;
}

Measured memory_bytes: 2560
import fileinput

n = int(input())

c = 0
for i in range(1, n + 1):
    cc = 0
    if i % 2 == 0:
        continue
    for j in range(1, i + 1):
        if i % j == 0:
            cc += 1
    if cc == 8:
        c += 1

print(c)


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

typedef long long ll;

typedef pair<ll,ll> ii;
typedef pair<ii, ll > iii;

const int kn = 2e5 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, inf = 1e18 ;

#define x first
#define y second

#define ff(i,n) for(int i=1;i<=n;i++)

ll n,m,k,a[kn];

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[1] != s[2] && s[2]== s[3]) cout<<"Yes";
	else cout<<"No";	
	
}
//hahahahahahahahahhahahahahahaahahahahhahahahahahahah


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var X = ReadInt();
            Println(X == 3 || X == 5 || X == 7 ? "YES" : "NO");
        }

        static List<int> ReadLines(int n)
        {
            var l = new List<int>();
            for (int i = 0; i < n; i++)
            {
                l.Add(ReadInt());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)

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

 string s;
  cin >> s;
  
  if(s=="SUN") cout << 7 << endl;
  else if(s=="MON") cout << 6 << endl;
  else if(s=="TUE") cout << 5 << endl;
  else if(s=="WED") cout << 4 << endl;
  else if(s=="THU") cout << 3 << endl;
  else if(s=="FRI") cout << 2 << endl;
  else if(s=="SAT") cout << 1 << endl;

}

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

using namespace std;

map< char, int > declaration;
map< pair< char, int >, int > assignment;

int expression(string &s, int &idx, int now)
{
  char array_name = s[idx];
  if(isalpha(array_name)) {
    ++idx;
    ++idx;
    int get = expression(s, idx, now);
    if(declaration[array_name] <= get) throw (now);
    if(!assignment.count({array_name, get})) throw (now);
    ++idx;
    return (assignment[{array_name, get}]);
  } else {
    int ret = 0;
    while(isdigit(s[idx])) {
      ret = ret * 10 - '0' + s[idx++];
    }
    return (ret);
  }
}


void exec(string &s, int now)
{
  char array_name = s[0];

  if(s.find('=') == string::npos) {
    int number = 0, ptr = 2;
    while(isdigit(s[ptr])) {
      number = number * 10 - '0' + s[ptr++];
    }

    declaration.emplace(array_name, number);
  } else {
    int ptr = 2;
    int number = expression(s, ptr, now);
    if(declaration[array_name] <= number) throw (now);
    ++ptr;
    ++ptr;
    int get = expression(s, ptr, now);
    assignment[{array_name, number}] = get;
  }
}

int main()
{
  string S[1005];
  while(cin >> S[0], S[0] != ".") {
    for(int i = 1; S[i - 1] != "."; ++i) {
      cin >> S[i];
    }

    try {
      for(int i = 0; S[i] != "."; i++) {
        exec(S[i], i + 1);
      }
      throw 0;
    } catch(int x) {
      cout << x << endl;
    }

    declaration.clear();
    assignment.clear();
  }
}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, m;
    cin >> n >> m;
    int maxL = -1, minR = 100001;
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        maxL = ::max(maxL,l);
        minR = ::min(minR,r);
    }
    int ans = minR-maxL;
    if(ans>=0){
        cout<<ans+1;
    }else{
        cout<<0;
    }
    cout<<endl;
}

Measured memory_bytes: 3548
s = int(input())
a = []
c = 1

def f(n):
    if n % 2 == 0:
        return int(n / 2)
    else:
        return int(3 * n + 1)


for i in range(1000000):
    
    a.append(s)
    s = f(s)
    if len(set(a)) != c:
        break
    else:
        c += 1
print(c)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
	The competition is over so I will start with my upsolving phase
*/

int main(){
	ll n,l=0; cin>>n;
	ll s[10][10]; 
	memset(s,0,sizeof(s));
	for(ll i=1;i<=n;i++){
		ll t=i;
		while(t>=10) t/=10;
		++s[t][i%10];
	}
	for(ll i=0;i<=n;i++){
		ll t=i;
		while(t>=10) t/=10;
		l+=s[i%10][t];
	}
	cout<<l;
    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (cnt + 1 == a[i]) {
            cnt++;
        }
    }
    int ans = cnt == 0 ? -1 : n - cnt;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>

using namespace std;

long roc[16][16];
long route[16][16];

long long hokusaigo(int x,int y);

int main(){
	int n;
	cin >> n;
	for(int m=0;m<n;m++){
	int g_x,g_y;
	cin >> g_x >> g_y;
	int p;
	cin >> p;
	for(int i=0;i<g_x+1;i++){
		for(int j=0;j<g_y+1;j++){
			roc[i][j]=-1;
			route[i][j]=3;
		}
	}
	roc[0][0]=1;
	for(int i=0;i<p;i++){
		int temp1_x,temp1_y,temp2_x,temp2_y;
		cin >> temp1_x >> temp1_y >> temp2_x >> temp2_y;
		if(temp1_x==temp2_x){
			if(temp1_y<temp2_y){
				route[temp1_x][temp1_y]-=1;
			}else{
				route[temp2_x][temp2_y]-=1;
			}
		}else{
			if(temp1_x<temp2_x){
				route[temp1_x][temp1_y]-=2;
			}else{
				route[temp2_x][temp2_y]-=2;
			}
		}	
	}
	long long ans=hokusaigo(g_x,g_y);
	if(ans==0){
		cout << "Miserable Hokusai!";
	}else{
		cout << ans;
	}
	cout << endl;
	}
	return 0;
}

long long hokusaigo(int x,int y){
	long long ret=0;
	if(roc[x][y]==-1){
		if(x>0&&((route[x-1][y]/2)%2==1)){
			ret+=hokusaigo(x-1,y);
		}
		if(y>0&&(route[x][y-1]%2)==1){
			ret+=hokusaigo(x,y-1);
		}
		roc[x][y]=ret;
	}else{
		ret=roc[x][y];
	}
	return ret;
}


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

int main(void) {
  int weight[10];
  weight[0] = 1;
  for (int i = 1; i < 10; i++) {
    weight[i] = weight[i-1]*2;
  }

  int w;
  while (cin >> w) {
    vector<int> used_weight;
    int pos = 9;
    while (w > 0) {
      if (w - weight[pos] >= 0) {
        w -= weight[pos];
        used_weight.push_back(weight[pos]);
      }
      pos--;
    }

    for (int i = used_weight.size()-1; i >= 0; i--) {
      cout << used_weight[i] << (i?" ":"");
    }
    cout << endl;
  }

  return 0;
}

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

#define ll long long
const int mx = 2e5;


int main(void){
  
  ll X=0;
  cin >> X;
  ll c500=0;
  ll c5=0;
  while(X>=500){
	X -= 500;
    c500++;
  }
  while(X>=5){
    X -= 5;
    c5++;
  }
  
  ll score = c500*1000 + c5*5;
  cout << score;

  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string s[a][b];
    for(int i = 0;i < a;i++){
        for(int j = 0;j < b;j++){
            cin >> s[i][j];
            if(s[i][j] == "snuke"){
                cout << (char)(j + 'A') << i+1 << endl;
            }
        }
    }
    
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,a;
	while(cin>>N>>K) {
		VI h(200001);
		REP(i, N) {
			cin>>a;
			h[a]++;
		}
		VI ch;
		for(auto e: h) if(e) ch.PB(e);
		sort(ALL(ch));
		ll ans=0;
		REP(i, max<ll>(0, ch.size()-K)) {
			ans+=ch[i];
		}
		
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

int main() {
    int N, C;
    cin >> N >> C;
    vector<vector<int>> change(C, vector<int>(C));
    vector<vector<int>> colors(3, vector<int>(C, 0));
    rep(i, C) rep(j, C) cin >> change[i][j];
    rep(i, N) rep(j, N) {
        int c;
        cin >> c;
        colors[((i+1)+(j+1))%3][c-1]++;
    }

    ll res = 1e9;
    rep(i, C) {rep(j, C) {rep(k, C) {
        if(i==j || j==k || k==i) continue;
        ll temp = 0;
        rep(c, C) temp += change[c][i]*colors[0][c];
        rep(c, C) temp += change[c][j]*colors[1][c];
        rep(c, C) temp += change[c][k]*colors[2][c];
        res = min(res, temp);
    }}}

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
T = [int(x) for x in input().split()]
m = int(input())

ans_org = sum(T)

for i in range(m):
    p, x = [int(x) for x in input().split()]
    for i in range(n):
        ans = ans_org - T[p-1] + x
    print(ans)

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


using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
int cnt[maxn];
int cnt2[maxn];
int main()
{
    int n;
    cin>>n;
    int _max1=0,_max11=0,_max1id=0;
    int _max2=0,_max22=0,_max2id=0;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=n; i+=2)
    {
        cnt[a[i]]++;
        if(cnt[a[i]]>_max1)
        {
            _max1=max(_max1,cnt[a[i]]);
            _max1id=a[i];
        }
    }
    for(int i=2; i<=n; i+=2)
    {
        cnt2[a[i]]++;
        if(cnt2[a[i]]>_max2)
        {
            _max2=max(_max2,cnt2[a[i]]);
            _max2id=a[i];
        }
    }
    for(int i=2; i<=n; i+=2)
    {
        if(cnt2[a[i]]>_max22&&cnt2[a[i]]<=_max2&&a[i]!=_max2id)
        {
            _max22=cnt2[a[i]];
        }
    }
    for(int i=1; i<=n; i+=2)
    {
        if(cnt[a[i]]>_max11&&cnt[a[i]]<=_max1&&a[i]!=_max1id)
        {
            _max11=cnt[a[i]];
        }
    }
    int ans;

    if(_max2id==_max1id)
    {
        ans=max(_max11+_max2,_max22+_max1);
    }
    else
        ans=_max1+_max2;
    cout<<n-ans<<endl;

}


Measured memory_bytes: 4740
#include<stdio.h>
int main ()
{
    int A,B,K,i,a=0;
    scanf ("%d %d %d",&K,&A,&B);
    if (A>=1&&A<=1000&&B>=1&&B<=1000&&K>=1&&K<=1000)
    {
        for (i=A;i<=B;i++)
        {
            if (i%K==0)
            a++;
        }
    }
    if (a++)
        printf ("OK\n");
    else
        printf ("NG\n");
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
    long long N, k; cin >> N >> k;
    set<long long> s;
    for (long long i = 1; i*i <= N; i++) {
        s.insert(i);
        s.insert(N/i);
    }
    vector<long long> v;
    for (auto x: s) {
        v.emplace_back(x);
    }
    int n = v.size();
    vector<long long> dp(n, 1);
    for (int ki = 1; ki <= k; ki++) {
        vector<long long> sw(n, 0);
        long long curr = 0;
        for (int i = 0; i < n; i++) {
            long long width;
            if (!i) width = v[i];
            else width = v[i] - v[i-1];
            curr += width * dp[i] % mod;
            curr %= mod;
            sw[n-i-1] = curr;
        }
        swap(dp, sw);
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 4860
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod2=998244353;
vector<vector<int> > adj;
vector<int> visited;
void dfs(int s)
{
    visited[s]=1;
    for(auto it:adj[s])
    {
        if(!visited[it])
        dfs(it);
    }
}
ll mod=1e9+7;
int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    visited.resize(n+1,0);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);

    }
    int ct=0;
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            dfs(i);
            ct++;
        }
    }
    cout<<ct-1<<endl;
    
    
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b + c >= 22)
        puts("bust");
        else
            puts("win");
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s; cin >> s;
	vector<string>v = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
	int x = find(all(v), s) - v.begin();
	cout << 7 - x << endl;


	return 0;
}


Measured memory_bytes: 256
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int a,v,b,w,t,dis;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a>>v>>b>>w>>t;
	dis=abs(a-b);
	if(v<=w||dis>t*(v-w))
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 3652
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int> II;

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		int h = -1, w, m, y, x, xm = 0, ym = 0, ans = 0;
		cin >> h >> w >> m;
		if (h <= 0) return 0;
		vector<int> yc(h), xc(w), by(m), bx(m);
		for (int i = 0; i < m; ++i) {
			cin >> y >> x;
			--y, --x;
			by[i] = y;
			bx[i] = x;
			yc[y] += 1;
			xc[x] += 1;
			ym = max(ym, yc[y]);
			xm = max(xm, xc[x]);
		}
		set<II> max_x_pos;
		set<int> max_x;
		map<int, set<int>> max_y_pos;
		for (int i = 0; i < m; ++i) {
			if (xm == xc[bx[i]]) {
				max_x.emplace(bx[i]);
				max_x_pos.emplace(II(by[i], bx[i]));
			}
			if (ym == yc[by[i]]) {
				max_y_pos[by[i]].emplace(bx[i]);
			}
		}
		for (auto kv : max_y_pos) {
			int cross = 0;
			for (int x : kv.second) {
				cross += max_x_pos.find(II(kv.first, x)) != max_x_pos.end();
			}
			ans = max(ans, xm + ym - (cross >= max_x.size()));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 78080
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
bool is_prime(ll x){
  for(ll i = 2; i * i <= x; i++){
    if(x % i == 0)return false;
  }
  return true;
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  int res = 0;
  rep(i, n){
    ll x;
    cin >> x;
    if(is_prime(x))res++;
  }
  cout << res << endl;
	return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    int tl;
    cin>>n>>tl;
    int c[n], t[n];
    for(int i=0; i<n; i++)
    {
        cin>>c[i]>>t[i];
    }
    int max_c=10000;
    for(int i=0; i<n; i++)
    {
        if(t[i]<=tl&& c[i]<max_c) max_c=c[i];
    }
    if(max_c==10000) cout<<"TLE\n";
    else cout<<max_c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a % 2 == 1 && b % 2 == 1){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <pthread.h>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <thread>
#include <math.h>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for(int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld;
using namespace std;

bool Chick(string s){
    int l = 0, r = s.size()-1;
    while(r >= 1){
        if(s[l] != s[r]){
            return false;
        }
        l++;    r--;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(NULL);
    cin.tie(NULL); cout.tie(NULL);
    string s;   cin >> s;
    int N = s.size();
    if(Chick(s)){
        string e = s.substr(0,(N-1)/2);
        string h = s.substr(((N-1)/2)+1,(N-1)/2);
        if(Chick(e) && Chick(h)){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	unsigned n, k; cin >> n >> k;
	if (2 * k > n + 1) { cout << -1 << endl; return; }

	int d = (n + 1) / 2;
	for (int p = 0; p < d; p++) {
		int a = k + 2 * p;
		int b = k + n + d - p - 1;
		int c = k + p + 2 * n;
		cout << a << " " << b << " " << c << endl;
	}
	for (int p = d; p < n; p++) {
		int a = k + 2 * (p - d) + 1;
		int b = k + n + n - (p - d) - 1;
		int c = k + p + 2 * n;
		cout << a << " " << b << " " << c << endl;
	}
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

VI graf[N];
int dep[N], a, b, i, maxx, n;

void go(int w, int o) {
	dep[w] = 1;
	for (auto &e : graf[w]) if (e != o) {
		go(e, w);
		dep[w] = max(dep[w], 1 + dep[e]);
	}
}

int main() {
scanf("%d", &n);
for (i=1;i<n;i++) {
	scanf("%d %d", &a, &b);
	graf[a].pb(b);
	graf[b].pb(a);
}
go(1, -1);
maxx = 0;
for (i=1;i<=n;i++) {
	maxx = max(maxx, dep[i]);
	int max1 = -1;
	int max2 = -1;
	for (auto &e : graf[i]) if (dep[e] < dep[i]) {
		if (dep[e] > max1) {
			max2 = max1;
			max1 = dep[e];
		} else if (dep[e] > max2) max2 = dep[e];
	}
	maxx = max(maxx, max1 + max2 + 1);
	//printf("%d %d\n", i, maxx);
}
//printf("%d\n", maxx);
if (maxx % 3 == 2) printf("Second\n"); else printf("First\n");
}



Measured memory_bytes: 20992
import itertools
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
L=list(itertools.permutations(range(2,n+1)))
c=0
for j in range(len(L)):
  if [1,L[j][0]] in l:
    x=0
    for k in range(n-2):
      if [L[j][k],L[j][k+1]] in l or [L[j][k+1],L[j][k]] in l:x+=1
    if x==n-2:c+=1
print(c)

Measured memory_bytes: 3572
n=int(input())
d={}
for _ in range(n):
  s=input()
  if s in d:
    d[s]+=1
  else:
    d[s]=1
m=max(d.values())
ans=[]
for i,k in d.items():
  if m==k:
    ans.append(i)
for i in sorted(ans):
  print(i)

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

int main()
{
	int x, y;
	int temp;
	cin >> x >> y;
	
	if (x < y){
		temp = x;
		x = y;
		y = temp;
	}

	while (x%y != 0){
		temp = x;
		x = y;
		y = temp % y;
	}

	cout << y << endl;

	return 0;
}

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

flag = 0
count = 0
for i in range(n):
  sai = input().split(" ")
  
  if int(sai[0]) == int(sai[1]):
    count += 1
  else:
    count = 0
  
  if count == 3:
    flag = 1

if flag == 1:
  print("Yes")
else:
  print("No")
  

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    string s; cin >> s;
    int len = s.length();
    int w; cin >> w;
    if(w == 1){cout << s << endl; return 0;}
    for(int i = 1; i <= len; i++){
        if(i%w == 1) cout << s[i-1];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int m = s.size();
    int res = 1<<30;
    for(int k=0;k<26;k++){
        int tmp = 0;
        char c = char('a'+k);
        string t = s;
        for(int i=m;i>=0;i--){
            int ccnt=0;
            rep(j,i)if(t[j]==c)ccnt++;
            if(ccnt==i)break;
            for(int j=0;j<i-1;j++){
                if(t[j]==c||t[j+1]==c)t[j]=c;
            }
            tmp++;
        }
        res = min(res,tmp);
    }
    cout << res << endl;
    return 0;
}

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

int diagonal (int check[][3])
{
    if(check[0][0] != 0 && check[1][1] != 0 && check[2][2] != 0)
    {
        return 1;
    }
    
    if(check[0][2] != 0 && check[1][1] != 0 && check[2][0] != 0)
    {
        return 1;
    }

    return 0;
}

int row (int check[][3])
{
    int i, j, cont = 0;
    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            if(check[i][j] != 0)
            {
                cont++;
            }
            else
            {   
                cont = 0;
                break;
            }
        }

        if(cont >= 3)
        {
            return 1;
        }
        
        cont = 0;
    }

    return 0;
}

int column (int check[][3])
{
    int i, j, cont = 0;
    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            if(check[j][i] != 0)
            {
                cont++;
            }
            else
            {
                cont = 0;
                break;
            }
        }

        if(cont >= 3)
        {
            return 1;
        }
        
        cont = 0;
    }

    return 0;
}

int main() {
    int card[3][3], check[3][3], i, j, l, numbers;

    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            scanf("%d", &card[i][j]);
            check[i][j] = 0;
        }
    }

    scanf("%d", &numbers);
    int bingo[numbers];

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

    i = 0;
    while (i < numbers)
    {
        for(l = 0; l < 3; l++)
        {
            for(j = 0; j < 3; j++)
            {
                if(bingo[i] == card[l][j])
                {
                    check[l][j] = card[l][j];
                    break;
                }
            }
        }

        i++;
    }

    if(diagonal(check) || row(check) || column(check))
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    
	return 0;
}

Measured memory_bytes: 128
import scala.annotation.tailrec

object Main{
  // 定数関係
  final private val mod : Int = 1e9.toInt + 7
  
  @tailrec
  def gcd(a : BigInt, b : BigInt): BigInt = {
      if(b == 0) a
      else if(a < b) gcd(b, a)
      else gcd(a % b, b)
  }
  def lcm(a : BigInt, b : BigInt): BigInt = a / gcd(a, b) * b
  
  type INTEGER = Long
  def power(a : Int, n : Int): Int = {
      val hd = 32 - java.lang.Integer.numberOfLeadingZeros(n)
      var isMATCH = 1 << hd
      var ans : INTEGER = 1

      while(isMATCH != 0){
          ans = ans * ans % mod
          if((n & isMATCH) != 0){
              ans = a * ans % mod
          }
          isMATCH >>>= 1
      }
      ans.toInt
  }
  def inv(n : Int): Int = power(n, mod - 2)
  
  
  // main 関数本体
  def main(args : Array[String]): Unit = {
      val n = scala.io.StdIn.readLine().toInt
      val A = scala.io.StdIn.readLine().split(' ').map(_.toInt)
      var sumInv : Int = 0
      var LCM : BigInt = 1
      for(ele <- A){
          LCM = lcm(ele, LCM)
          sumInv += inv(ele)
          if(sumInv >= mod) sumInv -= mod
      }
      val lcmMod : Long = (LCM % mod).toLong
      val ans = lcmMod * sumInv.toLong % mod
      println(ans)
  }
}

Measured memory_bytes: 117040
#include <iostream>
#include <algorithm>
#define llint long long
using namespace std;

llint n;
llint a[200005], sum[200005];

int main(void){
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i];
    sort(sum, sum+n+1);
    
    llint ans = 0, cnt = 0;
    for(int i = 0; i <= n; i++){
        if(i == 0 || sum[i] != sum[i-1]){
            ans += cnt*(cnt-1)/2;
            cnt = 1;
        }
        else cnt++;
    }
    ans += cnt*(cnt-1)/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int
main(void)
{
  int a, b, ans;
  char op;
  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '+') {
      ans = a + b;
    } else if (op == '-') {
      ans = a - b;
    } else if (op == '*') {
      ans = a * b;
    } else if (op == '/') {
      ans = a / b;
    } else {
      break;
    }
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1828
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

N, M = [int(x) for x in input().split()]

maxL = 0
minR = 10 ** 5

for _ in range(M):
    L, R = [int(x) for x in input().split()]
    maxL = max(maxL, L)
    minR = min(minR, R)

ans = minR - maxL + 1
print(max(0, ans))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> x(N), y(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    x[i].resize(A), y[i].resize(A);
    for (int j = 0; j < A; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ret = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    bool f = true;
    for (int i = 0; i < N; i++) {
      if (!(bit & (1 << i))) continue;
      for (int j = 0; j < x[i].size(); j++) {
        int xx = x[i][j], yy = y[i][j];
        if ((!((1 << xx) & bit) && yy == 1) || (((1 << xx) & bit) && yy == 0)) {
          f = false;
        }
      }
    }
    if (f) ret = max(ret, __builtin_popcount(bit));
  }
  cout << ret << endl;
}

Measured memory_bytes: 256