akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N;cin>>N;
  vector<P> vect(N);
  REP(i,0,N){
    cin>>vect[i].second>>vect[i].first;
  }
  sort(ALL(vect),greater<>());
  int limit=INF;
  REP(i,0,N){
    P p=vect[i];
    limit=min(limit,p.first);
    limit-=p.second;
    //debug(limit);
    if(limit<0){
      print("No")
      return 0;
    }
  }
  print("Yes")
}


Measured memory_bytes: 3328
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    int x;
    cin >> x;
    cout << 360 / (__gcd(360, x));
    return 0;
}

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

long F[45] = {};

void calcfib(){
	for (long i = 0; i < 45; i++){
		if (i == 0 || i == 1) F[i] = 1;
		else F[i] = F[i - 1] + F[i - 2];
	}
}

int main(){
	long n;
	cin >> n;
	calcfib();
	cout << F[n] << endl;
	return 0;
}

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

using namespace std;

const int N = 105;

string n;
int k;

long long dp[N][2][5];

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> k;
    dp[0][1][0] = 1;
    for (int pos = 0; pos < n.length(); pos++) {
        for (int high = 0; high < 2; high++) {
            for (int num = 0; num <= k; num++) {
                int lim = 9;
                if (high) lim = n[pos] - '0';
                for (int dig = 0; dig <= lim; dig++) {
                    int nhigh = 0;
                    if (high && dig == n[pos] - '0') nhigh = 1;
                    dp[pos + 1][nhigh][num + (dig != 0)] += dp[pos][high][num];
                }
            }
        }
    }
    
    cout << dp[(int)n.length()][0][k] + dp[(int)n.length()][1][k];
    return 0;
}

Measured memory_bytes: 256
/*
	Created by Rahul Goel.
*/

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1000000000;

#define pii pair < int, int >
#define vi vector < int >
#define vvi vector < vector < int > >
#define vpii vector < pair < int, int > >
#define vvpii vector < vector < pair < int, int > > >
#define pb push_back
#define f first
#define s second
#define mp make_pair

int main()
{
	int n, count=0, mn = INF;
	cin >> n;
	for(int i=0; i<n; i++){
		int num;
		cin >> num;
		mn = min(num, mn);
		if(mn == num)
			count++;
	}
	cout << count << endl;
	return 0;
}


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

int a, b, c, d, k, s[501][501];
const int M = 1e9;
ll tot;

int main(){
	scanf("%d%d%d%d", &a, &b, &c, &d);
        if(c == 1 && d == 1){ puts("No"); return 0; }
	k = M / (c * d - 1);
	while(-k * (c * d - 1) - 1 < -M) k--;
	for(int i = 1; i <= a; i++){
		for(int j = 1; j <= b; j++){
			if(i % c == 0 && j % d == 0) s[i][j] = -k * (c * d - 1) - 1;
			else s[i][j] = k;
			tot += s[i][j];
		}
	}
	if(tot <= 0) puts("No");
	else{
		puts("Yes");
		for(int i = 1; i <= a; i++, puts("")) for(int j = 1; j <= b; j++) printf("%d ", s[i][j]);
	}
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int n;
int a[15];

int main() {
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + n + 1);
	int sum = 0;
	for(int i = 1; i < n; i++) sum += a[i];
	if(a[n] < sum) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=8e5+7;
int n,m;
char a;
bool f=0;
char s[maxn];
int f1=300000,f2=300000;
int main(){
	scanf("%s",s+300000);
	f2+=strlen(s+300000)-1;
	scanf("%d",&n);
	while(n--){
        scanf("%d",&m);
        if(m==1) f^=1;
        else{
            scanf("%d%*c%c",&m,&a);
            if(m==1){
                if(f==0) s[--f1]=a;
                else s[++f2]=a;
            }
            else {
                if(f==0) s[++f2]=a;
                else s[--f1]=a;
            }
        }
	}
	if(f==0)
    for(int i=f1;i<=f2;i++)
        printf("%c",s[i]);
    else {
        for(int i=f2;i>=f1;i--)
            printf("%c",s[i]);
    }
	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<set>
#include<map>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)

int main(void){
  vector<set<int> > a(9);
  map<char,int> m;
  rep(i,9)m[(char)(i+'A')] = i;
  int i;
  a[0].insert('B'); a[0].insert('D');
  a[1].insert('A'); a[1].insert('C'); a[1].insert('E');
  a[2].insert('B'); a[2].insert('F');
  a[3].insert('A'); a[3].insert('G'); a[3].insert('E');
  a[4].insert('D'); a[4].insert('B'); a[4].insert('H'); a[4].insert('F');
  i = 5;a[i].insert('C'); a[i].insert('I'); a[i].insert('E');
  i = 6;a[i].insert('D'); a[i].insert('H');
  i = 7;a[i].insert('G'); a[i].insert('I'); a[i].insert('E');
  i = 8;a[i].insert('H'); a[i].insert('F');
  string s;
  bool f;
  while(cin>>s){
    f = true;
    rep(i,s.size()-1){
      if(a[m[s[i]]].find(s[i+1])==a[m[s[i]]].end()){
        f = false;
      //  cout<<s[i]<<" "<<s[i+1]<<endl;
      }
    }


    if(f)cout<<s<<endl;
  }
}

Measured memory_bytes: 3172
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long a, b;

int main(){
    scanf("%ld%ld", &a, &b);
    for(long ans = 1; ans <= 100000; ans++){
        if(a == ans * 8 / 100 && b == ans / 10){
            printf("%ld\n", ans);
            return 0;
        }
    }
    printf("-1\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;
int w[gf], val[gf];
int dp[gf];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, wt;
	cin >> n >> wt;

	rep(i, 1, n)
	{
		cin >> w[i] >> val[i];
	}
	rep(i, 1, n) {
		rzip(j, wt, w[i])
		{
			dp[j] = max(dp[j], dp[j - w[i]] + val[i]);
		}
	}
	int ans = -inf;
	rep(i, 1, wt)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans << en;



	return 0;
}




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

int main()
{
    int x, a, b;
    scanf("%d %d %d",&x,&a,&b);
    if ((b - a)>x)
    {
        printf("dangerous\n");
    }
    else if ((b - a)<=0)
    {
        printf("delicious\n");
    }
    else
    {
        printf("safe\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
class seg{
public:
	vector<int>val;
	seg(void){val.res(524288);
		for(int i=0;i<524288;i++){val[i]=0;}
	}
	int ask(int hda,int mgi){
		hda+=262144;
		mgi+=262144;
		int ans=0;
		while(hda+1<mgi){
			if(hda%2==0){ans+=val[hda+1];}
			if(mgi%2==1){ans+=val[mgi-1];}
			hda/=2;mgi/=2;
		}
		return ans;
	}
	void cha(int bas,int num){
		bas+=262144;
		while(bas>1){
			val[bas]+=num;
			bas/=2;
		}
	}
};

int main(void){
	int h,i,j,n;cin>>n;
	vector<string>Ss(n);
	for(i=0;i<n;i++){cin>>Ss[i];REV(Ss[i]);}
	//ソートする
	SO(Ss);
	llint ans=0;
	vector<tuple<int,int,int>>ivent[26];
	for(i=0;i<n;i++){
		int L,R;
		string s=Ss[i];
		s.back()='#';
		L=LBI(Ss,s);
		s.back()='~';
		R=LBI(Ss,s);
		//cerr<<L<<" "<<R<<endl;
		ivent[Ss[i].back()-'a'].pub(mt(Ss[i].size(),L,R));
		bool mita[26]={};
		for(j=Ss[i].size()-1;j>=0;j--){
			if(!mita[Ss[i][j]-'a']){
				mita[Ss[i][j]-'a']=true;
				ivent[Ss[i][j]-'a'].pub(mt(j+1,mod,i));
			}
		}
	}
	for(h=0;h<26;h++){
		SO(ivent[h]);
		REV(ivent[h]);
		seg ki;
		for(auto it:ivent[h]){
			int z,a,b;
			tie(z,a,b)=it;
			//cerr<<z<<" "<<a<<" "<<b<<endl;
			if(a==mod){ki.cha(b+1,1);}
			else{ans+=ki.ask(a,b+1);}
		}
		//cerr<<"de"<<endl;
	}
	cout<<ans-n<<endl;
}
/*
a
b
ba
bca
c
cba
d

*/

Measured memory_bytes: 22728
import math
  
a = int(input())
rs = []

for i in list(range(1,math.floor(a**0.5) + 1)):
  q, mod = divmod(a, i)
  if mod == 0:
    rs.append([i, q])
  else:
    pass
  
print(sum(rs[len(rs) - 1]) - 2)

Measured memory_bytes: 43380
#include <stdio.h>

int min(int x, int y) {
    if (x <= y)
        return x;
    return y;
}

int main() {
    int K, S;
    int cnt = 0;
    scanf("%d %d", &K, &S);

    for (int X = 0; X <= min(K, S); X++) {
        for (int Y = 0; Y <= min(K, S); Y++) {
            if (S - X - Y >= 0 && S - X - Y <= min(S - X - Y, K))
                cnt ++;
        }
    }
    printf("%d\n", cnt);
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    int cnt = 0;
    cin >> n;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        cnt += r - l + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i < 10; i++)
        for (int j = 1; j < 10; j++)
    if (i * j == n){
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int intpow(int a, int b) {
    int ans = 1;
    while (b) {
        if (b & 1)
            ans *= a;
        a *= a;
        b /= 2;
    }
    return ans;
}

int N;
int TEN[15];

void COUT(int x) {
    string s;
    //  cerr << x << endl;
    for (int i = N; i >= 1; i--) {
        cout << char('a' + (x % TEN[i]) / TEN[i - 1]);
    }
    cout << endl;
}

void solve() {
    FOR(i, 0, 14) {
        TEN[i] = intpow(10, i);
    }
    TEN[0] = 1;
    int MAX = intpow(10, N);
    FOR(x, 0, MAX) {
        // cerr << "now x  is " << x << endl;
        if (x >= TEN[N - 1])
            break;
        itn cnt = -1;
        bool flag = true;
        //cerr << "x : " << x << endl;
        for (int i = N; i >= 1; i--) {
            //  cerr << cnt << " " << (x % TEN[i]) / TEN[i - 1] << endl;
            if (cnt + 1 < (x % TEN[i]) / TEN[i - 1]) {
                x = (x / TEN[i] + 1) * TEN[i] - 1;
                //    cerr << "x ::: " << x << endl;
                flag = false;
                break;
            } else {
                chmax(cnt, (x % TEN[i]) / TEN[i - 1]);
            }
        }
        if (flag)
            COUT(x);
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;


    solve();
    return 0;
}


Measured memory_bytes: 1536
import java.util.Scanner;
import java.util.Arrays;

public class Main{
	public static void main(String[] args){
		java.util.Scanner sin = new java.util.Scanner(System.in);
		int[] a = new int[3];
		a[0] = sin.nextInt();
		a[1] = sin.nextInt();
		a[2] = sin.nextInt();
		java.util.Arrays.sort(a);

		System.out.println(a[0] + " " + a[1] + " " + a[2]);	
		
	}
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long

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

	int x;
	cin >> x;
	if(x >= 30) cout << "Yes";
	else cout << "No";
	return 0;
}

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

using ll = long long;
// #define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n;
  cin >> n;
  string ss[n];
  REP(i,n) {
    cin >> ss[i];
  }
  vector<map<char,int>> vm(n);
  REP(i,n) {
    map<char,int> mp;
    REP(j,ss[i].length()) {
      ++mp[ss[i][j]];
    }
    vm[i] = mp;
  }
  for(char c = 'a'; c <= 'z'; ++c) {
    int min_count = 100;
    REP(i,n) {
      min_count = min(min_count, vm[i][c]);
    }
    REP(i,min_count) {
      cout << c;
    }
  }
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 5e3 + 10;
int n;

int ls[maxn], rs[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", ls + i, rs + i);
  }
  return 1;
}

pair<int, int> tosort[maxn];

long long dp[2][maxn];

void solve() {
  for (int i = 0; i < n; ++i) {
    tosort[i] = mp(ls[i] + rs[i], i);
  }
  sort(tosort, tosort + n);
  reverse(tosort, tosort + n);

  dp[0][0] = 0;
  dp[1][0] = (long long) 1e18;

  for (int iter = 0; iter < n; ++iter) {
    dp[0][iter + 1] = dp[1][iter + 1] = (long long) 1e18;
    for (int type = 1; type >= 0; --type) {
      for (int tl = iter; tl >= 0; --tl) {
        auto cur = dp[type][tl];
        dp[type][tl + 1] = min(dp[type][tl + 1], cur + (long long) tl * tosort[iter].first + rs[tosort[iter].second]);
        if (!type && (n & 1)) {
          dp[1][tl] = min(dp[1][tl], cur + (long long) (n - 1) * tosort[iter].first / 2);
        }
        dp[type][tl] = cur + (long long) (iter - tl - type) * tosort[iter].first + ls[tosort[iter].second];
      }
    }
  }
  long long res = *min_element(dp[0], dp[0] + n + 1);
  if (n & 1) {
    res = min(res, dp[1][n / 2]);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/c++io.h>
#include <vector>
#include <tuple>
#include <queue>
#define N 100
#define INF 1e9 + 5
using namespace std;

#include <iostream>
#include <bits/c++io.h>
#include <vector>
#include <tuple>
#include <queue>
#define N 100
#define INF 1e9 + 5
using namespace std;
using ll = long long;
vector<int> dp(10000005,-1);
int c[10000005];
ll solve(int k){
    if(k<1)return INF;
    if(k==1)return 0;
    
    if(dp[k]!=-1) return dp[k];
    ll a = solve(k-1)+abs(c[k]-c[k-1]);
    ll b = solve(k-2)+abs(c[k]-c[k-2]);
    dp[k]= min(a,b);
    return dp[k];
}
//20          10
//10 30     20

int main()
{
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++){
        scanf("%d", &c[i]);
    }
    //재귀로 풀어봅시다. 
    //solve 는 n일 때 최소가 되는 값을 반환하는 함수라고 합시다. 
    dp[0]=INF;
    dp[1]=0;
    //dp[2]=abs(c[2]-c[1]);
    printf("%d",solve(n));
    //선형으로 풀어봅시다.
    // dp[0]=0; 
    // for(int i =0;i<n;i++){
    //     for(auto j:{i+1,i+2}){
    //         dp[j] = min( dp[j], dp[i]+abs(v[j]-v[i]) );
    //     }
    // }
    // cout<<dp[n-1];

    return 0;
}

Measured memory_bytes: 42880
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

// End of template.


int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    print((double) ((n+1) / 2) / (double) n);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


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

int X, Y, n;
vector<vector<int>> s;
vector<vector<int>> answer;
vector<int> area;

// id, 左上, 右下
bool placeable(vector<vector<int>> field, int id, int y1, int x1, int y2, int x2) {
    bool ok = false;
    for(int i = y1; i <= y2; ++i) for(int j = x1; j <= x2; ++j) {
        if(field[i][j] && field[i][j] != id) return false;
        if(field[i][j] == id) ok = true;
    }
    return ok;
}
vector<vector<int>> place(vector<vector<int>> field, int id, int y1, int x1, int y2, int x2) {
    for(int i = y1; i <= y2; ++i) for(int j = x1; j <= x2; ++j) field[i][j] = id;
    return field;
}

bool in(int y, int x) {
    return 0 <= y && y < Y && 0 <= x && x < X;
}

int dfs(vector<vector<int>> field, bitset<16> used) {
    if(used.count() == n) {
        answer = field;
        return 1;
    }

    int y, x;
    y = x = -1;
    for(int i = 0; y == -1 && i < Y; ++i) for(int j = 0; x == -1 && j < X; ++j) if(!used[field[i][j]]) {
        y = i;
        x = j;
    }

    int result = 0;
    for(int id = 1; id <= n; ++id) {
        if(used[id]) continue;
        if(field[y][x] && field[y][x] != id) continue;
        int a = area[id];
        for(int i = 1; i <= a; ++i) {
            if(a % i) continue;
            int j = a / i;
            int ny = y + i - 1;
            int nx = x + j - 1;
            if(!in(ny, nx)) continue;
            if(!placeable(field, id, y, x, ny, nx)) continue;
            result += dfs(place(field, id, y, x, ny, nx), used.set(id));
            used.reset(id);
        }
        /*
        for(int t = 0; t < a; ++t) {
            int i = y + t;
            int j = x + a / (t + 1) - 1;
            if(!in(i, j)) continue;
            if(!placeable(field, id, y, x, i, j)) continue;
            result += dfs(place(field, id, y, x, i, j), used.set(id));
            used.reset(id);
        }
        */
    }
    return result;
}

int main() {
    while(cin >> X >> Y >> n, X | Y | n) {
        area.clear();
        area.resize(n + 1);
        for(int i = 0; i < n; ++i) {
            int b, k;
            cin >> b >> k;
            area[b] = k;
        }
        s.clear();
        s.resize(Y, vector<int>(X));
        for(auto& y: s) for(auto& x: y) cin >> x;

        if(dfs(s, 0) == 1) {
            for(int i = 0; i < Y; ++i) {
                for(int j = 0; j < X; ++j) cout << (j ? " " : "") << answer[i][j];
                cout << endl;
            }
        } else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1244
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    write(N == M ? "Yes" : "No");
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr long long inf = (1ll << 60);

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  if (N % 2 == 0) {
    std::vector<long long> pref(N / 2 + 1), suff(N / 2 + 1);
    for (int i: range(0, N)) {
      if (i % 2 == 0) pref[i / 2 + 1] += A[i];
      else suff[i / 2 + 1] += A[N - i];
    }
    for (int i: range(0, N / 2)) {
      pref[i + 1] += pref[i];
      suff[i + 1] += suff[i];
    }
    long long ans = -inf;
    for (int i: range(0, N / 2 + 1)) {
      chmax(ans, pref[i] + suff[N / 2 - i]);
    }
    std::cout << ans << '\n';
    return 0;
  }
  else {
    std::vector<long long> pref(N + 1), suff(N + 1);
    for (int i: range(0, N)) {
      if (i % 2 == 0) {
        pref[i + 1] += A[i];
        suff[i + 1] += A[N - i - 1];
      }
    }
    for (int i: range(0, N)) {
      pref[i + 1] += pref[i];
      suff[i + 1] += suff[i];
    }
    std::vector<long long> fr(N + 1, -inf), ba(N + 1, -inf);
    fr[0] = 0;
    ba[0] = 0;
    for (int i: range(0, N)) {
      if (i % 2 == 1) {
        chmax(fr[i + 1], pref[i + 1]);
        chmax(ba[i + 1], suff[i + 1]);
        chmax(fr[i + 1], fr[i - 1] + A[i]);
        chmax(ba[i + 1], ba[i - 1] + A[N - i - 1]);
      }
    }
    long long ans = -inf, sum = 0;
    for (int i: range(0, N - 1)) {
      if (i % 2 == 0) {
        chmax(ans, fr[i] + suff[N - i - 2]);
      }
      else {
        sum += A[i];
        chmax(ans, pref[i] + ba[N - i - 2]);
      }
    }
    std::cout << std::max(ans, sum) << '\n';
  }
  return 0;
}


Measured memory_bytes: 10388
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	int n,k,x,y;cin >> n >> k >> x >> y;
	if(n<=k) cout << n*x << endl;
	else cout << k*x+(n-k)*y << endl;
} 
 

Measured memory_bytes: 3548
#include <stdio.h>

int main(void)
{
  	int i;
  	char moji[4];
  
  	scanf("%s",moji);
  	for(i=0; i<3; i++)
    
      	if(moji[i]=='7')
        {
        printf("Yes");
        return 0;
      

    }
    printf("No");
  
}


Measured memory_bytes: 1700
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N, i, j, k;
        N = sc.nextInt();
        int score[][] = new int [N+1][3];
        int score2[][] = new int [N+1][3];
        for(i = 0; i < N; i++){
        	for(j = 0; j < 3; j++){
        		score[i][j] = sc.nextInt();
        	}
        }
        
        //配列コピー
        for(i = 0; i < N; i++){
        	for(j = 0; j < 3; j++){
        		score2[i][j] = score[i][j];
        	}
        }
        
        //同じ数字を書いたやつは0点
        for(i = 0; i < 3; i++){
        	for(j = 0; j < N; j++){
        		for(k = 0; k < N; k++){
        			if(score[j][i] == score[k][i] && j != k){
        				score2[j][i] = 0;
        			}
        		}
        	}
        }
        
        //点数計算
        for(i = 0; i < N; i++){
        	for(j = 1; j < 3; j++){
        		score2[i][0] += score2[i][j];
        	}
        }
        
        //出力
        for(i = 0; i < N; i++){
        	System.out.println(score2[i][0]);
        }
        
    }
}

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

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

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;
	rep(i, S.size()) {
		int num = (S[i] + N - 65) % 26;
		cout << (char)(num + 65);
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 20000000
 
int A[N], B[N], C[N], n;

 
     
 int main()
{
 
  int i;
  int max=0;
 
  scanf("%d",&n);
 
  for(i = 1;i <= n;i++)
    {
      scanf("%d", &B[i]);
      if(max< B[i])
    {
      max = B[i];
    }
    }
 
  CountingSort(max);
 
  for(i = 1;i <= n;i++)
    {
      if(i > 1) printf(" ");
      printf("%d",C[i]);
    }
  printf("\n");
  return 0;
}
 void CountingSort(int k)
{
  int i, j;
  for(i = 0; i <= k; i++)
    {
      A[i] = 0;
    }
  for(j = 1;j <= n;j++)
    {
      A[B[j]]++;
    }
  for(i = 1;i <= k;i++)
    {
      A[i] = A[i] + A[i - 1];
    }
  for(j = n;j > 0;j--)
    {
      C[A[B[j]]] = B[j];
      A[B[j]]--;
    }
}

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

const int mod = 1000000007;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mod;
        x = x*x % mod;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}


int main() {
  fac[0] = 1;
  ifac[0] = 1;
  for(ll i = 0; i<300000; i++){
      fac[i+1] = fac[i]*(i+1) % mod; // n!(mod M)
      ifac[i+1] = ifac[i]*mpow(i+1, mod-2) % mod; // k!^{M-2} (mod M) ←累乗にmpowを採用
  }
  int n,m,k;
  cin >> n >> m >> k;
  mint ans;
  for (int d = 1; d <= n; d++) {
    ans += (mint)d * (n-d) * m * m * comb(n*m-2,k-2);
  }
  for (int d = 1; d <= m; d++) {
    ans += (mint)d * (m-d) * n * n * comb(n*m-2,k-2);
  }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 4992
N = int(input())
# cnt[i][j] := 先頭がi, 末尾がjで始まるような数
cnt = [[0] * 10 for i in range(10)]
for n in range(1, N + 1):
    cnt[int(str(n)[0])][int(str(n)[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]

print(ans)

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

int main(){
    ll x;
    cin >> x;
    ll ans=100;
    ll count=0;
    while(ans<x){
        ans*=1.01;
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3624
from collections import*
n,*L=map(int,open(0).read().split())
G=[[]for _ in range(n)]
for a,b in zip(*[iter(L)]*2):
	G[a-1]+=[b-1]
	G[b-1]+=[a-1]
def F(m):
	q=deque([m])
	d=[-1]*n
	while q:
		cur=q.popleft()
		for nxt in G[cur]:
			if d[nxt]<0:
				q.append(nxt)
				d[nxt]=d[cur]+1
	return d
print("FSennunkeec"[sum(i>j or-1 for i,j in zip(F(0),F(n-1)))>=0::2])

Measured memory_bytes: 37228
/*#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#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 CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	CI n;
	return;
}


int main(void) {
	input();
	double money = 100000;
	
	for (int i = 0; i < n; i++) {
		money *= 1.05;
	}
	
	if ((int)money % 1000 >= 500) {
		CO (int)(money - ((int)(money) % 1000) + 1000) E
	}
	else {
		CO (int)(money - ((int)(money) % 1000)) E
	}

	

	return 0;
}

*/

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#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 CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
long long int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

int data_[210][2] = { -2 };

void input(void) {
	
	return;
}


int main(void) {
	
	int i = 1;
	int sum = 0;
	
	while (scanf("%d",&n) != EOF) {
		while (true) {
			sum += (n * n * (i - 1) * n * (i - 1));
			if ((n * i) == 600)break;
			i++;
		}

		CO sum E
		sum = 0;
		i = 1;
	}
	return 0;
}

Measured memory_bytes: 3056
import sys
readline = sys.stdin.readline
write = sys.stdout.write

def solve():
    N, L = map(int, readline().split())
    if N == 0:
        return False
    ma = 0
    P = [list(map(int, readline().split())) for i in range(N)]
    ma = max(u for s, t, u in P)
    K = 86400
    EPS = 1e-8
    def check(x, M = 2):
        rest = L
        R = [0]*M
        for i in range(M):
            prv = 0
            for s, t, u in P:
                rest = min(rest + (s - prv) * x, L)
                rest = min(rest + (t - s) * (x - u), L)
                prv = t
                if rest < 0:
                    return 0
            rest = min(rest + (K - prv) * x, L)
            R[i] = rest
        return R[-2] - EPS < R[-1]
    left = 0; right = ma
    while left + EPS < right:
        mid = (left + right) / 2
        if check(mid):
            right = mid
        else:
            left = mid
    write("%.016f\n" % right)
    return True
while solve():
    ...


Measured memory_bytes: 24220
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

const int maxn = 400;
struct Point{
   int x,y,idx;
   Point (int x=0, int y=0,int idx = 0):x(x),y(y),idx(idx){}
};
Point p[maxn];
int n;

int gcd(int x, int y) {return y==0?x:gcd(y,x%y); }
int tx,ty,g;

struct node{
   int ida,idb;
   int x,y;
   node () {}
   node (Point a, Point b){
        ida = a.idx;
        idb = b.idx;
        x = a.x-b.x;
        y = a.y-b.y;
        tx = abs(x);
        ty = abs(y);
        g = gcd(tx,ty);
        x /= g; y /= g;

        if (x<0 && y<0) {x=-x; y=-y; }
        else if (x*y<0 && x<0) {x=-x; y=-y;}
        else if (x==0) y=1;
        else if (y==0) x=1;
   }
   bool operator ==(const node &rhs) const {
      return x==rhs.x && y==rhs.y;
   }
}e[maxn];

int tot,ans;
bool vis[maxn];
int v[maxn],cnt;

void dfs(int pos,int num){
   if (pos>=tot && num<n) return;
   if (num>=n) {
          int tmp = 0;
          //printf("FAQ%d\n",cnt);
          for (int i=0; i<cnt; i++)
            for (int j=i+1; j<cnt; j++) if (e[v[i]]==e[v[j]]) tmp++;
     ans = max(ans,tmp);
     return ;
   }

   for (int i=pos; i<tot; i++) {
      if (vis[e[i].ida] || vis[e[i].idb]) continue;
            vis[e[i].ida] = vis[e[i].idb] = 1;
            v[cnt++] = i;
            dfs(i+1,num+2);
            vis[e[i].ida] = vis[e[i].idb] = 0;
            cnt--;
   }
}

int main(){
    int x,y;
   //freopen("1.txt","r",stdin);
    while (scanf("%d",&n)==1) {
         for (int i=1; i<=n; i++) {
            scanf("%d%d",&x,&y);
            p[i] = Point(x,y,i);
         }

         tot = 0;
         node u;
         for (int i=1; i<=n; i++) {
            for (int j=i+1; j<=n; j++) e[tot++] = node(p[i],p[j]);
         }
         ans = 0;

         memset(vis,0,sizeof(vis));
         memset(v,0,sizeof(v));
         cnt = 0;
         for (int i=0; i<n; i++) {
            vis[e[i].ida] = vis[e[i].idb] = 1;
            v[cnt++] = i;
            dfs(n-2,2);
            vis[e[i].ida] = vis[e[i].idb] = 0;
            cnt--;
         }
         printf("%d\n",ans);

    }
    return 0;
}


Measured memory_bytes: 2748
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 5e5 + 10, M = (1 << 20) + 10, mod = 1e9 + 7;

vector<int> pos[M];
int a[N], pref[N], cnt_zero[N];
ll p2[N];

int main() {
	fast_cin();
	int n; cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		pref[i] = a[i] ^ pref[i - 1];
		cnt_zero[i] = cnt_zero[i - 1];
		if (pref[i] == 0) {
			++cnt_zero[i];
		} else {
			pos[pref[i]].pb(i);
		}
	}
	ll ans = 0;
	for (int x = 1; x < M; ++x) {
		int s = pos[x].size();
		if (!s) {
			continue;
		}
		ll c0 = 0, c1 = 0;
		if (pref[n] == 0) {
			++c0;
		} else if (pref[n] == x) {
			++c1;
		}
		if (!c0 and !c1) {
			continue;
		}
		pos[x].pb(n);
		for (int i = s - 1; i >= 0; --i) {
			ll temp = cnt_zero[pos[x][i + 1] - 1] - cnt_zero[pos[x][i]];
			c0 += temp * c1;
			c0 %= mod;
			c1 += c0;
			c1 %= mod;
		}
		ans += c1;
		ans %= mod;
	}
	if (pref[n] == 0) {
		ll x = 1, e = cnt_zero[n - 1];
		while (e--) {
			x *= 2;
			x %= mod;
		}
		ans += x;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 41600
#include <iostream>
#include <cmath>

 #define rep(i,n) for (int i = 0; i < (n); i++)
 using namespace std;
 using ll = long long;

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

     int h[n];
     rep(i,n) cin >> h[i];

     int d[n+1];
     d[0] = 0;
     d[1] = abs(h[1] - h[0]);

     for (int i = 2; i < n; i++) {
         d[i] = min(d[i - 1] + abs(h[i] - h[i - 1]), d[i - 2] + abs(h[i] - h[i - 2]));
     }

     cout << d[n-1] << endl;

     return 0;
     
 }

Measured memory_bytes: 1024
N, M = map(int, input().split())
A = []
for i in range(0, N):
	A.append(input())
B = []
for i in range(0, M):
	B.append(input())
flag1 = False
for i in range(0, N-M+1):
	for j in range(0, N-M+1):
		flag2 = True
		for p in range(0, M):
			for q in range(0, M):
				if A[i+p][j+q] != B[p][q]:
					flag2 = False
					break
			if not flag2:
				break
		if flag2:
			flag1 = True
			break
	if flag1:
		break
if flag1:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 38256