akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<3;++j)
        {
            cin>>a[i][j];
        }
    }
    
    
    for(int i=0;i<n-1;++i)
    {
        for(int j=0;j<3;++j)
        {
            int x = a[i+1][j];
            for(int k=0;k<3;++k)
            {
                if(k!=j)
                {
                    a[i+1][j] = max(a[i+1][j],x+a[i][k]);
                }
            }
        }
    }
    int maxi=0;
    for(int i=n-1;i<n;++i)
    {
        for(int j=0;j<3;++j)
        maxi = max(maxi,a[i][j]);
    }
    cout<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 4764
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BBuffet {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<int> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      vector<int> b(n);
      rep(i, n) {
        cin >> b[i];
      }
      vector<int> c(n-1);
      rep(i, n-1) {
        cin >> c[i];
      }
      ll ans = 0;
      rep(i, n) {
        ans += b[a[i]-1];
      }
      rep(i, n-1) {
        if (a[i]+1 == a[i+1]) {
          ans += c[a[i]-1];
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BBuffet solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
def dfs(problems: "scores", now_depth: int, g: int) -> int:
  if now_depth == 0:
    return 10 ** 9 # 十分に大きい値
  
  # ある得点帯iにおいて,gを達成するのに必要な問題数を考える
  # g // (100 * idx) は, コンプリートボーナスを考えない場合の問題数
  # これを min() でコンプリートボーナス達成に必要な問題数と比べる.
  solve_count = min(g // (100 * now_depth), problems[now_depth][0]) # // は余り切り捨て
  score = 100 * now_depth * solve_count

  # コンプリートボーナス(に必要な問題数)を選んだときは更に加算
  if solve_count == problems[now_depth][0]:
    score += problems[now_depth][1]
  
  if score < g:
    solve_count += dfs(problems, now_depth - 1, g - score)
  
  return min(solve_count, dfs(problems, now_depth - 1, g))

depth, g = [ int(x) for x in input().split() ]
# [0] は問題番号と入力の帳尻を合わせる為につけているもの.使用しない.
problems = [0] + [ [ int (x) for x in input().split() ] for _ in range(depth) ]
print(dfs(problems, depth, g))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    int main(){
        int A, B;
        cin >> A >> B;

        if(A!=1&&B!=1){
            cout << 1 << endl;
            }else if(A!=2&&B!=2){
                cout << 2 << endl;
            }else if(A!=3&&B!=3){
                cout << 3 << endl;
            }
        
    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  ll ans = 0;
  for(ll i = 1; i * i <= N; i++) {
    if(N % i == 0) {
       ll j = N / i;
       if(N / j < j - 1) {
           ans += j - 1;
       }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

# nの約数を求める。計算量O(sqrt(N))
def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            if n//num != num:
                divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

total = sum(A)
divisors = get_divisors(total, reverse=True)
ans = -1
for d in divisors:
    R = [a%d for a in A]
    R.sort(reverse=True)
    pr = 0
    nr = -sum(R)
    for i, r in enumerate(R):
        pr += d-r
        nr += r
        if nr+pr >= 0:
            if pr <= K and nr+pr == 0:
                ans = d
            break
    if ans != -1:
        print(ans)
        break
else:
    print(1)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
using ll = long long;
#define MX 1010
#define mod 1000000007
char matrix[MX][MX];
ll dp[MX][MX];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int H; cin>>H;
	int W; cin>>W;
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++) cin>>matrix[i][j];

	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++)
		{
			if(matrix[i][j]=='#') dp[i][j] = 0ll;
			else if(i==1 and j==1) dp[i][j] = 1ll;
			else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
		}

	cout << dp[H][W] << '\n';
	return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;
class Main{
	public static void main(String args[])
    {
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int arr[]=new int[n];
      	int dp[]=new int[n];
      	for(int i=0;i<n;i++){
        	arr[i]=sc.nextInt();
          	if(i == 0)	dp[i]=0;
          	else if(i ==1) dp[i]=Math.abs(arr[i]-arr[i-1]);
          	else{
            	int m1 = dp[i-1]+Math.abs(arr[i]-arr[i-1]);
              	int m2 = dp[i-2]+Math.abs(arr[i]-arr[i-2]);
              	if(m1< m2) dp[i]=m1;
              	else dp[i]=m2;
            }
        }
      System.out.println(dp[n-1]);
    }
}

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

using namespace std;
vector<vector<int>>G;
vector<int>P;
vector<int>ans;

void dfs(int v, int sum)
{
    ans[v] += sum + 1;
    for(auto nv: G[v])
    {
        if(ans[nv] != -1) continue;
        dfs(nv,sum + P[nv]);
    }
}

int main()
{
    int N,Q;
    cin >> N >> Q;
    G.resize(N);
    for(int i = 0; i < N - 1; i++)
    {
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    P.assign(N,0);
    for(int i = 0; i < Q; i++)
    {
        int p,x;
        cin >> p >> x;
        p--;
        P[p] += x;
    }
    ans.assign(N,-1);
    dfs(0,P[0]);
    for(int i = 0; i < N; i++)
    {
        cout << ans[i] << " ";
    }
}

Measured memory_bytes: 21932
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}


int main()
{ 
  IOS;

ll a,v;
ll b,w;
cin>>a>>v>>b>>w;

ll t;cin>>t;
/*
if(v<w){
  if()
  cout<<"NO";
  return 0;
}
if(w==v){
  if(a==b)cout<<"YES";
  else cout<<"NO"<<endl;
  return 0;
}*/

if(abs(a-b)<=t*(v-w))cout<<"YES"<<endl;
else cout<<"NO"<<endl;


 return 0;
 
 
}

Measured memory_bytes: 3656
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	string s, t;
	cin >> s >> t;
	N = s.size();
	for (int i = 0; i < N; i++) {
		string u;
		for (int j = 0; j < N; j++) {
			u.push_back(s[(i + j) % N]);
		}
		if (u == t) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner reader = new Scanner(System.in);

    String str = reader.next();
    int n = reader.nextInt();
    for (int i = 0; i < n; i++) {
      String command = reader.next();
      int a = reader.nextInt();
      int b = reader.nextInt();

      if (command.equals("print")) {
        String tempStr = str.substring(a, b + 1);
        System.out.println(tempStr);
      }
      else if (command.equals("reverse")) {
        char[] tempStr = str.toCharArray();
        for (int j = 0; j < (b - a + 1) / 2; j++) {
          char c = tempStr[a + j];
          tempStr[a + j] = tempStr[b - j];
          tempStr[b - j] = c;
        }
        str = String.valueOf(tempStr);
      }
      else if (command.equals("replace")) {
        char[] p = reader.next().toCharArray();
        char[] tempStr = str.toCharArray();
        for (int j = a; j <= b; j++) {
          tempStr[j] = p[j - a];
        }
        str = String.valueOf(tempStr);
      }
    }
  }
}

Measured memory_bytes: 29224
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  map<ll,ll>M;
  rep(i,n){
    M[a[i]]++;
    M[a[i]-1]++;
    M[a[i]+1]++;
  }
  ll MAX=0;
  ll ans=0;
  for(auto p:M){
          //cout<<p.first<<" "<<p.second<<endl;

    if(MAX<p.second){
      MAX=p.second;
    }
  }
  cout<<MAX<<endl;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

#define MIN(a, b) ((a) < (b) ? (a) : (b))

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

	ll n, a, b;
	cin >> n >> a >> b;

	cout << a * (n / (a + b)) + MIN(a, n % (a + b)) << '\n';
}


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

int main() {
    string S;
    cin >> S;
    int res = 0;

    if (S[0] == 'R' && S[1] == 'S' && S[2] == 'R') {
        cout << 1 << endl;
        return 0;
    }

    for (int i = 0; i < 3; i++) {
        if (S[i] == 'R') {
            res++;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3608
/*input
7 7
*/

// Nihesh Anderson - knandy

#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 long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int a, b;
	cin >> a >> b;
	if(a > b) {
		swap(a, b);
	}
	for(int i = 0; i < b; i++) {
		cout << a;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		DisjointSet ds = new DisjointSet(n);
		
		for (int i = 0; i < q; i++) {
			int c = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(c==0){
				ds.unite(a, b);
			} else {
				if (ds.same(a, b)) {
					System.out.println(1);
				} else {
					System.out.println(0);
				}
			}
		}
	}
	
	
	
	static class DisjointSet{
		int[] rank;
		int[] p;
		
		DisjointSet(int s){
			rank = new int[s];
			p = new int[s];
			for (int i = 0; i<s; i++) {
				p[i] = i;
			}
		}
		
		int findSet(int x){
			while(true){
				if(x == p[x]){
					return x;
				}
				x = p[x];
			}
		}
		
		public boolean same(int x, int y){
			return findSet(x) == findSet(y);
		}
		
		public void unite(int x, int y){
			linkSet(findSet(x),findSet(y));
		}
		
		public void linkSet(int x, int y){
			if(rank[x] > rank[y]){
				p[y] = x;
			} else {
				p[x] = y;
				if(rank[x] == rank[y]){
					rank[y]++;
				}
			}
		}
		
	}
	
	
	
	
	
}


Measured memory_bytes: 98500
/** author: __nishad__ **/

#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define Fast_IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a) for(int i=0; i<a;i++)
#define loop2(i,a,b) for(int i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    Fast_IOS;

    long long int a, b, k, i;
    cin>>a>>b>>k;

    for(i=a; i<=b; i++){
        if(abs(i-a) <k || abs(i-b) <k)
            cout<<i<<" ";
    }



}








Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bubblesort(int A[], int N) {
	bool flag = 1;
			int sw=0;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				sw++;
				flag = 1;
			}
		}

	}
	return sw;
}
int main() {
	int N, sw;
	int A[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sw = bubblesort(A, N);
	for (int i = 0; i < N; i++) {
		if(i){cout <<" ";}
		cout << A[i];
	}
	cout << endl;
	cout << sw<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
using namespace std;

void getPrime(int N, vector<int>& prime)
{
	vector<bool> isNotPrime(N + 1);
	for (auto i = 2; i <= N; ++i)
	{
		if (isNotPrime[i])
		{
			continue;
		}

		prime.push_back(i);
		for (auto j = i; j <= N; j += i)
		{
			isNotPrime[j] = true;
		}
	}
}

int dp[76][26];

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

	memset(dp, 0, sizeof(dp));

	vector<int> prime;
	getPrime(N, prime);
	vector<int> count(prime.size());
	for (auto i = 2; i <= N; ++i)
	{
		auto temp = i;
		for (auto j = 0; j < prime.size(); ++j)
		{
			while(temp % prime[j] == 0)
			{
				count[j]++;
				temp /= prime[j];
			}
		}
	}

	for (auto it = count.begin(); it != count.end();)
	{
		if (*it == 0)
		{
			it = count.erase(it);
		}
		else
		{
			++it;
		}
	}

	auto result = 0;
	for (auto i = 0; i <= 75; ++i)
	{
		for (auto j = 0; j < count.size(); ++j)
		{
			if (i <= 1)
			{
				dp[i][j] = 0;
			}
			else if (i == 2)
			{
				dp[i][j] = 1;
			}
			else
			{
				if (i <= count[j] + 1)
				{
					dp[i][j] += 1;
				}
				if (j > 0)
				{
					dp[i][j] += dp[i][j - 1];
					for (auto k = 1; k <= count[j]; ++k)
					{
						auto temp = k + 1;
						if ((i % temp) == 0 && i >= temp)
						{
							dp[i][j] += dp[i / temp][j - 1];
						}
					}
				}
			}
		}
	}
	result = dp[75][count.size() - 1];

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "3", "1 2 3" ].parse.expand.solve == 1 );
	assert( [ "5", "3 11 14 5 13" ].parse.expand.solve == 2 );
	
	assert( [ "5", "2 2 2 2 2" ].parse.expand.solve == 2 );		// 追加ケース
}



import core.bitop;
import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	// 2^^n-1 <= a < a+b == 2^^n <= 2a < 2^^n+1 なので、
	// a = max(as) のときの b は一意に決まるから、大きい順で貪欲にペアを作ればいい
	auto ans = 0L;
	auto rbt = redBlackTree!true( as );
	while( !rbt.empty )
	{
		auto a = rbt.back;
		rbt.removeBack;
		auto b = ( 2L << a.bsr ) - a;
		if( rbt.removeKey( b ) ) ans++;		// a に対応する b が見つかればペアにする
	}
	return ans;
}


Measured memory_bytes: 25016
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;int a[n];
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int z=0;int b[n];
for(int i=1;i<=n;i++)
{

b[a[i]]=++z;
}
for(int i=1;i<=n;i++)
{
cout<<b[i]<<" ";
}
}



Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int N,ans=0;
  cin>>N;
  
  int DP[10][10][200010];
  REP(i,10){
    REP(j,10){
      REP(k,200010){
        DP[i][j][k]=0;
      }
    }
  }
  
  
  for(int i=1; i<N+1; ++i){
    for(int j=1; j<10; ++j){
      for(int k=1; k<10; ++k){
        DP[j][k][i]=DP[j][k][i-1];
      }
    }
    
    int t=i;
    while(t>=10) t/=10;
    
    DP[t][i%10][i]++;
  }
  
  for(int i=1; i<10; ++i){
    for(int j=1; j<10; ++j){
      ans+=DP[i][j][N]*DP[j][i][N];
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;

    vi cnt(n, 1);
    vb ans(n, false);
    ans[0] = true;
    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        if (ans[x]) ans[y] = true;
        cnt[x]--;
        cnt[y]++;
        if (cnt[x] == 0) ans[x] = false;
    }
    cout << accumulate(ans.begin(), ans.end(), 0) << endl;
}

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

using namespace std;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	if(a*b*c == 5*7*5) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main()
{
	int a, b, c;
	char op;
	cin >> a >> op >> b;

	if( op == '+' ) {
		c = a + b;
	}
	else {
		c = a - b;
	}

	cout << c << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split()))

counter = Counter(A)

counts = counter.most_common()

dup_num = 0
for i in range(len(counts)):
    if counts[i][1] != 1:
        dup_num += counts[i][1]-1

if dup_num%2 == 0:
    print(N-dup_num)
else:
    print(N-dup_num-1)

Measured memory_bytes: 21980
A,B = map(int,input().split())

def f(n) :
    if n % 4 == 0 :
        return n
    elif n % 4 == 1 :
        return 1
    elif n % 4 == 2 :
        return n+1
    else :
        return 0

print(f(A-1)^f(B))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int visited[220000];
int main()
{
    ll n,k;
    cin >> n >> k;
    vector<int> a(n+1),res;
    rep(i,n)cin >> a[i+1];
    res.push_back(1);
    int i = 0;
    int past = 1;
    int go;
    visited[1] = 1;
    
    while(true){
        go = a[past];
        if(i> n+2 ||visited[go] )break;
        visited[go] = 1;
        res.push_back(go);
        past = go;
        i++;

    }
    int ind = 0;
    rep(j,(int)res.size()){
        
        if(res[j] == go){
            ind = j;
            break;
        }

    }
    int m = i - ind+1;
    if(k < ind){
        cout << res[k] << endl;
        return 0;
    }
    
    
    k-= ind;
    int ans;
    

    if(m!= 0) ans = res[ind + k%m];
    else ans = res[ind];

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 5884
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){

    int N;
    int L[200];
    cin >> N;
    REP(i,2*N) cin >> L[i];
    int ans = 0;
    sort(L,L+2*N,greater<int>());
    REP(i, N) {
        ans += L[2 * i + 1];
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
const int N=1e6+20;
const int M=30;
char s[M][M]={{"dream"},{"dreamer"},{"erase"},{"eraser"}};
int len[5];

int root,num=0;
int Next_n[N][M],word[N];//trie Next[u][id] u结点编号 
void insert(int x)
{
	int u=0,l=len[x];
	for(int i=0;i<l;i++)
	{
		char t=s[x][i];
		int id=t-'a';
		if(!Next_n[u][id])
		{
			Next_n[u][id]=++num;
		}
		u=Next_n[u][id];	
	}
	word[u]=x;//单词结束标记 
}
char str[N];
int n;
bool flag=false;
void dfs(int pos)
{
	if(pos>=n)
	{
		flag=true;
		return;
	}
	if(!flag)
	{
		int u=root;
		for(int i=pos+1;i<=n;i++)
		{
			int id=str[i]-'a';
			u=Next_n[u][id];
			
			if(!u)
			break;
		
			if(word[u]!=-1)
			{
				dfs(pos+len[word[u]]);//
			}
		}
		
	}
}
int main()
{
	memset(Next_n,0,sizeof(Next_n));
	memset(word,-1,sizeof(word));
	root=0;
	for(int i=0;i<4;i++)//dictionary
	{
		len[i]=strlen(s[i]);
		insert(i);
	}
	
	while(scanf("%s",str+1)!=EOF)
	{
		flag=false;
		n=strlen(str+1);
		dfs(0);//暴力匹配 
		if(flag)
		cout<<"YES"<<endl;
		else
		cout<<"NO"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 121984
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A, B;
  rd(A);
  rd(B);
  if((A*B)%2){
    wt_L("Odd");
    wt_L('\n');
  }
  else{
    wt_L("Even");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int A, B;
//   rd(A,B);
//   wt( if[(A*B)%2, "Odd", "Even"] );
// }


Measured memory_bytes: 256
#include <iostream> 
#include <math.h>  

using namespace std; 

  


void findNumberOfDigits(long n, int base) 
{ 

  

    int dig = (int)(floor( log(n) /  

                         log(base)) + 1);  

      

  

    cout << dig; 
} 

int main() 
{ 

  

    long int n;

    int base;
    cin>>n>>base;
    findNumberOfDigits(n, base); 

    return 0; 
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		
		Scanner input = new Scanner(System.in);
		int quantidade = input.nextInt();
		input.close();
		
		int n500 = quantidade / 500;
		quantidade %= 500;
		int n100 = quantidade / 100;
		quantidade %= 100;
		int n50 = quantidade / 50;
		quantidade %= 50;
		int n10 = quantidade / 10;
		quantidade %= 10;
		int n5 = quantidade / 5;
		
		if(n10 > 0) {
			n5 += n10 * 2;
		}
		
		if(n50 > 0) {
			n5 += n50 * 10;
		}
		
		if(n100 > 0) {
			n5 += n100 * 20;
		}
		
		System.out.println((n500 * 1000) + (n5 * 5));
		
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N,ans=1;
    string S;
    cin >> N >> S;
    for(int i=1;i<N;i++){
        if(S[i-1] != S[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
}

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

int main(){
  string a, b;
  int c;
  cin >> a >> b;
  a += b; c = atoi(a.c_str());
  int tmp = sqrt(c);
  if(tmp * tmp == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int N;
cin >> N;
vector<int> a(N + 1);
REP(i, N) cin >> a.at(i + 1);
vector<int> b(N + 1);
for(int i = N; i >= 1; i--){ 
   int sum = 0;
   for(int j = i + i; j <= N; j += i){ 
      sum ^= b.at(j);
   }
   b.at(i) = sum ^ a.at(i);
}
vector<int> ans;
for(int i = 1; i <= N; i++){ 
   if(b.at(i)) ans.push_back(i);
}
cout << ans.size() << endl;
REP(i, ans.size()){
  printf("%d%c", ans.at(i), i + 1 == ans.size()?'\n':' ');
}
return 0;

 }

Measured memory_bytes: 3064
T = int(input())
if T >= 400 and T <= 599:
    print(8)
if T >= 600 and T <= 799:
    print(7)
if T >= 800 and T <= 999:
    print(6)
if T >= 1000 and T <= 1199:
    print(5)
if T >= 1200 and T <= 1399:
    print(4)
if T >= 1400 and T <= 1599:
    print(3)
if T >= 1600 and T <= 1799:
    print(2)
if T >= 1800 and T <= 1999:
    print(1)


Measured memory_bytes: 9188
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
			int x = sc.nextInt();
			int a = sc.nextInt();			
				
			if(x<a) {
				System.out.println("0");
			}else if(x>=a) {
				System.out.println("10");
			}			
	}
}


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

int main() {
  
  int A, B, C;
  cin >> A >> B >> C;
  
  if((A == 7 && B == 5 && C == 5) || (B == 7 && A == 5 && C == 5) || (C == 7 && A == 5 && B == 5)){
    cout << "YES" << endl;
  }
     
  else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=1e9+7;
ll n,ans,jc[1000010],ny[1000010],f[1000010];
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y&1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
ll C(ll x,ll y){
	if(x<y)return 0;
	return jc[x]*ny[y]%p*ny[x-y]%p;
}
int main(){
	ll i;
	scanf("%lld",&n);
	jc[0]=ny[0]=1;
	for(i=1;i<=n;i++)jc[i]=jc[i-1]*i%p;
	ny[n]=ksm(jc[n],p-2);
	for(i=n-1;i;i--)ny[i]=ny[i+1]*(i+1)%p;
	n--;
	for(i=1;i<=n;i++){
		f[i]=C(i-1,n-i)*jc[i]%p*jc[n-i]%p;
	}
	for(i=n;i;i--){
		f[i]=(f[i]-f[i-1]+p)%p;
		ans=(ans+f[i]*i)%p;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 27180
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a,b;
    cin >> a >> b;
    cout << a*b-(a+b)+1 << endl;
    return 0;
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e17+10;
const ll N=1e5+10;


int main()
{
	boost;
	ll n;
	cin>>n;
	ll a[n];
	for(auto &i:a) cin>>i;
	ll tmp[3];	
	ll ans=0;
	for(ll i=1;i<(n-1);i++)
	{
		tmp[0]=a[i-1];
		tmp[1]=a[i];
		tmp[2]=a[i+1];
		sort(tmp,tmp+3);
		if(tmp[1]==a[i]) ans++;
	}	
	cout<<ans;
  	return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Main
 */
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int D = sc.nextInt();

		if(N%(2*D+1)==0){
			System.out.println(N/(2*D+1));

		}else{
			System.out.println(N/(2*D+1)+1);
		}

		sc.close();
	}
};


Measured memory_bytes: 23764
awk -M '\
function max(x,y){
    return x > y ? x : y
}
{
    N = split($0, A);
    ans = A[1] * A[3];
    ans = max(ans, A[1] * A[3]);
    ans = max(ans, A[1] * A[4]);
    ans = max(ans, A[2] * A[3]);
    ans = max(ans, A[2] * A[4]);
    print ans
}'

Measured memory_bytes: 4548
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll D, N;
  cin >> D >> N;
  ll base = pow(100, D);
  ll ans = base * (N + N / 100);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int n, a, b, c;
int data[101];

main(){
  cin >> n;
  cin >> a >> b >> c;
  for(int i=0;i<n;i++){
    cin >> data[i];
  }
  sort(data, data+n);
  reverse(data, data+n);
  int ans = c/a;
  int sum = c;
  for(int i=1;i<=n;i++){
    sum += data[i-1];
    if(ans <= sum / (a+b*i)){
      ans = sum / (a+b*i);
    }else{
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
//難しい問題解いてるなぁ
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N;
	N = getint();
	int A[200000];
	ll B[200001], C;
	B[0] = 0;
	C = 0;

	int V[20] = {};
	int k = 0;
	rep(i, N) A[i] = getint();
	ll mae = A[0];
	rep(i, N) {
		ll a = A[i];
		B[i + 1] = B[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				k++;
				a *= 4;
			}
			V[k] += 2;
		}
		else {
			while (mae < a) {
				B[i + 1] += V[k];
				if (k) {
					V[k - 1] += V[k];
					V[k] = 0;
					k--;
				}
				mae *= 4;
			}
			V[k] += 2;
		}
		mae = A[i];
	}
	rep(i, 20) V[i] = 0;
	k = 0;
	mae = A[N - 1];
	ll kotae = 2 * B[N] + N;
	for (int i = N - 1; i >= 0; i--) {
		ll a = A[i];
		if (mae >= a) {
			a *= 4;
			while (mae >= a) {
				k++;
				a *= 4;
			}
			V[k] += 2;
		}
		else {
			while (mae < a) {
				C += V[k];
				if (k) {
					V[k - 1] += V[k];
					V[k] = 0;
					k--;
				}
				mae *= 4;
			}
			V[k] += 2;
		}
		mae = A[i];
		kotae = min(kotae, B[i] + C + i);
	}

	printf("%lld", kotae);

	Would you please return 0;
}

Measured memory_bytes: 2688
def resolve():
    n, m = map(int, input().split())
    s = [list(map(int, input().split())) for _ in range(n)]
    c = [list(map(int, input().split())) for _ in range(m)]

    for i in range(n):
        mdis = float("inf")
        goal = -1
        x, y = s[i][0], s[i][1]
        for j in range(m):
            cx, cy = c[j][0], c[j][1]
            dis = abs(x-cx)+abs(y-cy)
            if mdis > dis:
                mdis = dis
                goal = j+1
        print(goal)
resolve()

Measured memory_bytes: 39152
#include<iostream>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1; 
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i=0; i<n; i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){
        minv = INFTY;
        u = -1;
        
        for(int i=0; i<n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }

        if(u == -1) break;

        color[u] = BLACK;

        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum = 0;

    for(int i=0; i<n; i++){
        if(p[i] != -1) sum += M[i][p[i]];
    }
      
    return sum;
}
 
int main(){
    cin >> n;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int e;
            cin >> e;
            M[i][j] = (e == -1)? INFTY : e;
        }
    }

    cout << prim() <<endl;

    return 0;
}




Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	float a,b,c,d,e,f;
	
	while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF){
		if((c*e-b*f)/(a*e-b*d)<0.00001&&(c*e-b*f)/(a*e-b*d)>-0.00001)
			printf("0.000 ");
		else
			printf("%.3f ",(c*e-b*f)/(a*e-b*d));

		if((a*f-d*c)/(a*e-b*d)<0.00001&&(a*f-d*c)/(a*e-b*d)>-0.00001)
			printf("0.000\n");
		else
			printf("%.3f\n",(a*f-d*c)/(a*e-b*d));
	}
	//for(i=0;i<=10000000000;i++);
	return 0;
}

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

int main() {
    int x, y;
    while(true) {
        cin >> x >> y;
        if(x == 0 && y == 0) break;

        if(x > y) {
            cout << y << " " << x << endl;
        } else {
            cout << x << " " << y << endl;
        }
    }

    return 0;
}    


Measured memory_bytes: 2996
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,flag=0,i;
	cin>>n;
	if(n>81)
	cout<<"No"<<endl;
	else
	{
		if(n<=9)
		cout<<"Yes"<<endl;
		else
		{
			for(i=2;i<=9;i++)
			 {
			 	if(n%i==0&&(n/i)<=9)
			 	  {
			 	  	cout<<"Yes"<<endl;
			 	  	flag=1;
			 	  	break;
			 	  }
			 }
			 if(!flag)
			 cout<<"No"<<endl;
		}
	}
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

S = input()
N = len(S)

# dp[i][j] := i文字目まで見て、ABCのうちj文字目まで選んだ状態の通り数
dp = list2d(N+1, 4, 0)
dp[0][0] = 1
for i in range(N):
    s = S[i]
    for j in range(4):
        # 今回の文字を選ばない
        if s == '?':
            # ?は3通り遷移させる
            dp[i+1][j] += dp[i][j] * 3
            dp[i+1][j] %= MOD
        else:
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        # 今回の文字を選ぶ
        if j < 3:
            # 条件に合わせて次の文字へ進む
            if s == '?' or s == 'A' and j == 0 \
                        or s == 'B' and j == 1 \
                        or s == 'C' and j == 2:
                dp[i+1][j+1] += dp[i][j]
                dp[i+1][j+1] %= MOD
# N文字目まで見て、3文字選び終わっている通り数
print(dp[N][3])


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

int main() {
  string s;
  cin >> s;
  for(char c='a'; c<='z'; c++) {
    bool found=false;
    for(int i=0; i<s.length(); i++) {
      if(s[i]==c) {
        found=true;
      }
    }
    if(!found) {
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <set>

using namespace std;

long long gcd(long long x, long long y) {
	return y ? gcd(y, x % y) : x;
}

set<long long> prime(long long n) {
	set<long long> ret;
	for (long long i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			ret.insert(i);
			while (n % i == 0) n /= i;
		}
	}
	if (n != 1) ret.insert(n);
	return ret;
}

int main() {
	long long A, B; cin >> A >> B;
	cout << prime(gcd(A, B)).size() + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    int x = 0;
    int y = 0;
    int z = 0;

    if (A > 2*C){
        // Xは全てCで
        z += 2*X;
        Y -= X;
        X -= X;
    }
    
    if (X < 0) X=0;
    if (Y < 0) Y=0;

    // cout << X << " " << Y << " " << z <<endl;

    if (B > 2*C){
        // Yは全てCで 
        z += 2*Y;
        X -= Y;
        Y -= Y;
    }

    // cout << X << " " << Y << " " << z <<endl;

    if (X < 0) X=0;
    if (Y < 0) Y=0;

    if (A + B > 2*C){
        // なるべくCで
        int n = min(X, Y);
        z += 2*n;
        X -= n;
        Y -= n;
    }

    // 残りは素直に
    x += X;
    y += Y;

    cout << A*x + B*y + C*z << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long;
using namespace std;
map<int,vector<int>> m;
int id[100005];
int d[100005];
bool vi[100005];
//priority_queue<pair<int,int>> q;
void bfs(int n)
{
  priority_queue<int> q;
  q.push(n);
  while(q.size()!=0)
  {
     
      int p;
      p=q.top();
      vi[p]=true;
    // cout<<p<<" ";
     q.pop();
     for(int i=0;i<m[p].size();i++)
     {
         int h=m[p][i];
         id[h]--;
         if(id[h]==0)
          {q.push(h);}//cout<<h<<" ";}
        d[h]=max(d[h],1+d[p]);
     }
     
  }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,ma,x,y;
    cin>>n>>ma;
    for(int i=1;i<=ma;i++)
    {
     cin>>x>>y;
     id[y]++;
     m[x].push_back(y);
    }
    //for(int i=1;i<=n;i++)
      //      q.push({id[i],i});
    for(int i=1;i<=n;i++)
     if(id[i]==0&&vi[i]==false)
     {bfs(i);}//cout<<"  dgs\n";}
     
     int ans=0;
    for(int i=1;i<=n;i++)
     {
     //    cout<<d[i]<<" ";
         ans=max(ans,d[i]);
     }
     //cout<<" \n";
     cout<<ans<<"\n";
}

Measured memory_bytes: 12032
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tiii;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int V;
int d[200][200];

void warshallFloyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

vector<tiii> edges;

int main() {
    int N, M;
    cin >> N >> M;
    V = N;
    for (int i = 0; i < V; i++) {
        fill(d[i], d[i] + V, 1000000);
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
        tiii t = make_tuple(a - 1, b - 1, c);
        edges.push_back(t);
    }
    warshallFloyd();
    ll ans = 0;
    for (int i = 0; i < M; i++) {
        tiii t = edges[i];
        if (d[get<0>(t)][get<1>(t)] < get<2>(t)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
    int A, B, C, D, a, b, c;
    scanf("%d%d%d%d", &A ,&B ,&C ,&D);

    if(A >= B)
      a = B; 
    else
      a = A;
    if(C >= D)
      b = D;
    else
      b = C;

    c = a + b;
    printf("%d\n", c);
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());
  int ans = 0;
  rep(i, n) {
    rep(j, i) {
      rep(k, j) {
        if (l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k]) ans++;
      }
    }
  }
  cout << ans << '\n';

  
  return 0;
}

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

const int MAX_N = 1e5;
lint N, a[MAX_N+5];

lint solve(lint next){
  lint s = 0, cnt = 0;
  for(int i=0;i<N;i++){
    s += a[i];
    if(next==1 && s<=0){
      cnt += next - s; s = 1;
    }else if(next==-1 && s>=0){
      cnt += s - next; s = -1;
    }
    next *= -1;
  }
  
  return cnt;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++) cin >> a[i];
  
  cout << min(solve(1), solve(-1)) << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  map<string, int> memo;
  string s;
  while (cin >> s) {
    memo[s] += 1;
  }
  
  int maxval = 0;
  for (const auto& p : memo) {
    int v = p.second;
    if (v > maxval) maxval = v;
  }
  for (auto it = memo.begin(); it != memo.end(); it++) {
    if (it->second == maxval) cout << it->first << endl;
  }
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
void solve(){
    string s;
    cin>>s;
    ll x=s.length();
    if(s[x-1]=='s') s.append("es");
    else s.append("s");
    cout<<s;
}
int main(){
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3588
from collections import Counter
import itertools

N = int(input())
src = [input() for i in range(N)]

ctr = Counter()
for s in src:
    ctr.update(s[0])

ans = 0
for ptn in itertools.combinations('MARCH',3):
    a,b,c = ptn
    ans += ctr[a] * ctr[b] * ctr[c]
print(ans)


Measured memory_bytes: 10232
N, K, C = gets.split.map(&:to_i)
S = gets.chomp

ml = []
cur = 0

S.each_char.with_index do |s, idx|
  next if s == 'x'

  if ml.size < K && cur <= idx
    ml << idx
    cur = idx + C + 1
  end
end

mr = []
cur = 0

S.reverse.each_char.with_index do |s, idx|
  next if s == 'x'

  if mr.size < K && cur <= idx
    mr.unshift(N - idx - 1)
    cur = idx + C + 1
  end
end

ans = []

K.times do |i|
  next if mr[i] != ml[i]

  ans << (mr[i] + 1)
end

puts ans.sort


Measured memory_bytes: 23092
import Control.Applicative

max_func [x] = x
max_func (x:rest) = max x (max_func rest)

min_func [x] = x
min_func (x:rest) = min x (min_func rest)

main = do
  n <- readLn :: IO Int
  ss <- (map read . words) <$> getLine
  -- sum
  let sum = show $ foldl (+) 0 ss
  let min = show $ min_func ss
  let max = show $ max_func ss
  putStrLn $ min ++ " " ++ max ++ " " ++ sum

Measured memory_bytes: 9324