akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, double> pdd;
const double eps = 1e-10;
const double pi = acos(-1);
inline int sgn(double d){if(fabs(d) < eps) return 0;if(d > 0) return 1;return -1;}
inline double rad(double _deg){return _deg / 180.0 * pi;}
inline double deg(double _rad){return _rad / pi * 180.0;}
struct Point{
	double x, y;
	void read(){scanf("%lf%lf", &x, &y);}
	Point():x(0.0), y(0.0){}
	Point(double a, double b = 0.0): x(a), y(b){}
	Point(const Point& p): x(p.x), y(p.y){}
	Point operator + (const Point& a){return {x + a.x, y + a.y};}
	Point operator - (const Point& a){return {x - a.x, y - a.y};}
	double operator * (const Point& a){return x * a.x + y * a.y;}
	double operator ^ (const Point& a){return x * a.y - y * a.x;}
	bool operator == (const Point& p){return sgn(x - p.x) == 0 && sgn(y - p.y) == 0;}
	bool operator < (const Point &p) const{
		if(sgn(x - p.x) == 0) 
			return sgn(y - p.y) == -1;
		return sgn(x - p.x) == -1;
	}
	double length(){return sqrt(x * x + y * y);}
}typedef Vector;
double distance(const Point &a, const Point &b) 
{
	double x = a.x - b.x;
	double y = a.y - b.y;
	return sqrt(x * x + y * y);
}
struct Line{
	Point a, b;
	void read(){a.read(); b.read();}
	Line() : a(0.0, 0.0) , b(0.0, 0.0){}
};
Point Projection(Point p, Line l)
{ 
	// 点在直线上的投影点
	Vector v1 = l.b - l.a;
	Vector v2 = p - l.a;
	double k1 = v1 * v2;
	double k2 = v1.length();
	k1 /= k2 * k2;
	return {l.a.x + v1.x * k1, l.a.y+ v1.y * k1};
}
Point Reflection(Point p, Line l)
{
	// 点关于直线对称
	Point p0 = Projection(p, l);
	Vector v0 = p0 - p;
	return p0 + v0;
}
int main()
{
	Line l;
	l.read();
	int n;
	scanf("%d", &n);
	while(n --)
	{
		Point p;
		p.read();
		Point ans = Reflection(p, l);
		printf("%0.9lf %0.9lf\n", ans.x, ans.y);
	}
	return 0;
}


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

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

#define long long ll

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<vector<int>> pre_cnt(n,vector<int>(26,0));
    char temp;
    int base = int('a');
    rep(i,n){
        temp = s[i];
        pre_cnt[i] = pre_cnt[max(i-1,0)];
        pre_cnt[i][int(temp)-base] += 1;
    }
    int cnt ;
        if (s.size() < 2){
            cout << -1 << " " << -1 << endl;
            return 0;                
        }
        if ( s.size() == 2 ){
        int max_cnt = 0;
        for(int k=0; k < 26; k++){
            cnt = pre_cnt[1][k] ;
            max_cnt = max(max_cnt,cnt);
        }
        if (max_cnt*2 > 2 ){
            cout << 1 << " " << 2 << endl;
            return 0;
        } else{
            cout << -1 << " " << -1 << endl;
            return 0;            
        }
    }                       
    rep(i,n){

        for(int j=i+2; j < min(n,i+3); j++){
            int max_cnt = 0;
            if(i > 0){
                for(int k=0; k < 26; k++){
                    cnt = pre_cnt[j][k] - pre_cnt[i-1][k] ;
                    max_cnt = max(max_cnt,cnt);
                }
            }else{
                for(int k=0; k < 26; k++){
                    cnt = pre_cnt[j][k] ;
                    max_cnt = max(max_cnt,cnt);
                }
            }
            if ( i > 0){
                if (max_cnt*2 > j-i+1 ){
                    cout << i+1 << " " << j+1 << endl;
                    return 0;
                }
            }else{
                if (max_cnt*2 > j+1 ){
                    cout << 1 << " " << j+1 << endl;
                    return 0;
                }                
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 13696
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    vector<int> nums(3);
    int k;

    for(int i=0; i<3; i++){
        cin >> nums[i];
    }
    cin >> k;
    sort(nums.begin(), nums.end());
    cout << nums[0]+nums[1]+nums[2]*int(pow(2,k));
    

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        //int K = sc.nextInt();

        int[] A = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
        }

        Set<Integer> set = new HashSet<Integer>();
        int pos = 1;
        set.add(pos);
        ArrayList<Integer> path = new ArrayList<Integer>();
        path.add(pos);
        int loopStart = -1;
        while (true) {
            if (set.contains(A[pos])) {
                loopStart = path.indexOf(A[pos]);
                break;
            }
            set.add(A[pos]);
            path.add(A[pos]);
            pos = A[pos];
        }

        long loopsize = path.size() - loopStart;
        int ans = -1;
        if (loopStart >= K) {
            ans = path.get((int)K);
        } else {
            // loopStart < 
            long tmp = (K - loopStart) % loopsize + loopStart;
            int idx = (int) tmp;
            ans = path.get(idx);
        }

        System.out.println(ans);

        return;
    }

}

Measured memory_bytes: 67172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if (6 - (a + b) == 1){
    cout << "1\n";
  }
  if (6 - (a + b) == 2){
    cout << "2\n";
  }
  if (6 - (a + b) == 3){
    cout << "3\n";
  }
  return 0;   
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e6 + 55;

ll dif[MAXN];
ll dp[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	if (n <= 2){
		printf("%d\n", n * n);
		return;
	}
	dif[0] = 1;
	dif[1] = -1;
	REP(i, 0, n){
		dp[i] = dif[i];
		if (i){
			dp[i] = (dp[i] + dp[i - 1]) % MOD;
		}
		dif[i + 1] = (dif[i + 1] + dp[i]) % MOD;
		dif[i + 2] = (dif[i + 2] - dp[i] + MOD) % MOD;
		dif[i + 3] = (dif[i + 3] + dp[i]) % MOD;
		dif[i + n + 2] = (dif[i + n + 2] - dp[i] + MOD) % MOD;
	}
	REP(i, n, 2 * n + 5){
		dp[i] = (dp[i - 1] + dif[i]) % MOD;
	}
	
	/*REPN(i, 0, n){
		printf("%d %lld\n", i, dp[i]);
	}*/
	
	ll ans = 0ll;
	ll mul = ((ll)(n - 1) * (ll)(n - 1)) % MOD;
	// a b b b b 
	REP(i, 0, n - 1){
		ans = (ans + dp[i] * mul) % MOD;
	}
	//printf("%lld\n", ans);
	// a 1 1 1 1 
	REP(i, 0, n - 1){
		ans = (ans + dp[i] * (n - 1)) % MOD;
	}
	//printf("%lld\n", ans);
	// 1 1 1 ... 1 1 
	ans = (ans + 1) % MOD;
	//printf("%lld\n", ans);
	// ... 1 a a ... a
	ans = (ans + dp[n - 1] * (n - 1)) % MOD;
	printf("%lld\n", ans);
	/*REP(i, 0, n){
		printf("%d %lld %lld\n", i, dif[i], dp[i]);
	}*/
	
	/*REPN(n, 1, 30){
		REPN(i, 0, 2 * n){
			REPN(j, 1, n){
				dp[i][j] = 0;
			}
		}
		dp[0][1] = 1;
		REP(i, 0, n){
			REPN(j, 2, n){
				dp[i + j][1] = (dp[i + j][1] + dp[i][j]) % MOD;
			}
			REPN(j, 1, n){
				dp[i + 1][j] = (dp[i + 1][j] + dp[i][1]) % MOD;
			}
		}
		ll ans = 0ll;
		REPN(i, n, 2 * n){
			REPN(j, 1, n){
				ans = (ans + dp[i][j]) % MOD;
			}
		}
		REP(i, 1, n){
			REPN(j, 2, n){
				ans = (ans + dp[i][j] * (n - 1)) % MOD;
			}
		}
		printf("%d: %lld\n", n, ans);
	}*/
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

int main(){
  int h,w; std::cin >> h >> w;
  std::vector<vector<char>> ans(h+2,vector<char>(w+2,'.'));
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      std::cin >> ans[i][j];
    }
  }
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if (ans[i][j] == '#') {
        std::cout << '#';
      }
      else{
        int count = 0;
        for (int a = -1; a < 2; a++) {
          for (int b = -1; b < 2; b++) {
            if (ans[i+a][j+b] == '#') {
              count++;
            }
          }
        }
        std::cout << count;
      }
    }
    std::cout << '\n';
  }
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    a.at(i) -= i + 1;
  }
  
  sort(a.begin(), a.end());
  
  ll b;
  if(n % 2 == 1) b = a.at(n / 2);
  else b = (a.at(n / 2 - 1) + a.at(n / 2)) / 2;
  
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans += abs(a.at(i) - b);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
sunukes = [list(map(int, input().split())) for i in range(k*2)]

names = list(range(1,n+1))
for i in range(0,k):
  j = i*2
  syoji = sunukes[j]
  okashi = sunukes[j+1]
  for n in okashi:
    if n in names:
      names.remove(n)

print(len(names))

Measured memory_bytes: 67796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair
#define eb emplace_back

const int MAX_N = 2e5+10;

int N, M;
int A[MAX_N], B[MAX_N];
vector<int> G[MAX_N];
int sz[MAX_N];
bool vis[MAX_N];

void add_edge(int from,int to)
{
	G[from].pb(to);
	G[to].pb(from);
}

int dfs(int x)
{
	vis[x] = true;
	int res = 1;
	for(int y : G[x])if(!vis[y]){
		res += dfs(y);
	}
	return sz[x] = res;
}

void solve()
{
    if(M == 0 ) {
        cout<<1<<'\n';
        return;
    }
	for(int i=0;i<M;++i){
		add_edge(A[i],B[i]);
	}
	for(int i=0;i<N;++i)if(!vis[i]){
		dfs(i);
	}
	int ans = 0;
	for(int i=0;i<N;++i)ans=max(ans,sz[i]);
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> N >> M;
	for(int i=0;i<M;++i){
		cin >> A[i] >> B[i];
		A[i]--, B[i]--;
	}
	solve();
	return 0;
}

Measured memory_bytes: 26544
n = int(input())
a = list(map(int,input().split()))
v = [0] * 100100
for i in range(n):
    v[a[i]] += 1
    v[a[i]+1] += 1
    v[a[i]-1] += 1
ans = 0
for i in range(100100):
    ans = max(ans,v[i])
print(ans)

Measured memory_bytes: 13964
#include <stdio.h>

int main(void)
{
	int H, W, i, j, k;
	for (i = 0;; i++)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (j = 0; j < H; j++)
		{
			for (k = 0; k < W; k++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2040
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define lll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
#define Lets_be_precise cout<<fixed<<setprecision(10)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
	cin>>v[i];
}
//#define cerr if(false)cerr//uncomment to remove cerr from program...
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>m;
vector<int> col[m];
vector<int> row[n];
int ans=0;
string s[n];
for(int i=0;i<n;i++)
{cin>>s[i];}
for(int i=0;i<n;i++)
{
row[i].pb(-1);
for(int j=0;j<m;j++)
{
    if(i==0)
    {col[j].pb(-1);}
    if(s[i][j]=='.')
    continue;
    col[j].pb(i);
    row[i].pb(j);
}
row[i].pb(m);
}
for(int i=0;i<m;i++)
col[i].pb(n);
int rowans;
int colans;
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {
        if(s[i][j]=='#')
        continue;
        auto itcol=ub(col[j],i);
        colans=*itcol;
        itcol--;
        colans-=*itcol;
        colans--;
        auto itrow=ub(row[i],j);
        rowans=*itrow;
        itrow--;
        rowans-=*itrow;
        rowans--;
        ans=max(ans,colans+rowans);
    }
}
cout<<ans-1;
return ;
}

int main()
{
	ios_base::sync_with_stdio(false);
	Lets_be_precise;
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 38784
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int a[5],s=0;
r(i,5)cin>>a[i];
r(i,5){
if(a[i]<40)s+=40;
else s+=a[i];
}
cout<<s/5<<endl;
}

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

int main(){
  string s;
  cin >> s;
  int al[26] = {0};
  for(int i = 0; i < s.length(); i++)
    al[int(s[i]-'a')]++;

  for(int i = 0; i < 26; i++){
    if( al[i] == 0 ){
      cout << char('a'+i) << "\n";
      return 0;
    }
  }
  cout << "None\n";
  return 0;
}


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

class UnionFindTree
{
    vector<int> parent;
    vector<int> depth;
    vector<int> cnt;

public:
    UnionFindTree(int n) : parent(n), depth(n), cnt(n)
    {
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
            depth[i] = 0;
            cnt[i] = 1;
        }
    }

    //木の根を求める
    int find(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            return parent[x] = find(parent[x]);
        }
    }

    //xとyの属する集合を併合
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (depth[x] < depth[y])
        {
            parent[x] = y;
            cnt[y] += cnt[x];
        }
        else
        {
            parent[y] = x;
            cnt[x] += cnt[y];
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    int size(int x)
    {
        return cnt[find(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFindTree utree(n + 10);
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        utree.unite(x, y);
    }
    map<int, int> fl;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!fl[utree.find(i)])
        {
            fl[utree.find(i)] = 1;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
while True:
    x = []
    x = input().split( )
    y = [int(s) for s in x]
    if sum(y) == -3:
        break
    if y[0] == -1 or y[1] == -1:
        print("F")
    elif y[0] + y[1] < 30:
        print("F")
    elif y[0] + y[1] >= 30 and y[0] + y[1] <50:
        if y[2] >= 50:
            print("C")
        else:
            print("D")
    elif  y[0] + y[1] >= 50 and y[0] + y[1] <65:
        print("C")
    elif  y[0] + y[1] >= 65 and y[0] + y[1] <80:
        print("B")
    elif  y[0] + y[1] >= 80:
        print("A")


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

queue<long> q;
const long MAXN=200100;
long n,a[MAXN];
long ans;

bool cmp(long a,long b) {return a>b;}

int main() {
	cin>>n;
	register long i;
	for(i=1;i<=n;++i)
		scanf("%ld",&a[i]);
	sort(a+1,a+n+1,cmp);
	q.push(a[1]);
	
	for(i=2;i<=n;++i) {
		ans+=q.front();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main(){
    int n,W;
    cin>>n>>W;
    int a[n],w[n];
    for(int i=0;i<n;i++){
        cin>>w[i]>>a[i];
    }
    long long dp[W+1]={};
    for(int i=0;i<n;i++){
        for(int j=W;j>=w[i];j--){
            dp[j]=max(dp[j],dp[j-w[i]]+a[i]);
            //cout<<dp[j]<<"  "<<dp[j-w[i]]+a[i]<<endl;;
        }
    }
    cout<<dp[W]<<endl;
    return 0;
}

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

using namespace std ;

typedef long long ll ;

const int N = 300010 ;

int n ;
ll ans ;
ll S[4] ;
ll minx ;
ll maxx ;
ll sum[N] ;
ll base[N] ;

ll gt(ll x){
    return x < 0 ? -x : x ;
}
void chkmin(ll x){
    minx = x >= minx ? minx : x ;
}
void chkmax(ll x){
    maxx = x >= maxx ? x : maxx ;
}
int main(){
    cin >> n ;
    ans = (1ll << 62) ;
    for (int i = 1 ; i <= n ; ++ i){
        scanf("%lld", &base[i]) ;
        sum[i] = sum[i - 1] + base[i] ;
    }
    int l = 2, r = 4 ;
    S[0] = base[1] ; S[2] = base[3] ;
    S[1] = base[2] ; S[3] = sum[n] - sum[3] ;
    for (int i = 3 ; i <= n ; ++ i){
        while (l < i && gt(S[0] - S[1]) > gt(S[0] + base[l] - S[1] + base[l])){
            S[0] += base[l], S[1] -= base[l], ++ l ;
        }
        while (r <= n && gt(S[3] - S[2]) > gt(S[2] + base[r] - S[3] + base[r])){
            S[2] += base[r], S[3] -= base[r], ++ r ;
        }
        minx = (1ll << 61) ; maxx = -(1ll << 61) ;
        for (int j = 0 ; j <= 3 ; ++ j) chkmin(S[j]), chkmax(S[j]) ;
        ans = min(ans, maxx - minx) ; S[1] += base[i] ; S[2] -= base[i] ;
        //for (int j = 0 ; j <= 3 ; ++ j) cout << S[j] << " " ; puts("") ;
    }
    cout << ans << endl ; return 0 ;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 2e4 + 48, mod = 1e9 + 7;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, dp[2][N];

struct block {
	int w, s, v;

	bool operator < (const block &x) const {
		return s + w < x.s + x.w;	
	}
} a[N];


main () {
	cin >> n;
	forn (i, 1, n) 
		cin >> a[i].w >> a[i].s >> a[i].v;

	sort(a + 1, a + 1 + n);
	forn (i, 1, n)
		forn (x, 1, N - 1) 
			dp[i & 1][x] = max({dp[i & 1][x - 1], dp[(i - 1) & 1][x], (x >= a[i].w && x - a[i].w <= a[i].s ?  dp[(i - 1) & 1][x - a[i].w] + a[i].v : -INF)});
		

	cout << dp[n & 1][N - 1] << endl;
}          
 

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll pi, yi;
    vector<array<ll,3>> X;
    map<array<ll,2>, size_t> index;
    unordered_map<ll, set<ll>> m;
    for(int i=0;i<M;i++){
        cin >> pi >> yi;
        X.push_back(array<ll,3>{pi, yi, 0});
        index[array<ll,2>{pi, yi}] = i;
        if(m.count(pi)==0) m[pi] = set<ll>();
        m[pi].insert(yi);
    }
    for(auto p : m){
        ll res = 1;
        for(auto& n : p.second){
            auto i = index[array<ll,2>{p.first, n}];
            X[i][2] = res++;
        }
    }
    for(auto x : X){
        cout<<std::setfill('0') << std::right << std::setw(6) << x[0];
        cout<<std::setfill('0') << std::right << std::setw(6) << x[2];
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 23508
#include<cstdio>

const int maxn = 44 + 1;
int a[maxn];

int calcFibonacciNumber(int n) {
    if (n < 0) {
        return 0;
    }
    if (n == 0 || n == 1) {
        return 1;
    }
    if (a[n] != -1) {
        return a[n];
    }
    a[n] = calcFibonacciNumber(n - 1) + calcFibonacciNumber(n - 2);
    return a[n];
}

int getFibonacciNumber(int n) {
    return calcFibonacciNumber(n);
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < maxn; i++) {
        a[i] = -1;
    }
    printf("%d\n", getFibonacciNumber(n));
    return 0;
}


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

#define ll long long

void solve()
{
    ll need=0;
    int n;
    cin >> n;
    int a[n+10];
    for(int i=0; i<n; i++)
        cin >> a[i];
    int prev = a[0];
    for(int i=1; i<n; i++){
        if(prev>a[i]){
            need+=(prev-a[i]);
            a[i] = prev;
        }
        prev = a[i];

    }
    cout << need << "\n";
    
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("D:\\Codings\\CPP\\input.in", "r", stdin);
    freopen("D:\\Codings\\CPP\\output.in", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int t=1;
    //cin >> t;
    while(t--)
        solve();
   
    return 0;
}


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

void solve(long long H){
    long long ans=0,num=1;
    while(H>1)
    {
        ans+=num;
        H/=2;
        num*=2;
    }
    cout<<ans+num<<endl;
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
n,t = map(int,input().split())
s = [list(map(int,input().split())) for i in range(n)]
Min = 1001
for i in range(n):
    if s[i][1] <= t:
        Min = min(Min,s[i][0])
if Min == 1001:
	print("TLE")
else:
	print(Min)

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

int main()
{	
	char a[3][3],c;
	int i,j;
	
	for (i=0;i<3;i++)
	{
		for (j=0;j<3;j++)
		{
			scanf("%c",&a[i][j]);
		}
		
		c=getchar();
	}
	
	printf("%c%c%c",a[0][0],a[1][1],a[2][2]);
	
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
# define M_PI           3.14159265358979323846  /* pi */
using namespace std;

int main() {
	string s;
	cin >> s;
	int count = 0;

	for (int i = 0; i < 3; i++) {
		if (s.at(i) == '1') {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <vector>
using namespace std;
#define LL long long

char s[105], t[105];

int main()
{
    while(~scanf("%s", s))
    {
        int n = strlen(s);
        int minn = 1000005;
        for(int i = 'a'; i <= 'z'; ++i)
        {
            strcpy(t, s);
            int cnts = 0;
            for(int j = n - 1; j > 0; --j)
            {
                int flag = 0;
                for(int k = 0; k <= j; ++k)
                {
                    if(t[k] != i) flag = 1;
                }
                if(!flag) break;
                for(int k = 0; k <= j; ++k)
                {
                    if(t[k] == i) continue;
                    else if(t[k + 1] == i) t[k] = i;
                }
                cnts++;
                flag = 0;
                for(int k = 0; k <= j; ++k)
                {
                    if(t[k] != i) flag = 1;
                }
                if(!flag) break;
            }
            minn = min(minn, cnts);
        }
        printf("%d\n", minn);
    }
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        string s = Console.ReadLine();

        for (int i = 0; i < s.Length - 1; i++)
        {
            for (int j = 0; j <= s.Length - i; j++)
            {
                if(s.Remove(i, j) == "keyence")
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
        }
        Console.WriteLine("NO");
    }
}

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

const long long inf=1ll<<40;
char p[2][2],ans[35];
int n,x[1010],y[1010],m;
long long d[35];

void solve(long long x,long long y)
{
	int i=1,px,py;
	long long nwx=0,nwy=0;
	p[0][0]='L',p[0][1]='D',p[1][0]='U',p[1][1]='R';
	if (!(x&1)) ans[0]=p[1][1],nwx++,nwy++,i++,ans[0]=p[1][1];
	for (; i<m; i++)
	{
		if ((nwx+d[i]+inf)%(4*d[i])==(x+inf)%(4*d[i])) px=0,nwx-=d[i]; else px=1,nwx+=d[i];
		if ((nwy+d[i]+inf)%(4*d[i])==(y+inf)%(4*d[i])) py=0,nwy-=d[i]; else py=1,nwy+=d[i];
		ans[i-1]=p[px][py];
	}
	if (nwx+d[m]==x) px=1; else px=0;
	if (nwy+d[m]==y) py=1; else py=0;
	ans[m-1]=p[px][py],puts(ans);
}

int main()
{
	scanf("%d",&n),m=0;
	for (int i=1; i<=n; i++) scanf("%d%d",&x[i],&y[i]);
	for (int i=1; i<n; i++) if (((x[i]+y[i])&1)!=((x[i+1]+y[i+1])&1)) return puts("-1"),0;
	if (!((x[1]+y[1])&1)) d[++m]=1;
	for (int i=0; i<=30; i++) d[++m]=(1ll<<i);
	printf("%d\n",m);
	for (int i=1; i<=m; i++) printf("%lld ",d[i]); puts("");
	for (int i=1; i<=n; i++) solve(x[i]+y[i],x[i]-y[i]);
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;

public class Main {
  private static void solve() {
    int n = ni();

    long ret = 0;
    Map<Integer, Long> map = new HashMap<>();
    for (int k = 1; k <= n; k++) {
      String s = k + "";
      int ds = s.charAt(0) - '0';
      int de = s.charAt(s.length() - 1) - '0';
      int key = ds * 10 + de;
      if (ds == 0 || de == 0)
        continue;
      map.putIfAbsent(key, 0L);
      map.put(key, map.get(key) + 1);
    }

    for (Map.Entry<Integer, Long> entry : map.entrySet()) {
      int key = entry.getKey();
      long val = entry.getValue();
      int nk = (key / 10) + (key % 10) * 10;

      if (map.containsKey(nk)) {
        ret += val * map.get(nk);
      }
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 41804
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scn = new Scanner(System.in);
		long k = scn.nextLong();
		int n = scn.nextInt();
		Long d[] = new Long[n];
		long s = scn.nextLong();
		long p = s;
		for (int i = 1; i < n - 1; i++) {
			long v = scn.nextLong();
			d[i] = v - p;
			p = v;
		}
		long v = scn.nextLong();
		d[n - 1] = v - p;
		d[0] = k - v + (s);
		Arrays.sort(d);
		System.out.println(k - d[n - 1]);
	}
}

Measured memory_bytes: 81856
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	makei(N);
	vi v = { 1,2,4,8,16,32,64 };
	rep(v.size()) {
		if (v[i] > N) {
			say(v[i - 1]);
			re;
		}
	}
	say(64);
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    print('Yes' if ni() >= 30 else 'No')
    return

solve()


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

long long INF = 1e18;

int main(){
    string s, t,u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u){
        cout << a - 1 << " " << b << endl;
    }else{
        cout << a<< " " << b -1<< endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long int> vec(5);
  for(int i = 0; i < 5; i++) {
    cin >> vec.at(i);
    if(vec.at(i) == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}

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

#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template<typename X, typename T>
auto vectors(X x, T a) {
    return vector<T>(x, a);
}

template<typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
    auto cont = vectors(y, z, zs...);
    return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
    return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &x: v) { is >> x; }
    return is;
}

template<typename T>
class CumulativeSum {
    vector<T> a;
public:
    CumulativeSum(vector<T> &x) : a(x.size() + 1, 0) {
        rep(i, x.size()) {
            a[i + 1] = a[i] + x[i];
        }
    }

    T get(int l, int r) { // [l, r]の区間の合計を求める
        return a[r + 1] - a[l];
    }

    T operator[](const int i) const {
        return a[i];
    }
};


bool C(int mid, int k, int n, vector<int> &a, CumulativeSum<int> &sum) {
    int d = distance(a.begin(), lower_bound(all(a), mid));
    int total = sum.get(0, d - 1) + (a.size() - d) * mid;
    //show(d)show(total)show(mid*k)
    return total >= mid * k;
}

signed main() {
    int n;
    cin >> n;
    vector<int> a(300005, 0);
    rep(i, n) {
        int x;
        cin >> x;
        a[x]++;
    }
    sort(all(a));

    CumulativeSum<int> sum(a);

    range(k, 1, n + 1) {
        int right = n + 1, left = 0;
        rep(i, 100) {
            int mid = (right + left) / 2;
            if (C(mid, k, n, a, sum)) left = mid;
            else right = mid;
        }
        cout << left << endl;
    }
}

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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;

  int x = 0, ans = x;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'I') {
      ++x;
    }
    if (s[i] == 'D') {
      --x;
    }
    ans = max(ans, x);
  }

  cout << ans << '\n';

  return 0;
}


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

class Point{
public:
  string name;  
  int l,r,u,d,s,ss;
};

int main(){
  while(1){
  int i,j,n,x[100],y[100],c,s;
  Point p[1000];
  string str;
    cin >> n;
    if(n == 0) break;
    cin >> str;
    for(i=0;i<n;i++) cin >> x[i] >> y[i];
    
    c = 0;
    s = 0;
    
    for(i=0;i<str.size()-1;i++){
      if(str[i] == '<' && str[i+1] != '/'){
	i++;
	for(;str[i] != '>';i++) p[c].name += str[i];
	
	i++;
	p[c].l = p[c].r = p[c].u = p[c].d = 0;
	
	for(;str[i] != ',';i++){
	  p[c].l *= 10;
	  p[c].l += str[i] - '0';
	}
	i++;
	for(;str[i] != ',';i++){
	  p[c].u *= 10;
	  p[c].u += str[i] - '0';
	}
	i++;
	for(;str[i] != ',';i++){
	  p[c].r *= 10;
	  p[c].r += str[i] - '0';
	}
	i++;
	for(;str[i] != '<';i++){
	  p[c].d *= 10;
	  p[c].d += str[i] - '0';
	}
	p[c].s = s;
	c++;
	s++;
	i--;
      }
      else if(str[i] == '<' && str[i+1] == '/') s--;
    }
    
    for(i=0;i<c;i++){
      p[i].ss = 0;
      for(j=i+1;j<c;j++){
	if(p[i].s >= p[j].s) break;
      else if(p[i].s + 1 == p[j].s) p[i].ss++;
      }
    }
    
    for(i=0;i<n;i++){
      Point u,v;
      bool f = false;
      for(j=0;j<c;j++){
	if(p[j].l <= x[i] && x[i] <= p[j].r && p[j].u <= y[i] && y[i] <= p[j].d){
	  if(!f){
	    f = true;
	    u = p[j];
	  }
	  else{
	    v = p[j];
	    if(u.s < v.s) u = v;
	  }
	}
      }
      if(f) cout << u.name << " " << u.ss << endl;
      else cout << "OUT OF MAIN PANEL 1" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> masu(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> masu.at(i).at(j);
        }
    }
    
    for(int i = 0; i < H; i++) {
        bool white = true;
        for(int j = 0; j < W; j++) {
            if(masu.at(i).at(j)=='#') white = false;
        }
        if(white) {
            for(int j = 0; j < W; j++) masu.at(i).at(j) = 'x';
        }
    }
    
    for(int j = 0; j < W; j++) {
        bool white = true;
        for(int i = 0; i < H; i++) {
            if(masu.at(i).at(j)=='#') white = false;
        }
        if(white) {
            for(int i = 0; i < H; i++) masu.at(i).at(j) = 'x';
        }
    }
    
    for(int i = 0; i < H; i++) {
        bool skip = true;
        for(int j = 0; j < W; j++) {
            if(masu.at(i).at(j)!='x') {
                cout << masu.at(i).at(j);
                skip = false;
            }
            if(j==W-1 && !skip) cout << endl;
        }
    }
}


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

using namespace std;
const int maxn = 2050;
const int inf = 1e8;
int res[maxn][maxn];

vector<int> adj[maxn];

int pa[maxn];
bool vs[maxn];

bool bfs(int s, int t){
  deque<int> Q;
  Q.push_back(s);
  pa[s] = -1;
  memset(vs, false, sizeof(vs));
  while(!Q.empty()){
    int v = Q.front(); Q.pop_front();
    if(vs[v]) continue;
    vs[v] = true;
    for(int u : adj[v]){
      if(res[v][u] == 0) continue;
      if(vs[u]) continue;
      pa[u] = v;
      Q.push_back(u);
      if(u == t){
	return true;
      }
    }
  }
  return false;
}

int mxflow(int s, int t){
  int ans = 0;
  while(true){
    if(!bfs(s, t)) return ans;
    vector<int> path; path.push_back(t);
    while(path.back() != s){
      path.push_back(pa[path.back()]);
    }
    reverse(path.begin(), path.end());
    ans += 1;
    for(int i=0;i<path.size()-1;i++){
      int a = path[i];
      int b = path[i+1];
      res[a][b] -= 1;
      res[b][a] += 1;
    }
  }
  return ans;
}

int main(){
  int h,w; cin >> h >> w;
  int s = h + w;
  int t = h + w + 1;
  int sx, sy, tx, ty;
  for(int i=0;i<h;i++){
    string q; cin >> q;
    for(int j=0;j<w;j++){
      if(q[j] == 'S'){
	adj[s].push_back(i); adj[i].push_back(s);
	adj[s].push_back(h+j); adj[h+j].push_back(s);
	res[s][i] = inf;
	res[s][h+j] = inf;
	sx = i; sy = j;
      }
      if(q[j] == 'T'){
	adj[t].push_back(i); adj[i].push_back(t);
	adj[t].push_back(h+j); adj[h+j].push_back(t);
	res[i][t] = inf;
	res[h+j][t] = inf;
	tx = i; ty = j;
      }
      if(q[j] == 'o'){
	//add an edge
	adj[i].push_back(h+j);
	adj[h+j].push_back(i);
	res[i][h+j] = 1;
	res[h+j][i] = 1;
      }
    }
  }
  if(sx == tx || sy == ty){
    cout << -1 << "\n";
    return 0;
  }
  cout << mxflow(s, t) << "\n";
}


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

int muls_to_exceed(const int a, int b) {
    int ans = 0;

    while (b <= a) {
        b *= 2;
        ++ans;
    }

    return ans;
}

bool solve(const int A, int B, const int C, int K) {
    const int one = muls_to_exceed(A, B);
    K -= one;
    if (K < 0) return false;

    for (int i = 0; i < one; ++i) B *= 2;
    return K >= muls_to_exceed(B, C);
}

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

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    cout << (solve(A, B, C, K) ? "Yes" : "No") << "\n";

    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	string s;
	cin >> s;
	cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No");
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>

#define ll long long
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define fd(i, l, r) for (int i = r; i >= l; i--)

using namespace std;

inline ll read()
{
	ll x = 0, f = 1;
	char ch = getchar();
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

int n;
int a[100050],b[100050],v[100050];
int a1,a2,b1,b2;

int main()
{
	n = read();
	fo(i,1,n){
		v[i] = read();
	}
	fo(i,1,n){
		if(i&1)a[v[i]]++;
		else b[v[i]]++;
	}
	fo(i,1,100000){
		if(a[i] > a[a1]) a1 = i;
		if(b[i] > b[b1]) b1 = i;
	}
	fo(i,1,100000){
		if(i != a1 && a[i] > a[a2]) a2 = i;
		if(i != b1 && b[i] > b[b2]) b2 = i;
	}
	int ans = n;
	if(a1 == b1) ans = min(n-a[a1]-b[b2],n-a[a2]-b[b1]);
	else ans = n-a[a1]-b[b1];
	cout<<ans;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    map<string, int> mp;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        mp[s]++;
    }

    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3632
# include <bits/stdc++.h>
  using namespace std;
# define res(a,b,c) for (int64 a=b ; a<c ; a++)
# define ress(a,b)  for (auto a = b.begin() ; a!=b.end() ; a++) 
# define all(con) con.begin() , con.end()
# define INF (int)1e9  
# define MOD 1000000007
# define pb push_back   
# define mp make_pair
# define f first
# define s second   
# define MAX numeric_limits<int>::max() 
# define MIN numeric_limits<int64>::min()
# define mymin -1000000000000000001
# define mymax 1000000000000000001
# define watch(x) cout<<(#x)<<" is "<<(x)<<endl
# define in(x) cin>>(x)
# define inn(x,y) cin>>(x)>>(y)  
# define out(x) cout<<(x)<<"\n"  
# define outt(x,y) cout<<(x)<<" "<<(y)<<"\n"  
typedef long long int int64;
typedef unsigned long long int uint64;
typedef vector<int64> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int64,int64> pi; 
bool doubleSame(double a, double b)
{ const double eps = 1e-15; return ( abs(a-b)<= eps*abs(a) ); }

struct itemSet{
	int64 wt, val;
};

vector<vector<int64>> dp(101,vector<int64>(100001,-1));

int64 binaryKnap(int64 ind, vector<itemSet> &item, int64 n, int64 cap)
{
	if(ind>n) return 0;

	if(dp[ind][cap]!=-1) return dp[ind][cap];

	int64 a1 = 0, a2 = 0;
	if(cap>=item[ind].wt)
		a1 = item[ind].val + binaryKnap(ind+1, item, n, cap-item[ind].wt);

	a2 = binaryKnap(ind+1, item, n, cap);

	dp[ind][cap] = max(a1,a2);
	return dp[ind][cap];
}

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

	vector<itemSet> item(n+1);
	for(int64 i = 1 ; i<=n ; i++)
		cin>>item[i].wt>>item[i].val;

	cout<<binaryKnap(1,item,n,cap);
}

Measured memory_bytes: 80256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

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

    int ct = 0;

    for(int i = 0; i < 3; i++){
        if(s[i] == t[i]){
            ct++;
        }
    }
    printf("%d\n", ct);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,c,j,cant=0,flg,flg2,m;
	char a[11],b[101][11],bb[101][21];
	scanf("%s",a);
	scanf("%d",&c);
	for(i=0;i<c;i++){
		scanf("%s",b[i]);
	}
	for(i=0;i<c;i++){
		strcpy(bb[i],b[i]);
		strcat(bb[i],b[i]);
	}
	for(i=0;i<c;i++){
		flg2=0;
		for(j=0;j<strlen(bb[i]);j++){
			flg=1;
			if(bb[i][j]==a[0]){
				for(m=0;m<strlen(a);m++){
					if(j+m+1>20){
						flg=0;
						break;
					}
					if(bb[i][j+m]!=a[m]){
//						printf(" %c %c\n",bb[j+m][i],a[m]); 
						flg=0;
//						printf("i=%d j=%d m=%d\n",i,j,m);
						break;
					}

				}
//				printf("j=%d flg=%d\n",j,flg);
				if(flg==1){
					flg2=1;
					break;
				}
			}
			
		}
//		printf("flg2=%d i=%d\n",flg2,i);
		if(flg2==1){
			cant++;
		}
	}
	printf("%d\n",cant);
	return 0;
}

Measured memory_bytes: 1052
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N,K;
    cin>>N>>K;

    if(N%K==0){
        cout<<0<<endl;
    }
    else{
        cout<<1<<endl;
    }
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  int ans = 1;
  int nmax = 0;
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
   	int j = i;
    while (j % 2 == 0) {
      j /= 2;
      cnt++;
    }
    if (cnt > nmax) {
      nmax = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

void CountingSort( unsigned short *A,unsigned short *B, int n);

int n;

int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int  i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);


  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
  }

   for ( i = 0; i <= VMAX; i++ ) C[i] = 0;

  CountingSort(A,B,VMAX);

  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];

  for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


void CountingSort(unsigned short *A,unsigned short *B, int n){
  int i,j;
  unsigned short C[VMAX+1];

  /* for(i = 0 ; i <= VMAX ; i++)  C[i] = 0;
      
  for(j = 1 ; j <= n ; j++) C[A[j]]++;

  for(i = 1 ; i <= VMAX ; i++) C[i] = C[i] + C[i-1];

   for(j = n ; j >= 1 ; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
    }
    }*/
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(K+1);
    A[0] = 1;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        vector<long long> B(K+1);
        B[0] = A[0];
        for (int j = 1; j <= K; j++) {
            B[j] = B[j-1] + A[j];
        }
        for (int j = K; j >= 0; j--) {
            int lo = max(0, j - a);
            int hi = j;
            A[j] = (B[hi] - B[lo] + A[lo]) % MOD;
        }
    }
    cout << A[K] << endl;
    return 0;
}

Measured memory_bytes: 1408