akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include<iomanip>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};

ll conb(ll n){
  return n*(n-1)/2;
}

int main(){
  long double l;
  cin >> l;
  cout << fixed << setprecision(10) << l*l*l/27 << endl;

  return 0;
}


Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 05/05/2018 14:44:37
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	int h, w;
	string str;
	cin>>h>>w;
	bool mat[h+2][w+2];
	for(int i = 0; i < h+2; i++) {
		for(int j = 0; j < w+2; j++) {
			mat[i][j] = 0;
		}
	}
	for(int i = 1; i <= h; i++) {
		cin>>str;
		for(int j = 1; j <= w; j++) {
			if(str[j-1] == '#') mat[i][j] = true;
			else mat[i][j] = false;
		}
	}
//	for(int i = 0; i <= h+1; i++) {
//		for(int j = 0; j <= w+1; j++) {
//			cout<<mat[i][j];
//		}
//		cout<<endl;
//	}

	bool flag = true;
	
	for(int i = 1; i < h+1; i++) {
		for(int j = 1; j < w+1; j++) {
			if(mat[i][j] == 1 && (mat[i+1][j] != 1 && mat[i-1][j] != 1 && mat[i][j+1] != 1 && mat[i][j-1] != 1) ) {
				flag = false;
			}
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast
    
  	ll a;
  	cin>>a;
  	ll c=a+(a*a)+(a*a*a);
  	pt(c);
  	

    

    

}


/*

// 

*/

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

#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define rrep(i, a, b) for (int i = b - 1; i >= int(a); i--)

using namespace std;

using ll = long long;
using vi = vector<int>;

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

    vi si(n, 0);
    rep(i, 0, n) { si[i] = int(s[i] - '0'); }

    ll sum = 0;

    if (p == 2 || p == 5) {
        rep(i, 0, n) {
            if (si[i] % p == 0) {
                sum += i + 1;
            }
        }
    } else {
        vi counter(p, 0);
        counter[0]++;

        int num = 0;
        int power = 1;

        reverse(si.begin(), si.end());

        rep(i, 0, n) {
            num = (num + (si[i] * power) % p) % p;
            power = power * 10 % p;
            sum += counter[num];
            counter[num]++;
        }
    }

    cout << sum << endl;
    return 0;
}

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

using namespace std;

int const size = 404;

long long int arr[size];
long long int dp[size][size];

long long int solve(int left, int right){
	if(left == right) return 0;
	if(right - left == 1) return arr[right] - arr[left-1];
	if(dp[left][right] != -1) return dp[left][right];
	long long int ans = pow(10,14); 
	for(int x=left;x<right;x++) ans = min(ans, solve(left, x) + solve(x+1, right) + arr[right] - arr[left-1]);
	dp[left][right] = ans;
	return ans;
}

int main(){
	int n;
	scanf("%d",&n);
	arr[0] = 0;
	for(int x=1;x<=n;x++){
		scanf("%lld",&arr[x]);
		arr[x] =  arr[x] + arr[x-1];
	}
	for(int x=0;x<size;x++){
		for(int i=0;i<size;i++) dp[x][i] = -1;
	}
	cout<<solve(1,n);
	// for(int x=1;x<=n;x++) {
	// 	for(int i=x;i<=n;i++) cout<<solve(x,i)<<" ";
	// 	cout<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<math.h>
int main(){
	int N,C,p,cg=0,m,i;
	scanf("%d %d",&N,&C);
	for(i=1;i<=C;i++){
		scanf("%d",&p);
		cg+=p;
	}
	m=(cg/(N+1));
	if(cg%(N+1)!=0)m++;
	printf("%d\n",m);
	return 0;
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define fo(i,n) for(int i=1;i<=n;i++)
#define fo1(i,n) for(int i=0;i<n;i++)
#define llu long long int
#define vi vector <int>
#define pb push_back
#define mod 1000000007

using namespace std;
int dp[3001][3001];
string loop(string x,string y,int n,int m)
{
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(x[i-1]==y[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	int i=n,j=m;
	string s="";
	while(i>0 && j>0)
	{
		if(x[i-1]==y[j-1])
		{
			s.pb(x[i-1]);
			i--;j--;
		}
		else if(dp[i][j-1]>dp[i-1][j])
			j--;
		else
			i--;
	}
	return s;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string x,y;
    cin>>x>>y;
    int n,m;
    n=x.size();
    m=y.size();
    string l=loop(x,y,n,m);
	reverse(l.begin(),l.end());
    cout<<l;
}


Measured memory_bytes: 35456
from itertools import permutations
from math import sqrt

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

fact = [1]
for i in range(1, n + 1):
    fact.append(fact[-1] * i)

sm = 0
for pat in permutations(range(n), n):
    for e1, e2 in zip(pat, pat[1:]):
        x1, y1 = xy[e1]
        x2, y2 = xy[e2]
        dist = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
        sm += dist

ans = sm / fact[n]
print(ans)


Measured memory_bytes: 3064
import math
import sys


def debt(debt_s, week):
    if week == 0:
        return debt_s
    debt_s = int(math.ceil((debt_s * 1.05)/1000) * 1000)
    return debt(debt_s, week - 1)


n = int(sys.stdin.readline())

debt_s = 100000
print debt(debt_s, n)

Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int mod=998244353;
long long dp[5003][5003];
long long lgput (long long val)
{
    long long exp=mod-2;
    long long rez=1;
    while(exp)
    {
        if(exp&1)
        {
            rez=(rez*1LL*val)%mod;
            exp^=1;
        }
        else
        {
            val=(val*1LL*val)%mod;
            exp>>=1;
        }
    }
    return rez;
}
long long cmmdc (long long a, long long b)
{
    long long r;
    while(b)
    {
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int main()
{
    long long n,m,k,i,j,s=0,rz=0,a,b;
    cin>>a>>b;
    cout<<a*1LL*b/cmmdc(a,b);
    return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> maze(h,vector<char>(w));
  rep(i,h)rep(j,w) cin >> maze[i][j];
  
  int num=0;
  
  rep(i,h)rep(j,w) if(maze[i][j] == '#') num++;
  
  if(num == h+w-1){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
  
  return(0);
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(br.readLine());
        String s;
        Set<String> set = new TreeSet<>();
        for (int i = 0; i < n; i++) {
            s = br.readLine();
            set.add(s);
        }

        br.close();

        bw.write(String.valueOf(set.size()));

        bw.flush();

    }
}

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

ll mod = 1000000007;

ll power(ll x, ll y){
    ll ret = 1;

    for(int i = 1; i <= y; i++)
        ret = ret*x%mod;

    return ret;
}

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

    ll ans = power(10,n) - 2*power(9,n) + power(8,n);

    ans%=mod;

    ans = (ans + mod)%mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

string a[]={"Sunny","Cloudy","Rainy"}; 
int main(){
    string s;
    cin>>s;
    if(s==a[0])cout<<a[1]<<endl;
    if(s==a[1])cout<<a[2]<<endl;
    if(s==a[2])cout<<a[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static final boolean RED = true, WHITE = false;

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        String S = scanner.next();
        boolean[] C = new boolean[N];
        for (int i = 0; i < N; i++) {
            C[i] = (S.charAt(i) == 'R') ? RED : WHITE;
        }

        int left = 0 , right = N-1, R = 0;
        while(true){
            while (C[left]  == RED   && left < N-1 ) left++;
            while (C[right] == WHITE && 0 < right  ) right--;

            if (left < right){
                R++;
                left++;
                right--;
            } else {
                break;
            }
        }

        System.out.println(R);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 40880
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<typename T>
void print(T &arr){
    ll sz = sizeof(arr)/sizeof(arr[0]);
    for(int i = 0;i < sz-1;i++){cout << arr[i] << ' ';}
    cout << arr[sz-1] << endl;
}


int main(){
    ll n,k; cin >> n >> k;
    deque<ll> que;
    rep(i,n){
        ll tmp; cin >> tmp;
        que.push_back(tmp);
    }
    ll res = 0;
    rep(i,min(n+1,k+1)){
        rep(j,i+1){
            deque<ll> temp_que = que;
            set<ll> st;
            ll temp_val = 0;
            rep(jj,j){
                ll temp = temp_que.front();temp_que.pop_front();
                temp_val += temp;
                st.insert(temp);
            }
            rep(l,i-j){
                ll temp = temp_que.back();temp_que.pop_back();
                temp_val += temp;
                st.insert(temp);
            }
            auto itr = st.begin();
            ll len = st.size();
            rep(m,min(len, k-i)){
                if(itr == st.end())break;
                if(*itr < 0)temp_val -= *itr;
                itr++;
            }
            res = max(res, temp_val);
            st.clear();temp_que.clear();
            // print(i,j,temp_val);
        }
        
    }

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

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  cout << A+B+C+(threemax(A,B,C)*(pow(2,K)-1));
}

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

using namespace std;

vector<string> split(string&);
bool space(char);
bool not_space(char);

int main(){
  string line;
  vector<string> str, Search;

  getline(cin, line);
  str = split(line);

  for(vector<string>::size_type i=0; i != str.size(); ++i){
    if(str[i].size() > 2 && str[i].size() < 7)
      Search.push_back(str[i]);
  }

  for(vector<string>::size_type i=0; i != Search.size()-1; ++i){
    cout << Search[i] << " ";
  }
  cout << Search[Search.size()-1] << endl;

  return 0;
}

vector<string> split(string& str){
  string s;
  vector<string> Str;
  string::iterator i, j;

  j = str.begin();
  while(i != str.end() && j != str.end()){
    i = find_if(j, str.end(), not_space);
    j = find_if(i, str.end(), space);
    copy(i, j, back_inserter(s));

    if(s[s.size()-1] == ',' || s[s.size()-1] == '.')
      s = s.substr(0, s.size()-1);

    Str.push_back(s);
    s.clear();
  }

  return Str;
}

bool space(char c){
  return (isspace(c));
}

bool not_space(char c){
  return (!isspace(c));
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
using namespace std;

void chmin(int &a, int b) {
     a = min(a, b);
}

const int INF = 1 << 25;
int N, M, R;
int dl[210][210], ds[210][210], dist[1010][210], op[1010];

int main() {
    while(scanf("%d%d", &N, &M)) {
        if(N == M && M == 0) break;
        for(int i=0; i<N; i++) {
            fill(dl[i], dl[i] + N, INF);
            fill(ds[i], ds[i] + N, INF);
            dl[i][i] = ds[i][i] = 0;
        }

        for(int i=0; i<M; i++) {
            int x, y, t; char s;
            scanf(" %d%d%d %c", &x, &y, &t, &s);
            x--; y--;
            if(s == 'L') {
                chmin(dl[x][y], t);
                chmin(dl[y][x], t);
            }
            else {
                chmin(ds[x][y], t);
                chmin(ds[y][x], t);
            }
        }

        for(int k=0; k<N; k++) {
            for(int i=0; i<N; i++) {
                for(int j=0; j<N; j++) {
                    chmin(dl[i][j], dl[i][k] + dl[k][j]);
                    chmin(ds[i][j], ds[i][k] + ds[k][j]);
                }
            }
        }

        scanf("%d", &R);
        for(int i=0; i<R; i++) {
            scanf("%d", &op[i]); op[i]--;
            fill(dist[i], dist[i] + N, INF);
        }

        dist[0][op[0]] = 0;
        for(int i=0; i<R-1; i++) {
            for(int j=0; j<N; j++) {
                if(dist[i][j] == INF) continue;
                int cur = op[i], nxt = op[i+1];

                // land only
                chmin(dist[i+1][j], dist[i][j] + dl[cur][nxt]);

                // land + sea
                for(int k=0; k<N; k++) {
                    chmin(dist[i+1][k], dist[i][j] + dl[cur][j] + ds[j][k] + dl[k][nxt]);
                }
            }
        }

        printf("%d\n", *min_element(dist[R-1], dist[R-1] + N));
    }
    return 0;
}


Measured memory_bytes: 3852
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC127B
{
    static class Program
    {
        static void Main(string[] args)
        {
            var n = ReadLine().SplitTryParseToList<int>();

            int[] a = new int[11];
            a[0] = n[2];
            foreach (var i in Enumerable.Range(0, 10))
            {
                a[i + 1] = a[i] * n[0] - n[1];
            }

            foreach (var i in Enumerable.Range(1,10))
            {
                WriteLine(a[i]);
            }
        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 14548
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
  n = ni()

  for i in range(1, 10):
    for j in range(1, 10):
        if i * j == n:
            print("Yes")
            return
  print("No")

main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,ans=0;
	cin>>n>>d;
	if(2*d+1>=n)
	{
		cout<<"1";
		exit(0);
	}
	if(n%(d*2+1)==0)
	{
		cout<<n/(d*2+1);
	}
	else
	{
		cout<<n/(d*2+1)+1;
	}
	return 0;	
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use datastructure::*;
use grapth::*;
use input_scanner::*;
use math::*;
use string_algorithm::*;
use util::*;

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

fn main() {
    const MOD: u64 = 998244353;
    const INV: u64 = 499122177;
    let mut scan = Scanner::new();
    let n: usize = scan.next();
    let s: usize = scan.next();
    let a: Vec<usize> = scan.next_vec(n);

    let mut pow2: Vec<u64> = vec![1; n + 1];
    for i in 1..n + 1 {
        pow2[i] = pow2[i - 1] * 2 % MOD;
    }

    let mut dp: Vec<Vec<u64>> = vec![vec![0; s + 1]; n + 1];
    dp[0][0] = pow2[n];

    let mut ans: u64 = 0;
    for i in 0..n {
        for j in 0..s {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
            if j + a[i] <= s {
                dp[i + 1][j + a[i]] += dp[i][j] * INV % MOD;
                dp[i + 1][j + a[i]] %= MOD;
            }
        }
        ans += dp[i + 1][s];
        ans %= MOD;
    }
    println!("{}", ans);
}

mod datastructure {}
mod grapth {}
mod math {}
mod string_algorithm {}
mod util {}
mod input_scanner {
    pub struct Scanner {
        bytes: Vec<u8>,
        begin: usize,
        end: usize,
    }

    impl Scanner {
        pub fn new() -> Self {
            use std::io::Read;
            let mut buffer: Vec<u8> = Vec::new();
            std::io::stdin().read_to_end(&mut buffer).unwrap();
            let end = (0..buffer.len())
                .find(|i| buffer[*i].is_ascii_whitespace())
                .unwrap_or(buffer.len());
            Scanner {
                bytes: buffer,
                begin: 0,
                end: end,
            }
        }
        pub fn next<T: std::str::FromStr>(&mut self) -> T {
            let s: &str =
                unsafe { std::str::from_utf8_unchecked(&self.bytes[self.begin..self.end]) };
            let ret: T = s.parse::<T>().ok().expect("Parse error.");
            self.skip();
            ret
        }
        pub fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
        pub fn next_word(&mut self) -> Vec<u8> {
            let r = Vec::from(&self.bytes[self.begin..self.end]);
            self.skip();
            r
        }
        fn skip(&mut self) {
            self.begin = (self.end..self.bytes.len())
                .find(|i| !self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
            self.end = (self.begin..self.bytes.len())
                .find(|i| self.bytes[*i].is_ascii_whitespace())
                .unwrap_or(self.bytes.len());
        }
    }
}


Measured memory_bytes: 72568
def main():
    n, k = [int(e) for e in input().split()]
    mod = 10 ** 9 + 7

    ans = 0
    for ki in range(k, n + 2):
        ans += n * (n + 1) // 2 - (n - ki) * (n - ki + 1) // 2 - \
            (ki * (ki + 1) // 2 - ki) + 1
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 63464
#include<stdio.h>
#include<string.h>
int main(void){
  char c[201],n;
  int len,m,h,a,b,d,e;
  while(1){
    scanf("%s",c);
    if(strcmp(c,"-")==0)break;
    len=strlen(c);
    scanf("%d",&m);
    for(d=0;d<m;d++){
      scanf("%d",&h);
      for(a=0;a<h;a++){
    n=c[0];
    for(b=1;b<=len-1;b++){
      c[b-1]=c[b];
    }
    c[len-1]=n;
      }
    }
    printf("%s\n",c);
  }
  return 0;
}

Measured memory_bytes: 584
n = int(input())
s = input()

if n == 1:
    print('No')
    exit()
elif n == 2:
    if s[0] == s[1]:
        print('Yes')
    else:
        print('No')
    exit()
elif n == 3:
    if s[0:1] == s[1:2]:
        print('Yes')
    else:
        print('No')
    exit()
if n%2 == 0:
    if s[0:(n//2-1)] == s[(n//2):(n-1)]:
        print('Yes')
    else:
        print('No')
else:
    if s[0:(n-1)//2] == s[(n+1)//2:n-1]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 38384
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#define ll long long
using namespace std;

int main()
{
    int a,b,c;
    while(~scanf("%d%d%d",&a,&b,&c))
    {
        if(a+b+c>=22)
            printf("bust\n");
        else
            printf("win\n");
    }
}


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

const int MAX = 1e5+5;
vector<int> e[MAX];
int in_degree[MAX];
int dist[MAX];
bool visited[MAX];
void dfs(int a)
{
    visited[a] = true;
    for(int b:e[a])
    {
        dist[b] = max(dist[b],dist[a]+1);
        --in_degree[b];
        if(in_degree[b]==0)
        {
            dfs(b);
        }
    }
}
int main()
{
    int n,m;
    cin >> n >> m;
    while(m--)
    {
        int a,b;
        cin >> a >> b;
        e[a].push_back(b);
        ++in_degree[b];
    }
    for(int i=1;i<=n;++i)
    {
        if(!visited[i] && in_degree[i]==0)
        {
            dfs(i);
        }
    }

    int answer = 0;
    for(int i=1;i<=n;++i)
    {
        answer = max(answer,dist[i]);
    }
    cout << answer << endl;
}

Measured memory_bytes: 9728
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int x;
    cin >> x;
    if(x == 5 || x == 7 || x == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

signed main(){
    //AOJ 1142
    int m;
    cin >> m;
    rep(i, 0, m){
        string str;
        cin >> str;
        string s[2], t[2];
        set<string> st;
        rep(i, 1, str.size()){
            s[0] = str.substr(0, i);
            t[0] = str.substr(i, str.size() - i);
            s[1] = s[0];
            reverse(all(s[1]));
            t[1] = t[0];
            reverse(all(t[1]));
            rep(j, 0, 2){
                rep(k, 0, 2){
                    string tmp = s[j] + t[k];
                    st.insert(tmp);
                    tmp = t[k] + s[j];
                    st.insert(tmp);
                }
            }
        }
        cout << st.size() << endl;
    }
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int>r, g;
	set<int>b;
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'R')r.push_back(i);
		else if (s.at(i) == 'B')g.push_back(i);
		else b.insert(i);
	}
	ll ans = 0;
	for (int i = 0; i < r.size(); i++) {
		for (int j = 0; j < g.size(); j++) {
			int x, y ,z1, z2, z3;
			x = r.at(i);
			y = g.at(j);
			z1 = -1;
			z2 = -1;
			z3 = -1;
			if (x > y)swap(x, y);
			if (x - y + x >= 0)z1 = x - y + x;
			if ((y - x) % 2 == 0)z2 = x + (y - x) / 2;
			if (y + y - x <= n - 1)z3 = y + y - x;
			if (b.count(z1))ans++;
			if (b.count(z2))ans++;
			if (b.count(z3))ans++;
		}
	}
	ans = r.size() * g.size() * b.size() - ans;
	cout << ans << endl;

}

Measured memory_bytes: 3700
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
	}
	else if (n < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String pencilCount = sc.next();
        char oneDigits = pencilCount.charAt(pencilCount.length()-1);
        
        
        if(oneDigits=='2' || oneDigits=='4' || oneDigits=='5' || oneDigits=='7' || oneDigits=='9'){
            System.out.println("hon");
        }
        else if(oneDigits=='0' || oneDigits=='1' || oneDigits=='6' || oneDigits=='8'){
            System.out.println("pon");
        }
        else{ // oneDigits=='3'
            System.out.println("bon");
        }
    }
}

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

int main() {
  string O, E;
  cin >> O >> E;
  int i = 0;
  if(O.size() == E.size()){
    while(i < O.size() || i < E.size()){
      cout << O.at(i) << E.at(i);
      i++;
    }
    cout << endl;
  }
  else{
    for(int j = 0; j < E.size(); j++){
      if(j == E.size() - 1) cout << O.at(j) << E.at(j) << O.at(j + 1);
      else cout << O.at(j) << E.at(j);
    }
    cout << endl;
  }
}
    

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    ll n;
    cin>>n;
    ll ans=0;
    ans=(n-1)*n/2;
    cout<<ans<<endl;





    return 0;
}


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

#define INF 10000
#define MAXN 8
#define MAXM 30

int T[MAXN];
int G[MAXM][MAXM];
bool used[MAXM][1 << MAXN];
double dp[MAXM][1 << MAXN];
int n, m, p, a, b;

double dijkstra(){
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < (1 << n); j++) {
            dp[i][j] = INF;
            used[i][j] = false;
        }
    }
    dp[a][(1 << n) - 1] = 0;
    
    while (true) {
        int v = -1;
        int w;
        for (int u = 0; u < m; u++) {
            for (int s = 0; s < (1 << n); s++) {
                if (!used[u][s] && (v == -1 || dp[u][s] < dp[v][s])) {
                    v = u; w = s;
                }
            }
        }
        if (v == -1) {
            break;
        }
        used[v][w] = true;
        for (int u = 0; u < m; u++) {
            for (int i = 0; i < n; i++) {
                if (G[v][u] == INF) {
                    continue;
                }
                if (w >> i & 1) {
                    dp[u][w & ~(1 << i)] = min(dp[u][w & ~(1 << i)], dp[v][w] + (double)G[v][u] / T[i]);
                }
            }
        }
    }
    
    double ans = INF;
    for (int i = 0; i < (1 << n); i++) {
        ans = min(ans, dp[b][i]);
    }
    return ans;
}

int main()
{
    int x, y ,z;
    while (true) {
        cin >> n >> m >> p >> a >> b;
        if (n == 0 && m == 0) {
            break;
        }
        a--; b--;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < m; j++) {
                G[i][j] = INF;
            }
        }
        for (int i = 0; i < m; i++) {
            G[i][i] = 0;
        }
        for (int i = 0; i < n; i++) {
            cin >> T[i];
        }
        for (int i = 0; i < p; i++) {
            cin >> x >> y >> z;
            x--; y--;
            G[x][y] = G[y][x] = z;
        }
        double res = dijkstra();
        if (res == INF) {
            cout << "Impossible" << endl;
        }else{
            printf("%.3f\n", res);
        }
    }
    
    return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a[102],n,k=0,l=0,cnt=0,x;
    map<int,int>m;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    for(i=0;i<n;i++){
        if(a[i]>=1&&a[i]<=399){m[1]++;}
       else if(a[i]>=400&&a[i]<=799){m[2]++;}
      else if(a[i]>=800&&a[i]<=1199){m[3]++;}
    else if(a[i]>=1200&&a[i]<=1599){m[4]++;}
     else if(a[i]>=1600&&a[i]<=1999){m[5]++;}
     else if(a[i]>=2000&&a[i]<=2399){m[6]++;}
    else if(a[i]>=2400&&a[i]<=2799){m[7]++;}
    else if(a[i]>=2800&&a[i]<=3199){m[8]++;}
  }
    for(i=1;i<=8;i++){
        if(m[i]!=0){cnt++;}
        else if(m[i]==0){k++;}
    }
    for(i=0;i<n;i++){
        if(a[i]>=3200){
            l++;
        }}
    if(cnt==0&&l>0){cnt=1;l--;}
      x=cnt+l;
    
    
    cout<<cnt<<" "<<x<<endl;
    }
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define FOD(i,a,b) for(int i=a; i>=b; i--)
#define pa pair<int,int>
#define fi first
#define se second
#define MOD xxx
#define getbit(n,i) ((n>>(i-1))&1)
#define offbit(n,i) ((n^(1<<(i-1))
#define onbit(n,i) (n|(1<<(i-1)))
#define cntone(x) (__builtin_popcount(x))

using namespace std;
string s;
int ans = 0;
int main()
{
    cin >> s;
    for(int j = 0; j < s.size(); j++) ans = ans + s[j] - '0';
    if(ans%9==0) cout << "Yes" ;
    else cout << "No";
	return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<sstream>
#include<string>
#include<math.h>
using namespace std;
int check(int x)
{
	if (x == 2)return 1;
	if (x <2||x%2==0)return 0;
	for (int i = 3; i <= sqrt(x); i+=2)
	{
		if (x%i == 0)return 0;
	}
	return 1;
}
int main()
{
	int n;
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		ans += check(a);
	}
	cout << ans << endl;

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  long long int a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector<int64_t> dataa(a);
  vector<int64_t> datab(b);
  vector<int64_t> datac(c);
  for ( int i = 0 ; i < a ; i++ ) {
    cin >> dataa.at(i);
  }
  for ( int i = 0 ; i < b ; i++ ) {
    cin >> datab.at(i);
  }
  for ( int i = 0 ; i < c ; i++ ) {
    cin >> datac.at(i);
  }
  
  sort(dataa.begin(),dataa.end());
  sort(datab.begin(),datab.end());
  sort(datac.begin(),datac.end());
  
  vector<int64_t> red(x);
  vector<int64_t> green(y);
  for ( int i = 0 ; i < x ; i++ ) {
    red.at(i) = dataa.at(a-1-i);
  } 
  for ( int i = 0 ; i < y ; i++ ) {
    green.at(i) = datab.at(b-1-i);
  }
  
  vector<int64_t> ans(x+y+c);
  for ( int i = 0 ; i < x+y+c ; i++ ) {
    if ( i<x ) {
      ans.at(i)=red.at(i); 
    }
    else if ( x <=i && i < x+y) {
      ans.at(i) = green.at(i-x);
    }
    else {
      ans.at(i) = datac.at(i-x-y);
    }
  }
  long long int sum=0;
  sort(ans.begin(),ans.end());
  for ( int i = 0 ; i < x+y ; i++ ) {
    sum += ans.at(ans.size()-1-i);
  }
  cout << sum << endl;
 }

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
#include <math.h>
using namespace std;
#define MAXSIZE 100005
#define PI 3.141592653589793
#define MOD_CONST 1000000007
typedef long long int lli;

string s;

bool is_inconvenient(int i);

int main(){
  cin >> s;
  for(int i = 0; s[i] != '\0'; ++i){
    if(is_inconvenient(i)){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}
       
bool is_inconvenient(int i){
  if((i + 1) % 2 == 1 && s[i] == 'L') return true;
  if((i + 1) % 2 == 0 && s[i] == 'R') return true;
  return false;
}

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

int main() {
	string s, ans;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '0'){
			ans += '0';
		}else if(s[i] == '1'){
			ans += '1';
		}else if(s[i] == 'B' && ans.size() != 0){
			ans.erase(--ans.end());
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
match_cnt = 0

S = input()
T = input()

S_len = len(S)
T_len = len(T)

for S_idx in range(S_len - T_len + 1):
  cnt = 0

  for T_idx in range(T_len):
    if(S[S_idx + T_idx] == T[T_idx]):
      cnt += 1
  
  if( cnt > match_cnt ):
    match_cnt = cnt

print(T_len - match_cnt)

Measured memory_bytes: 9068
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

def canBuild(n, h):
    now = 0

    for x in h:
        if x < now: return False
        if x > now: now = x-1
    return True


def main():
    n = int(input())
    h = map(int, input().split())
    print("Yes") if canBuild(n, h) else print("No")

if __name__ == '__main__':
    main()


Measured memory_bytes: 11152
#include<stdio.h>
const int size=1000000;
int main(){
  int i,k,n;
  int data[size];
  int sum[size];
  for(i=2;i<size;i++){
    data[i]=1;
  }
  for(i=2;i<size;i++){
    if(data[i]){
      for(k=2*i;k<=size;k+=i){
        data[k]=0;
      }
    }
  }
  for(i=2;i<size;i++){
    sum[i+1]=sum[i]+data[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n+1]);
  }
}

Measured memory_bytes: 10388
#include <iostream>

using namespace std;

long pow = 1000000007;

long make_pattern(long arg) {
  if (arg <= 1) return 1;
  if (arg == 2) return 2;
  if (arg == 3) return 3;
  if (arg == 4) return 5;
  if (arg == 5) return 8;
  if (arg == 6) return 13;
  if (arg == 7) return 21;
  if (arg == 8) return 39;
  return 0;
}

int main(void) {
  long H, W, K;
  cin >> H >> W >> K;

  long data[H+1][W];
  for (long i = 0; i < H+1; i++) for (long j = 0; j < W; j++) data[i][j] = 0;
  data[0][0] = 1;

  for (long i = 0; i < H; i++) {
    for (long j = 0; j < W; j++) {
      long current = data[i][j];
      if (j > 0) data[i+1][j-1] = (data[i+1][j-1] + current * make_pattern(j - 1) % pow * make_pattern(W - j - 1) % pow) % pow;
      data[i+1][j] = (data[i+1][j] + current * make_pattern(j) % pow * make_pattern(W - j - 1) % pow) % pow;
      if (j < W-1) data[i+1][j+1] = (data[i+1][j+1] + current * make_pattern(j) % pow * make_pattern(W - j - 2) % pow) % pow;
    }
  }

/*
  for (long i = 0; i < H+1; i++) {
    for (long j = 0; j < W; j++) {
      cout << data[i][j] << ", ";
    }
    cout << endl;
  }
*/

  cout << data[H][K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


/*
vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}
*/

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}


int main(){
	ll n,q,s,t,x,d;
	vector<pair<ll,P>> v;
	cin>>n>>q;
	rep(i,0,n){
		cin>>s>>t>>x;
		v.push_back({s-x,{1,x}});
		v.push_back({t-x,{-1,x}});
	}
	sort(ALL(v));
	set<ll> st;
	int j=0;
	rep(i,0,q){
		cin>>d;
//print("#");
		while(v[j].first<=d&&j<v.size()){
			if(v[j].second.first==1)
				st.insert(v[j].second.second);
			else
				st.erase(v[j].second.second);
			j++;
		}
		if(st.size())print(*st.begin());
		else print("-1");
	}
}

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

using namespace std;


long long f(long long A, long long B, long long C) {
    return A * B * (C % 2);
}

int main() {
    string X;
    cin >> X;
    stack<char> S;
    for(int i = 0 ; i < X.size() ; i++){
        if( X[i] == 'S' ){
            S.push('S');
        }else{
            if( S.size() && S.top() == 'S' ){
                S.pop();
            }else{
                S.push('T');
            }
        }
    }
    cout << S.size() << endl;

}


Measured memory_bytes: 644
# -*- coding: utf-8 -*-
import heapq
def dijkstra(g, s):
    '''現時点で最短のものをheapqにぶち込みながら探索していく．
    '''
    n = len(g)
    dist = [10**9] * n
    dist[s] = 0
    hq = []
    heapq.heappush(hq, (dist[s], s))
    while hq:
        cost, u = heapq.heappop(hq)
        if dist[u] < cost:
            continue
        for v, c in g[u]:
            if dist[v] <= dist[u] + c:
                continue
            dist[v] = dist[u] + c
            heapq.heappush(hq, (dist[v], v))
    return dist

v, e, r = map(int, input().split())
g = [[] for _ in range(v)]
for i in range(e):
    s, t, c = map(int, input().split())
    g[s].append((t, c))
if e == 0:
    for i in range(v):
        if i == r:
            print(i)
        else:
            print("INF")
else:
    rets = dijkstra(g, r)
    for item in range(v):
        if rets[item] == 10**9:
            print("INF")
        else:
            print(rets[item])


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

int main(){

    int n, temp, sum=0;
    cin >> n;
    temp = n;

    while(temp > 0){
        sum += temp % 10;
        temp /= 10;
    }

    if(n % sum == 0) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,g[MAXN],r[MAXN],b[MAXN];

void solve(){
    cin>>n;
    string s;
    cin>>s;
    for(int i=s.sz-1;i>=0;i--){
        if(s[i]=='G')g[i]++;
        if(s[i]=='R')r[i]++;
        if(s[i]=='B')b[i]++;
        g[i]+=g[i+1];
        r[i]+=r[i+1];
        b[i]+=b[i+1];
    }
    ll ans=0;
    for(int i=0;i<s.sz-2;i++){
        for(int j=i+1;j<s.sz-1;j++){
            if((s[i]=='R'&& s[j]=='B') || (s[i]=='B'&& s[j]=='R')){
                ans+=g[j+1];
                if(s[j+j-i]=='G')ans--;
            }
            if((s[i]=='G'&& s[j]=='B') || (s[i]=='B'&& s[j]=='G')){
                ans+=r[j+1];
                if(s[j+j-i]=='R')ans--;
            }
            if((s[i]=='R'&& s[j]=='G') || (s[i]=='G'&& s[j]=='R')){
                ans+=b[j+1];
                if(s[j+j-i]=='B')ans--;
            }
        }
    }
    cout<<ans;
}



int main(){
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>

using namespace std;

#define pb push_back
#define int long long

void func(int a, int b, int c, int k = 0){
    if (a < b && b < c){
        cout << "Yes";
        exit(0);
    }
    if (k == 0){
        return;
    }
    func(a * 2, b, c, k - 1);
    func(a, b * 2, c, k - 1);
    func(a, b, c * 2, k - 1);
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    func(a, b, c, k);
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i=0;i<n;i++){
            arr[i] = in.nextInt();
        }

        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1]= Math.abs(arr[1]-arr[0]);

        for(int i=2;i<n;i++){

            int x = Math.abs(arr[i]-arr[i-2]);
            int y = Math.abs(arr[i]-arr[i-1]);

            dp[i] = Math.min((dp[i-2]+x),(dp[i-1]+y));


        }


        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 51100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		int n = sc.nextInt();
		int m = sc.nextInt();
		Integer[] array = new Integer[m];
		for(int i=0;m>i;i++) {
			array[i] = 0;
		}
		for(int i=0;n>i;i++) {
			int k = sc.nextInt();
			for(int j=0;k>j;j++) {
				int a = sc.nextInt();
				array[a-1] = array[a-1]+1;
			}
		}
		int count=0;

		for(int i=0;m>i;i++) {
			if(array[i]>n-1)
				count++;
		}
		System.out.println(count);
	}
}




Measured memory_bytes: 22740