akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()

using ll = long long;
constexpr ll INF = 10000000000;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
	int a; cin >> a;
	string s; cin >> s;

	for (int i = 0; i < s.size(); i++) {
		int x = s[i] - 'A';
		x = (x + a) % 26;
		char n = x + 65;
		cout << n;
	}
	cout << endl;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll dp[1500][1500]={},c[1500][1500];
signed main(){
  init_io();
  ll h,w,ans=0;
  cin >> h >> w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
    }
  }
  for(int i=0;i<h;i++){
    if(c[i][0]==0) dp[i][0]=1;
  }
  for(int i=0;i<w;i++){
    if(c[0][i]==0) dp[0][i]=1;
  }
  for(int i=1;i<h;i++){
    for(int j=1;j<w;j++){
      if(c[i][j]==0){
        dp[i][j] = min(min(dp[i-1][j-1],dp[i][j-1]),dp[i-1][j])+1;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      ans = max(ans,dp[i][j]*dp[i][j]);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 31304
#include<stdio.h>
int main(void)
{
	int a,b, d,r;
	double o,p,f;
	
	scanf("%d %d",&a,&b);

	o=a;
	p=b;

	d =	a/b;
	r = a%b;
	f = o/p;


	printf("%d %d %lf\n",d,r,f);

    return 0;
}

Measured memory_bytes: 636
//@source : 
//@create : 15:27:16 Tuesday 30/06/2020
//@author : nghethuat102
//@status : 
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1000001;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> cnt(maxn, 0);
    vector<int> dp(maxn, 0);
    for (auto &i: a) {
        cin >> i;
        ++cnt[i];
    }
    for (int i = 1; i < maxn; ++i) {
        for (int j = i; j < maxn; j += i) {
            dp[j] += cnt[i];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (dp[a[i]] == 1) {
            ++ans;
        }
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
  //  cerr << fixed << setprecision(5) << double(clock()) * 1000 / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)

#define ull unsigned long long

const int mxn = 505;
int n, s[mxn], t[mxn];
ull u[mxn], v[mxn], x[mxn][mxn];
int nw[mxn][mxn];
int vx[mxn], xsz, vy[mxn], ysz;

bool chk() {
	rep(i, n) if (s[i] == 0) { ull c = (ull)(-1); rep(j, n) c &= x[i][j]; if (c != u[i]) return 0; }
	rep(j, n) if (t[j] == 0) { ull c = (ull)(-1); rep(i, n) c &= x[i][j]; if (c != v[j]) return 0; }
	rep(i, n) if (s[i] == 1) { ull c = 0; rep(j, n) c |= x[i][j]; if (c != u[i]) return 0; }
	rep(j, n) if (t[j] == 1) { ull c = 0; rep(i, n) c |= x[i][j]; if (c != v[j]) return 0; }
	return 1;
}

int main() {
	scanf("%d", &n);
	rep(i, n) scanf("%d", &s[i]);
	rep(i, n) scanf("%d", &t[i]);
	rep(i, n) scanf("%llu", &u[i]);
	rep(i, n) scanf("%llu", &v[i]);
	rep(lv, 64) {
		xsz = ysz = 0;
		rep(i, n) {
			if (s[i] == 0 && (u[i] >> lv & 1) == 1) rep(j, n) nw[i][j] = 1; else
			if (s[i] == 1 && (u[i] >> lv & 1) == 0) rep(j, n) nw[i][j] = 0; else
			vx[xsz ++] = i;
		}
		rep(j, n) {
			if (t[j] == 0 && (v[j] >> lv & 1) == 1) rep(i, n) nw[i][j] = 1; else
			if (t[j] == 1 && (v[j] >> lv & 1) == 0) rep(i, n) nw[i][j] = 0; else
			vy[ysz ++] = j;
		}
		if (xsz == 0 || ysz == 0) {
		} else if (xsz == 1) {
			rep(j, ysz) {
				bool ok = 0;
				rep(i, n) if (i != vx[0] && nw[i][vy[j]] == (v[vy[j]] >> lv & 1)) { ok = 1; break; }
				if (ok) nw[vx[0]][vy[j]] = u[vx[0]] >> lv & 1; else nw[vx[0]][vy[j]] = v[vy[j]] >> lv & 1;
			}
		} else if (ysz == 1) {
			rep(i, xsz) {
				bool ok = 0;
				rep(j, n) if (j != vy[0] && nw[vx[i]][j] == (u[vx[i]] >> lv & 1)) { ok = 1; break; }
				if (ok) nw[vx[i]][vy[0]] = v[vy[0]] >> lv & 1; else nw[vx[i]][vy[0]] = u[vx[i]] >> lv & 1;
			}
		} else {
			rep(i, xsz) rep(j, ysz) nw[vx[i]][vy[j]] = (i + j) & 1;
		}
		rep(i, n) rep(j, n) x[i][j] |= (ull)(nw[i][j]) << lv;
	}
	if (!chk()) { puts("-1"); return 0; }
	rep(i, n) rep(j, n) printf("%llu%c", x[i][j], " \n"[j + 1 == n]);
	return 0;
}


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

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

    int K, X; cin >> K >> X;

    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << " ";
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int    nextInt()    { int d;      cin >> d;   return d;   }
string nextString() { string str; cin >> str; return str; }

string solve(string input) {
  string ret;

  char keys[][5] = {
    {},
    {'.', ',', '!', '?', ' '},
    {'a', 'b', 'c'},
    {'d', 'e', 'f'},
    {'g', 'h', 'i'},
    {'j', 'k', 'l'},
    {'m', 'n', 'o'},
    {'p', 'q', 'r', 's'},
    {'t', 'u', 'v'},
    {'w', 'x', 'y', 'z'}
  };
  
  int key_size[] = {
    -1, 5, 3, 3, 3, 3, 3, 4, 3, 4
  };
  
  char next = '\0';
  int idx = 0;
  for (int i = 0; i < input.size(); i++) {
    char c = input[i];
    if (c == '0') {
      if (next > 0 && next < 128) {
        ret += next;
      }
      next = '\0';
      idx = 0;
    } else {
      next = keys[c - '0'][idx];
      idx = (idx + 1) % key_size[c - '0'];
    }
  }
  
  return ret;
}

int main() {
  int n = nextInt();
  for (int i = 0; i < n; i++) {
    string input = nextString();
    cout << solve(input) << endl;
  }
  return 0;
}

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

int main()
{
    int N, X, sum=0, ans=0;
    cin >> N;
    cin >> X;

    vector<int> m(N);
    for (int i = 0; i < N; i++)
    {
        cin >> m.at(i);
        sum += m.at(i);
    }

    X -= sum;
    //cout << X << endl;

    sort(m.begin(), m.end());
    ans = X / m.at(0);
    cout << ans+N << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007;
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
  ll a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b) D("Zero");
  else if (a > 0) D("Positive");
  else if (a < 0) {
    if ((b - a) % 2 == 0) {
      D("Negative");
    } else {
      D("Positive");
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a / gcd(a, b) * b;
}

int main(){// 22:40?
    int n;
    cin >> n;
    long long ans=1;
    long long t;
    for(int i=0;i<n;++i){
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc160/tasks/abc160_d

n, x, y = map(int, input().split())

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

x -= 1
y -= 1
graph[x].append((1, y))
graph[y].append((1, x))

from heapq import heappop, heappush
def dijkstra_with_heap(graph, start, v):
    # graphは隣接リスト形式（有向・無向は問わない）
    # graphは、(cost, vertex)の順で格納すること
    # startは出発点。有向グラフの場合は到達しない点はinf
    # vは全部の頂点数
    distance = [float('infinity')] * v
    distance[start] = 0
    stack = [[0, start]] # cost, vertex
    while stack:
        _, vertex = heappop(stack)
        edges = graph[vertex]
        for d, t in edges:
            if d + distance[vertex] < distance[t]:
                distance[t] = d + distance[vertex]
                heappush(stack, (d, t))
    return distance

ans = [0] * n
for i in range(n):
    d = dijkstra_with_heap(graph, i, n)
    for j in range(i, n):
        ans[d[j]] += 1
for a in ans[1:]: # 先頭はk=0なので、除外する
    print(a)

Measured memory_bytes: 108764
#include<bits/stdc++.h>
#define maxn 120000
using namespace std;
vector<int> G[maxn];
typedef long long LL;
const LL mod = 1000000007;
LL f[2][maxn];
void DFS(int u, int fa = 0){
	f[0][u] = f[1][u] = 1;
	for(int v : G[u]) if(v != fa){
		DFS(v, u);
		f[0][u] = f[0][u] * f[1][v] % mod;
		f[1][u] = f[1][u] *(f[0][v] + f[1][v]) % mod;
	}
}
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 1; i < N; i += 1){
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	DFS(1);
	cout << (f[0][1] + f[1][1]) % mod;
}

Measured memory_bytes: 14720
#include <iostream>
using namespace std;
int main()
{
	long int n,m;
	long int counta;
	cin >> n >> m;
	if((n * 2) <= m)
	{
		counta = (n + ((m - (2 * n)) / 4));
	}
	else
	{
		counta = (m / 2);
	}
	cout << counta << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    int N;
    cin >> N;
    vector<float> v(N);
    for (int i = 0; i < N;i++)
        cin >> v[i];

    sort(v.begin(),v.end());

    float ans;
    for (int i = 0; i < N;i++){
        if(i == 0)
            ans = v[i];

        else
        {
            ans = (ans + v[i]) / 2;
        }
        
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int h,w;
    cin>>h>>w;
    int cnt=0;
    rep(i,0,h*w){
        char c;
        cin>>c;
        if(c=='#') cnt++;
    }
    
    cout<<(cnt==h+w-1 ? "Possible" : "Impossible")<<endl;
}



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

using namespace std;

int main() {
    int n, m, x;

    cin>>n>>m>>x;
    int a[m];
    int ans=0;
    int sum1=0,sum2=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        if(a[i]>x){
            sum1++;
        }
        else{
            sum2++;
        }
    }
    ans=min(sum1,sum2);

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


Measured memory_bytes: 256
/*
                ____________    ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    __________
          /  /\     /  /\             /  /\  /_______  /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/
       
          A FAN OF FIZZYDAVID
           
*/
 
#include<bits/stdc++.h>
 
#define HEAP priority_queue
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define forn(i,l,r) for(int i=(l);i<=(r);i++)
#define nrof(i,r,l) for(int i=(r);i>=(l);i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-20
#define pi 3.1415926535897932384626433832795
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define debug puts("OK");
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()
 
using namespace std;
 
typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const int iinf=1e9+7;
const LL linf=1ll<<60;
const flt dinf=1e10;
 
template <typename T>
inline void scf(T &x)
{
	bool f=0; x=0; char c=getchar();
	while((c<'0' || c>'9') && c!='-') c=getchar();
	if(c=='-') { f=1; c=getchar(); }
	while(c>='0' && c<='9') { x=x*10+c-'0'; c=getchar(); }
	if(f) x=-x; return;
}
 
template <typename T1,typename T2>
void scf(T1 &x,T2 &y) { scf(x); return scf(y); }
 
template <typename T1,typename T2,typename T3>
void scf(T1 &x,T2 &y,T3 &z) { scf(x); scf(y); return scf(z); }
 
#ifdef ONLINE_JUDGE
#else
#define DEBUG
#endif
 
//---------------------------head----------------------------
 
const int N=23333;
 
int n;
int a[N],b[N],p[N];
 
orz yjz()
{
	scf(n);
	forn(i,1,n) scf(p[i]);
	a[1]=1; forn(i,2,n) a[i]=a[i-1]+n;
	b[n]=1; nrof(i,n-1,1) b[i]=b[i+1]+n;
	forn(i,2,n) a[p[i]]+=i-1;
	forn(i,1,n) printf("%d%c",a[i],i==n?'\n':' ');
	forn(i,1,n) printf("%d%c",b[i],i==n?'\n':' ');
	fizzydavid ak la
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s;
ll b=0;
int main()
{
	cin>>s;
	for(int i=0;i<=s.size();i++)
	{
		b=b+s[i];
	}
	if(b==198)
	cout<<"ARC";
	else
	cout<<"ABC"; 
    return 0;
}


Measured memory_bytes: 3620
H,W =map(int,input().split())

a=[list(input()) for i in range(H)]
l_idx=[]
c_idx=[]
for i in range(H):
    for j in range(W):
        if a[i][j]=="#":
            l_idx.append(i)
            c_idx.append(j)

for i in range(W-1,-1,-1):
    if not i in c_idx:
        for j in range(H):
            a[j].pop(i)

for i in range(H):
    if i in l_idx:
        print("".join(a[i]))


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

int main(){
  int N; cin >> N;
  vector<string> J(N);
  int ac = 0, wa = 0, tle = 0, re = 0;
  
  for (int i=0; i<N; i++){
    cin >> J.at(i);
    if (J.at(i) == "AC"){ac++;}
    else if (J.at(i) == "WA"){wa++;}
    else if (J.at(i) == "TLE"){tle++;}
    else {re++;}
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  
}

Measured memory_bytes: 6420
#include <cassert>
#include <cstdio>
#include <cstdlib>

int
main()
{
    int n, a;
    assert(scanf("%d %d", &n, &a) == 2);

    if (n % 500 <= a)
        printf("Yes\n");
    else
        printf("No\n");
    exit(0);
}


Measured memory_bytes: 128
def main():

    n = int(input())
    cards = list(map(int, input().split()))
    cards.sort(reverse=True)
    alice, bob = 0, 0
    if n % 2 == 0:
        for i in range(int(n / 2)):
            alice += cards[2 * i]
            bob += cards[2 * i + 1]
    else:
        for j in range(int(n / 2)):
            alice += cards[2 * j]
            bob += cards[2 * j + 1]
        alice += cards[n - 1]
    ans = alice - bob
    print(ans)

if __name__ == '__main__':
    main()

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

const int N = 1e5 + 10;

int n, v[N], cnt[2][N], minv[2], mini[2], minv2[2], mini2[2];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++) scanf("%d", v + i);
	for(int i = 1; i <= n; i ++) cnt[i & 1][v[i]] ++;
	minv[0] = minv[1] = n + 1;
	for(int d, i = 1; i <= 100000; i ++) {
		d = n / 2 - cnt[0][i];
		if(d < minv[0]) {
			minv[1] = minv[0];
			mini[1] = mini[0];
			minv[0] = d;
			mini[0] = i;
		} else if(d < minv[1]) {
			mini[1] = i; minv[1] = d;
		}
	}
	minv2[0] = minv2[1] = n + 1;
	for(int d, i = 1; i <= 100000; i ++) {
		d = n / 2 - cnt[1][i];
		if(d < minv2[0]) {
			minv2[1] = minv2[0];
			mini2[1] = mini2[0];
			minv2[0] = d;
			mini2[0] = i;
		} else if(d == minv2[0]) {
			if(mini2[0] == mini[0]) {
				mini2[0] = i;
			}
		} else if(d < minv2[1]) {
			mini2[1] = i; minv2[1] = d;
		}
	}
	printf("%d\n", mini[0] == mini2[0] ? min(minv[1] + minv2[0], minv[0] + minv2[1]) : minv[0] + minv2[0]);
	return 0;
}


Measured memory_bytes: 1280
from scipy.sparse.csgraph import shortest_path
import numpy as np
import itertools

N,M,R = map(int,input().split())
r = [int(x) for x in input().split()]

# 任意の2地点間の距離を求める
edge = np.zeros((N+1,N+1))
for _ in range(M):
  A,B,C = map(int,input().split())
  edge[A,B] = C
  
dist = shortest_path(edge, directed = False).astype(int)

# 全訪問順を試す。8! = 40320なので十分
answer = 10**18
for visit in itertools.permutations(r):
  p = 0
  prev = visit[0]
  for x in visit[1:]:
    if prev != None:
      p += dist[prev,x]
    prev = x
  answer = min(answer,p)
  
print(answer)

Measured memory_bytes: 15068
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

// range sum query
const ll SEG_LEN = 1LL << 20;
int seg[SEG_LEN * 2] = {0};

void add(int idx, int x){
    idx += SEG_LEN;
    seg[idx] += x;
    while(1){
        idx /= 2;
        if(idx==0) break;
        seg[idx] = seg[idx*2] + seg[idx*2+1];
    }
}

int get_sum(int l, int r){
    l += SEG_LEN;
    r += SEG_LEN;
    int ret = 0;

    while(l<r){
        if(l%2){
            ret += seg[l];
            ++l;
        }
        l /= 2;

        if(r%2){
            ret += seg[r-1];
            --r;
        }
        r /= 2;
    }
    return ret;
}

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

    int n, q;
    cin >> n >> q;

    vector<int> a(n);
    vector<int> li(n+1, -1);
    vector<vector<int>> ps(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        int l = li[a[i]];
        if(l != -1) ps[i].push_back(l);
        li[a[i]] = i;
    }

    vector<vector<pair<int, int>>> qs(n);
    for(int i = 0; i < q; ++i){
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        qs[r].push_back(make_pair(l, i));
    }
    
    vector<int> res(q);
    for(int i = 0; i < n; ++i){
        for(int pl: ps[i]){
            add(pl+1, 1);
        }

        for(pair<int, int> p: qs[i]){
            int ql = p.first;
            int sub = get_sum(ql+1, n+1);

            int qi = p.second;
            res[qi] = (i - ql + 1) - sub;
        }
    }

    for(int i = 0; i < q; ++i) cout << res[i] << endl;

}

Measured memory_bytes: 62004
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  REP(i, m) cin >> a[i] >> b[i];

  int cnt;
  REP(i, n){
    cnt = 0;
    REP(j, m){
      if(a[j] == i + 1 || b[j] == i + 1) cnt++;
    }
    cout << cnt << endl;
  }

}


Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
n = int(input())
s = []
for i in range(n):
    s.append(input())

dic = {}

for i in range(n):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

result = []
maximum = max(list(dic.values()))
for key in dic:
    if dic[key] == maximum:
        result.append(key)

result.sort()
for i in range(len(result)):
    print(result[i])

Measured memory_bytes: 121300
from collections import deque
N = int(input())
 
num = []
for i in range(N):
  num.append(int(input()))
  
num = deque(sorted(num))
ans = deque([num.popleft()])
 
for i in range(N-2):
  if i % 4 == 0:
    ans.append(num.pop())
  elif i % 4 == 1:
    ans.appendleft(num.pop())
  elif i % 4 == 2:
    ans.append(num.popleft())
  else:
    ans.appendleft(num.popleft())

answer = max(abs(num[0]-ans[0]), abs(num[0]-ans[-1]))
for i in range(len(ans)-1):
  answer += abs(ans[i] - ans[i+1])
  
print(answer)

Measured memory_bytes: 8888
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define jloop(n) for(int j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
const ll N = 2e5+9;
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
#define endl '\n'
ll po(ll,ll);













int n, a[N], mn, ans;
int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n; mn=n+1;
  loop(n) cin >> a[i];
  loop(n) {
    if(a[i] < mn) ans++;
    mn=min(mn, a[i]);
  }
  cout << ans << endl;
  R 0;
}
/*

*/



































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

int main() 
{
	#ifdef gupta_samarth
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	test()
	{
		ll n,m,a,b;
		cin>>n>>m>>a>>b;

		cout<<floor_sum(n,m,a,b),nl;
	}	

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 3684
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in sorted(a):
    if i[1] == s:
        print(i[0])
        sys.stdout.flush 

Measured memory_bytes: 59368
n = 1_000_000

ns = Math.sqrt(n).to_i + 1

is_prime = [false, false] + [true]*(n-1)

2.upto(ns) do |i|
  next unless is_prime[i]
  (i*i).step(n, i) do |j|
    is_prime[j] = false
  end
end

count = 0
count_list = (0..n).map do |i|
  count += 1 if is_prime[i]
  count
end

while n = gets.to_i
  break if n <= 0
  puts count_list[n]
end

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

using namespace std;
#define ll long long int
#define pii pair < ll , ll >
#define ff first
#define ss second
vector < pii > vv;
vector < ll > ans_vec;

ll parent[100005],sz[100005];
ll pre;

void Make_set(ll n)
{
    for(ll i=1; i<=n; i++)
    {
        parent[i]=i;
        sz[i]=1;
    }
}

ll Find(ll r)
{
    if(parent[r]==r) return r;
    return parent[r]=Find(parent[r]);
}

void Union(ll u, ll v)
{
    u=Find(u),v=Find(v);
    if(u!=v)
    {
        pre-=(sz[u]*sz[v]);

        if(sz[u]>sz[v])
        {
            sz[u]+=sz[v];
            sz[v]=0;
            parent[v]=u;
        }
        else
        {
            sz[v]+=sz[u];
            sz[u]=0;
            parent[u]=v;
        }
    }
    ans_vec.push_back(pre);

}

int main()
{
    ll n,m,i,j;
    cin>>n>>m;
    Make_set(n);
    for(i=1; i<=m; i++)
    {
        ll u,v;
        cin>>u>>v;
        vv.push_back({u,v});
    }
    reverse(vv.begin(),vv.end());
    pre=(n*(n-1))/2LL;
    ans_vec.push_back(pre);
    for(i=0; i<vv.size(); i++)
    {
        Union(vv[i].ff,vv[i].ss);
    }
    reverse(ans_vec.begin(),ans_vec.end());
    ll cn=0;
    vector < ll > temp;
    for(i=ans_vec.size()-1; i>=0; i--)
    {
        temp.push_back(ans_vec[i]);
        cn++;
        if(cn==m) break;
    }

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

    for(ll x: temp)
    {
        cout<<x<<endl;
    }
    return 0;





}



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

int main(){
  long long a,b,x;
  cin>>a>>b>>x;
  long long sum=0;
  
  if(a%x==0){
    cout<<b/x-a/x+1<<endl;
  }else{
    cout<<b/x-a/x<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

int n, p;
int a[50];
ll dp[51][2];

int main(){
    cin >> n >> p;
    rep(i, n){
        cin >> a[i];
    }

    dp[0][0] = 1;
    for(int i = 1; i <= n; ++i){
        rep(j, 2){
            dp[i][j] = dp[i - 1][j + a[i - 1] & 1] + dp[i - 1][j];
        }
    }

    cout << dp[n][p] << endl;
    return 0;
}

Measured memory_bytes: 256
S = list(input())
cnt=0
ans=0

for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T':
        cnt +=1
        if ans < cnt:
            ans=cnt
    else:
        cnt=0
        
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

// フェンウィックツリー(バイナリーインデクスドツリー)
//sum(l,r) = [l, r)の和, add(i, a) = 0-indexedでi番目の要素にaを足す
template <class T>
struct fenwick_tree {
    int n;
    vector<T> x;
    fenwick_tree(int n_ = 0) : n(n_), x(n + 1, 0) {}
    int size() const { return n; }
    T sum(int r) const {
        T S = 0;
        for (r = r - 1; r >= 0; r = (r & (r + 1)) - 1) S += x[r];
        return S;
    }
    T sum(int l, int r) const { return sum(r) - sum(l); }
    void add(int k, const T &a) {
        for (; k < n; k |= k + 1) x[k] += a;
    }
    void set(int k, const T &a) { add(k, a - sum(k, k + 1)); }
};

// 判定関数 f(x): T → bool ( x∈[s,t) ) が false から true に変わる
// 広義単調増加であるとき f(x) = true となる最小の x を求める
// 返り値が t のときは任意の x について false ということ
template <class Function>
int binary_search_int (int s, int t, Function f) {
    int ng = s - 1, ok = t;
    while (ok - ng > 1) {
        int mid = (ng + ok) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

int main(void) {
    lint n;
    cin >> n;
    vector<lint> a(n+1, 0);
    repeat (i, n) cin >> a[i+1];
    
    
    auto f = [&] (lint k) -> bool {
        vector<int> b(n+1, 0), c(n+1, 0);
        const lint SFT = 1e6;
        fenwick_tree<lint> ft(n+SFT+3);
        
        // 中央値が k 以下か？　⇔　k 以下の数が N/2 より大
        repeat (i, n) {
            b[i+1] = (a[i+1] <= k) ? -1 : +1;
        }
        
        repeat (i, n) {
            c[i+1] = c[i] + b[i+1];
        }
        lint cnt = 0;
        
        repeat (i, n+1) {
            cnt += ft.sum(c[i]+SFT+1, n+SFT+2);
            //dump(i); dump(c[i]); dump(ft.sum(c[i]+SFT+1, n+SFT+2)); dump(cnt); el;
            ft.add(c[i]+SFT, 1);
        }
        bool judge = (cnt > 1LL*n*(n+1)/4);
        return judge;
    };
    
    lint min_elem = *min_element(a.begin(), a.end());
    lint max_elem = *max_element(a.begin(), a.end());
    cout << binary_search_int(min_elem, max_elem + 1, f) << endl;
    
}

Measured memory_bytes: 10460
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	LL a, b, c, d;
	inl2(a, b);inl2(c, d);
	LL a1 = a*c;
	LL a2 = a*d;
	LL a3 = b*c;
	LL a4 = b*d;
	cout<<max(max(a1, a2), max(a3, a4))<<en;
}

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


Measured memory_bytes: 3684
#include <iostream>
//#include <string>
using namespace std;
int n;
int h[100010];

int max(int *num) {
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (res < num[i]) {
			res = num[i];
		}
	}
	return res;
}

int main() {
	int count[100010] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	h[n] = 2000000000;
	int j=0;
	int k = 0;
	for (int i = 0; i < n - 1; i++) {
		j = i;
		k = i;
		while (h[j] >= h[j + 1]) {
			j++;
			count[i]++;
		}
		if (count[i] != 0) {
			while (count[k] != 0) {
				k++;
				count[k] = count[k - 1] - 1;
			}
			i = k;
		}
	}
	cout << max(count) << endl;
	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

  vector<ll> d;
  for (ll i = 1; i*i <= n; ++i) {
    if (n%i == 0) {
      d.push_back(i);
      if (n/i != i) {
        d.push_back(n/i);
      }
    }
  }

  ll ans = 0;
  each (i, d) {
    i--;
    if (i == 0) continue;
    if (n/i == n%i) {
      ans += i;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
h, w = map(int,input().split())
grid = [list(map(int,input().split())) for i in range(h)]
out = []
for i in range(h):
    for j in range(w):
        ii, ij, nii, nij = 0, 0, 0, 0
        ii = i
        ij = j if i%2==0 else w-1-j
        if (i%2==0 and ij==w-1) or (i%2==1 and ij==0): nii = i+1
        else: nii = i
        if i%2==0 and ij<w-1: nij = ij+1
        elif i%2==1 and ij>0: nij = ij-1
        else: nij = ij
        if grid[ii][ij]%2==1 and nii<h:
            grid[ii][ij] -= 1
            grid[nii][nij] += 1
            out.append([ii+1,ij+1,nii+1,nij+1])
print(len(out))
for i in out:
    print(i[0],i[1],i[2],i[3])

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

struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    UF.unite(x, y);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (UF.root(i) == i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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

int main()
{

	vector<long> prime;
	vector<bool> is_prime(1000000,false);
	prime.push_back(2);
	prime.push_back(3);
	prime.push_back(5);

	is_prime[2]=is_prime[3]=is_prime[5]=true;

	for(long i=7;i<1000000;i+=2){
		bool ok=true;
		for(long j=0;prime[j]*prime[j]<=i && ok;j++){
			if(i%prime[j]==0) ok=false;
		}
		if(ok){is_prime[i]=true; prime.push_back(i);}
//		if(ok) cout<<i<<endl;
	}

	long a,d,n;
	while(cin>>a>>d>>n,a){

		int num=0;
		for(long i=a;;i+=d){
			if(is_prime[i]){
				num++;
			}
			if(num==n){cout<<i<<endl; break;}
		}

	}


	return 0;
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;


int main(){
    long long a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", abs((a - 2) * (b - 2)));
    return 0;
}

Measured memory_bytes: 768
n = gets.chomp.to_i
sum = 0
score = []

n.times do |i|
    score[i] = gets.chomp.to_i
end

sum = score.inject(:+)
score.sort!

0.upto(score.length - 1) do |j|
    if score[j] % 10 == 0
        next
    elsif (sum % 10 == 0) && (sum != 0)
        sum -= score[j]
    else 
        break
    end
end

if sum % 10 == 0 ; sum = 0
end

puts sum

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, s;
  cin >> A >> B;
  if((A > 9) || (B > 9)){
    cout << -1 << endl;
  }else{
    s = A * B;
    cout << s << endl;
  }
}

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

int main() {
    ios::sync_with_stdio(false);
    int n, a[200005] = {};
    multiset<int> s;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], s.insert(a[i]);
    for (int i = 1; i <= n; i++) {
        s.erase(s.find(a[i]));
        cout << *s.rbegin() << '\n';
        s.insert(a[i]);
    }
}

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

class FastReader 
{ 
    BufferedReader br; 
    StringTokenizer st; 
    
    public FastReader() 
    { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    
    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    
    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
    
    long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
    
    double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
    
    String nextLine() 
    { 
          String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} 

class Solution
{
    void solve()
    {
        FastReader sc = new FastReader();

        int X = sc.nextInt();
        boolean flag;

        for(int i = X;;i++)
        {
            //check if i is prime

            flag = true;

            for(int j = 2; j * j <= i; j++)
            {
                if(i % j == 0)
                {
                    flag = false;
                    break;
                }
            }

            if(flag == true)
            {
                System.out.println(i);
                return;
            }
        }
    }
}
  
public class Main 
{ 
    public static void main(String[] args) 
    { 
        Solution ob = new Solution();

        ob.solve();
    } 
} 

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

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

int main() {

    int n; cin >> n;

    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);

    int ans = 0;

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

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

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

    for (int i = 0; i < n-1; ++i) {
        if (a[i] + 1 == a[i+1]) ans += c[a[i] - 1];
    }

    cout << ans << endl;


}

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

int main() {
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int cnt = 0;
  for (int i = 0; i < 16; ++i) {
    if (s[i] != t[i]) ++cnt;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

    String line;
    int[][] pqr;
    int idx,cnt;

    void solve(){
        Scanner sc = new Scanner(System.in);

        idx = 0;
        pqr = new int[27][3];
        getPQR(0,new int[3]);

        while(true){
            line = sc.next();
            if(line.equals(".")) break;

            cnt = 0;
            String line2 = line;
            LinkedList<Integer> left = new LinkedList<Integer>();
            for(int i=0; i<27; i++){
                line = line2;
                char[] c = line.toCharArray();
                for(int j=0; j<line.length(); j++){
                    if(c[j]>='P' && c[j]<='R') c[j] = (char)(pqr[i][c[j]-'P']+'0');  
                }
                line = String.valueOf(c);

                for(int j=0; j<line.length(); j++){
                    if(line.charAt(j)=='(') left.add(j);
                    if(line.charAt(j)==')'){
                        int l = left.pollLast();
                        String s = line.substring(l+1,j);
                        String front = line.substring(0,l);
                        String rear = line.substring(j+1,line.length());
                        String newS = getAns(s);
                        line = front + newS + rear;
                        j = j-(s.length()-newS.length())-2;
                    }
                }
                if(getAns(line).equals("2")) cnt++;
            }

            System.out.println(cnt);
        }
    }

    String getAns(String s){
        String x = "",y = "";
        boolean and = false,or = false;
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i)=='*'){
                and = true;
                x = s.substring(0,i);
                y = s.substring(i+1,s.length());
            }else if(s.charAt(i)=='+'){
                or = true;
                x = s.substring(0,i);
                y = s.substring(i+1,s.length());
            }
        }

        if(and){
            return String.valueOf(Math.min(getNum(x),getNum(y)));
        }else if(or){
            return String.valueOf(Math.max(getNum(x),getNum(y)));
        }else{
            return String.valueOf(getNum(s));
        }
    }

    int getNum(String s){
        int ii = 0;
        while(s.charAt(ii)=='-') ii++;

        int n = Integer.parseInt(s.substring(ii,s.length()));
        for(int i=0; i<ii; i++) n = 2-n;
  
        return n;
    }

    void getPQR(int pos,int[] num){
        if(pos==3){
            for(int i=0; i<3; i++) pqr[idx][i] = num[i];
            idx++;
            return;
        }

        for(int i=0; i<3; i++){
            num[pos] = i;
            getPQR(pos+1,num);
        }
    }

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

Measured memory_bytes: 12000
import heapq
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    dp = [[float("inf")] * N for _ in range(N)]
    edges = list()
    for i in range(N):
        dp[i][i] = 0

    for _ in range(M):
        a, b, c, = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = c
        dp[b][a] = c
        if a > b:
            a, b = b, a
        edges.append((a, b, c))

    # ワーシャルフロイド
    for k in range(N):
        for i in range(N):
            for j in range(N):
                tmp = dp[i][k] + dp[k][j]
                if tmp < dp[i][j]:
                    dp[i][j] = tmp

    ans = 0
    for i, j, c in edges:
        if dp[i][j] < c:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    
    if (a < b) {
        rep(i, b) cout << a;
        cout << endl;
    }
    else {
        rep(i, a) cout << b;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3552
def ABC_47_B():
    W,H,N = map(int, input().split())
    al=[]
    bl=[]
    cl=[]
    dl=[]

    for i in range(N):
        x,y,a = map(int, input().split())

        if a == 1:
            al.append(x)
        elif a == 2:
            bl.append(x)
        elif a ==3:
            cl.append(y)
        else:
            dl.append(y)
    
    if len(al) != 0:
        at= max(al)
    else:
        at=0
    if len(bl) != 0:
        bt= min(bl)
    else:
        bt=W
    if len(cl) != 0:
        ct= max(cl)
    else:
        ct=0
    if len(dl) != 0:
        dt= min(dl)
    else:
        dt=H
    

    if (bt-at) >= 0 and (dt-ct) >=0:
        s = (bt-at)*(dt-ct)
    else:
        s = 0


    print(s)

if __name__ == '__main__':

    ABC_47_B()

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

int main(){
    int n; cin >> n;
    int nn = n;
    n = (1<<n);
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    vector<int> s;
    s.push_back(a.back());
    a.back() = -1;
    rep(i,nn){
        vector<int> p = s;
        sort(p.begin(),p.end());
        int ai = n-1;
        while (p.size() > 0 && ai >= 0) {
            if(a[ai] == -1){
                --ai;
                continue;
            }
            if(a[ai] < p.back()){
                s.push_back(a[ai]);
                p.pop_back();
                a[ai] = -1;
            }
            --ai;
        }
        if(p.size() > 0){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int seq[N];
  for(int i=0;i<N;i++) cin >> seq[i];
  int flag;
  int ans=0;
  if(seq[0]<seq[1]){flag=0;}
  if(seq[0]>seq[1]){flag=1;}
  if(seq[0]==seq[1]){flag=-1;}
  for(int i=1;i<N-1;i++){
    if(seq[i]==seq[i+1]) {continue;}
    if(seq[i]<seq[i+1]){
      if(flag==1){
        ans++;
        flag=3;
      }
      else flag=0;
    }
    if(seq[i]>seq[i+1]){
      if(flag==0){
        ans++;
        flag=4;
      }
      else flag=1;
    }
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	string S;
	cin >> S;

	int dp[3000] = {};
	dp[0] = 1;
	const int mod = 1e9 + 7;
	rep(i, N - 1) {
		if (S[i] == '<') {
			int k = 0;
			int tmp = dp[0];
			dp[0] = 0;
			rep(j, i + 1) {
				k += tmp;
				if (k >= mod) k -= mod;
				tmp = dp[j + 1];
				dp[j + 1] = k;
			}
		}
		else {
			int k = 0;
			for (int j = i; j >= 0; j--) {
				k += dp[j];
				if (k >= mod) k -= mod;
				dp[j] = k;
			}
		}
	}
	int kotae = 0;
	rep(i, N) kotae = (kotae + dp[i]) % mod;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n, x;
    while(1){
        cin>>n>>x;
        if(n == 0 && x == 0) break;
        int count=0;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i <= j) break;
                for(int k=1;k<=n;k++){
                    if(j <= k) break;
                    if(i + j + k == x){
                        if(i == j || i == k || j == k) break;
                        else count++;
                    }
                }
            }
        }
        cout<<count<<endl;
    }
}



Measured memory_bytes: 2992
#include<stdio.h>
int main () {
    int S,h,m,temp,s;
    scanf("%d",&S);
    h=S/3600;
    temp=S%3600;
    m=temp/60;
    temp=temp%60;
    s=temp;
    printf("%d:%d:%d\n",h,m,s);


return 0;
}



Measured memory_bytes: 2100