akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::str::FromStr;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .unwrap();
  line
}

fn line_to_vec_num<T: FromStr>(line: &str) -> Vec<T> {
  line
    .trim()
    .split_whitespace()
    .map(|val| { val.parse::<T>().ok().unwrap() })
    .collect()
}

fn main() {
  let _n = get_line();
  let mut vec = line_to_vec_num::<i64>(&get_line());
  vec.reverse();
  let vec = vec.iter()
    .map(|val| val.to_string())
    .collect::<Vec<String>>();
  println!("{}", vec.join(" "));
}



Measured memory_bytes: 5040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,p,mx=0,mn=34324,l;
    cin>>x>>n;
    map<int , int>mp;
    map<int , int>::iterator it;
    if(n==0)
        cout<<x<<endl;
    else
    {

        for(int i=0;i<n;i++)
        {
           cin>>p;
           mp[p]=p;
           mx=max(mx,p);
        }
        for(int i=0;i<mx+10;i++)
        {
            if(mp[i]==0)
            {
               l=abs(i-x);
               mn=min(mn,l);
            }
        }
//        cout<<mn<<endl;
        int a,b;
        a=x-mn;
        b=x+mn;
//        cout<<a<<endl;
//        cout<<b<<endl;
        if(mp[a]==0 && mp[b]==0)
        {
            cout<<a<<endl;
        }
        else if(mp[a]!=0&& mp[b]==0)
            cout<<b<<endl;
        else if(mp[a]==0 && mp[b]!=0)
            cout<<a<<endl;;
    }
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int A, B, C, D, E, F;
set<ll> wtmp, water, stmp, sugar;

int main() {
  cin >> A >> B >> C >> D >> E >> F;
  for (ll i = 0; i <= 30; ++i) {
    for (ll j = 0; j <= 30; ++j) {
      wtmp.insert(100 * i * A + 100 * j * B);
    }
  }
  for (auto e : wtmp) {
    if (e <= F) {
      water.insert(e);
    }
  }

  for (ll i = 0; i <= 3000; ++i) {
    for (ll j = 0; j <= 3000; ++j) {
      stmp.insert(i * C + j * D);
    }
  }

  for (auto e : stmp) {
    if (e <= F) {
      sugar.insert(e);
    }
  }

  double maxc = -1;
  ll ansf = 0, anss = 0;
  for (auto w : water) {
    for (auto s : sugar) {
      if (w + s > F) continue;
      if (s > w / 100 * E) continue;

      if (chmax(maxc, double(100 * s) / double(w + s))) {
        ansf = w + s;
        anss = s;
      }
    }
  }

  cout << ansf << " " << anss << endl;
}


Measured memory_bytes: 10928
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::string S, T;
	std::cin >> S >> T;
	std::cout << boost::count_if(boost::irange(0, 3), [&](int i) {return S[i] == T[i]; }) << std::endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		long double x0, y0, x1, y1, x2, y2, x3, y3; cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		long double vec1_x = x1 - x0, vec1_y = y1 - y0, vec2_x = x3 - x2, vec2_y = y3 - y2;
		if ((vec1_x*vec2_x + vec1_y*vec2_y) == 0) { cout << "1" << endl; continue; }
		if ((vec1_x*vec2_y - vec1_y*vec2_x)==0) { cout << "2" << endl; continue; }
		cout << "0" << endl;
	}
}

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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

int main() {
	int n; cin >> n;
	string S; cin >> S;
	if (n & 1) {
		cout << "No\n";
	}
	else {
		string S1="", S2="";
		for (int i = 0; i < n/2; i++) {
			S1 += S[i];
			S2 += S[i + n/2];
		}
		if (S1 == S2) cout << "Yes\n";
		else cout << "No\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b ;
    string s;
    cin >> s;
    if(a+b+1==s.size())
    {
        bool mrk = 0 ;

        for(int i=0; i<s.size(); i++)
        {
             if(i==a && s[i]!='-'){mrk = 1;break;}
             if(i!=a)
             {
                 if(s[i]>='0' && s[i]<='9')continue;
                 else {mrk = 1;break;}
             }
        }
        if(!mrk)cout << "Yes" << endl;
        else cout << "No" << endl;

    }
    else cout << "No" << endl;

}


Measured memory_bytes: 3608
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int A, B, C;		//生地の値段、トッピングの値段、生地のカロリー。
		int N = sc.nextInt();				//トッピングの種類数。
		int[] topping = new int[N];
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		for(int i=0; i<N; i++){
			topping[i] = sc.nextInt();
		}
		sort_down00(topping, N);
		for(int i=0; i<N; i++){
			if((C/A) <= ((C+topping[i])/(A+B))){
				C += topping[i];
				A += B;
			}
		}
		System.out.println((int)C/A);

	}
	
	static void sort_down00(int[] data, int n){
		int i;
		int idx;
		int work;
		for(i=0; i<n; i++){
			idx = max_idx00(data, i, n);
			work = data[i];
			data[i] = data[idx];
			data[idx] = work;
		}
		return;
	}
	
	static int max_idx00(int[] data, int from, int to){
		int i;
		int idx = from;
		for(i=from; i<to; i++){
			if(data[idx] < data[i]){
				idx = i;
			}
		}
		return idx;
	}

}

Measured memory_bytes: 18128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 2000000
#define MOD 1000000007

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  ll N,M;
  cin>>N>>M;
  COMinit();

  ll ans=1;
  ll i=2;
  while(M>1){
    ll count=0;
    while(M%i==0){
      M/=i;
      count++;
    }
    ans*=COM(N+count-1,N-1);
    ans%=MOD;
    i++;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 47104
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
 
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll st = 1, sa = 1;
	int n;
	ll t,a;
	ll x1,x2;
	cin >> n;
	rep(i, 0, n){
		cin >> t >> a;
		x1=(sa+a-1)/a;
		x2=(st+t-1)/t;
		ll m = max(x1,x2);
		sa = m*a;
		st = m*t;
	}
	cout << (sa + st) << endl;
 
 
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k;
    cin>>k;
    ll ans = 0;
    FOR(i,1,k+1)FOR(j,1,k+1)FOR(p,1,k+1){
        ans += gcd(gcd(i,j),p);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main(){
	queue<long long> que;
	que.push(1);
	que.push(2);
	que.push(3);
	que.push(4);
	que.push(5);
	que.push(6);
	que.push(7);
	que.push(8);
	que.push(9);
	int k;
	cin>>k;
	while(--k){
		long long now=que.front();
		que.pop();
		if(now%10==0){
			que.push(now*10);
			que.push(now*10+1);
		}else if(now%10==9){
			que.push(now*10+now%10-1);
			que.push(now*10+now%10);
		}else{
			que.push(now*10+now%10-1);
			que.push(now*10+now%10);
			que.push(now*10+now%10+1);
		}
	}
	cout<<que.front()<<endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var ans = GetIntArray().Distinct().Count();

            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 13400
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;
const LL BIT_MAX = 2100000; // 2^21 = 2097152

LL dp[21][BIT_MAX] = {0};

LL a[25][25] = {0};

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

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

    vector<vector<LL>> bit(n);
    REP(i,n){
        REP(j,n){
            if(a[i][j] == 1){
                bit[i].PB(1 << j);
            }
        }
    }

    for(LL b : bit[0]){
        dp[0][b] = 1;
    }
    REP(i,n-1){
        FOR(j, 1, BIT_MAX){
            if(dp[i][j] == 0)continue;
            for(LL b : bit[i+1]){
                if((j & b) != 0)continue;
                dp[i+1][j | b] += dp[i][j];
                dp[i+1][j | b] %= MOD;
            }
        }
    }

    PUTS(dp[n-1][(1 << n)-1]);
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n;
    cin>>n;
    vc<pi> xl;
    rep(i,n){
        int x,l;
        cin>>x>>l;
        xl.emplace_back(x,l);
    }

    sort(all(xl));
    
    int r=-1000000005;
    int ans=0;

    rep(i,n){
        if(r<=xl[i].first-xl[i].second){
            ans++;
            r=xl[i].first+xl[i].second;
        }else if(r>=xl[i].first+xl[i].second){
            r=xl[i].first+xl[i].second;
        }
    } 

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main()
{
    int n;
    cin >> n;
    char str[1000] = {};
    cin >> str;
    int Count = 0;
    for(int i = 0; i < n-2; i++)
    {
        if(str[i] == 'A' && str[i+1] == 'B' && str[i+2] == 'C')
        {
            Count++;
        }
    }
    cout << Count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
string s,l,r;
int n;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>s;
	n=s.size();
	for(int lef=0;lef<n;lef++){
		for(int rig=lef;rig<=n;rig++){
			l=s.substr(0,lef);
			r=s.substr(rig);
			if(l+r=="keyence"){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define make make_pair
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
        ll n;cin>>n;
	ll t=0,maxi=-1;
	vii v,v1;
	bool flag=0;
	ll avail=0;
	rep(i,0,n)
	{
		ll l,r;cin>>l>>r;
		v.pb(make_pair(r,l));
	}
	sort(all(v));
	rep(i,0,n)
	{
		v1.pb(make_pair(v[i].ss,v[i].ff));
	}
	rep(i,0,n)
	{
		ll l=v1[i].ff,r=v1[i].ss;
		avail+=l;
		//test2(l,r);
		if(avail>r)
		flag=1;

		maxi=max(maxi,r);
		t+=l;
	}
	if(maxi>=t && flag==0)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
}
		

Measured memory_bytes: 12524
#include<stdio.h>//?????£??????????????°???
#define F 44

int main()
{
  int i,n,f[F];

  scanf("%d",&n);//???????????´??° n ???????????????????????? 
  f[0]=1;
  f[1]=1;

  for( i=2 ; i<=n ; i++ ){
    f[i] = f[i-1] + f[i-2];
  }
  printf("%d\n",f[n]);//?????£??????????????°???????¬¬ n ??????????????????????????????????????? 
  return 0;
}
/*
        1 (n = 0)
fib(n)= 1 (n = 1)
        fib(n-1)+fib(n-2)
 */

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000002
vector<int> v[MAX];
int leaf_count[MAX];
int noOfChild[1000005];
vector<int> adj[1000005];
bool visited[MAX];

void dfs(int k,int p)
{
    visited[k] = true;
    if(p!=-1)
    {
        noOfChild[p]++;
    }
    if(v[k].size()==1 && p!=-1) 
    {
       leaf_count[p]+=1;
      
    }
    
    for(auto i : adj[k])
    {
    
    
    if(visited[i]) continue;
    
     dfs(i,k);
    
        
        
        
    }
    
    
    
    
    
}
void ddfs(int k , int par)
{
    if(v[k].size()!=2 && par!=-1)
        adj[par].push_back(k);
    visited[k]=true;
   //  cout<<k<<" --- "<<par<<endl;
    for(auto i : v[k])
    {

    if(visited[i]) continue;
  
     if(v[k].size()==2 && k!=1)
    { 
          // cout<<i<<" --- "<<par<<" "<<"inner"<<endl;
        ddfs(i,par);
    
    }
     else
     ddfs(i,k);

    }
    
    
}


int main()
{
    
    
int d,l,r;
cin>>l>>r>>d;
int cnt=0;
for(int i=l;i<=r;i++)
{
    if(i%d==0)cnt++;
    
    
}
    cout<<cnt<<endl;
    return 0;
    
}





Measured memory_bytes: 50440
A = list(map(int, input().split()))

B = [A[0]-min(A),A[1]-min(A),A[2]-min(A)]
B.sort()

ans = 0
if B[1] >= 2:
    ans += int(B[1] / 2)
    B[2] -= int(B[1] / 2) * 2
    B[1] %= 2

print(int(ans + sum(B)))



Measured memory_bytes: 3060
n = int(input())
ans = ''
for i in range(1, 99):
    if n <= 26 ** i:
        n -= 1
        for j in range(i):
            ans += chr(ord('a') + n%26)
            n //= 26
        break
    else:
        n -= 26 ** i
print(ans[::-1])

Measured memory_bytes: 9124
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int p = kbd.nextInt();
        int q = kbd.nextInt();
        int r = kbd.nextInt();
        int pq = p + q;
        int qr = q + r;
        int rp = r + p;
        if (pq <= qr && pq <= rp) {
            System.out.println(pq);
        } else if (qr <= pq && qr <= rp) {
            System.out.println(qr);
        } else if (rp <= pq && rp <= qr) {
            System.out.println(rp);
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
main() {
    string S; cin>>S;
    int c=0;  // cost
    for(int i=0; i<S.size(); ++i) {
        if(i%2==0) {
            if(S[i]=='1') ++c;
        } else {
            if(S[i]=='0') ++c;
        }
    }
    cout<< min(c, (int)S.size()-c) <<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
    #define pb push_back
    #define tam 320
    #define se second
    #define fi first
    #define pitem item*
    #define forr(i,p,n) for(int i=p;i<n;i++)
    using namespace std;
    typedef long long ll;
    const ll MOD=1000000007 ;
    ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
    ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
    typedef pair<int,int> ii;
    typedef vector<vector<int> > vvi;
    typedef  double lld;
    bool grafo[tam][tam];
    int ca,cb,n;
    const int INF=1e7;
    int dp[50][410][410];
    int v1[tam],v2[tam],c[tam];
    int f(int pos,int tot1,int tot2)
    {
        //cout<<pos<<endl;
        if (pos==n)
        {
            if (__gcd(tot1,tot2)!=0 && tot1/__gcd(tot1,tot2)==ca&& tot2/__gcd(tot1,tot2)==cb)
                return 0;
            return INF;
        }
        if (dp[pos][tot1][tot2]!=-1)
            return dp[pos][tot1][tot2];
        if (__gcd(tot1,tot2)!=0&& tot1/__gcd(tot1,tot2)==ca && tot2/__gcd(tot1,tot2)==cb)
            return 0;
        int min1=min(f(pos+1,tot1+v1[pos],tot2+v2[pos])+c[pos],INF);
        int min2=f(pos+1,tot1,tot2);
        return dp[pos][tot1][tot2]=min(min1,min2);
    }
    int main()
    {
        ios::sync_with_stdio(false);cin.tie(0);
        cin>>n>>ca>>cb;
        forr(i,0,n)
        {
            cin>>v1[i]>>v2[i]>>c[i];
        }
        memset(dp,-1,sizeof dp);
        int val=f(0,0,0);
        if (val==INF)
            cout<<-1<<endl;
        else
            cout<<val<<endl;
    }

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

using namespace std;

int main() {
  long long n;
  cin>>n;
  long long ans=0;
  for(long long i=1;i<n+1;i++){
    long long k=n/i;
    ans+=i*(k)*(k+1)/2;
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.buffer.readline
from numba import njit
import numpy as np
INF = 10**18

@njit('(i8, i8[:,:])')
def solve(N, XYP):
    X = XYP[:, 0]
    Y = XYP[:, 1]

    def calcCost(sign, A):
        ret = np.ones((1 << N, N), dtype=np.int64) * INF
        for state in range(1 << N):
            useA = [a for i, a in enumerate(A) if (state & (1 << i)) != 0]
            for i in range(N):
                xyp = XYP[i]
                cost = abs(xyp[sign])
                for z in useA:
                    cost = min(cost, abs(xyp[sign] - z))
                ret[state][i] = cost * xyp[2]
        return ret

    costX = calcCost(0, X)
    costY = calcCost(1, Y)
    ans = np.ones(N + 1, dtype=np.int64) * INF

    for state in range(pow(3, N)):
        stateX = 0
        stateY = 0
        M = N
        for _ in range(N):
            state, r = divmod(state, 3)
            stateX <<= 1
            stateY <<= 1
            if r == 0: M -= 1
            if r == 1: stateX |= 1
            if r == 2: stateY |= 1

        cx, cy = costX[stateX], costY[stateY]
        cost = 0
        for i in range(N):
            cost += min(cx[i], cy[i])
        ans[M] = min(ans[M], cost)

    for a in ans:
        print(a)

def sol():
    N = int(input())
    XYP = np.asarray([list(map(int, input().split())) for _ in range(N)])
    solve(N, XYP)

sol()


Measured memory_bytes: 138984
#include<iostream>
#include<map> 
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	map<int,int>m;
	for(int i = 0; i < n; i++)
	{
		int x;
		cin>>x;
		m[x]++;
	}
	int sum=0;
	for(map<int,int>::iterator i=m.begin();i!=m.end();i++)
	{
		if(i->second%2==1)
		sum++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cstdio>
#include <memory>

using namespace std;

int main() {
  int w, n;
  scanf("%d", &w);
  scanf("%d", &n);

  unique_ptr<int[]> order(new int[w]);
  for (int i = 0; i < w; ++i) { order[i] = i + 1; }

  for (int i = 0; i < n; ++i) {
    int j, k;
    scanf("%d,%d", &j, &k);
    swap(order[j - 1], order[k - 1]);
  }

  for (int i = 0; i < w; ++i) { printf("%d\n", order[i]); }

  return 0;
}

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

int main() {

    int N, K;
    cin >> N >> K;

    vector<int> V(N);
    rep(i, N) cin >> V[i];

    int ans = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K - i; j++) {
            if (i + j > N)
                continue;
            vector<int> res;
            int d = K - i - j;
            int now = 0;
            rep(l, i) {
                now += V[l];
                res.push_back(V[l]);
            }
            rep(l, j) {
                now += V[N - l - 1];
                res.push_back(V[N - l - 1]);
            }

            sort(res.begin(), res.end());
            rep(l, d) {
                if (l >= res.size())
                    break;
                if (res[l] >= 0)
                    break;
                now -= res[l];
            }
            ans = max(ans, now);
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007


int main()
{
	ll N;
	cin >> N;
	
	if (N%2==0) {
		cout << N << ' ' << N << ' ' << N / 2 << endl;
	}
	else {
		fyg(3501,1) {
			fzg(3501,1) {
	if ((4 * y*z - N*(y + z))==0) {
					continue;
				}
				if ((N*y*z)%(4*y*z-N*(y+z))==0&& 4 * y*z - N*(y + z)>0) {
					cout << y << ' ' << z << ' ' << (N*y*z) / (4 * y*z - N*(y + z)) << endl;
					y = MOD; z = MOD;
				}
			}
		}
	}


    return 0;
}



Measured memory_bytes: 256
function main()
    n, k = parse.(Int, split(readline()))
    d = zeros(Int, k)
    a = Vector{Vector{Int}}(undef, k)
    for i in 1:k
        d[i] = parse(Int, readline())
        a[i] = zeros(Int, d[i])
        a[i] = parse.(Int, split(readline()))
    end

    x = zeros(Int, n)
    for i in 1:k
        for j in 1:d[i]
            x[a[i][j]] += 1
        end
    end

    println(count(x->x==0, x))

end

main()


Measured memory_bytes: 175376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int ans = N;
		if (N % 2 == 1) {
			ans *= 2;
		}

		reader.close();
		System.out.print(ans);
	}
}



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

int main() {
  string s;
  vector<vector<char>> v(3, vector<char>(0));
  for(int i=0; i<3; i++) {
    cin >> s;
    for(int j=0; j<s.size(); j++) {
      v[i].push_back(s[s.size()-j-1]);
    }
  }
  
  int i = 0;
  while(true) {
    if(i==0) {
      if(v[0][v[0].size()-1]=='a') {
        v[0].pop_back();
        i = 1;
      }
      else if(v[0][v[0].size()-1]=='b') {
        v[0].pop_back();
        i = 2;
      }
      else if(v[0][v[0].size()-1]=='c') {
        v[0].pop_back();
        i = 3;
      }
    }
    
    else if(i==1) { //A
      if(v[0].size()==0) {
        cout << "A" << endl;
        break;
      }
      else if(v[0][v[0].size()-1]=='a') {
        v[0].pop_back();
        i = 1;
      }
      else if(v[0][v[0].size()-1]=='b') {
        v[0].pop_back();
        i = 2;
      }
      else if(v[0][v[0].size()-1]=='c') {
        v[0].pop_back();
        i = 3;
      }
    }
    
    else if(i==2) { //B
      if(v[1].size()==0) {
        cout << "B" << endl;
        break;
      }
      else if(v[1][v[1].size()-1]=='a') {
        v[1].pop_back();
        i = 1;
      }
      else if(v[1][v[1].size()-1]=='b') {
        v[1].pop_back();
        i = 2;
      }
      else if(v[1][v[1].size()-1]=='c') {
        v[1].pop_back();
        i = 3;
      }
    }
    
    else if(i==3) { //C
      if(v[2].size()==0) {
        cout << "C" << endl;
        break;
      }
      else if(v[2][v[2].size()-1]=='a') {
        v[2].pop_back();
        i = 1;
      }
      else if(v[2][v[2].size()-1]=='b') {
        v[2].pop_back();
        i = 2;
      }
      else if(v[2][v[2].size()-1]=='c') {
        v[2].pop_back();
        i = 3;
      }
    }
  }
  return 0;
}

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

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

	int i = 700;
	if (s[0] == 'o')i += 100;
	if (s[1] == 'o')i += 100;
	if (s[2] == 'o')i += 100;

	cout << i;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,a[100],b[100],c[100],x,y,z,xh,yh,s=0;
	scanf("%d",&n);
	scanf("%d",&x);
	for(int i=0;i<x;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&y);
	for(int i=0;i<y;i++){
		scanf("%d",&b[i]);
	}
	scanf("%d",&z);
	for(int i=0;i<z;i++){
		scanf("%d",&c[i]);
	}
	
	for(int i=0;i<z;i++){
		xh=0;
		yh=0;
		for(int m=0;m<x;m++){
			 if(c[i]==a[m]){
			 	xh=1;
			 }
		for(int yy=0;yy<y;yy++){
			 if(c[i]==b[yy]){
			 	yh=1;
			 }
			 }
		 }
		 if(xh==0){s++;}
		 if(yh==1){s++;}
		 if((xh==0)&(yh==1)){s--;}
	}
	printf("%d\n",s);


}


Measured memory_bytes: 2712
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define N 1000000007
using namespace std;
ll power(ll a, ll b)
{
    if(b == 0)
        return 1;
    ll x = power(a, b/2);
    x = (x*x)%N;
    if(b%2 == 1)
        x = (x*a)%N;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,y,i,ans = 0,a,b,t;
    cin>>x>>y;
    ll fact[x+1], ifact[x+1];
    fact[0] = 1;
    for(i=1;i<=x;i++)
        fact[i] = (fact[i-1]*i)%N;
    for(i=0;i<=x;i++)
        ifact[i] = power(fact[i], N-2);
    for(int i=0;i<=x;i++)
    {
        a = i;
        b = 2*i;
        a = x-a;
        b = y-b;
        if(a>=0 and b>=0 and a==2*b)
        {
            t = (fact[i+b]*ifact[i])%N;
            t = (t*ifact[b])%N;
            ans = (ans + t)%N;
        }
    }
    cout<<ans;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int h, n;
	cin >> h >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	if (h <= accumulate(ASC(a), 0)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>

int main()
{
    int num;
    std::string str;
    
    std::cin >> num;
    
    str = std::to_string(num);
    
    if(str[0] == str[1] && str[2] == str[1]){
        std::cout << "Yes";
    }else if(str[2] == str[1] && str[3] == str[1]){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }
    
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

shop_list = [None] * N
for n in range(N):
    a, b = map(int, input().split())
    shop_list[n] = [a, b]

total = 0
for a, b in sorted(shop_list, key = lambda x: x[0]):
    if M > b:
        total += a * b
        M -= b
    else:
        total += a * M
        break
print(total)


Measured memory_bytes: 21976
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n, m, mas[1001];
  while( cin >> n >> m, n){
    for(int i = 1 ; i <= n ; i++ ){
      cin >> mas[i];
    }
    int ret = -1;
    for(int i = 1, now = 1, MLE ; i <= m ; i++ ){
      cin >> MLE;
      now = min( now + MLE, n);
      if( !~ret && now == n) ret = i;
      now = min( now + mas[now], n);
      if( !~ret && now == n) ret = i;
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  vector<Int> cnt(50);
  for(Int i=0;i<n;i++)
    for(Int j=0;j<50;j++)
      cnt[j]+=(a[i]>>j)&1;

  Int ans=0;
  function<void(Int, Int, Int)> dfs=
    [&](Int x,Int v,Int f){
      if(x<0){
        chmax(ans,v);
        return;
      }
      if(f){
        dfs(x-1,v+max(cnt[x],n-cnt[x])*(1LL<<x),1);
        return;
      }
      if((k>>x)&1){        
        dfs(x-1,v+(cnt[x])*(1LL<<x),1);   // 0 
        dfs(x-1,v+(n-cnt[x])*(1LL<<x),0); // 1
      }else{
        dfs(x-1,v+(cnt[x])*(1LL<<x),0);   // 0
      }
    }; 
  dfs(49,0,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1152
/*
[abc103] C - Modulo Summation
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 3000;

int N;
int a[MAX_N];

ll solve() {
    ll ret = 0;
    for (int i = 0; i < N; i++) {
        ret += a[i] - 1;
    }
    return ret;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


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

  res = N * 100 / 108;

  if(res * 108 / 100 == (int)N)
  {
    cout << res << endl;
  }
  else if((res+1) * 108 / 100 == (int)N)
  {
    cout << res + 1 << endl;
  }
  else
  {
    cout << ":(" << endl;
  }

  return 0;    
}



Measured memory_bytes: 256
n, k = gets.split(" ").map(&:to_i)
probability = 0.0
(1..n).each do |index|
  point = index
  multiply_times = 0
  while point < k do
    point *= 2
    multiply_times += 1
  end
  probability += 1.0 / n / (2 ** multiply_times)
end
puts probability

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007 //(10^9 +7)
#define INF 1000000000000000000 //(10^18)
using namespace std;
typedef long long  ll;
typedef long double ld;
const ll N=100005;
const ll inf=1e18;
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b&1){
            res=res*a;
        }
        a=a*a;
        b>>=1;
    }
    return res;
}
int main(){
    fastIO;
    ll n,k;
    cin>>n>>k;
    vector<ll> vect(n,0);
    ll i=0,j=0;
    for(i=0;i<n;i++){
        cin>>vect[i];
    }
    vector<ll> dp(n,INF);
    dp[0]=0;
    dp[1]=abs(vect[1]-vect[0]);
    for(i=0;i<n-1;i++){
        //dp[i]=min(dp[i-1]+abs(vect[i]-vect[i-1]),dp[i-2]+abs(vect[i]-vect[i-2]));
        for( j=i+1;j<=i+k;j++){
            if(j>n-1){
                break;
            }
            else{
                dp[j]=min(dp[j],dp[i]+abs(vect[i]-vect[j]));
            }
        }
    }
    cout<<dp[n-1];
}


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

int main(){
    int a[9];
    rep(i,9){
        cin >> a[i];
    }

    int n;
    cin >> n;
    int b[n];
    bool ed[9];
    memset(ed,0,sizeof(ed));
    rep(i,n){
        cin >> b[i];
        rep(j,9){
            if(a[j]==b[i]) ed[j]=true;
        }
    }

    rep(i,3){
        if(ed[i] && ed[i+3] && ed[i+6]){
            printf("Yes\n");
            return 0;
        }
    }
    for(int i=0;i<9;i+=3){
        if(ed[i] && ed[i+1] && ed[i+2]){
            printf("Yes\n");
            return 0;
        }
    }
    if(ed[0] && ed[4] && ed[8]){
        printf("Yes\n");
        return 0;
    }
    if(ed[2] && ed[4] && ed[6]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");
}

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

int n,t[10001];

int main(){
	while(scanf("%d",&n), n != 0){
		for(int i = 0; i < n; i++){
			scanf("%d",&t[i]);
		}
		sort(t,t+n);

		long long int ans = 0;
		for(int i = 1; i < n; i++){
			ans += t[i-1] * (n-i);
		}
		printf("%lld\n",ans);
	}
	return 0;
}



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

ll gcd(ll n, ll m){
  if(n%m == 0) return m;
  return gcd(m, n%m);
}

ll lcm(ll n, ll m){
  return n * m / gcd(n, m);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  vector<ll> A(N, 0);
  for(auto &i : A) cin >> i;
  vector<ll> AA(N, 0);
  vector<ll> AB(N, 0);
  REP(i, N){
    if(i == 0){
      AA[i] = A[i];
      AB[N-1-i] = A[N-1-i];
    }else{
      AA[i] = gcd(AA[i-1], A[i]);
      AB[N-1-i] = gcd(AB[N-i], A[N-1-i]);
    }
  }
  ll ans = 0, tmp;
  REP(i, N){
    if(i == 0){
      tmp = AB[1];
    }else if(i == N-1){
      tmp = AA[N-2];
    }else{
      tmp = gcd(AA[i-1], AB[i+1]);
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>

using namespace std;


int main(void)
{
    long int L,R;
    cin>>L>>R;
    if(R-L>2019){
        cout<<0<<endl;
    }
    else{
        int min=9999;
        for(int i=L;i<R;i++){
            for(int j=i+1;j<=R;j++){
                if(((i%2019)*(j%2019))%2019<min){
                    min=((i%2019)*(j%2019))%2019;
                }
            }
        }
        cout<<min<<endl;
    }
    
    
}


Measured memory_bytes: 256
def find_nearest_index(xs, i)
  ind = xs.bsearch_index{|x| x >= i }
  return xs.length-1 if ind.nil?
  return ind if ind == 0
  i-xs[ind-1] < xs[ind]-i ? ind-1 : ind
end

A,B,Q = gets.split.map(&:to_i)
ss = A.times.map{ gets.to_i }
ts = B.times.map{ gets.to_i }
xs = Q.times.map{ gets.to_i }

s_neigbor_cost = ss.map{|s| (s-ts[find_nearest_index(ts, s)]).abs }
t_neigbor_cost = ts.map{|t| (t-ss[find_nearest_index(ss, t)]).abs }

puts xs.map{|x|
  s_neigbor_index = find_nearest_index(ss, x)
  s_candidates = [s_neigbor_index]
  s_candidates << s_neigbor_index-1 if s_neigbor_index != 0
  s_candidates << s_neigbor_index+1 if s_neigbor_index != ss.length-1
  s_cost = s_candidates.map{|i|
    (x - ss[i]).abs + s_neigbor_cost[i]
  }.min

  t_neigbor_index = find_nearest_index(ts, x)
  t_candidates = [t_neigbor_index]
  t_candidates << t_neigbor_index-1 if t_neigbor_index != 0
  t_candidates << t_neigbor_index+1 if t_neigbor_index != ts.length-1
  t_cost = t_candidates.map{|i|
    (x - ts[i]).abs + t_neigbor_cost[i]
  }.min

  [s_cost, t_cost].min
}.join("\n")


Measured memory_bytes: 9140
def solve():
    N = int(input())
    Ass = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(N)]

    games = []
    for i in range(N):
        for j in range(i+1, N):
            games.append(i*N+j)
    adjL = [[] for _ in range(N*N)]

    indegs = [0] * (N*N)
    for i, As in enumerate(Ass):
        for j in range(len(As)-1):
            p1, p2, p3, p4 = i, As[j], i, As[j+1]
            if p1 > p2:
                p1, p2 = p2, p1
            if p3 > p4:
                p3, p4 = p4, p3
            adjL[p1*N+p2].append(p3*N+p4)
            indegs[p3*N+p4] += 1

    gameTodays = set()
    for game in games:
        if indegs[game] == 0:
            gameTodays.add(game)

    ans = 0
    numDone = 0
    while gameTodays:
        gameTomorrows = set()
        for game in gameTodays:
            numDone += 1
            for game2 in adjL[game]:
                indegs[game2] -= 1
                if indegs[game2] == 0:
                    gameTomorrows.add(game2)
        ans += 1
        gameTodays = gameTomorrows

    if numDone == N*(N-1)//2:
        print(ans)
    else:
        print(-1)

solve()



Measured memory_bytes: 188448
A_HP, A_AP, B_HP, B_AP = map(int, input().split())
while True:
  B_HP -= A_AP
  if B_HP <= 0:
    print("Yes")
    break
  else:
    pass
  A_HP -= B_AP
  if A_HP <= 0:
    print("No")
    break
  else:
    pass


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d,e,f,g,ans=0;
  cin >> a >> b >> c >> d >> e >> f >> g;
  ans+=b+a/2*2+d/2*2+e/2*2;
  if(a>0&&d>0&&e>0){
    ans=max(ans,b+(a-1)/2*2+(d-1)/2*2+(e-1)/2*2+3);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 22;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
priority_queue <int> qua;
vector <int> vec;
int n, q;
char s[maxx];
int l, r;
int pos[maxx];

int main() {
	scanf("%d %d", &n, &q);
	scanf("%s", s + 1);
	s[n + 1] = 'A', s[n + 2] = 'C';
	int tot = 0;
	for(int i = 1; i < n + 2; i++) {
		if(s[i] == 'A' && s[i + 1] == 'C') pos[++tot] = i;
	}
	while(q--) {
		scanf("%d %d", &l, &r);
		int cntr = lower_bound(pos + 1, pos + tot + 1, r) - pos; //pos中第一个大于等于r的下标
		cntr--; //r之前AC的个数
		int cntl = lower_bound(pos + 1, pos + tot + 1, l) - pos; //pos中第一个大于等于l的下标
		cntl--; //l之前AC的个数
		//printf("%d %d\n", cntl, cntr);
		printf("%d\n", cntr - cntl);
	}
}

/*
1 3 6
3 7 -> 2
2 3 -> 0
1 8 -> 3
*/

Measured memory_bytes: 1152
h, w = map(int, input().split())
canvas = [input() for _ in range(h)]
dx_list = [0, 1, 0, -1]
dy_list = [-1, 0, 1, 0]
clear = True

for y in range(h):
    for x in range(w):
        if canvas[y][x] == '.':
            continue
        else:
            count = 0
            for d in range(4):
                dx = x + dx_list[d]
                dy = y + dy_list[d]

                if 0 <= dx <= w-1 and 0 <= dy <= h-1:
                    if canvas[dy][dx] == '#':
                        count += 1

            if count == 0:
                clear = False
                break
    if clear is False:
        break

if clear:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

// same as div2_553 E
// no cycles 
// count number of component
// ans += nodes(L,R)-edges(L,R)
// total nodes is S(1) + s(2) + s(3) + .. + s(n)
// O(n) needed try try dont cry
// for each edges subtract 1 in each interval it appear

ll S(ll n){
	return n*(n+1)/2;
}

void test_case(){
	ll ans = 0;
	int n; cin >> n;
	for(int i = 0 ; i <=n ; i++){
		ans+=S(i);
	}
	for(int i = 0 ; i < n-1 ; i++){
		ll a , b;
		cin >> a >> b;
		if(a > b)
			swap(a,b);
		ans-=a*(n-b+1);
	}
	cout<<ans<<"\n";
			
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3608