akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> l4;
typedef long double ld;
typedef pair<ld,ld> ldd;
const ld pi = acosl(-1);
const int maxn = 2010;
const ll mod = 998244353;
const ll inf = 1e18;
const ld eps = 1e-10;

bitset<maxn*maxn> s;
int a[maxn],n;
int main() {
    scanf("%d",&n);
    s[0] = 1;
    int sum = 0;
    rep(i, 0, n) {
        scanf("%d",a+i);
        s |= (s<<a[i]);
        sum += a[i];
    }
    rep(i, (sum+1)/2, maxn*maxn) if (s[i]) {
        printf("%d",i);
        return 0;
    }
}


Measured memory_bytes: 1792
# include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;

int main(){

  string S;
  cin >> S;
  int N = S.size();
  vector<char> q;
  for(int i=0; i < N; i++){
    if(q.size() == 0 || q.back() == S[i]){
      q.push_back(S[i]);
    } else {
      q.pop_back();
    }
  }
  int ans;
  ans = N - q.size();
  cout << ans << endl;

}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main() {
    int a, b, c, d, e, k;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
    if (e - a <= k) {
        printf("Yay!");
    } else {
        printf(":(");
    }
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    l = 0
    now = 0
    ans = 0
    for r,a in enumerate(A):
        while now&a:
            now -= A[l]
            l+=1
        now += a
        ans += r-l+1
    print(ans)
if __name__ == '__main__':
    main()

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

int INF = -1e9;

struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<int> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        //ここでminを使うことで区間の最小値となる、最大にすれば最大値
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

//x番目(0-indexed)の要素をvalにする
void update(int x, int val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = val;
    while(x > 0) {
        x = (x - 1) / 2;
        //ここでminを使うことで区間の最小値となる、最大にすれば最大値
        node[x] = max(node[2*x+1], node[2*x+2]);
    }
}

// 要求区間 [a, b) 中の要素の最大値を答える(つまりbは含まれない)
// k := 自分がいるノードのインデックス
// 対象区間は [l, r) にあたる

int getmax(int a, int b, int k = 0, int l = 0, int r = - 1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す(今回は最小値なので、結果に影響しないような大きい値を返しておく)
    if(r <= a || b <= l) return INF;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
    int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
    return max(vl, vr);
}

// 要求区間 [a, b) 中の要素の最大値を答える(つまりbは含まれない)
// k := 自分がいるノードのインデックス
// 対象区間は [l, r) にあたる

int getleft(int x, int val, int k = 0, int l = 0, int r = - 1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す(今回は最小値なので、結果に影響しないような大きい値を返しておく)
    if(r <= x || n <= l) return INF;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(x <= l && r <= n)
	{
		if (k >= n - 1)
			return (node[k] >= val ? k - n + 2 : INF);
		if (getmax(l, (l+r)/2) >= val)
			return (getleft(x, val, 2*k+1, l, (l+r)/2));
		if (getmax((l+r)/2, r) >= val)
			return (getleft(x, val, 2*k+2, (l+r)/2, r));
		return (INF);
	}

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    int vl = getleft(x, val, 2*k+1, l, (l+r)/2);
    int vr = getleft(x, val, 2*k+2, (l+r)/2, r);
	if (vl != INF) return (vl);
    if (vr != INF) return (vr);
	return (INF);
}

};

int	main(void)
{
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	SegmentTree seg(a);
	for (int i = 0; i < q; i++)
	{
		int t, x, v;
		cin >> t >> x >> v;
		if (t == 1) seg.update(x - 1, v);
		else if (t == 2) cout << seg.getmax(x - 1, v) << endl;
		else 
		{
			int ans = seg.getleft(x - 1, v);
			cout << ((ans == INF) ? n + 1 : ans) << endl;
		}
	}
	return (0);
}


Measured memory_bytes: 6976
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

    map<ll, int> mp;
    for(int i = 0; i < N; i++) {
        mp[i - a[i]]++;
    }

    ll ans = 0;
    for(int i = 0; i < N; i++) {
        ll x = a[i] + i;
        ans += mp[x];
        mp[i - a[i]]--;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  int n,x,y;
  cin >> n >> x >> y;

  int ans[n];
  rep(i,n) ans[i] = 0;
  for(int i=1;i<n;i++){
    for(int j=i+1;j<=n;j++){
      //      cout << i << "," << j << endl;
      if(i<=x && j<=x){
	//cout << "A:" << j-i << endl;
	ans[j-i]++;
      }
      if(i<=x && x<j && j<=y){
	if(j-i < x-i+1+y-j){
	  ans[j-i]++;
	  //cout << "B" << j-i << endl;
	}
	else{
	  ans[x-i+1+y-j]++;
	  //cout << "B" << x-i+1+y-j << endl;
	}
      }
      if(i<=x && y < j){
	//cout << "C" << endl;
	ans[x-i+1+j-y]++;
      }
      if(x < i && j <= y){
	//cout << "D" << endl;
	if(j-i < i-x+1+y-j){
	  ans[j-i]++;
	}
	else ans[i-x+1+y-j]++;
      }
      if(x < i && i <= y && y < j){
	if(j-i < i-x+1+j-y)ans[j-i]++;
	else ans[i-x+1+j-y]++;
      }
      if(y < i)ans[j-i]++;
    }
  }

  rep(i,n-1)cout << ans[i+1] << endl;
  return 0;
}


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

using namespace std;

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

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

  sort(A, A + N);

  int remaining = x;
  int answer = 0;
  for (int i = 0; i < N; i++) {
    if (remaining < 0) {
      break;
    }

    int a = A[i];

    if (a <= remaining) {
      answer += 1;
    };

    remaining -= a;
  }

  if (remaining > 0) {
    answer -= 1;
  }

  cout << answer << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  long long a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0){
    printf("Zero\n");
  }else if (a > 0 && b > 0){
    printf("Positive\n");
  }else{
    long long t = b - a;
    if (t%2 == 0){
      printf("Negative\n");
    }else{
      printf("Positive\n");
    }
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1e9 + 7;
int dp1[3001][2];
int dp2[3001][2];
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    
    dp1[0][0] = 0;
    dp1[0][1] = 1;
    for (int i = 1; i <= n; ++i) {
        dp1[i][0] = 1;
        dp1[i][1] = 0;
    }
    
    for (int it = 1; it <= m; ++it) {
        for (int i = 0; i <= n; ++i) {
            if (i > 0) {
                dp2[i][0] += dp1[i - 1][0];
                dp2[i][0] %= mod;
            
                dp2[i][1] += dp1[i - 1][1];
                dp2[i][1] %= mod;
            
                dp2[i][1] += dp1[i][1];
                dp2[i][1] %= mod;
            }
            if (i > 1) {
                dp2[i][0] += dp1[i][0];
                dp2[i][0] %= mod;
            }
            if (0 < i && i < n) {
                dp2[i][0] += dp1[i + 1][0];
                dp2[i][0] %= mod;
            }
            if (i < n) {
                dp2[i][1] += dp1[i + 1][1];
                dp2[i][1] %= mod;
                
                dp2[i][0] += dp1[i][0];
                dp2[i][0] %= mod;
            
                dp2[i][1] += dp1[i][1];
                dp2[i][1] %= mod;
            }
        }
        dp2[0][1] += dp1[1][0];
        dp2[0][1] %= mod;
        
        dp2[1][1] += dp1[1][0];
        dp2[1][1] %= mod;
        for (int i = 0; i <= n; ++i) {
            dp1[i][0] = dp2[i][0];
            dp1[i][1] = dp2[i][1];
            
            dp2[i][0] = 0;
            dp2[i][1] = 0;
        }
    }
    
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        ans += dp1[i][1];
        ans %= mod;
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main()
{
    int n, m;
    set<int> d;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> m;
        d.insert(m);
    }
    cout << d.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a * b % 2 == 1) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	lli h, a;
	cin>>h>>a;
	if(h%a!= 0) cout<<((h/a)+1)<<"\n";
	else cout<<(h/a)<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin >> x;
    if (x<1200)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
    
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int t[] = { 0, 6000, 4000, 3000, 2000 }, a, b;
	for (int i = 0; i < 4; ++i) {
		cin >> a >> b;
		cout << t[a] * b << endl;
	}

	return 0;
}

Measured memory_bytes: 3124
import Control.Monad

readInt = readLn :: IO Int
readInts = map read . words <$> getLine :: IO [Int]
readNInts = flip replicateM readInts

main :: IO ()
main = do
    [n, h, w] <- readInts
    ab <- readNInts n
    print . length $ filter (\[x, y] -> h <= x && w <= y) ab

Measured memory_bytes: 2300
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int N = 18;
const int MAX_N = 301;

int value[N];
int dp[N][MAX_N];

void make_Table() {
  for(int i = 1 ; i < N ; i++) {
    value[i] = i * i;
  }
}

void solve() {
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  
  for(int i = 1 ; i < N ; i++) {
    for(int j = 0 ; j < MAX_N ; j++) {
      int prevalue = j - value[i];
      
      dp[i][j] = dp[i-1][j];
      if(prevalue >= 0) dp[i][j] += dp[i][prevalue];
    }
  }
}

int main() {
  int n;
  make_Table();
  solve();
  while(cin >> n, n) {
    cout << dp[N-1][n] << endl;
  }
  return 0;
}

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

#define int long long
typedef pair<int, int> P;

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int H, W;
string S[12];
bool box[12];

void check(vector<int> vec) {
    bool ikkai = H % 2 == 1;
    bool used[12] = {};
    for (int i = 0; i < H; i++) {
        if (used[i]) continue;
        for (int j = i + 1; j < H; j++) {
            if (used[j]) continue;
            for (int k = 0; k + 1 < W; k += 2) {
                if (S[i][vec[k]] != S[j][vec[k + 1]] || S[i][vec[k + 1]] != S[j][vec[k]]) goto check1;
            }
            if (W % 2 == 1) {
                if (S[i][vec[W - 1]] != S[j][vec[W - 1]]) goto check1;
            }
            used[i] = true;
            used[j] = true;
            goto check2;
        check1:;
        }
        if (!ikkai) return;
        for (int k = 0; k + 1 < W; k += 2) {
            if (S[i][vec[k]] != S[i][vec[k + 1]]) return;
        }
        used[i] = true;
        ikkai = false;
    check2:;
    }
    cout << "YES" << endl;
    exit(0);
}

void dfs(vector<int> saki, bool box[12]) {
    if (saki.size() == 0 && W%2==1) {
        for (int i = 0; i < W; i++) {
            bool newbox[12] = {};
            newbox[i] = true;
            vector<int> a;
            a.push_back(i);
            dfs(a, newbox);
        }
        return;
    }
    if (saki.size() == W && W%2==1) {
        vector<int> a;
        for (int i = 1; i < W; i++)a.push_back(saki[i]);
        a.push_back(saki[0]);
        check(a);
        return;
    }
    if (saki.size() == W) {
        check(saki);
        return;
    }
    if (saki.size() == W - 1) {
        for (int i = 0; i < W; i++) {
            if (!box[i]) {
                saki.push_back(i);
                check(saki);
                return;
            }
        }
    }
    for (int i = 0; i < W; i++) {
        if (!box[i]) {
            saki.push_back(i);
            for (int j = i + 1; j < W; j++) {
                if (!box[j]) {
                    bool newbox[12];
                    for (int k = 0; k < W; k++) {
                        newbox[k] = box[k];
                    }
                    newbox[i] = true;
                    newbox[j] = true;
                    saki.push_back(j);
                    dfs(saki, newbox);
                    saki.pop_back();
                }
            }
            return;
        }
    }

}

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }
    vector<int> emp;
    dfs(emp, box);
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
        int n,i;
        scanf("%d",&n);
        char s[n],t[n];

        scanf("%s%s",s,t);


        for(i=0;i<n;i++){
                printf("%c%c",s[i],t[i]);
        }
        return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
	int a,b;
    scanf("%d" "%d",&a,&b);
	
		
		if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0 ){
			printf("Possible");
			printf("\n");
		}else{
			printf("Impossible");
			printf("\n");						
		}

	return 0;
}    



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
  int[] doIt(String data){
    int time = -1;
    int lpmax = data.length();
    int[] res = new int[lpmax];
    
    for(int i = 0;i<lpmax;i++){
      switch(data.charAt(i)){
        case 'c':
          time = 0;
          res[i] = time++;
          break;
        case '.':
          res[i] = time;
          if(time != -1) time++;
          break;
      }
    }
    return res;
  }

  void dispLine(int[] data){
    int lpmax = data.length;
    for(int i = 0;i<lpmax;i++){
      System.out.print(data[i]);
      if(i != lpmax - 1) System.out.print(" ");
    }
    System.out.println();
  }
  
  public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    int h = sc.nextInt(),w = sc.nextInt();
	    int[][] res = new int[h][w];
	    Main ma = new Main();

	    for(int i = 0;i<h;i++) res[i] = ma.doIt(sc.next());
	    for(int i = 0;i<h;i++) ma.dispLine(res[i]);
	    sc.close();
	  }
}

Measured memory_bytes: 34884
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    long long a[n];
    long long sum = 0;
    for (long long i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    long long b[100001] = {0};
    for (long long i = 0; i < n; i++)
    {
        b[a[i]]++;
    }
    long long q;
    cin >> q;
    while (q--)
    {
        long long x, y;
        cin >> x >> y;
        sum = sum - b[x] * x + b[x] * y;
        b[y] += b[x];
        b[x] = 0;
        if (q != 0)
            cout << sum << endl;
        else
            cout << sum;
    }
}

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

int main () {
    
    int H, W;
    for (int i = 0;; i++) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll N;
ll ans=0;
ll time10[10];

void check(ll x){//3,5,7が1回ずつ出ているか
	ll tmp=x;
	bool three=false,five=false,seven=false;
	for(int i=9;i>=0;i--){
		ll tp=tmp/time10[i];
		
		if(tp==3) three=true;
		else if(tp==5) five=true;
		else if(tp==7) seven=true;

		tmp%=time10[i];
	}
	if(three && five && seven) ans++;
}

void rec(ll x){//xの末尾に3,5,7をつける
	ll nw=x*10+3;
	//cout<<nw<<endl;
	if(nw<=N){
		check(nw);
		rec(nw);
	}

	nw=x*10+5;
	//cout<<nw<<endl;
	if(nw<=N){
		check(nw);
		rec(nw);
	}

	nw=x*10+7;
	//cout<<nw<<endl;
	if(nw<=N){
		check(nw);
		rec(nw);
	}
}

//a,b x
int main(){
	cin>>N;
	time10[0]=1;
	rep1(i,9) time10[i]=time10[i-1]*10;

	rec(0);
	cout<<ans;
}

Measured memory_bytes: 256
# ABC162
n,k=map(int,input().split())
"""
3 2
->9
3 200
->10813692
100000 100000
->742202979
"""
ans = 0
xl=[0]*(k+1)
MOD = int(1e+9 + 7)

for x in range(k,0,-1):
    xl[x] = pow(k // x,n, MOD) 

for x in range(k,0,-1):
    xl[x] -= sum([xl[i*x] for i in range(2,1 + k//x)])

ans = 0
for i in range(k+1):
    ans += i * xl[i]

print(ans % MOD)


Measured memory_bytes: 12072
n=int(input())
p=[]
for _ in range(n):
    p.append(list(map(int,input().split())))
dp=[[0,0,0] for _ in range(n)]
dp[0][0]=p[0][0]
dp[0][1]=p[0][1]
dp[0][2]=p[0][2]
for i in range(1,n):
    dp[i][0]=p[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=p[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=p[i][2]+max(dp[i-1][0],dp[i-1][1])
    
print(max(dp[-1]))
    

Measured memory_bytes: 50232
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve2(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve2(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int[] stones = new int[n];
        for (int i = 0; i < n; i++) {
            stones[i] = scanner.nextInt();
        }

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 0; i < n; i++) {
            if (i+1 < n) {
                dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(stones[i+1] - stones[i]));
            }
            if (i+2 < n) {
                dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(stones[i+2] - stones[i]));
            }
        }

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

Measured memory_bytes: 50524
#include <stdio.h>
#include <ctype.h>
#define SIZE 200

void push(int);
int pop(void);

int top = 0;
int s[SIZE];

int main(void){
	int c, a, op1, op2;
	while((c = getchar()) != EOF){
		if(isdigit(c)){
			ungetc(c, stdin);
			scanf("%d", &a);
			push(a);
		}else{
			switch(c){
			case '+':
					op2 = pop();
					op1 = pop();
					push(op1 + op2);
					break;
			case '*':
					op2 = pop();
					op1 = pop();
					push(op1 * op2);
					break;
			case '-':
					op2 = pop();
					op1 = pop();
					push(op1 - op2);
					break;
			case '\n':
					printf("%d\n", pop());
					break;
			case ' ':
					break;
			default:
					break;
			}
		}
	}

	return 0;
}

void push(int x){
	if(top < SIZE){
		top++;
		s[top] = x;
	}else{
		printf("error: Stack full\n");
	}
}

int pop(void){
	if(top > 0){
		top--;
		return s[top + 1];
	}else{
		printf("error: Stack empty\n");
	}
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
unsigned long long n,m,mod=(long long)(1e9)+7;
long long dp[1001][1001];
int main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
cin>>n>>m;
char ch;
for(unsigned long long i=0;i<n;i++){
    for(unsigned long long j=0;j<m;j++){
        cin>>ch;
        if(ch=='#') dp[i+1][j+1]=-1;
    }
}
for(unsigned long long i=1;i<=n;i++){
    for(unsigned long long j=1;j<=m;j++){
        if(i==1&&j==1) {
            dp[i][j]=1;
            continue;
        }
        if(dp[i][j]==-1) continue;
        unsigned long long fst=dp[i][j-1],snd=dp[i-1][j];
        if(fst==-1) fst=0;
        if(snd==-1) snd=0;
        dp[i][j]=(fst+snd)%mod;
    }
}
cout<<dp[n][m]<<'\n';
return 0;
}


Measured memory_bytes: 11444
#include <stdio.h>
int main(void){
    int N,Y;
    scanf("%d%d", &N, &Y);
    Y /= 1000;
    for (int i = 0; i <= N; i++) {
        int x = (Y - N - 4 * i) / 9;
        if ((Y - N == 9 * x + 4 * i) && (0 <= x) && (x <= N)){
            int z = N - x - i;
            if (0 <= z && z <= N) {
                printf("%d %d %d\n", x, i, z);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  int x,y,z,tmp;

  scanf("%d%d",&x,&y);

  if(x<y){
    tmp=x;
    x=y;
    y=tmp;
  }

  while(y>0){
    z=x%y;
    x=y;
    y=z;
  }

  printf("%d\n",x);
  return 0;
}

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

namespace B.Foods_Loved_by_Everyone
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(null).Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            int ans = 0;

            var foodsList = new List<List<int>>();

            for (int n = 0; n < N; n++)
            {
                var tmpList = Console.ReadLine().Split(null).Select(int.Parse).ToList();
                tmpList.Remove(tmpList.First());
                foodsList.Add(tmpList);
            }

            for (int m = 1; m <= M; m++)
            {
                if (foodsList.SelectMany(x => x).Count(x => x == m) == N)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 13408
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 998244353;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e3 + 5;
ll vis[N],res[N];
int dp[N];

void add(int& x, int y){
	x += y;
	if(x>=M) x -= M;
}

int solve() 
{
  //happy coding


	int n,m;
	cin>>n>>m;

	std::vector<int> a(n);

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

	ll inv2 = (M+1)/2;

	dp[0] = 1;

	for(int i=0;i<n;i++)dp[0] = dp[0]*2%M;

	/*for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}cout<<endl;*/

	for(int i=0;i<n;++i){
		for(int j=m;j>=a[i];--j){
			//cout<<dp[j-a[i]]<<endl;
			add(dp[j],dp[j-a[i]]*inv2 % M);
		}
	}

	/*for(int i=0;i<n;i++){
		cout<<dp[i]<<" ";
	}cout<<endl;*/

	cout<<dp[m]<<endl;
  

  
  return 0;
}
int main(){
  int test = 1;
  //scanf("%d", &test);
  while (test--)solve();return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstring>
using namespace std;
int map[110][110];
int com[110][110];
int lx,ly,sx,sy,gx,gy;
int py[4]={1,0,-1,0};
int px[4]={0,1,0,-1};
int fl;
int mei(int zx,int zy ,int cei[][110])
{
	int i;
	if(zx==gx && zy==gy)
	{
		fl=1;
		return 0;
	}
	cei[zy][zx]=1;
	for(i=0;i<4;i++)
	{
		if(cei[zy+py[i]][zx+px[i]]==0 && map[sy][sx]==map[zy+py[i]][zx+px[i]])
		{
			mei(zx+px[i],zy+py[i],cei);
			if(fl) return 0;
		}
	}
	return 0;
}
int main()
{
	int n,col,muk,vx,vy;
	int i,j,t;
	while(cin >> lx >> ly, lx!=0 && ly!=0)
	{
		fl=0;
		cin >> sx >> sy >> gx >> gy >> n;
		memset(map,0,sizeof(map));
		memset(com,0,sizeof(com));
		for(i=0;i<n;i++)
		{
			cin >> col >> muk >> vx >> vy;
			if(muk==0)
			{
				for(j=vy;j<2+vy;j++)
				{
					for(t=vx;t<4+vx;t++)
					{
						map[j][t]=col;
					}
				}
			}
			else
			{
				for(j=vy;j<4+vy;j++)
				{
					for(t=vx;t<2+vx;t++)
					{
						map[j][t]=col;
					}
				}
			}
		}
		if(map[sy][sx]!=map[gy][gx])
		{
			cout << "NG" << endl;
			continue;
		}
		mei(sx,sy,com);
		if(fl) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using ll = long long;
class UnionFind {
private:
  vector<long long> par;  // 親ノード
  vector<long long> rank; // 各ノードのランク
  long long n;            // 全体のサイズ
public:
  // コンストラクタ
  UnionFind(long long sz_) : n(sz_), par(sz_), rank(sz_, 1) {
    for (long long i = 0; i < sz_; i++) {
      par[i] = i;
    }
  }

  // メンバ関数
  long long root(long long x) {
    if (par[x] == x) {
      return x;
    } else {
      par[x] = root(par[x]);
      return par[x];
    }
  }

  void unite(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) {
      return;
    }
    if (rank[x] < rank[y]) {
      swap(x, y);
    }
    rank[x] += rank[y];
    par[y] = x;
  }

  bool isSame(long long x, long long y) { return root(x) == root(y); }

  long long siz(long long x) { return rank[root(x)]; }
};
int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    uf.unite(a - 1, b - 1);
  }
  ll ans = 0;
  REP(i, n) { ans = max(ans, uf.siz(i)); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6424
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s = s_input()

    print(s+ 'es' if s[-1] == 's' else s + 's')

if __name__ == '__main__':
    main()


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

int main()
{
	int n;
	cin>>n;
	string a[n+1];
	
	map<string,int> mp;
	
	for(int i=1; i<=n; i++)	cin>>a[i];
	
	for(int i=1; i<=n; i++)
	{
		if(mp.count(a[i])==0)
			mp[a[i]]=1;
		else
			mp[a[i]]++;
	}
	
	string s[n+1];
	int maxv=0;
	
	for(int i=1; i<=n; i++)
	{
		if(mp[a[i]]>maxv)
			maxv=mp[a[i]];
	}
	
	int j=0;
	for(int i=1; i<=n; i++)
	{
		if(mp[a[i]]==maxv)
			s[j++]=a[i];
	}
	
	sort(s,s+j);
	
	for(int i=0; i<j; i++)
	{
		if(s[i]==s[i+1])
			continue;
		
		cout<<s[i]<< endl;
	}
		
	return 0;
	
}

Measured memory_bytes: 28288
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct edge { int to, cost; edge(int to, int cost) : to(to), cost(cost) {} edge() {} };
typedef vector<edge> edges;

edges G[3010];
int d[3010];

void dijkstra(int s)
{
    priority_queue<pii, vpii, greater<pii> > pq;
    d[s] = 0;
    pq.push(pii(0, s));
    
    while (pq.size()) {
        pii p = pq.top(); pq.pop();

        int v = p.scd;

        if (d[v] < p.fst) continue;

        rep(i, G[v].size()) {
            edge &e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(pii(d[e.to], e.to));
            }
        }
    }
}

signed main()
{
    omajinai;

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

    fill_n(d, N + 1, inf);

    rep(i, M) {
        int a, b, l; cin >> a >> b >> l;
        a--, b--;

        G[a].PB(edge(b, l));
        G[b].PB(edge(a, l));
    }

    rep(i, K) {
        int s; cin >> s;
        s--;
        dijkstra(s);
    }

    double ma = -1.0;

    rep(i, N) {
        rep(j, G[i].size()) {
            edge &e = G[i][j];
            ma = max(ma, (d[i] + d[e.to] + e.cost) / 2.0);
        }
    }

    cout << round(ma) << endl;
}

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

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

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , B[MAXN] , ans;

int main() {
    fast_io;

    cin >> n;
    B[1] = INF , B[n + 1] = INF;
    for(ll i = 2 ; i <= n ; i++)    cin >> B[i];

    for(ll i = 1 ; i <= n ; i++)    ans += min(B[i] , B[i + 1]);
    cout << ans << endl;

    return 0;
}
/*

*/


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

int main(){
  long A, B, K;
  cin >> A >> B >> K;
  if(A-K>=0){
    cout << A-K << ' ' << B << endl;
  }else if(B-(K-A)>=0){
    cout << '0' << ' ' << B-(K-A) << endl;
  }else{
    cout << '0' << ' ' << '0' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

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

  rep(i, n) {
    if(a[i]%2==0) {
      if(a[i]%3!=0&&a[i]%5!=0) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }

  cout << "APPROVED" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(int i=p;i<n;++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll N, X;
    cin >> N >> X;

    vector<ll> L(N);
    for (auto& l : L) { cin >> l; }

    ll ans = 1;

    ll D = 0;

    for (const auto& l : L)
    {
        D += l;

        if (D <= X) { ++ans; }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int n, m, res, N = 1e5 + 7;
vector<vector<int>> g(N);
vector<int> h(N);

int dfs(int u) {
    if (h[u]) return h[u];
    h[u] = 1;
    for (auto& v : g[u]) h[u] = max(h[u], 1 + dfs(v));
    return h[u];
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    for (int i = 0; i++ < n;) dfs(i);
    sort(h.begin(), h.end());
    cout << h.back() - 1 << '\n';

    return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{
  gearup;
  int n;string s;
  cin >> n >> s;
  ll res = 0;
  rep(i,n){
    string s1 = s.substr(i);
    string s2 = s.substr(0,i);
    set<char> s3;
    set<char> s4;
    rep(j,s1.size())s3.insert(s1[j]);
    rep(j,s2.size())s4.insert(s2[j]);
    ll ans = 0;
    for(int ch = 'a';ch<='z';ch++){
      if(s3.find(ch) != s3.end() && s4.find(ch) != s4.end())ans++;
    }
    res = max(res,ans);
  }
  out(res);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

x=int(input())

import math
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

SET=set(LIST)
SET.remove(x)
ANS=0
for i in SET:
    y=x//i-1
    if x//y==x%y:
        ANS+=y

print(ANS)

Measured memory_bytes: 3900
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    string s;
    int a = 0, b = 0;
    cin >> s;
    for (char ch : s) {
        if (ch == 'A')
            a++;
        else
            b++;
    }
    if (a > 0 && b > 0)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 3640
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(int i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll n;
	cin>>n;
	long double a[n];
	ll i;
	long double sum=0;
	forin(i,0,n-1)
	{
		long double q;
		cin>>q;
		sum+=(1/q);
	}
	cout<<setprecision(9)<<1/sum<<endl;
}



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

using namespace std;

//#define FILE_IO

typedef long long LL;

const int NMAX = 1e5 + 5;

int N;
int v[3 * NMAX];
LL sumst[3 * NMAX], sumdr[3 * NMAX];
multiset<int> st;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d", &N);
    for(int i = 1; i <= 3 * N; i++) scanf("%d", &v[i]);

    for(int i = 1; i <= 2 * N; i++)
    {
        sumst[i] = sumst[i - 1] + v[i];
        st.insert(v[i]);

        if(i > N)
        {
            sumst[i] -= *(st.begin());
            st.erase(st.begin());
        }
    }

    st.clear();
    for(int i = 3 * N; i > N; i--)
    {
        sumdr[i] = sumdr[i + 1] + v[i];
        st.insert(-v[i]);

        if(i <= 2 * N)
        {
            sumdr[i] += *(st.begin());
            st.erase(st.begin());
        }
    }

    LL ans = -(1LL << 60);
    for(int i = N; i <= 2 * N; i++)
        ans = max(ans, sumst[i] - sumdr[i + 1]);

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 9472
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;
int card[11],n,k,bit=1,ans=0;
string str;
vector<string> V;
vector<int> num;
string IntToString(int n){
	stringstream ss;
	ss<<n;
	return ss.str();
}

int main(){
	while(1){
		cin>>n;
		cin>>k;
		ans=0;
		if(n==0 && k==0)
		break;
		for(int i=0;i<n;i++)
		cin>>card[i];
		V.erase(V.begin(),V.end());
		for(int i=0;i<(1<<n);i++){
			num.erase(num.begin(),num.end());
			int count=0;
			int flag=0;
			for(int j=0;j<n;j++){
				if(i&(1<<j)){
					num.push_back(card[j]);
					count++;
				}
			}
			if(count==k){
				sort(num.begin(),num.end());
				while(1){
					flag=0;
					str="";
					for(int j=0;j<k;j++){
						str+=IntToString(num[j]);
					}
					for(int j=0;j<V.size();j++){
						if(V[j]==str)
						flag=1;
					}
					if(flag==0){
						V.push_back(str);
						ans++;
					}
					if(next_permutation(num.begin(),num.end())==0)
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1396
package main

import "fmt"

func main() {
	var x, y [4]int
	fmt.Scan(&x[0], &y[0], &x[1], &y[1])
	x[2] = y[0] - y[1] + x[1]
	y[2] = -x[0] + x[1] + y[1]
	x[3] = y[1] - y[2] + x[2]
	y[3] = -x[1] + x[2] + y[2]
	fmt.Println(x[2], y[2], x[3], y[3])
}


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

typedef long long ll;

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

  int n;
  cin >> n;

  vector<char> s(n);
  for (int i = 0; i < n; i++){
    cin >> s.at(i);
  }

  char c = '0';
  int num = 0;
  for (int i = 0; i < n; i++){
    if (s.at(i) != c){
      num++;
    }
    c = s.at(i);
  }

  cout << num << endl;

  return 0;
}

Measured memory_bytes: 384