akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define M 1000000007


int main()
{
	int n;
	scanf("%d", &n);
	long i;
	long dp[3];
	dp[0] = 1;
	dp[1] = 0;
	dp[2] = 0;
	long s = 0;
	for (i = 0; i < n-1; i++)
	{
		long dp2[3];
		dp2[0] = (dp[0] + dp[1]) % M;
		dp2[1] = dp[2];
		dp2[2] = (dp[2] + dp[0]) % M;
		s += dp[0] * (n - 1) % M * (n - 1) % M;
		s %= M;
		if (i < n - 2)
		{
			s += dp[0] * (i + 2) % M;
		}
		else
		{
			s += dp[0] * (i + 1) % M;
		}
		s %= M;
		dp[0] = dp2[0];
		dp[1] = dp2[1];
		dp[2] = dp2[2];
	}
	s += dp[0] * n;
	s %= M;
	printf("%ld\n", s);
	return 0;
}


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

int main(){
    char s[202], t[101], p[101];
    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(s, t);

    if (strstr(s, p) == NULL) printf("No\n");
    else printf("Yes\n");

    return 0;
}


Measured memory_bytes: 2752
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

int A[100100];
int DP[100100];

int main(){
    int N, K;
    cin >> N >> K;
    int m = INT_MAX;
    REP(i,N){
        int a;
        cin >> a;
        A[i] = a;
        m = min(m, a); 
    }

    fill(DP, DP+K, -1);
    for(int i = 0; i < m; i++){
        DP[K-i] = 0;
    }
    for(int i = K; i >= 0; i--){
        if(DP[i] == -1) continue;
        for(int j = 0; j < N; j++){
            int a = A[j];
            if(i-a < 0) break;
            if(DP[i-a] != 1)
                DP[i-a] = !DP[i];
        }
    }

    //REP(i,K+1){
    //    printf("%d ", DP[i]);
    //}
    //printf("\n");

    if(DP[0])
        cout << "First" << endl;
    else
        cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 640
import numpy as np
N, K, *XYC = open(0).read().split()
N = int(N)
K = int(K)
board = np.zeros((4 * K + 1, 4 * K + 1), dtype=np.int64)
for x, y, c in zip(XYC[::3], XYC[1::3], XYC[2::3]):
    x = int(x)
    y = int(y)
    if c == 'W':
        x += K
    x = x % (2 * K)
    y = y % (2 * K)
    board[x, y] += 1
    board[(x + K) % (2 * K), (y + K) % (2 * K)] += 1
board[1 + 2 * K:, 1 + 2 * K:] = board[:2 * K, :2 * K]
board[1:1 + 2 * K, 1 + 2 * K:] = board[1 + 2 * K:, 1 + 2 * K:]
board[1 + 2 * K:, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[1:1 + 2 * K, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[0, :] = 0
board[:, 0] = 0
for j in range(1, 3 * K):
    board[:, j] += board[:, j - 1]
for j in range(1, 3 * K):
    board[j, :] += board[j - 1, :]
ans = np.max(board[K:3 * K, K:3 * K] + board[:2 * K, :2 * K] -
             board[:2 * K, K:3 * K] - board[K:3 * K, :2 * K])
print(ans)


Measured memory_bytes: 199776
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a,b;
int main(){
	scanf("%lld%lld",&a,&b);
    printf("%lld",a<=5?0:a<=12?b/2:b);
}



Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.LinkedList;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        System.out.println(N/3);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

// graph by adjacency matrix
template <typename T>
struct Graph {
  int V;
  std::vector<std::vector<T>> adj;
  T inf;

  Graph(const int V, const T inf = std::numeric_limits<T>::max())
      : V(V), adj(V, std::vector<T>(V, inf)), inf(inf) {
    for (int i = 0; i < V; i++) adj[i][i] = 0;
  }

  void add_edge(const int src, const int dst, const T weight) {
    adj[src][dst] = weight;
  }
};

template <typename T>
struct AllPairsShortestPath {
  Graph<T> g;
  std::vector<std::vector<T>> dist;
  T inf;

  AllPairsShortestPath(const Graph<T> &g, T inf = std::numeric_limits<T>::max())
      : g(g), dist(g.V, std::vector<T>(g.V)), inf(inf) {
    for (int i = 0; i < g.V; i++) {
      for (int j = 0; j < g.V; j++) dist[i][j] = g.adj[i][j];
    }
  }

  void run() {
    for (int k = 0; k < g.V; k++) {
      for (int i = 0; i < g.V; i++) {
        for (int j = 0; j < g.V; j++) {
          if (dist[i][k] != inf and dist[k][j] != inf) {
            dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
          }
        }
      }
    }
  }

  bool has_negative_loop() const {
    for (int i = 0; i < g.V; i++) {
      if (dist[i][i] < 0) return true;
    }
    return false;
  }
};

void aoj() {
  // https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_1_C
  int V, E;
  std::cin >> V >> E;
  Graph<long long> g(V);
  for (int i = 0; i < E; i++) {
    int s, t, d;
    std::cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }
  AllPairsShortestPath<long long> apsp(g);
  apsp.run();
  if (apsp.has_negative_loop()) {
    std::cout << "NEGATIVE CYCLE" << std::endl;
  } else {
    for (int i = 0; i < g.V; i++) {
      for (int j = 0; j < g.V; j++) {
        if (apsp.dist[i][j] == apsp.inf) {
          std::cout << "INF" << (j == g.V - 1 ? '\n' : ' ');
        } else {
          std::cout << apsp.dist[i][j] << (j == g.V - 1 ? '\n' : ' ');
        }
      }
    }
  }
}

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

  aoj();
  return 0;
}



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

int main(){
    string s;
    cin >> s;
    int counter = 0;
    if(s[0]=='o') ++counter;
    if(s[1]=='o') ++counter;
    if(s[2]=='o') ++counter;
    cout<<700+counter*100<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1LL << 30
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define pb push_back
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " = " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) cout << x[i][j] << " "; printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define F first
#define S second
#define mp make_pair
 
typedef long long int ll;
typedef pair < int, int > ii;
typedef pair < int, ii > iii;


int main()
{
	
	ll a, b; cin >> a >> b;
	
	if((a*b)%2==0) puts("Even");
	else puts("Odd");
	
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);
  ll ans = 0;
  //string ans = "No";

  ll a, b; cin >> a >> b; ans = (ll)(a - 2) * (ll)(b - 2);

  if (a == b && a == 1){
    cout << 1 << endl;
    return 0;
  }
  else if(a == 1 || b == 1){
    cout << max(a,b) - 2 << endl;
    return 0;
  }

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

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

  int main(){

  int a,b,c;
  cin>>a>>b>>c;
  int y = 0;
  for(int i = a; i <= b; i++){
    if(c % i == 0) y++;
}

  cout<<y<<endl;
   return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define FAST ios_base::sync_with_stdio(false);cin.tie(0);
    const double EPS = 1e-9;
    const double PI = acos(-1);
    const int knightDir[8][2] = {{-2,-1},{-2,1},{-1,2},{1,2},{2,-1},{2,1},{-1,-2},{1,-2}};
    //const int dx[]={0,0,0,1,1,1,-1,-1,-1};
    //const int dy[]={-1,0,1,-1,0,1,-1,0,1};
    const int dx[] = {0 , 1 , 0 , -1};
    const int dy[] = {1 , 0 , -1 , 0};
    //#define MOD         1000000007LL
    #define MAX         1000005
    const ll MOD = 1000000000 + 7;

    int main()
    {
        FAST
        int t;
        t = 1;;

        while(t--)
        {
           int h , w , f;
           cin >> h >> w >> f;

           int row[h + 1] = { 0 }, col[w + 1] = { 0 };
           char maze[h + 1][w + 1];

           for(int i = 1 ; i <= h ; i++)
           {
               cin >> maze[i] + 1;
           }
           int total = 0;

           for(int i = 1 ; i <= h ; i++)
           {
               for(int j = 1 ; j <= w ; j++)
               {
                   if(maze[i][j] == '#')total++;
               }
           }

           for(int i = 1 ; i <= h ; i++)
           {
               int sum = 0;
               for(int j = 1 ; j <= w ; j++)
               {
                   if(maze[i][j] == '#')sum++;
               }
               row[i] = sum;
           }

           for(int i = 1 ; i <= w ; i++)
           {
               int sum = 0;
               for(int j = 1 ; j <= h ; j++)
               {
                   if(maze[j][i] == '#')sum++;
               }
               col[i] = sum;
           }

           int ans = 0;

           for(int i = 0 ; i <= (1 << h) ; i++)
           {
              vector<int> r;
              for(int k = 0 ; i >= (1 << k) ; k++)
              {
                  if(i & (1 << k))r.push_back(k + 1);
              }
              for(int j = 0 ; j < (1 << w) ; j++)
              {
                  vector<int> c;
                  for(int k = 0 ; j >= (1 << k) ; k++)
                  {
                      if(j & (1 << k))c.push_back(k + 1);
                  }

                  int sum = 0;
                  for(int a : r)sum += row[a];
                  for(int b : c)sum += col[b];
                  for(int a : r)
                  {
                      for(int b : c)
                      {
                          if(maze[a][b] == '#')sum--;
                      }
                  }

                  if(total - sum == f)ans++;
              }

           }

           cout << ans << endl;
        }
    }



Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include<iostream>
#include <algorithm>
using namespace std;
//sort(a, a + N, greater<int>());
//n：数の個数、偶数
int main(void){
	int n,i;
	int *x,*xx;
	int center;
	scanf("%d",&n);
	x = new int[n];
	xx = new int[n];
	
	for(i = 0; i< n; i++)
		scanf("%d",&x[i]);
	center = n/2;
	memcpy(xx,x,sizeof(int)*n);
	sort(x,x+n,greater<int>());
	for(i = 0; i < n; i++){
		if(xx[i] < x[center-1])
			printf("%d\n",x[center-1]);
		else
			printf("%d\n",x[center]);
	}
	delete x;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  ll N, K; cin >> N >> K;
  double s = 0;
  REP(k, 1, N + 1) {
    ll val = k;
    double u = 1.0 / N;
    while (val < K) {
      u /= 2.0;
      val *= 2;
    }
    s += u;
  }
  printf("%.200f\n", s);
}


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

string prefix(string s, int n) {
	string ret;
	for (int i = 0; i < n; i++) ret += s[i];
	return ret;
}

string suffix(string s, int n) {
	string ret;
	for (int i = 0; i < n; i++) ret += s[s.length() - 1 - i];
	return ret;
}

string reverse(string s) {
	int l = 0, r = s.length() - 1;
	while (l < r) {
		swap(s[l], s[r]);
		l++; r--;
	}
	return s;
}

int m;
string s;

int main() {
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> s;
		
		int n = s.length();
		vector<string> hensei;
		
		for (int j = 1; j < n; j++) {
			for (int k = 0; k < 8; k++) {
				string t[2] = {prefix(s, j), suffix(s, n - j)};
				if ((k >> 2) & 1) t[0] = reverse(t[0]);
				if ((k >> 1) & 1) t[1] = reverse(t[1]);
				hensei.push_back(t[k % 2] + t[(k + 1) % 2]);
			}
		}
		sort(hensei.begin(), hensei.end());
		hensei.erase(unique(hensei.begin(), hensei.end()), hensei.end());
		
		cout << hensei.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3176
package main

// 実験する 両端においていく？
// 最後のやつを先頭に付けるタイプとそのままのタイプで比較（なんでだろうね
// 6ケースでなぜかWA まじでなんでだろうね 意味不明
// じゃ先頭のやつを最後に付けるのも試す？

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var V int
		fmt.Scan(&V)
		A[i] = V
	}
	B := append([]int{}, A...)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	sort.Ints(B)
	s, t := []int{}, []int{}
	l, r := 0, N-1
	for l <= r {
		s = append(s, A[l])
		t = append(t, B[l])
		l++
		if l > r {
			break
		}
		s = append(s, A[r])
		t = append(t, B[r])
		r--
	}
	// 意味がわからんが先頭を末尾に/末尾を先頭にしたものを揃えてみる 意味は分からんが
	// なんかサンプルではans5かans6になりそうだがなぜなのかは不明
	ans1, ans2 := 0, 0
	for i := 1; i < N; i++ {
		ans1 += abs(s[i-1] - s[i])
		ans2 += abs(t[i-1] - t[i])
	}
	ans3 := ans1 - abs(s[0]-s[1]) + abs(s[0]-s[N-1])
	ans4 := ans2 - abs(t[0]-t[1]) + abs(t[0]-t[N-1])
	ans5 := ans1 - abs(s[N-2]-s[N-1]) + abs(s[0]-s[N-1])
	ans6 := ans2 - abs(t[N-2]-t[N-1]) + abs(t[0]-t[N-1])
	fmt.Println(max(ans1, max(ans2, max(ans3, max(ans4, max(ans5, ans6))))))
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func abs(x int) int {
	if x < 0 {
		x *= -1
	}
	return x
}


Measured memory_bytes: 10752
S = input()
T = input()
sid = {}
tid = {}
ss = []
tt = []
sn = 0
tn = 0
for i in range(len(S)):
    if not S[i] in sid:
        sid[S[i]] = sn
        sn += 1
    ss += [sid[S[i]]]
    if not T[i] in tid:
        tid[T[i]] = tn
        tn += 1
    tt += [tid[T[i]]]
if ss == tt:
    print('Yes')
else:
    print('No')

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

int a,b;

int main ( void ) {
	cin>>a>>b;
	if(b==1){
		cout<<"0"<<endl;
		return 0;
	}
	for(int i=1;i<=100;i++)
		if(a*i+1-i>=b){
			cout<<i<<endl;
			break;
		}
	
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, sum, q int
	fmt.Scan(&N)
	q = N
	for q != 0 {
		sum += q % 10
		q /= 10
	}
	if N%sum == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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


ll p = 1000000007;

ll po(ll a, ll b){
ll c = a, d = 1;
while (b>0){
if (b%2==1){
d*=c;
d%=p;
}
c=c*c%p;
b/=2;
}
return d;
}

ll co(ll a,ll b){
ll c=1,d=1;
for (int i=1;i<=b;i++){
c*=(a+1-i);
c%=p;
d*=i;
d%=p;
}
c*=po(d,p-2);
c%=p;
return c;
}


int main(){
ll n,a,b;
cin >>n>>a>>b;
ll ans = 3*p+po(2LL,n)-1-co(n,a)-co(n,b);
ans%=p;
cout <<ans<<endl;
//cout <<po(2LL,n);
}

Measured memory_bytes: 256
function Main(input) {
    // input????????????????????\??????????????????????????????????????§?????????????????? input.split("\n") ????????§???????????????

    var data = input.split("\n")
    
    var fl = data[0].split(" ")

    console.log(parseInt(fl[0])*parseInt(fl[1]),(parseInt(fl[0])+parseInt(fl[1]))*2);
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15412
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, m, p, cor = 0, pena[100000] = {}, penanum = 0;
string s;
bool answered[100000] = {};

int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p >> s;
		p--;
		if (s == "AC") {
			if (!answered[p]) {
				cor++;
				answered[p] = true;
			}
		}
		else {
			if (!answered[p])pena[p]++;
		}
	}
	rep(i, n) {
		if (answered[i])penanum += pena[i];
	}
	cout << cor << " " << penanum << endl;
	return 0;
}

Measured memory_bytes: 1152
/*
[abc141] C - Attack Survival
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 1e5;

int N, K, Q;
int A[MAX_N];
int cnt[MAX_N];

void solve() {
    for (int i = 0; i < Q; i++) {
        cnt[A[i]]++;
    }
    for (int i = 0; i < N; i++) {
        cout << (K - Q + cnt[i] > 0 ? "Yes" : "No") << endl;
    }
}

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

    solve();

    return 0;
}


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

// 答えみた
// imos法?
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    for (int t = 0; t < min(50, k); ++t) {
        vector<int> b(n, 0);
        // cout << "## " << t << endl;  // debug
        for (int i = 0; i < n; ++i) {
            ++b[max(0, i - a[i])];
            if (i + a[i] + 1 < n) --b[i + a[i] + 1];
        }
        // cout << "before: ";  // debug
        // for (int i = 0; i < n; ++i) cout << b[i] << " ";

        for (int i = 1; i < n; ++i) b[i] += b[i - 1];

        // cout << endl << "after: ";  // debug
        // for (int i = 0; i < n; ++i) cout << b[i] << " ";

        a = b;
        // cout << endl;  // debug
    }
    for (int i : a) cout << i << " ";
    return 0;
}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int x; cin>>x;
  int sho=x/100;
  int amari=x%100;
  int sho5=amari/5;
  if(amari%5>0)sho5++;
  if(sho>=sho5){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define POWER_INDEX 3.0
int main(void){
	char string_input_value[3];
	double result_value;
	double power_index = 3 ;
	scanf("%s",string_input_value);
	int integer_input_value = atoi(string_input_value);
	result_value = pow(integer_input_value,POWER_INDEX);
	int output_value = (int)result_value;
	printf("%d\n",output_value);
	return 0;
	
}



Measured memory_bytes: 2052
#include <iostream>
#include <iomanip>
#include <cmath>

int main(void)
{
    double r;
    std::cin >> r;

    std::cout << std::fixed << std::setprecision(6)
        << M_PI * r * r << " " << 2 * M_PI * r << std::endl;

    return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;
typedef mp::cpp_int BigInt;
typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b) {
        std::swap(a, b);
    }
    
    return b ? gcd(b, a % b) : a;
}

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

BigInt gcdBigInt(BigInt a, BigInt b)
{
    if (a < b) {
        std::swap(a, b);
    }
    
    return b ? gcdBigInt(b, a % b) : a;
}

BigInt lcmBigInt(BigInt a, BigInt b)
{
    return a * b / gcdBigInt(a, b);
}

const ll MOD = 1000000007; // 1e9 + 7

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

ll solve(const std::vector<ll> a)
{
    const ll n = a.size();
    ll m = a[0];
    std::vector<ll> lcmArray;

    for (int i = 1; i < n; i++) {
        ll last_m = m;
        m = lcm(m, a[i]);
        if ((m / last_m < 1)||(m % last_m != 0)) {
            lcmArray.push_back(last_m);
            m = a[i];
        }
    }
    lcmArray.push_back(m);

    BigInt mBigInt = lcmArray[0];
    for (int i = 1; i < lcmArray.size(); i++) {
        mBigInt = lcmBigInt(mBigInt, lcmArray[i]);
    }

    m = static_cast<ll>(mBigInt % MOD);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        //sum += static_cast<ll>((mBigInt / a[i]) % MOD);
        sum += m * modinv(a[i], MOD);
        sum %= MOD;
    }

    return sum;
}

int main(int argc, char *argv[])
{
    ll n;
    std::vector<ll> a;

    std::cin >> n;

    a.resize(n);

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

    ll ans = solve(a);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 796
cookie = list(map(int, input().split()))
sc = sum(cookie)
cnt = 0
if cookie[0] == cookie[1] and cookie[1] == cookie[2] and cookie[0]%2 == 0:
    print(-1)
    exit()
memo = [0]*3
while cookie[0]%2 == 0 and cookie[1]%2 == 0 and cookie[2]%2 == 0:
    memo[0] = (cookie[1] + cookie[2]) // 2
    memo[1] = (cookie[0] + cookie[2]) // 2
    memo[2] = (cookie[1] + cookie[0]) // 2
    for i in range(3):
        cookie[i] = memo[i]
    cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    int main(int argc, char const *argv[])
    {
        int n;
        cin>>n;
        unordered_set<int>s;
        for (int i = 0; i < n; ++i)
        {
            int a;
            cin>>a;
            s.insert(a);
        }
        cout<<s.size()<<endl;
        return 0;
    }

Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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

  int N, M; cin >> N >> M;
  vi S(M); vc C(M); 
  REP(i,M) {
    cin>>S[i]>>C[i];
    S[i]--;
  }

  vi num(N, 'N');
  bool ok = true;
  REP(i,M) {
    if (num[S[i]]!='N' && num[S[i]]!=C[i]) {
      ok = false;
      break;
    }
    num[S[i]] = C[i];
  }
  if (!ok || N>1 && num[0] == '0') {
    cout << -1 << endl;
    return 0;
  }

  string ans = "";
  REP(i,N) {
    if (num[i] == 'N') {
      if (N==1) ans += '0';
      else { assert(N>1);
        if (i==0) ans += '1';
        else ans += '0';
      }
    } else {
      ans +=  num[i];
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1e9;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

// 15:10-15:34

// N, E, S, W
const int dx[4] = {-1, 0,  1,  0};
const int dy[4] = { 0, 1,  0, -1};

int w, h;
char a[100][100];
int d[100][100][2]; // (i, j): pos, k: foot(0:right, 1:left)

bool inside(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}

int dijkstra() {
    using State = tuple<int, int, int, int>; // cost, i, j, k
    priority_queue<State, vector<State>, greater<State>> pq;
    rep(i, h) rep(j, w) rep(k, 2) {
        if (a[i][j] == 'S') {
            d[i][j][k] = 0;
            pq.push(State(0, i, j, k));
        }
        else {
            d[i][j][k] = inf;
        }
    }

    while (!pq.empty()) {
        int cost, i, j, k;
        tie(cost, i, j, k) = pq.top(); pq.pop();
        if (d[i][j][k] < cost) continue;
        int nk = k^1;
        for (int dr = -2; dr <= +2; dr++) {
            for (int dc = 1; dc <= 3; dc++) {
                int ni = i + dr;
                int nj = j + dc * (k ? +1 : -1);
                if (!inside(ni, nj)) continue;
                if (abs(ni - i) + abs(nj - j) > 3) continue;
                if (a[ni][nj] == 'X') continue;
                int ncost = 0;
                if (isdigit(a[ni][nj])) ncost = a[ni][nj] - '0';
                if (d[ni][nj][nk] > cost + ncost) {
                    d[ni][nj][nk] = cost + ncost;
                    if (a[ni][nj] != 'T') pq.push(State(cost + ncost, ni, nj, nk));
                }
            }
        }
    }

    int ret = inf;
    rep(i, h) rep(j, w) rep(k, 2) {
        if (a[i][j] == 'T') chmin(ret, d[i][j][k]);
    }
    if (ret == inf) ret = -1;
    return ret;
}

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

    while (cin >> w >> h, w) {
        rep(i, h) rep(j, w) cin >> a[i][j];
        cout << dijkstra() << endl;
    }
}

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

int main(){
  ll n, l;
  cin >> n >> l;
  ll w[n], v[n];
  rep(i,n) cin >> w[i] >> v[i];
  ll a = w[0];
  rep(i,n) w[i] -= a;
  ll ans = 0;
  vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(3*n+1)));
  rep(i,n) {
    rep(j,n) {
      rep(k,3*n+1) {
        dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
        if(k+w[i] <= 3*n) dp[i+1][j+1][k+w[i]] = max(dp[i+1][j+1][k+w[i]],dp[i][j][k]+v[i]);
      }
    }
  }
  rep(i,n+1) {
    rep(j,3*n+1) {
      if(a*i+j <= l) ans= max(ans,dp[n][i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int a,b;

void input(){
    cin >> a >> b;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    if((a <= 0 && b >= 0) || (a <= 0 && b >= 0)){
        cout << "Zero" << endl;
        return 0;
    }
    else if(a > 0 && b > 0){
        cout << "Positive" << endl;
        return 0;
    }
    else{
        if((b-a+1)%2){
            cout << "Negative" << endl;
            return 0;
        }
        else{
            cout << "Positive" << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

ll lay[60];

ll ans(int n, ll x) {
	if (x == 0)return 0;
	if (n == 0)return 1;

	if (x <= lay[n - 1] + 1)return ans(n - 1, x - 1);
	if (x == lay[n - 1] + 2)return ans(n - 1, lay[n - 1]) + 1;
	if (x <= lay[n - 1] * 2 + 2)return ans(n - 1, lay[n - 1]) + 1 + ans(n - 1, x - (lay[n - 1] + 2));
	return 2* ans(n - 1, lay[n - 1]) + 1;
}



int main() {

	ll n, x;
	cin >> n >> x;
	lay[0] = 1;
	rep1(i, n)lay[i] = 2 * lay[i - 1] + 3;

	cout << ans(n,x) << endl;
}

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

int main(){
    char p[100000];
    int z=0,w=0;
    for(int i=0;i<MAX;i++){
        p[i]='a';
    }
    for(int i=0;i<MAX;i++){
        cin>>p[i];
        if(p[i]=='1')w++;
        if(p[i]=='0')z++;
    }
    int k=min(w,z);
    cout<<2*k<<endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int W=sc.nextInt();
	int H=sc.nextInt();
	int x=sc.nextInt();
	int y=sc.nextInt();
	int r=sc.nextInt();
	if(x>0&&x<W&&y>0&&y<H){
	    if(x+r<=W&&x-r>=0&&y+r<=H&&y-r>=0){
		System.out.println("Yes");
	    }else{
		System.out.println("No");	
	    }
	}else{
	    System.out.println("No");
	}
    
    }
}



Measured memory_bytes: 26416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    ios::sync_with_stdio(false);
    map<pair<ll,ll>,int> mp;
    int n;
    cin >> n;
    mint ans = 0;
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) {ans+=1;continue;}
        else if(a == 0) mp[make_pair(0,1)]++;
        else if(b == 0) mp[make_pair(1,0)]++;
        else {
            ll g = __gcd(a,b);
            mp[make_pair(a/g, b/g)]++;
        }
    }
    vector<mint> pow2(n);
    pow2[0] = 1;
    rep(i,n-1) pow2[i+1] = pow2[i]*2;
    mint ans2 = 1;
    if(mp.size()==1) {cout << 1 << endl;return 0;}
    while(!mp.empty()) {
        auto now = begin(mp);
        mp.erase(now);
        ll a = (*now).first.first;
        ll b = (*now).first.second;
        int num = (*now).second;
        int enemy = 0;
        if(a == 0) {
            enemy += mp[make_pair(1,0)];
            mp.erase(make_pair(1,0));
        } else if(b == 0) {
            enemy += mp[make_pair(0,1)];
            mp.erase(make_pair(0,1));
        } else {
            num += mp[make_pair(-a,-b)];
            mp.erase(make_pair(-a,-b));
            enemy += mp[make_pair(-b,a)];
            mp.erase(make_pair(-b,a));
            enemy += mp[make_pair(b,-a)];
            mp.erase(make_pair(b,-a));
        }
        ans2 *= pow2[num] + pow2[enemy] - 1;
    }
    ans += ans2;
    ans-=1;
    cout << ans << endl;
}


Measured memory_bytes: 17072
#include<stdio.h>
int main(void){

int n;
int i=0;
int A[100];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d", &A[i]);
	}
	for(i=n-1;0<=i;i--){
		printf("%d", A[i]);
			if(i!=0){
				printf(" ");
			}
	}
	printf("\n");
return 0;
}


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

using namespace std;

int n, b, c, x[2005];

int main()
{
    cin >> n >> b >> c;
    for (int i = 1; i <= n; i++)
        cin >> x[i];
    if (n == 1) cout << abs (c - x[1]);
    else cout << max (abs (c - x[n]), abs (x[n - 1] - x[n]));
}


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

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int N, ans=0, A=0, B=0;
  cin >> N;
  REP(i,N) {
    int H;
    cin >> H;
    if(A >= H) {
      A = H;
      B++;
      ans = max(ans, B);
    }
    else {
      A = H;
      B = 0;
    }
  }
  cout << ans << 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 int long long  
int main(){
    string s;
    cin >> s;
    int Ans=0;
    REP(i,3){
        if(s[i]=='1')Ans++;
    }
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  map<int,int>k;
  for(int i=0;i<N;i++){
    cin>>a[i];
    k[a[i]]++;
  }
  int ans=0;
  for(auto c:k){
   int x=c.first;
   int y=c.second;
   if(y>x){ans+=(y-x);}
   if(y<x){ans+=y;}
  }
  cout<<ans<<endl;
  return 0;
}

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

bool pn[1000001];
int main()
{
  pn[0] = pn[1] = false;

  for (int i = 2; i <= 1000001; i++){
    pn[i] = true;
  }
  for (int i = 2; i <= 1001; i++){
    if (pn[i]){
      for (int j = i * 2; j <= 1000001; j += i){
        pn[j] = false;
      }
    }
  }
  int n;
  while (cin >> n, n){
    int s = 0, ct = 0;
    
    for (int i = 1; i <= 1000001; i++){
      if (ct >= n)  break;
      if (pn[i]){
      s += i;
      ct++;
      }
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 2136
#include <stdio.h>
#include <stdlib.h>


typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, p[100001], x[100001], y[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &(p[i]));
	for (i = 1; i <= M; i++) scanf("%d %d", &(x[i]), &(y[i]));

	list **adj = (list**)malloc(sizeof(list*) * (N + 1)), *d = (list*)malloc(sizeof(list) * M * 2);
	for (i = 0; i < M; i++) {
		d[i*2].v = y[i+1];
		d[i*2+1].v = x[i+1];
		d[i*2].next = adj[x[i+1]];
		d[i*2+1].next = adj[y[i+1]];
		adj[x[i+1]] = &(d[i*2]);
		adj[y[i+1]] = &(d[i*2+1]);
	}
	
	list *po;
	int k, u, w, comp[100001] = {}, q[100001], head, tail;
	for (i = 1, k = 1; i <= N; i++) {
		if (comp[i] != 0) continue;
		comp[i] = k;
		q[0] = i;
		for (head = 0, tail = 1; head < tail; head++) {
			u = q[head];
			for (po = adj[u]; po != NULL; po = po->next) {
				w = po->v;
				if (comp[w] == 0) {
					comp[w] = comp[u];
					q[tail++] = w;
				}
			}
		}
		k++;
	}
	
	int ans = 0;
	for (i = 1; i <= N; i++)if (comp[i] == comp[p[i]]) ans++;
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 7512
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define min(a,b)	(a)>(b)?(b):(a)
#define ll long long 
int cmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	ll n,c,k,sum,t,s,i;
	int x[100005];
	scanf("%lld%lld%lld",&n,&c,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x[i]);
	}
	qsort(x+1,n,sizeof x[0],cmp);
	s=0;
	for(i=1;i<=n;i++)
	{
		if(i==1)
		{
			t=x[1]+k;
			sum=1;
			s=1;
		}
		else
		{
			if(s==c)			//车满 
			{
				t=x[i]+k;
				sum++;
				s=1;
			}	
			else				//车没满 
			{
				if(x[i]<=t)			//超时过了 
					s++;
				else
				{
					t=x[i]+k;
					sum++;
					s=1;
				}
			}
		}
	}
	 printf("%lld\n",sum); 
	return 0;
 } 

Measured memory_bytes: 892
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c){if(c>='0' and c<='9'){return (int)(c-'0');}return -1;}



int main()
{
  //IOS; /* making cin faster */
  int N,M;
  scanf("%d%d",&N,&M);

  int k,g,ming;
  int flag_NG = 1;

  ming = M;
  
  
  for( k = 1 ; k <= (int)sqrt(M) ; ++ k)
    {
      if( M % k == 0)
	{
	  g = M / k;
	  
	  if( k >= N )
	    {
	      
	      printf("%d\n",g);
	      flag_NG = 0;

	      break;
	    }
	  else
	    {
	      if( g >= N )
		{
		  ming = g;
		  
		}
	      
	      
	    }
	  
	}
      
      
    }

  if(flag_NG)
    {
      printf("%d\n",M/ming);
      
    }
  

  

}


Measured memory_bytes: 256
n,m=map(int,input().split())
abc=[list(map(int,input().split())) for _ in [0]*m]
g=[[] for _ in [0]*n]
[g[a-1].append([b-1,c]) for a,b,c in abc]

dist=[-10**15 for _ in [0]*n]
dist[0]=0
a,b=-10**15,-10**15

for _ in range(n):
    for p in range(n):
        for i,j in g[p]:
            dist[i]=max(dist[i],dist[p]+j)
    a,b=b,dist[n-1]

if a==b:
    print(a)
else:
    print("inf")

Measured memory_bytes: 3828
import sys, heapq
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
  
def solve():
    Q = int(single_input())
    n, a, b = map(int, line_input())
    left, right = [-a], [a]
    heapq.heapify(left)
    heapq.heapify(right)
    minans =  b
    ans = ""
    for i in range(1, Q):
        queri = [int(i) for i in line_input()]
        if queri[0] == 1:
            a, b = queri[1:]
            minans += b
            if -1 * left[0] <= a <= right[0]:
                heapq.heappush(left, -a)
                heapq.heappush(right, a)
            elif a < -1 * left[0]:
                minans += (-1 * left[0]) - a
                heapq.heappush(left, -a)
                heapq.heappush(left, -a)
                heapq.heappush(right, -1 * heapq.heappop(left))
            else:
                minans += a - right[0]
                heapq.heappush(left, -1 * heapq.heappop(right))
                heapq.heappush(right, a)
                heapq.heappush(right, a)
        else: ans += str(-1 * left[0]) + " " + str(minans) + "\n"
    print(ans)

    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 19068
#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>
using namespace std;




/*hantei(int num,int *h){
    int mini=100;
    for(int i=num;i<N;i++){
        if(h[i]==0)hantei(i,h);
        if(h[i]<mini && h[i]>0)mini=h[i];
    }

}*/

int main(){
    int count=0;
    int end=0;
    int N;
    int index1=0;
    int index2=0;
    cin >> N;

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

    while(end==0){
        int k=0;
        for(int j=0;j<N;j++){
            //cout << h[i];
            if(h[j]>0)k++;
        }
        //cout << endl;
        if(k==0)end++;

        for(int i=0;i<N;i++){
            while(h[i]>0){
                int bre=0;
                for(int j=i;j<N&&bre==0;j++){
                    if(h[j]>0)h[j]-=1;
                    else bre++;
                    //cout << j << h[j] << endl; 
                }
                count++;
                //cout << count << endl;
            }
        }

        /*int mini=100;
        i=index1=index2;
        //cout << "index2:" << index2 << " "; 
        for(i;i<N;i++){
            if(h[i]<mini && h[i]>0)mini=h[i];
        }
        if(mini==100){index2=0;continue;}
        cout << mini << endl;
        index2=0;
        i=index1;
        for(i;i<N;i++){
            h[i] -= mini;
            cout << h[i];
            if(h[i]==0){cout << i << endl;index2=i;}
        }*/
        //cout << "count"  << endl;
        //count+=mini;
    }
    
    cout << count <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
struct Element{
    int pos; int value;
    bool operator <(const Element& other)const{
        return value<other.value;
    }
};
Element e[100005];
long long a[100005];
int b[100005];
int c[100005];


void change(int p,int x,int n){
    while(p<=n){
        c[p] += x;
        p += p&-p;
    }
}

int ask(int p){
    int res = 0;
    while(p!=0){
        res += c[p];
        p -= p&-p;
    }
    return res;
}

long long getNumber(int n){
    int cnt0 = 0;
    for(int i = 0; i <= n; i++) c[i] = 0;
    for(int i = 1; i <= n; i++){
        cnt0 += (b[i]==0);
        e[i].value = 2*cnt0-i, e[i].pos = i;
    }
    e[n+1].value = 0, e[n+1].pos = 0;
    std::sort(e+1,e+1+n+1);
    int p = n+1;
    long long res = 0;
    while(p>=1){
        //printf("p = %d\n",p);
        int np = p;
        while(np-1>=1 && e[np-1].value==e[p].value) np--;
        for(int i = np; i <= p; i++){
            res += (long long)(ask(n)-ask(e[i].pos));
        }
        for(int i = np; i <= p; i++){
            if(e[i].pos!=0) change(e[i].pos,1,n);
        }
        p = np-1;
    }
    return res;
}

long long min(long long a,long long b){ return a>b?b:a; }

long long max(long long a,long long b){ return a>b?a:b; }

int main(){
    int n;
    scanf("%d",&n);
    long long minn = -1, maxn = -1;
    long long total = 0;
    for(int i = 1; i <= n; i++){ 
        total += n-i+1;
        scanf("%lld",&a[i]);
        if(i==1) minn = maxn = a[i];
        else{
            minn = min(minn,a[i]);
            maxn = max(maxn,a[i]);
        }
    }
    long long need = total/2+1;
    long long L = minn, R = maxn;
    long long res = -1;
    while(L<=R){
        long long M = (L+R)/2;
        for(int i = 1; i <= n; i++){
            if(a[i]<=M) b[i] = 0;
            else b[i] = 1;
        }
        if(getNumber(n)>=need){
            res = M;
            R = M-1;
        }
        else L = M+1;
    }
    printf("%lld\n",res);
    return 0;
}


Measured memory_bytes: 4056