akhauriyash/Code-Regression huggingface dataset:
#include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <time.h>
#define ll long long
#define N 500003
#define M 103
#define db double
#define P putchar
#define G getchar
#define inf 998244353
using namespace std;
char ch;
void read(int &n)
{
    n=0;
    ch=G();
    while((ch<'0' || ch>'9') && ch!='-')ch=G();
    ll w=1;
    if(ch=='-')w=-1,ch=G();
    while('0'<=ch && ch<='9')n=(n<<3)+(n<<1)+ch-'0',ch=G();
    n*=w;
}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
ll abs(ll x){return x<0?-x:x;}
ll sqr(ll x){return x*x;}
void write(ll x){if(x>9) write(x/10);P(x%10+'0');}

int d[N],pos[N],f[N],q,n,m,x,y;

int main()
{
    read(n);read(m);

    pos[0]=m;
    for(int i=1;i<=n;i++)
        read(d[i]),pos[i]=min(pos[i-1],abs(pos[i-1]-d[i]));

    f[n+1]=1;
    for(int i=n;i;i--)
    {
        f[i]=f[i+1];
        if(d[i]<(f[i+1]<<1))f[i]+=d[i];
    }

    read(q);
    for(int i=1;i<=q;i++)
    {
        read(x);
        if(pos[x-1]>=f[x+1])puts("YES");
            else puts("NO");
    }

    return 0;
}


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

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int prev_place[200001] = {};
int edges[200001] = {};
int ret[200001] = {};
int main(){
    std::ios::sync_with_stdio(false);
    int n, tmp;
    cin >> n;

    fill(prev_place, prev_place + 200001, -1);
    fill(edges, edges + 200001, -1);
    for(int i=0;i<n;++i)
    {
        cin >> tmp;
        if(prev_place[tmp] != -1)
        {
            if(i - prev_place[tmp] >= 2)
            {
                edges[i] = prev_place[tmp];
            }
        }
        prev_place[tmp] = i;        
    }
    
    ret[0] = 1;

    for(int i=1;i<n;++i)
    {
        ret[i] = ret[i-1];
        if(edges[i] != -1)
        {
            ret[i] += ret[edges[i]];
        }
        ret[i] %= 1000000007;
    }
    cout << ret[n-1] << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 610000
ll n,m,k;
double dp[400][400][400];
ll a[N];
ll b[N];
int mp[2000][2000];
bool visited[4000][4000];
ll mem[4000][4000];
ll dfs(int x,int y){
    if(visited[x][y]){
        return mem[x][y];
    }
    visited[x][y]=1;
    if(x>y||y<x)return (ll)0;
    if((n-(y-x))%2){
        ll aa=dfs(x+1,y)+a[x],bb=dfs(x,y-1)+a[y];
        aa=max(aa,bb);
        return mem[x][y]=aa;
    }
    else{
        ll aa=dfs(x+1,y)-a[x],bb=dfs(x,y-1)-a[y];
        aa=min(aa,bb);
        return mem[x][y]=aa;
    }
}
int main(){
    n=in();
    rep(i,n)a[i]=lin();
    cout<<dfs(0,n-1);
    return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << endl;
    else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3624
def main():
    n = int(input())
    dices=[]
    same = 0
    for _ in range(n):
        dices.append(list(map(int, input().split())))

    for i in range(n-1):
        for j in range(i+1,n):
            same += check_dice(dices[i], dices[j])
        if same >= 1:
            print('No')
            break

    if same == 0:
        print('Yes')


def check_dice(f, s):
    yes = 0
    for _ in range(4):
        s[0],s[2],s[5],s[3] = s[2],s[5],s[3],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    for _ in range(4):
        s[0],s[1],s[5],s[4] = s[1],s[5],s[4],s[0]
        for _ in range(4):
            s[1],s[2],s[4],s[3] = s[2],s[4],s[3],s[1]
            if f == s:
                yes = 1

    return yes

if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
s = input()
ans = [0] * len(s)
i = 0
while i < len(s):
    si = i
    while s[i] == 'R':
        i += 1
    ti = i
    while i < len(s) and s[i] == 'L':
        i += 1
    ri = i
    l = ti - si
    ans[ti - 1] += (l + 1) // 2
    ans[ti] += l // 2
    r = ri - ti
    ans[ti - 1] += r // 2
    ans[ti] += (r + 1) // 2
print(*ans)


Measured memory_bytes: 6400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define maxll(a, b) (a > b ? a : b)

int main() {
  int n;
  cin >> n;
  vector<int> xv(n), yv(n);
  vector<int> hv(n);
  REP(i, n) {
    cin >> xv[i] >> yv[i] >> hv[i];
  }
  int h;
  int tmp;
  bool flag = true;
  int tmpx, tmpy;
  int hoge;
  REP(cx, 101) {
    REP(cy, 101) {
      flag = true;
      REP(i, n) if (hv[i] > 0) tmp = hv[i] + abs(xv[i] - cx) + abs(yv[i] - cy);
      REP(i, n) {
        hoge = tmp - abs(xv[i] - cx) - abs(yv[i] - cy);
        //if (cx == 2 && cy == 2) cout << maxll(hoge, 0) << endl;
        if (hoge < 0) hoge = 0;
        if (hoge != hv[i]) flag = false;
      }
      //if (cx == 2 && cy == 2) cout << tmp;
      if (flag) {
        h = tmp;
        tmpx = cx;
        tmpy = cy;
      }
    }
  }
  cout << tmpx << " " << tmpy << " " << h << endl;

  return 0;
}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    priority_queue<int, vector<int>, greater<int>> num_cnt;
    for (auto p: mp) {
        num_cnt.push(p.second);
    }
    int ans = 0;
    int now_kind = mp.size();
    while (now_kind > k) {
        int t = num_cnt.top(); num_cnt.pop();
        ans += t;
        now_kind--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11516
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n,m;
  cin>>n>>m;
  int s=0;
  rep(i,m){
    int a;
    cin>>a;
    s+=a;
  }
  if(n-s<0){
    cout<<-1<<endl;
  }
  else{
    cout<<n-s<<endl;
  }
  return(0);
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	int flag = 0;
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		if (a == 1) {
			if (mp[b] == 1)flag = 1;
			mp[b] = 1;
		}
		else if (b == n) {
			if (mp[a] == 1)flag = 1;
			mp[a] = 1;
		}
	}
	if (flag)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = (2 << 16), LG = 18, INF = 1e9 * 1e6;
ll n, m;
ll grid[LG][LG], inter[SZ], dp[SZ], mx[SZ];

int main() {
	fastInp;

	cin >> n >> m;

	for (int i = 0; i < LG; i++) {
		for (int j = 0; j < LG; j++) grid[i][j] = INF;
	}

	ll sum = 0;
	for (int i = 0; i < m; i++) {
		ll u, v, c;
		cin >> u >> v >> c;
		sum += c;
		u--; v--;
		grid[u][v] = c;
		grid[v][u] = c;
	}

	ll pw = (1ll << n);
	for (int i = 0; i < pw; i++) {
		ll cur = 0;
		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (((i >> k) & 1) && ((i >> j) & 1) && grid[k][j] != INF) {
					cur += grid[k][j];
				}
			}
		}

		inter[i] = cur;
	}

	for (int i = 0; i < pw; i++) {
		for (int j = 0; j < LG; j++) dp[i] = -INF;
	}

	for (int i = 0; i < LG; i++) dp[(1ll << i)] = 0;
	dp[1] = 0;
	for (int i = 2; i < pw; i++) {
		for (int j = 0; j < LG; j++) {
			for (int k = 0; k < LG; k++) {
				if (j != k && (i & (1ll << k)) && (i & (1ll << j)) && grid[j][k] != INF) {
					ll msk = i ^ (1ll << j);
					dp[i] = max(dp[i], dp[msk] + grid[k][j]);
				}
			}
		}
	}

	ll ans = -INF;

	for (int i = 0; i < pw; i++) {
		if (!(i & 1)) continue;
		if (!((i >> (n - 1)) & 1)) continue;
		for (int sub = i; true; sub = ((sub - 1) & i)) {
			for (int j = 0; j < LG; j++) {
				if ((i >> j) & 1) {
					ll msk = (i ^ sub);
					if ((msk & 1) && ((msk >> (n - 1)) & 1)) dp[i] = max(dp[i], dp[msk] + inter[sub | (1ll << j)]);
				}
			}
			if (sub == 0) break;
		}
		ans = max(ans, dp[i]);
	}

	cout << sum - ans;

	return 0;
}

Measured memory_bytes: 4184
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin>>x;
    cout<<1-x<<endl;
    return 0;
}


Measured memory_bytes: 3608
S_hint = input()
T = input()


def isEqual(s1, s2):
    for i in range(len(s1)):
        if s1[i] != '?' and s1[i] != s2[i]:
            return False

    return True


kouhos = []
for i in range(len(S_hint)-len(T)+1):
    if isEqual(S_hint[i:i+len(T)], T):
        kouho = S_hint[0:i] + T + S_hint[i+len(T):]
        kouho = kouho.replace('?', 'a')
        kouhos.append(kouho)

if len(kouhos) == 0:
    print('UNRESTORABLE')
else:
    kouhos.sort()
    print(kouhos[0])


Measured memory_bytes: 3064
n,m = list(map(int, input("").split()))
h = list(map(int, input("").split()))

p = [1] * n

for i in range(m):
  a,b = map(int, input().split())
  if h[a-1] <= h[b-1]:
    p[a-1]=0

  if h[a-1] >= h[b-1]:
    p[b-1]=0

print(sum(p))

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

public class Main {

	int[] nums, c;
	int[][] as;
	char[] colors;

	//
	boolean dfs(int k){
		if(k==9){
			// 色が違ったらfalse
			for(int i=0;i<3;i++)if(colors[as[i][0]]!=colors[as[i][1]]||colors[as[i][1]]!=colors[as[i][2]])return false;
			for(int i=0;i<3;i++){
				int[] t = new int[3];
				// 数値の比較準備
				for(int j=0;j<3;j++)t[j]=nums[as[i][j]];
				Arrays.sort(t);
				// 数値が連続、または同一でなかったらfalse
				if(!(t[0]==t[1]&&t[1]==t[2]||t[0]+1==t[1]&&t[1]+1==t[2]))return false;
			}
			return true;
		}
		// 全パターンを生成
		for(int i=0;i<3;i++){
			if(c[i]==3)continue;
			as[i][c[i]] = k;
			c[i]++;
			if(dfs(k+1))return true;
			c[i]--;
		}
		return false;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int handNum = sc.nextInt();
		while(handNum--!=0){
			nums = new int[9]; colors = new char[9]; c = new int[3];
			for(int i=0;i<9;i++)nums[i]=sc.nextInt();
			for(int i=0;i<9;i++)colors[i]=sc.next().charAt(0);
			as = new int[3][3];
			System.out.println(dfs(0)?1:0);
		}

		sc.close();
	}

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


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

int main()
{
    string S;
    cin >> S;

    if (S == "AAA" || S == "BBB")
    {
        cout << "No" << endl;
    }

    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

//6 5 6 5

ll N, ans;

int main() {
  scanf("%lld", &N);
   
  ans += N / 11 * 2;
  ll r = N % 11;
  if (r > 0) {
    if (r <= 6) ans++;
    else ans += 2;
  }
  
  printf("%lld", ans);
  return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;


int main()
{
	int m, d; cin >> m >> d;
	int cnt = 0;
	rep(i, d+1
       ) {
		int d1 = i % 10, d10 = i / 10;
		if (d1 >= 2 && d10 >= 2&&d1*d10<=m) {
			cnt++;
		}
	}
	cout << cnt << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string bans(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x,a,b;cin>>x>>a>>b;
  int ans=(x-a)%b;
  cout << ans << endl;
  return 0;
}


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

const int N = 710;

int n, m;
bool G[N][N];
int cnt[2], col[N];

bool dfs(int u, int c)
{
    col[u] = c;
    ++cnt[c];
    for (int v = 1; v <= n; ++v) if (!G[u][v] && u != v) {
        if (col[v] == -1) { if (!dfs(v, c^1)) return false; }
        else if (col[v] == c) return false;
    }
    return true;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u][v] = G[v][u] = true;
    }
    for (int i = 1; i <= n; ++i)
        col[i] = -1;
    set<int> dp;
    dp.insert(0);
    for (int i = 1; i <= n; ++i) {
        if (col[i] == -1) {
            cnt[0] = cnt[1] = 0;
            if (!dfs(i, 0)) {
                printf("-1\n");
                return 0;
            }
            set<int> ndp;
            for (auto x : dp) {
                ndp.insert(x + cnt[0]);
                ndp.insert(x + cnt[1]);
            }
            dp = ndp;
        }
    }
    int ans = 1e9;
    for (auto x : dp) {
        int y = n-x;
        ans = min(ans, x*(x-1)/2 + y*(y-1)/2);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
int main()
{
	string s;
	cin >> s;
	int a[27] = {0};
	for(int i = 0 ; i < (int)s.size() ; i++){
		a[s[i] - 'a']++;
	}
	for(int i = 0 ; i <= 25 ; i++){
			if(a[i] == 0){
				cout << char(i + 'a') << endl;
				return 0;
			}
	}
	cout << "None" << endl;
	return 0;
} 




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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
  int64_t n, a, b, c, d;
  cin >> n;
  a=n/15;
  b=n/3;
  c=n/5;
  d=(n*(n+1)/2)+(15*a*(a+1)/2)-(3*b*(b+1)/2)-(5*c*(c+1)/2);
  cout <<d<<endl;
  return 0;
}

Measured memory_bytes: 3632
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
template <typename T>
using Vec3 = vector<Vec2<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repe(i, n) REPN(i, 0, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define reper(i, n) REPNR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

Vec2<ll> memo(3001, Vec(3001, -LINF));
Vec a;

ll f(ll l, ll r){
	if(r-l == 0) return memo[l][r] = 0;
	if(r-l == 0) return memo[l][r] = a[l];
	if(memo[l][r] != -LINF) return memo[l][r];
	return memo[l][r] = max(a[l]-f(l+1, r), a[r-1]-f(l, r-1));
}

int main(void){
	ll n;
	cin >> n;
	a.resize(n);
	rep(i, n) cin >> a[i];
	co(f(0, n));

	return 0;
}


Measured memory_bytes: 70912
s=input()

n=len(s)

C=[0]*n

cnt_r=0
cnt_l=0


def calc(tmp_r,tmp_l):
    n=cnt_r+cnt_l
        
    if n%2==0:
        C[tmp_r]=n//2
        C[tmp_l]=n//2
    else:
        if cnt_r>cnt_l:
            if cnt_r%2==0:
                C[tmp_r]=n//2
                C[tmp_l]=n//2+1
            else:
                C[tmp_r]=n//2+1
                C[tmp_l]=n//2
        else:
            if cnt_l%2==0:
                C[tmp_r]=n//2+1
                C[tmp_l]=n//2
            else:
                C[tmp_r]=n//2
                C[tmp_l]=n//2+1

for i in range(n-1):
    if s[i]=='R' and s[i+1]=='R':
        cnt_r+=1
    
    if s[i]=='R' and s[i+1]=='L':
        cnt_r+=1
        tmp_r=i
        tmp_l=i+1
        
    if s[i]=='L' and s[i+1]=='R':
        cnt_l+=1
        if i==n-2:
            cnt_l+=1
            
        calc(tmp_r,tmp_l)
        
        cnt_r=0
        cnt_l=0
    if s[i]=='L' and s[i+1]=='L':
        cnt_l+=1
    
    if i==n-2:
        cnt_l+=1
        calc(tmp_r,tmp_l)
        

print(*C)

Measured memory_bytes: 6400
while True:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break
    for n in range(a):
        if n == 0 or n == a - 1:
            print("#" * b)
        else:
            print("#" + "." * (b - 2) + "#")
    print("")


Measured memory_bytes: 5612
#include <stdio.h>
#include <string.h>
 
int main(void) {
    int N;
    char shop_name[100];
    char old_board[200];
    int cut_i,cut_j,cut_k;
    int count;
    int board_num;
    int len;
    int shop_len;
    int hantei1,hantei2;

    scanf("%d",&N);
    scanf("%s",shop_name);
    shop_len=strlen(shop_name);
    count=0;

    for(board_num=0;board_num<N;board_num++) {

        scanf("%s",old_board);

        len=strlen(old_board);
        hantei1=0;

        for(cut_i=0;cut_i<len;cut_i++) {
            for(cut_j=1;cut_j<len;cut_j++) {
                if(cut_i+cut_j*(shop_len-1)>=len)break;

                hantei2=1;

                for(cut_k=0;cut_k<shop_len && hantei2;cut_k++) {
                    if(old_board[cut_i+cut_j*cut_k]!=shop_name[cut_k])hantei2=0;
                }

                if(hantei2)hantei1=1;
            }
        }
        if(hantei1)count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int csum = 0, ans = 0;
	int N, P;
	string S;
	vector<int> con;
	
	P = 2019;
	cin>>S;
	
	N = S.size();

	if(10%P){
		con.resize(P);
	
		con[0] = 1;
	
		for(int i = S.size()-1, ten = 1 % P; i >= 0; i--){
			csum = csum + ten * (S[i] - '0') % P;
			csum %= P;
			
			ans += con[csum];
			
			con[csum]++;
			ten *= 10;
			ten %= P;
		}
	} else{
		for(int i = 0; i < S.size(); i++){
			if((S[i] - '0') % P == 0) {
				ans += i + 1;
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3748
/*! if g++ -g alds_1_7_a.cpp -o alds_1_7_a.out; then ./alds_1_7_a.out < alds_1_7_a.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

vector<vector<int> > g;
vector<bool> is_child(0);
vector<int> parent(0);
int root_id;
vector<int> depth(0);

void search_child(int n){
  vector<int>& children = g[n];
  for (size_t i = 0; i < children.size(); i++) {
    int child = children[i];
    is_child[child] = true;
    parent[child] = n;
    search_child(child);
  }
}
void calc_depth(int n, int d){
  //cout << "n: " << n << ",\t d: " << d << endl;
  vector<int>& children = g[n];
  depth[n] = d;
  for (size_t i = 0; i < children.size(); i++) {
    calc_depth(children[i], d+1);
  }
}

int main(int argc, char *argv[]){
  size_t n;
  cin >> n;
  g.resize(n);
  for (size_t i = 0; i < n; i++) {
    int id, k, buf;
    cin >> id >> k;
    g[id].resize(k);
    for (size_t j = 0; j < k; j++) {
      cin >> g[id][j];
    }
  }
  is_child.resize(n, false);
  parent.resize(n, -1);
  depth.resize(n, 0);
  for (size_t i = 0; i < n; i++) {
    if(is_child[i]) continue;
    search_child(i);    
  }
  for (size_t i = 0; i < n; i++) {
    if(!is_child[i]) {
      root_id = i;
      break;
    }
  }
  calc_depth(root_id, 0);
  for (int i = 0; i < n; i++) {
    printf("node %d: parent = %d, depth = %d, %s, [",
           i, parent[i], depth[i],
           !is_child[i] ? "root" : (g[i].size() > 0 ? "internal node" : "leaf"));
    for (int j = 0; j < (int)g[i].size()-1; j++) {
      cout << g[i][j] << ", ";
    }
    if(g[i].size() > 0) cout << g[i].back();
    cout << "]" << endl;;
  }

  return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	int count_ball[100000];
	for (int i = 0; i < n; ++i)count_ball[i] = 1;
	bool red[100000] = { false };
	red[0] =  true;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		if (red[x]) {
			--count_ball[x];
			++count_ball[y];
			red[y] = true;
			if (count_ball[x] == 0) {
				red[x] = false;
			}
		}
		else {
			--count_ball[x];
			++count_ball[y];
		}
	}
	int ans = 0;
	for (bool i : red) {
		ans += i ? 1 : 0;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	int n,k,ans=1000000000;
	cin>>n>>k;
	vector<int>v(n);	
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end());
	for(int i=k-1;i<n;i++)
	{
		//cout<<v[i]<<" "<<v[i-k+1]<<endl;
		ans=min(ans,v[i]-v[i-k+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
typedef pair<int,int>pii;
#define fi first
#define se second
set<int>node[MN];
map<pii,int>mp;
queue<pii>q;
int n,par[MN];
inline int find(int x){return par[x]==x?x:par[x]=find(par[x]);}
inline void del(int x,int y){
	node[x].erase(y);mp[make_pair(min(x,y),max(x,y))]=0;
}
inline void add(int x,int y){
	if(x>y)swap(x,y);node[x].insert(y);node[y].insert(x);
	if((++mp[make_pair(x,y)])==2)q.push(make_pair(x,y));
}
int main(){
	scanf("%d",&n);
	for(reg int i=1,s,t;i<n+n-1;i++)
		scanf("%d%d",&s,&t),add(s,t);
	for(reg int i=1;i<=n;i++)par[i]=i;
	while(!q.empty()){
		reg pii v=q.front();q.pop();
		reg int x=find(v.fi),y=find(v.se);
		node[x].erase(y);node[y].erase(x);
		if(node[x].size()<node[y].size())swap(x,y);
		for(auto t:node[y])del(t,y),add(t,x);
		par[y]=x;node[y].clear();
	}
	for(reg int i=2;i<=n;i++)
		if(find(i)!=find(1))return 0*puts("NO");
	return 0*puts("YES");
}

Measured memory_bytes: 39296
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main(void){
    string S;
    cin>>S;
    int A;
    for(int i=0;i<3;i++){
        if(S[i]=='1'){
            A++;
        }
    }

    cout<<A<<endl;

}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> ostream& operator << (ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":" ");return r;}
template<typename T> ostream& operator << (ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator << (ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator << (ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}

map<string, vi> book;
string s;
int n;

int main()
{
  while(cin >> s >> n) book[s].pb(n);

  vrep(v, book){
    sort(ALL(v->second));
    cout << v->first << endl;
    cout << v->second << endl;
  }

  return 0;
}

Measured memory_bytes: 1248
def main():
    mod = 998244353
    fact = [1, 1]
    for i in range(2, 400001):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    n, m, k = map(int, input().split())
    ans = 0
    for i in range(k+1):
        ans = (ans+m*pow(m-1, n-i-1, mod)*nCr(n-1, n-i-1)) % mod

    print(ans)


main()


Measured memory_bytes: 96964
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val monstersCount = sc.nextInt()
    val attackCount = sc.nextInt()
    val monsters = Array.fill(monstersCount)(sc.nextInt())

    val attackingMonsters: Array[BigInt] =
      monsters.sorted.reverse.drop(attackCount).map(BigInt(_))

    val ans = attackingMonsters.sum

    println(ans)
  }
}


Measured memory_bytes: 74456
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;

deque <char> d;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	string s;
	cin >> s;
	for(auto to : s) d.pb(to);
	int q;
	cin >> q;
	int ok = 1;
	while(q--)
	{
		int type;
		cin >> type;
		if(type == 1) ok ^= 1;
		else
		{
			int k;
			char c;
			cin >> k >> c;
			if(k == 1) 
			{
				if(ok) d.push_front(c);
				else d.push_back(c);
			}
			else
			{
				if(ok) d.push_back(c);
				else d.push_front(c);
			}
		}
	}
	if(!ok) for(int i = sz(d) - 1; i >= 0; i--) cout << d[i];
	else for(auto to : d) cout << to;
}      

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, k;
  cin >> n >> k;
  vl ways(n+1);
  vii jmps(k);
  rep(i,0,k) cin >> jmps[i].fst >> jmps[i].snd;

  ways[1] = 1;
  ways[2] = -1;
  const ll mod = 998244353;
  rep(i,1,n+1) {
    ways[i] += ways[i-1];
    ways[i] %= mod;
    ways[i] += mod;
    ways[i] %= mod;
    for (auto [a, b]: jmps) {
      if (i+a<=n) {
        ways[i+a] += ways[i];
        ways[i+a] %= mod;
      }
      if (i+b+1<=n) {
        ways[i+b+1] -= ways[i];
        ways[i+b+1] %= mod;
      }
    }
  }


  cout << (ways[n]%mod + mod) % mod << '\n';

}

Measured memory_bytes: 4820
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int c = scanner.nextInt();
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int s = scanner.nextInt();
			int d = scanner.nextInt();
			if ((c | n | m | s | d) == 0)
				break;
			s--;
			d--;
			List<List<Pair>> list = new ArrayList<List<Pair>>();
			for (int i = 0; i < n; i++) {
				list.add(new ArrayList<Pair>());
			}
			for (int i = 0; i < m; i++) {
				int a = scanner.nextInt() - 1;
				int b = scanner.nextInt() - 1;
				int cost = scanner.nextInt();
				list.get(a).add(new Pair(b, cost));
				list.get(b).add(new Pair(a, cost));
			}
			PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
			pq.add(new Pair(s, 0, c));
			int[][] costs = new int[c + 1][n];
			for (int[] a : costs)
				Arrays.fill(a, 1 << 24);
			for (int i = 0; i <= c; i++)
				costs[i][s] = 0;
			boolean[][] b = new boolean[c + 1][n];
			while (!pq.isEmpty()) {
				Pair pair = pq.poll();
				int first = pair.first;
				b[pair.c][first] = true;
				if (costs[pair.c][first] < pair.second)
					continue;
				if (pair.first == d) {
					System.out.println(pair.second);
					break;
				}
				for (Pair p : list.get(first)) {
					if (b[pair.c][p.first] )
						continue;
					if (costs[pair.c][p.first] > p.second + pair.second) {
						costs[pair.c][p.first] = p.second + pair.second;
						pq.add(new Pair(p.first, p.second + pair.second, pair.c));
					}
					if (pair.c > 0) {
						if(b[pair.c-1][p.first])
							continue;
						if (costs[pair.c - 1][p.first] > p.second / 2
								+ pair.second) {
							costs[pair.c - 1][p.first] = p.second / 2
									+ pair.second;
							pq.add(new Pair(p.first,
									p.second / 2 + pair.second, pair.c - 1));
						}
					}
				}
			}

		}
	}

	class Pair implements Comparable<Pair> {
		int first;
		int second;
		int c;

		public Pair(int first, int second) {
			super();
			this.first = first;
			this.second = second;
		}

		public Pair(int first, int second, int c) {
			super();
			this.first = first;
			this.second = second;
			this.c = c;
		}

		@Override
		public int compareTo(Pair o) {
			return this.second - o.second;
		}

	}
}

Measured memory_bytes: 55228
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var hs = new HashSet<string>();
            var p = ReadLine();
            hs.Add(p);
            for (var i = 0; i < N - 1; ++i)
            {
                var s = ReadLine();
                if (p.Last() != s.First() || hs.Contains(s))
                {
                    WriteLine("No");
                    return;
                }
                hs.Add(s);
                p = s;
            }
            WriteLine("Yes");
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28148
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int m=s.length();
    if(k==m||k>m)
        {
            cout<<s<<endl;
            return 0;
        }
        else{
    for(int i=0;i<k;i++)
    {
      cout<<s[i];
    }
    cout<<"..."<<endl;
}
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int l[12];
	for (int i = 0; i < 12; i++){
		cin >> l[i];
	}
	sort(l, l + 12);
	if (l[0] == l[1] && l[1] == l[2] && l[2] == l[3]) {
		if (l[4] == l[5] && l[5] == l[6] && l[6] == l[7]) {
			if (l[8] == l[9] && l[9] == l[10] && l[10] == l[11]) {
				cout << "yes";
			}
			else
			{
				cout << "no";
			}
		}
		else { 
			cout << "no"; 
		}
	}
	else
	{
		cout << "no";
	}
	cout << endl;
}

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

using ll = long long;
const ll INF=1e15+7;
struct Edge {
  int to;
  ll weight;
  Edge(int t, ll w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int n;
vector<ll> d;

void dijkstra(Graph &G, int x) {
  int i;
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
  for(i=0; i<n; i++)
    d.at(i) = INF;
  d.at(x) = 0;
  pq.push(make_pair(0,x));

  while(!pq.empty()) {
    pair<int,int> p = pq.top();
    pq.pop();
    int v = p.second;

    if(d.at(v) < p.first)
      continue;
    for(i=0; i<G[v].size(); i++) {
      Edge e = G[v][i];
      if(d.at(e.to) > d.at(v) + e.weight) {
        d.at(e.to) = d.at(v) + e.weight;
        pq.push(make_pair(d.at(e.to), e.to));
      }
    }
  }
}

int main() {
  int m,i,u,v,a,b,s,t;
  cin >> n >> m >> s >> t;
  d.resize(n);
  vector<ll> r(n);
  priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> res;

  Graph Gy(n), Gs(n);
  for(i=0; i<m; i++) {
    cin >> u >> v >> a >> b;
    Gy[u-1].push_back(Edge(v-1, a));
    Gy[v-1].push_back(Edge(u-1, a));
    Gs[u-1].push_back(Edge(v-1, b));
    Gs[v-1].push_back(Edge(u-1, b));
  }

  dijkstra(Gy, s-1);
  for(i=0; i<n; i++)
    r.at(i) = d.at(i);

  dijkstra(Gs, t-1);
  for(i=0; i<n; i++)
    r.at(i) += d.at(i);

  for(i=0; i<n; i++)
    res.push(make_pair(r.at(i), i));
  for(i=0; i<n; i++) {
    pair<ll,int> a = res.top();
    while(a.second < i) {
      res.pop();
      a = res.top();
    }
    cout << 1000000000000000 - a.first << endl;
  }
}

Measured memory_bytes: 19824
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    for (int i = k; i < n; i++) cout << (a[i - k] < a[i] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3932
#include <iostream>
#include <vector>
#include <stack>

#define MOD 1000000007

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> arrow(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    arrow[a].push_back(b);
    arrow[b].push_back(a);
  }
  
  vector<bool> visited(n, false);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (!visited[i]) {
      stack<int> s;
      s.push(i);
      visited[i] = true;
      int ingroup = 0;
      while (!s.empty()) {
        int node = s.top();
        s.pop();
        ingroup++;
        for (int next : arrow[node]) {
          if (!visited[next]) {
            s.push(next);
            visited[next] = true;
          }
        }
      }
      ans = max(ans, ingroup);
    }
  }
  cout << ans << endl;
    
  return 0;
}

Measured memory_bytes: 14756
using System;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        int M = cin.nextInt();
        int[] A = cin.ArrayInt(N);
        int[] X = new int[M];
        int[] Y = new int[M];
        for (int i = 0; i < M; i++)
        {
            X[i] = cin.nextInt() - 1;
            Y[i] = cin.nextInt();
        }


        sum = new int[N + 1];
        root = new int[N + 1];
        cost = 0;

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

        for (int i = 0; i < M; i++)
        {
            sub(A[X[i]]);
            A[X[i]] = Y[i];
            add(A[X[i]]);
            Console.WriteLine(cost);
        }
    }

    int cost;
    int[] sum;
    int[] root;
    void add(int a)
    {
        sum[a]++;
        if (sum[a] > a) cost++;
        else
        {
            root[a - sum[a]]++;
            if (root[a - sum[a]] >= 2) cost++;
        }

    }

    void sub(int a)
    {
        if (sum[a] > a) cost--;
        else
        {
            if (root[a - sum[a]] >= 2) cost--;
            root[a - sum[a]]--;
        }
        sum[a]--;
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
        
    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}





Measured memory_bytes: 36060
loop do
  n = gets.to_i
  break if n == 0
  arr = []
  n.times do
    arr << gets.to_i
  end
  max = -300000
  size = arr.size
  size.times do |i|
    current = 0
    (i..(size - 1)).each do |j|
      current += arr[j]
      max = current if max < current
    end
  end
  puts max
end



Measured memory_bytes: 6892
#include <cstdio>
#include <cmath>
#include <cstring>
#define int long long
char s1[10+1],s2[10+1];
inline int max(int a,int b){return (a>b)?a:b;}
signed main(){
    int n;
    std::scanf("%lld",&n);
    for(int i=std::sqrt(n);i>=1;--i) if(n%i==0){
        int j=n/i;
        std::sprintf(s1,"%lld",i);
        std::sprintf(s2,"%lld",j);
        std::printf("%lld\n",max(std::strlen(s1),std::strlen(s2)));
        return 0;
    }
}

Measured memory_bytes: 128
n = int(raw_input())
S = map(int,raw_input().split())
q = int(raw_input())
T = map(int,raw_input().split())

c = 0
for t in T:
    left = 0
    right = n
    while left < right:
        mid = (left + right)/2
        if(S[mid] == t):
            c+=1
            break
        elif(t<S[mid]):
            right = mid
        else:
            left = mid+1

print c

Measured memory_bytes: 12880
#include <iostream>
#include <string>
typedef long long ll;
//#include <algorithm>
using namespace std;

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

  int student[N];

  for(int i = 0; i < N; i++){
      int a;
      cin >> a;
      //cout << a << endl;
      student[a - 1] = i + 1;
  }

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


Measured memory_bytes: 1152