akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
fn main() {
    input!(n: usize);
    let mut count = 0;
    for _ in 0..n {
        input!(d1: i32, d2: i32);
        if d1 == d2 { count += 1; }
        else { count = 0; }
        if count >= 3 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
int main()
{
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  rep(i, n) {
    if (i==0) {
      h[i]--;
      continue;
    }
    if (h[i]<h[i-1]) {
      cout << "No" << endl;
      return 0;
    }
    if (h[i]==h[i-1]) continue;
    h[i]--;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())

p_sum = 0
p_min = float("inf")

for _ in range(n):
    s = int(input())
    p_sum += s
    if s % 10 != 0:
        p_min = min(p_min, s)

# print(p_min, p_sum)


if p_sum % 10 != 0:
    print(p_sum)

else:
    if p_min == float("inf"):
        print(0)
    else:
        print(p_sum - p_min)


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(void)
{
    int student;
    double ave;
    double alpha;
    double point[1024] = {};
    
    while(1){
        ave = 0.0;
        alpha = 0.0;
        scanf("%d", &student);
        
        if(student == 0){
            break;
        }
        
        for(int i = 0; i < student; i++){
            scanf("%lf", &point[i]);
            ave = ave + point[i]/student;
        }
        
        for(int i = 0; i < student; i++){
            alpha = alpha + ((ave - point[i]) * (ave - point[i]));
        }
        printf("%lf\n", sqrt(alpha/student));
    }
    
    return 0;
}



Measured memory_bytes: 2696
N, W = map(int, input().split())
vw = [list(map(int, input().split())) for i in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    v, w = vw[i]
    for j in range(W+1):
        if j-w >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v)
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])


Measured memory_bytes: 25948
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    pw.println(a + a * a + a * a * a);
  }
}


Measured memory_bytes: 35748
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>x(N), y(N), h(N);
	rep(i, N)cin >> x[i] >> y[i] >> h[i];
	rep(i, N)rep(cx, 101)rep(cy, 101) {
		int H = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
		if (H < 1)continue;
		bool isOK = true;
		for (int i = 1; i < N; i++) {
			int height = max(H - abs(x[i] - cx) - abs(y[i] - cy), 0ll);
			if (h[i] != height)isOK = false;
		}
		if (isOK) {
			cout << cx << " " << cy << " " << H << endl;
			return 0;
		}
	}
}

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

public class Main {

    private  static void solver(InputReader sc, PrintWriter out) {
       int n= sc.nextInt();
       int arr[] = new int[n];
       for(int i=0;i<n;i++){
           arr[i]= sc.nextInt();
       }
       int[] dp = new int[n];
       dp[0] = 0;
       dp[1] = Math.abs(arr[1]-arr[0]);
       for(int i=2;i<n;i++){
           dp[i] = Math.min(Math.abs(arr[i]-arr[i-1])+dp[i-1],Math.abs(arr[i]-arr[i-2])+dp[i-2]);
       }
      /* for(int i=0;i<n;i++)
           out.print(dp[i]+" ");*/
       out.println(dp[n-1]);
    }
    public static void main(String[] args) throws Exception{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public void readLongArr(int n){
            long arr[] = new long[n];
            for(int i=0;i<n;i++){
                arr[i] = nextLong();
            }
        }
        public void readIntArr(int n){
            int arr[] = new int[n];
            for(int i=0; i<n; i++){
                arr[i] = nextInt();
            }
        }
    }
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

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

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define mod 1000000007
 
#define p(x) cout<<x<<" ";
#define p2(x,y) cout<<x<<" "<<y<<" "
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<" "
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
 
#define ff first
#define ss second
#define mp(x,y) make_pair(x,y)
#define pi pair<ll,ll>
#define ppi pair<ll,pi>
#define pb push_back
#define all(v) v.begin(), v.end() 

ll power(ll a,ll b){
  ll result=1;
  while(b){
    if(b&1)
      result=(result*a)%mod;
      a=(a*a)%mod;
      b=b/2;
  }
  return result;
}

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


ll dp[100005][4];
vi a(1e5+5),b(1e5+5),c(1e5+5);

ll solve(ll n,ll f){
  //p2(n,f)<<endl;
  if(n<=0)
    return 0;
  if(dp[n][f]!=-1)
    return dp[n][f];
  ll ans=INT_MIN;
  F(i,1,3){
    if(i!=f){
      if(i==1){
        ans=max(ans,a[n-1]+solve(n-1,i));
      }else
      if(i==2){
        ans=max(ans,b[n-1]+solve(n-1,i));
       
      }else
      if(i==3){
        ans=max(ans,c[n-1]+solve(n-1,i));
        
      }
    }
  }
 dp[n][f]=ans;
  return ans;
}










int main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cout<<fixed<<setprecision(6);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
  
    ll t=1;
    //cin>>t;
    
    while(t--)
    {
      ll n;
      cin>>n;
      F(i,0,n-1) cin>>a[i]>>b[i]>>c[i];
      memset(dp,-1,sizeof(dp));
      cout<<solve(n,0)<<"\n";

      
    }
        
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  vector<ll> B(N + 1), C(N + 1);
  B.at(0) = 0, C.at(0) = 0;
  for (ll i = 0; i < N; i++)
  {
    B.at(i + 1) = B.at(i) + A.at(i);
    C.at(i + 1) = C.at(i) + max(0LL, A.at(i));
  }

  ll ans = -INF;
  for (ll i = 0; i < N - K + 1; i++)
  {
    ll positive = C.at(i + K) - C.at(i);
    ll all = B.at(i + K) - B.at(i);
    chmax(ans, C.back() - (positive - all));
    chmax(ans, C.back() - positive);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
n=int(input())
a=[0]*(n+1)
b=[0]*n
a[:]=map(int,input().split())
b[:]=map(int,input().split())

r=sum(a)
minab=min(a[0],b[0])
a[0]-=minab
b[0]-=minab
for ii in range(n):
  minab=min(a[ii+1],b[ii])
  a[ii+1]-=minab
  b[ii]-=minab
  if ii+1<n:
    minab=min(a[ii+1],b[ii+1])
    a[ii+1]-=minab
    b[ii+1]-=minab
print(r-sum(a))


Measured memory_bytes: 19432
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  int a,i;
  priority_queue<int> que; //宣言
  for(i=0;i<n;i++){
    cin >> a;
    que.push(a);
  }
  for(i=0;i<m;i++){
    int x=que.top();
    que.pop();
    x=x/2;
    que.push(x);
  }
  long long ans=0;
  for(i=0;i<n;i++){
    int x=que.top();
    que.pop();
    ans+=x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3876
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  
  int res = 0;
  
  for(int  i = 0; i <= N; i++)
  {
    int odd = 0;
    int ii = i;
    while(ii >= 10)
    {
      int oo = ii / 10;
      odd += ii - (oo * 10);
      ii = oo;
    }
    
    int c = odd + ii;
    if(A <= c && c <= B) res += i;
  }
  
  cout << res << endl;
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    double t1,t2;
    double a1,a2;
    double b1,b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll ans = 1;
    if(t1*a1 + t2*a2 == t1*b1 + t2*b2){
        cout << "infinity" << endl;
        return 0;
    }else if((a1 > b1 && t1*a1 + t2*a2 > t1*b1 + t2*b2) || (a1 < b1 && t1*a1 + t2*a2 < t1*b1 + t2*b2)){
        cout << 0 << endl;
        return 0;
    }else{
        if(b1 > a1){
            swap(a1,b1);    swap(a2,b2);
        }
        ll dif = (t2*b2 + t1*b1 - t2*a2 - t1*a1);
        ll dif2 = t1*(a1 - b1);
        if(dif2%dif == 0){
            ans += (dif2/dif-1)*2;
            ans += 1;
        }else{
            ans += (dif2/dif-1)*2;
            ans += 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  for (int i = 1; i < n-1; i++) {
    if (p[i-1] < p[i] && p[i] < p[i+1]) ans++;
    if (p[i-1] > p[i] && p[i] > p[i+1]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
l=[1]*n
m.times do
  a,b=gets.split.map(&:to_i)
  if h[a-1]>=h[b-1]
    l[b-1]=0
  end
  if h[a-1]<=h[b-1]
    l[a-1]=0
  end
end
puts l.sum


Measured memory_bytes: 22508
void main() {
    int a = readln.chomp.to!int;
    int b = readln.chomp.to!int;
    int c = readln.chomp.to!int;
    int d = readln.chomp.to!int;
    writeln(min(a, b) + min(c, d));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 155555;

int N;
ll W;
ll w[110], v[110];
ll dp[110][lim];

int main(){
    cin >> N >> W;
    for(int i=0; i<N; i++) cin >> w[i] >> v[i];

    for(int i=0; i<110; i++){
        for(int j=0; j<lim; j++) dp[i][j] = 1e9+1;
    }
    
    for(int i=0; i<110; i++) dp[i][0] = 0;

    for(int i=0; i<N; i++){
        for(int j=0; j<=lim; j++){
            dp[i+1][j + v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }
    
    ll ans = 0;
    for(int i=0; i<lim; i++){
        if(dp[N][i] <= W) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 133888
import { readFileSync } from "fs";

const memo: number[][] = [];
const gcd = (a: number, b: number): number => {
  memo[a] || (memo[a] = []);
  return memo[a][b] || (memo[a][b] = a === 0 ? b : gcd(b % a, a));
};

export const solveC = (n: number): number => {
  let sum = 0;
  for (let i = 1; i <= n; i++)
    for (let j = 1; j <= n; j++)
      for (let k = 1; k <= n; k++) {
        const [a, b, c] = [i, j, k].sort((x, y) => x - y);
        sum += gcd(gcd(a, b), c);
      }
  return sum;
};

if (require.main === module)
  console.log(solveC(+readFileSync("/dev/stdin", "utf8")));


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

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

#define MAX 100005
#define INF INT_MAX

typedef long long ll;
typedef pair<int, int> P;

class Node
{
public:
    int parent;
    int depth;
    vector<int> child;
    Node(int id) { parent = -1; depth = 0; }
};

void dfs(int v, int p, vector<Node>& nodes)
{
    for (int c : nodes[v].child) {
        nodes[c].depth = nodes[v].depth + 1;
        dfs(c, v, nodes);
    }
}

int main(int, char**)
{
    int n;
    cin >> n;

    vector<Node> nodes;
    rep(i,n) nodes.push_back(Node(i));
    rep(i,n) {
        int id, k;
        cin >> id >> k;
        rep(j,k) {
            int tmp;
            cin >> tmp;
            nodes[id].child.push_back(tmp);
            nodes[tmp].parent = id;
        }
    }
    auto itr = find_if(nodes.begin(), nodes.end(), [] (Node& nd) { return nd.parent == -1; } );
    int root = distance(nodes.begin(), itr);
    dfs(root, -1, nodes);

    rep(i,n) {
        Node nd = nodes[i];
        cout << "node " << i << ": parent = " << nd.parent << ", depth = " << nd.depth << ", ";
        if (nd.parent == -1) cout << "root";
        else if (nd.child.size() == 0) cout << "leaf";
        else cout << "internal node";
        cout << ", [";
        int s = nd.child.size();
        rep (j,s) { if(j) cout << ", "; cout << nd.child[j]; }
        cout << "]" << endl;
    }

    return 0;
}


Measured memory_bytes: 7008
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>

using namespace std;

int n,x,y,siz[200001],fa[200001],maxs[200001],maxp[200001],mins[200001],minp[200001],maxl[200001],minn;
long long ans;
vector<int> point[200001];
char str[200001];

void dfs1(int u,bool check){
	siz[u]=str[u]-'0';
	for(int v:point[u])if(v!=fa[u]){
		fa[v]=u;
		dfs1(v,true);
		siz[u]+=siz[v],maxs[u]=max(maxs[u],maxs[v]+1);
		if(mins[v]<0x7f7f7f7f)mins[u]=min(mins[u],maxs[v]+1);
	}
	if(point[u].size()==check)maxs[u]=0,mins[u]=str[u]-'0'?0:0x7f7f7f7f;else if(str[u]-'0')mins[u]=min(mins[u],maxs[u]);
}

void dfs2(int u,bool check){
	maxp[u]=max(maxp[u],check+maxp[fa[u]]);
	if(check)maxl[u]=max(maxl[u],maxp[u]-1);
	int mx=-1;for(int v:point[u])if(v!=fa[u])maxp[v]=max(maxp[v],mx+2),mx=max(mx,maxs[v]);
	mx=-1;for(int i=point[u].size()-1;~i;--i){int v=point[u][i];if(v!=fa[u])maxp[v]=max(maxp[v],mx+2),mx=max(mx,maxs[v]);}
	for(int v:point[u])if(v!=fa[u])dfs2(v,true);
}

int main(){
	memset(mins,0x7f,sizeof(mins)),memset(minp,0x7f,sizeof(minp));
	scanf("%d",&n);for(int i=1;i<n;++i)scanf("%d%d",&x,&y),point[x].push_back(y),point[y].push_back(x);scanf("%s",str+1);
	dfs1(1,false),dfs2(1,false);
	for(int i=1;i<=n;++i){
		if(str[i]-'0')minn=0;else minn=min(mins[i],siz[i]==siz[1]?2147483647:maxp[i]);
		int d=max(maxs[i],maxp[i])-1;for(int v:point[i])if(v!=fa[i])d=min(d,maxl[v]+1);else d=min(d,maxs[i]+1);
		if(d>=minn)ans+=d-minn+1;
	}
	printf("%lld",ans+1);
}

Measured memory_bytes: 26368
#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>;
 
int main(){
    int n, m, x, in;
    cin >> n >> m >> x;
    vector<int> a(n);
    rep(i, n) a.at(i) = 0;
    rep(i, m){
        cin >> in;
        a.at(in-1) = 1;
    }
    int cos0 = 0;
    int cos1 = 0;
    int f = 0;
    rep(i, n){
        if(f == 0){
            cos0 += a.at(i);
        }else{
            cos1 += a.at(i);
        }
        if(i == x-1) f = 1;
    }
    cout << min(cos0, cos1) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

p_dic = {}
i=2
while i ** 2 <= N:
  if N % i == 0:
    p_dic[i] = 0
    while N % i == 0:
      p_dic[i] += 1
      N /= i
  i += 1

if N > 1:
  p_dic[N] = 1
  
def foo(x):
  r = 0
  base = 1
  while x >= base:
    x -= base
    r+=1
    base += 1
  return r

ans = 0
for v in p_dic.values():
#  print(v, foo(v))
  ans += foo(v)

print(ans)

Measured memory_bytes: 9276
from sys import stdin
import numpy as np
from numba import njit
def main():
    #入力
    readline=stdin.readline
    n,k=map(int,readline().split())
    a=np.array(list(map(int,readline().split())),dtype=np.int64)

    cnt=0
    while cnt<k:
        s=f(n,a)
        a=np.cumsum(s)
        cnt+=1
        if a[a==n].size==n:
            break

    print(*a)

@njit("i8[:](i8,i8[:])",cache=True)
def f(n,a):
    s=np.zeros(n,dtype=np.int64)
    for i in range(n):
        x_min=i-a[i]
        x_max=i+a[i]+1
        s[max(0,x_min)]+=1
        if n-1<x_max:
            pass
        else:
            s[x_max]-=1
    return s

if __name__=="__main__":
    main()

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

#define ll long long
#define mod 1000000007
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fo(i,n) for(i=0;i<n;i++)
#define fok(i,k,n) for(i=k;i<n;i++)
#define dbg(x) cout<<#x<<" "<<x
#define sci(x) scanf("%d",&x)
#define scd(x) scanf("%lf",&x)
#define scl(x) scanf("%lld",&x)
#define pfi(x) printf("%d",x)
#define pfd(x) printf("%lf",x)
#define pfl(x) printf("%lld",x)


auto fatafat=[](){std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); return 0;}();

int minCost(int n,vector<int>& v,int i,vector<int>& dp)
{
    if(i==n-1)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    
    if(i+2<=n-1)
        dp[i]= min(abs(v[i]-v[i+1])  +minCost(n,v,i+1,dp) , abs(v[i]-v[i+2])+ minCost(n,v,i+2,dp));
    else
        dp[i]= abs(v[i]-v[i+1]) +minCost(n,v,i+1,dp);
    
    return dp[i];
    
}


int main()
{
   
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    
    vector<int> dp(n,-1);
    
    cout<<minCost(n,v,0,dp);
    
    
    
    
}

Measured memory_bytes: 4992
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	rep(i, N)cin >> A[i];

	int mx = -1;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (mx < abs(A[i] - A[j]))mx = abs(A[i] - A[j]);
		}
	}

	cout << mx << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main(){
	int N, K;
	scanf("%d%d", &N, &K);
	K--;
	vector<long long> H(N);
	rep(i, N)cin >> H[i];
	sort(H.begin(), H.end());
	long long ans = INF;
	for(int i = 0; i < N - K; i++){
		long long dis = H.at(i + K) - H.at(i);
		if(ans > dis)ans = dis;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
  
 int main(void){
 	int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
	d=a;
	a=b;
	b=d;
	d=0;
}
if(a>c){
	d=a;
	a=c;
	c=d;
	d=0;
}
if(b>c){
	d=b;
	b=c;
	c=d;
	d=0;
}
printf("%d %d %d\n",a,b,c);
return 0; 
}



Measured memory_bytes: 2736
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

#define X first
#define Y second

int a, b;

pair<int, int> calc(int d) {
	int x = 0, y = 0, diff = 0;

	while(diff != d) {
		const int ad = abs(diff + a - d), bd = abs(diff - b - d);
		if(ad > bd) {
			diff -= b;
			++y;
		}
		else {
			diff += a;
			++x;
		}
	}

	return make_pair(x, y);
}

void chans(pair<int, int>& p, const pair<int, int>& q) {
	const int p_sum = p.X + p.Y, q_sum = q.X + q.Y;
	if(p_sum > q_sum || (p_sum == q_sum && p.X * a + p.Y * b > q.X * a + q.Y * b))
		p = q;
}

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

	for(int d; cin >> a >> b >> d, a | b | d;) {
		int g = __gcd(a, b);
		a /= g;
		b /= g;
		d /= g;

		pair<int, int> ans = calc(d);
		chans(ans, calc(-d));

		if(d % a == 0)
			chans(ans, make_pair(d / a, 0));

		if(d % b == 0)
			chans(ans, make_pair(0, d / b));

		for(int x = 1; a * x < d; ++x) {
			const int rest = d - a * x;
			if(rest % b == 0)
				chans(ans, make_pair(x, rest / b));
		}

		cout << ans.X << " " << ans.Y << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18;

typedef struct {
  ll from;
  ll to;
  ll cost;
} S_Edge;

int main()
{
  ll N, M;
  std::cin >> N >> M;
  std::vector<S_Edge> ve(M);

  for (ll i = 0; i < M; i++) {
    S_Edge edge;
    std::cin >> edge.from >> edge.to >> edge.cost;
    edge.from--;
    edge.to--;
    edge.cost *= -1;
    ve.push_back(edge);
  }

  std::vector<ll> dist(N, INF);
  dist[0] = 0;

  for (ll v = 0; v < N; v++) {
    bool was_updated = false;

    std::vector<S_Edge>::iterator it;
    for (it = ve.begin(); it != ve.end(); it++) {
      if (dist[it->from] != INF && dist[it->to] > dist[it->from] + it->cost) {
	dist[it->to] = dist[it->from] + it->cost;
	was_updated = true;
      }
    }

    if (!was_updated) {
      break;
    }
  }

  ll ans = -dist[N-1];

  std::vector<bool> negative(N);
  for (ll v = 0; v < N; v++) {
    dist[v] = 0LL;
    negative[v] = false;
  }
  for (ll v = 0; v < N; v++) {
    std::vector<S_Edge>::iterator it;
    for (it = ve.begin(); it != ve.end(); it++) {
      if (dist[it->to] > dist[it->from] + it->cost) {
	dist[it->to] = dist[it->from] + it->cost;
	//std::cout << v << " from:" << it->from+1 << " to:" << it->to+1 << " " << dist[it->to] << std::endl;
	if (v == N - 1) {
	  negative[it->to] = true;
	}
      }
    }
  }

  if (negative[N-1]) {
    std::cout << "inf" << std::endl;
  } else {
    std::cout << ans << std::endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
// ll gcd(ll a, ll b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
ll mod(ll x) {
	x%=MOD;
	if(x<0)x+=MOD;
	return x;
}
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = mod(prod*b);
// 		}
// 		b = mod(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
//0 is white, 1 is black
int n,m,x,c[12],a[12][12],cnt[(1<<12)][12],cost[(1<<12)];
void solve() {
	scanf("%d %d %d",&n,&m,&x);
	for (int i = 0; i < n; i++) {
		scanf("%d",&c[i]);
		for (int j = 0; j < m; j++) {
			scanf("%d",&a[i][j]);
		}
	}
	int ans = INF;
	for (int i = 1; i < (1<<n); i++) {
		int last = log2(i);
		cost[i] = cost[i^(1<<last)] + c[last];
		int num = 0;
		for (int j = 0; j < m; j++) {
			cnt[i][j] = cnt[i^(1<<last)][j] + a[last][j];
			if (cnt[i][j]>=x)num++;
		}
		if (num==m)ans=min(ans,cost[i]);
	}
	if (ans==INF) {
		printf("-1\n");
	} else {
		printf("%d\n",ans);
	}
}
int main() {
	int t=1;
	// cin >> t;
	for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	}
}

Measured memory_bytes: 4112
N, K = map(int, input().split())
S = input()

ones = [0]
zeros = []
flag = '1'
for s in S:
    if s == '1':
        if flag == '1':
            ones[-1] += 1
        else:
            ones.append(1)
    else:
        if flag == '1':
            zeros.append(1)
        else:
            zeros[-1] += 1
    flag = s
ones.append(0)

tmp = sum(ones[0 : K + 1]) + sum(zeros[0 : K])
ans = tmp
for i in range(len(zeros) - (K + 1) + 1):
    tmp = tmp + ones[i + K + 1] - ones[i] + zeros[i + K] - zeros[i]
    ans = max(ans, tmp)
    
print(ans)

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

signed main()
{
  int N; cin>>N;
  vector<int> a(N+1);
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }

  vector<int> cnt(N+1);
  vector<int> ans;
  for(int i=N;i>=1;i--){
    int c=0;
    for(int j=i*2;j<=N;j+=i){
      c+=cnt[j];
    }
    if(c%2!=a[i]){
      cnt[i]=1;
      ans.push_back(i);
    }
  }

  cout<<ans.size()<<endl;
  for(int x:ans){
    cout<<x<<' ';
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 4980
'use strict';

const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');

const m = parseInt(inputs[0].split(' ')[1], 10);

const products = inputs[1].split(' ').map(v => parseInt(v, 10));

products.sort((a, b) => a - b).reverse();

const totalVotes = products.reduce((acc, cur) => cur + acc, 0);

for (let i = 0 ; i < m ; ++i) {
  if (products[i] < totalVotes / (4 * m)) {
    console.log('No');
    return;
  }
}

console.log('Yes');

Measured memory_bytes: 21064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

ll add(ll a, ll b)
{
	a+=b; a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	if(a>MOD) a%=MOD;
	if(b>MOD) b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}

class PointSegmentTree{
private:
	int size_;
	vector<ll> v;
	
	void update(int p, ll val, int k, int l, int r)
	{
		if(p < l || r < p) return;
		if(l == r){
			v[k]=add(v[k],val);	//modification
			return;
		}
		int mid = (l+r)>>1;
		update(p, val, k*2, l, mid);
		update(p, val, k*2+1, mid+1, r);
		v[k] = merge(v[k*2], v[k*2+1]);
	}
	
	ll query(int s, int e, int k, int l, int r)
	{
		if(e < l || r < s) return 0; //dummy value
		if(s <= l && r <= e) return v[k];
		int mid = (l+r)>>1;
		ll lc = query(s, e, k*2, l, mid);
		ll rc = query(s, e, k*2+1, mid+1, r);
		return merge(lc, rc);
	}
	
public:
	PointSegmentTree(): v(vector<ll>()) {}
	PointSegmentTree(int n){
		for(size_=1;size_<n;) size_<<=1;
		v.resize(size_*4);
	}
	//void reset(){}
	inline ll merge(ll x, ll y){
		return add(x,y);
	}
	inline void update(int p, ll val){
		update(p, val, 1, 0, size_-1);
	}
	inline ll query(int l, int r){
		return query(l, r, 1, 0, size_-1);
	}
};

const bool DEBUG = 0;
const int MAXN = 200005;

int n,K;
vii a;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n>>K;
	a.resize(K);
	forn(i,0,K) cin>>a[i].F>>a[i].S;
	
	PointSegmentTree st(n+5);
	st.update(1,1);
	fore(i,2,n)
	{
		for(ii e: a)
		{
			int l=max(i-e.S,0LL), r=max(i-e.F,0LL);
			st.update(i, st.query(l,r));
		}
	}
	cout<<st.query(n,n)<<'\n';
	
	return 0;
}


Measured memory_bytes: 11404
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <limits>
#include <cmath>

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
#define rep(i, a, b) for(int i = (a); i < (b); ++i )
#define rrep(i, a, b) for(int i = (a); i > (b); --i )
#define REP(i, a, b) for(int i = (a); i <= (b); ++i )
#define RREP(i, a, b) for(int i = (a); i >= (b); --i )

ll A, B;
ll h, w;

char G[101][101];

int main() {
    std::cin >> A >> B;
    ll cnt_a = 1, cnt_b = 1;
    rep(i, 0, 100) {
        rep(j, 0, 100) {
            if (i < 50) {
                //White
                if((i%2 == 0) && (j%2) && (cnt_b < B) && (j < 99)) {
                    G[i][j] = '#';
                    cnt_b++;
                }else{
                    G[i][j] = '.';
                }
            } else {
                //Black
                if((i%2 == 1) && (j%2) && (cnt_a < A) && (j < 99)) {
                    G[i][j] = '.';
                    cnt_a++;
                }else{
                    G[i][j] = '#';
                }
            }
        }
    }
    std::cout << 100 << " " << 100 << std::endl;
    rep(i, 0, 100) {
        rep(j, 0, 100) {
            std::cout << G[i][j];
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
char s[N] ;
int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1) ;
    int cnt = 0;
    for(int i = 1; i <= n; i++) {
        if(s[i] == 'o') cnt++;
    }
    if(cnt + 15 - n >= 8) cout << "YES";
    else cout << "NO" ;
    return 0;
}


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

namespace ConsoleApp11
{
    class Class28
    {
        static void Main()
        {
            string S = Console.ReadLine();
            string a, b;
            for(int i = S.Length / 2; i >= 1; i--)
            {
                a = S.Substring(0, i);
                b = S.Substring(i,i);
                if (a == b&i*2!=S.Length)
                {
                    Console.WriteLine(a.Length * 2);
                    break;
                }
                   
            }     
            
        }
    }
}

Measured memory_bytes: 13140
//日本語を含むjavaプログラムのコンパイルは
//javac -encoding utf-8 Main.java
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    String[] r = new String[3];
    for (int i = 0; i < 3; i++) {
      r[i] = sc.next();
    }
    for (int i = 0; i < 3; i++) {
      System.out.print(r[i].charAt(i));
    }
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

typedef vector<ll> vec;
typedef vector<vec> mat;

ll M;

// A*Bの計算
mat mul(mat &A, mat &B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < B[0].size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M;
                if (C[i][j] < 0) C[i][j] += M;
            }
        }
    }

    return C;
}

// A^nの計算
mat pow(mat A, ll n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while(n > 0) {
        if (n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;


}


int main() {
    ll L, A, B;
    cin >> L >> A >> B >> M;
    ll ub[19];
    ub[0] = 0;
    for (auto i = 1; i <= 18; i++)
    {
        ll x = ub[i - 1];
        if ((to_string(A + B * x)).size() != i)
        {
            ub[i] = ub[i - 1];
            continue;
        }
        ll ok = x;
        ll ng = L;
        while (abs(ok - ng) > 1)
        {
            ll t = (ok + ng) / 2;
            if ((to_string(A + B * t)).size() == i)
            {
                ok = t;
            }
            else
            {
                ng = t;
            }
        }
        ub[i] = ng;
//        cout << ub[i] << endl;
    }
    ll ans = 0;
    A %= M;
    if (A < 0) A+= M;
    vector<ll> d = {0, A, 1};
    REP(i, 1, 19) {
        ll x = 1;
        for (ll j = 0; j < i; j++) {
            x *= 10;
            x %= M;
            if (x < 0) x += M;
        }
        mat mm(3, vec(3));
        B %= M;
        if (B < 0) B+=M;
        mm[0] = {x, 1, 0};
        mm[1] = {0, 1, B};
        mm[2] = {0, 0, 1};

        ll y = ub[i] - ub[i-1];

        if (y == 0) {
            continue;
        }

        mat m2 = pow(mm, y);
        vector<ll> r(3, 0);
        rep(i, 3) {
            rep(j, 3){
                r[i] += (m2[i][j]*d[j]) % M;
                if (r[i] < 0) r[i] += M;
            }
            r[i] %= M;
            if (r[i] < 0) r[i] += M;
        }

        d = r;


    }

    cout << d[0] << endl;



}

Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().input().solve().output();
	}
	
//	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);
	int N = 0;
	int M = 0;
	int K = 0;
	boolean ans = false;
	public Main input() throws IOException {
		//n = Integer.parseInt(br.readLine());
		N = in.nextInt();
		M = in.nextInt();
		K = in.nextInt();
		return this;
	}

	public Main solve() throws IOException {
		for(int i=0; i<=N; i++) {
			for( int j=0; j<=M; j++) {
				if(i*M + j*N - i*j*2 == K){
					ans = true;
					return this;
				}
			}
		}
		return this;
	}
	
	public Main output() {
		out.println(ans ? "Yes" : "No");
		out.flush();
		return this;
	}
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

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

  string t = "CODEFESTIVAL2016";
  int cnt = 0;
  REP(i, s.size()){
    if(s[i] != t[i]) cnt++;
  }

  cout << cnt << endl; 

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char s[10];

    scanf("%s", s);

    if(strcmp(s, "SUN") == 0) puts("7");
    else if(strcmp(s, "MON") == 0) puts("6");
    else if(strcmp(s, "TUE") == 0) puts("5");
    else if(strcmp(s, "WED") == 0) puts("4");
    else if(strcmp(s, "THU") == 0) puts("3");
    else if(strcmp(s, "FRI") == 0) puts("2");
    else if(strcmp(s, "SAT") == 0) puts("1");

    return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define print printf("==================\n")
#define ll long long
#define pi acos(-1.0)
#define eps 1e-16
#define max3(a,b,c) max(a,max(b,c))
const ll INF = 1 << 30;
#define mod 1000000007
typedef pair<double, double  > payar;
typedef struct
{
    ll  x, y;
} point;
priority_queue<payar, vector<payar>,  greater<payar> > pq; ///accending
vector< pair<double,payar  > > vpp;
vector < payar >  vp;
int n, k;
ll ara[100005];
ll dp[3001][3001][3];
ll rec(int i,int j,int player=1)
{
    if(i>j)
        return 0;
    if(i>n)
        return 0;
    if(j<1)
        return 0 ;
    ll maxi =-1;
    ll maxi2=-1;
    if(dp[i][j][player] != -1)
        return dp[i][j][player];
    ll &ans = dp[i][j][player];
    if(player==1)
        ans=max(ara[i]+rec(i+1,j,2), ara[j]+rec(i,j-1,2));
    if(player==2)
        ans =min(-ara[j]+rec(i,j-1,1),-ara[i]+rec(i+1,j,1));
    return ans ;


}
int main()
{

    cin>>n;
    for(int i = 1 ; i<=n ; i++)
        cin>>ara[i];
   memset(dp,-1,sizeof dp);
    cout<< rec(1,n,1);
    return 0 ;
}




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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=114514;
pi buf[Nmax][11];
vi g[Nmax];

signed main(){
	int n=read(),m=read();
	REP(i,m){
		int a=read()-1,b=read()-1;
		g[a].PB(b);
		g[b].PB(a);
	}
	int q=read();
	FOR(i,1,q+1){
		int v=read()-1,d=read(),c=read();
		buf[v][d]=pi(i,c);
	}
	REP(_,10)REP(i,n)for(auto j:g[i])FOR(k,1,11)chmax(buf[j][k-1],buf[i][k]);
	REP(i,n)
		print(max_element(buf[i],buf[i]+11)->second);
}


Measured memory_bytes: 24948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long>a(n);
  long long sum1=0;
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
    sum1+=a[i];
  }
  int m=a[0];
  long long sum2=0;
  for (int i=0;i<n-1;i++) {
    if(a.at(i)>a.at(i+1)){
      a.at(i+1)=a.at(i);
    }
    else{
      m=a[i+1];
    }
  }
  for (int i=0;i<n;i++) {
    sum2+=a[i];
  }
  cout << sum2-sum1 << endl;
}

Measured memory_bytes: 4824
using System;
using System.Linq;
class Program
{
    public static void Main()
    {
        char[] n = Console.ReadLine().ToCharArray();
        int sum = (int)Char.GetNumericValue(n[0]) - 1;
        sum += 9 * (n.Length - 1);
        bool f = true;
        if (n.Length >= 2)
            for (int i = 1; i < n.Length; i++)
                f = f && (int)Char.GetNumericValue(n[i]) == 9;
        if (f)
            Console.WriteLine(sum + 1);
        else
            Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define mx 100000
#define pb push_back
#define print(a) printf("%d",a)
#define sc1(a) scanf("%d",&a)
using namespace std;

typedef unsigned long  ull;
typedef long long int lli;

int main()
{
		string s;
		cin>>s;
		if (s[2]==s[3] && s[4]==s[5])
			cout<<"Yes\n";
		else
			cout<<"No\n";


 return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

// Driver program
void Main() {

  int X,A,B;
  cin>>X>>A>>B;

  X-=A;

  while(X>=B){
    X-=B;
  }

  cout<< X<<"\n";
}


//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,i;
cin>>n;
for(i=1;i<=n;i++){
    int x=(double)i*(double)1.08;
    if(x==n){
        cout<<i<<endl;
        return 0;
    }
}
cout<<":("<<endl;
}


Measured memory_bytes: 256
N,x=map(int,input().split())
A=[int(a) for a in input().split()]
ans=0
for i in range(N-1):
  if A[i]+A[i+1] > x:
    cnt=(A[i]+A[i+1])-x
    if cnt<=A[i+1]:
      A[i+1]-=cnt
      ans+=cnt
    else:
      A[i+1]=0
      ans+=cnt
print(ans)

Measured memory_bytes: 14064
#include <iostream>

using namespace std;
int main(){
    int i,j,n;
    cin >> n;
    if(n==2){
        cout << 2 << endl;
        cout << 0 << endl;
        cout << 11 << endl;
        return 0;
    }else if(n==1){
        cout << 1 << endl;
        cout << 0 << endl;
        return 0;
    }
    cout << n - 1 << endl;
    for(i=0;i<n - 1;i++){
        cout << 0;
        for(j=0;j<i;j++){
            cout << 1;
        }
        cout << 0 << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string s,t; cin>>s>>t;
    if(s==t) {cout<<"EQUAL"<<endl; return 0;}
    if(s.size()>t.size()) {cout<<"GREATER"<<endl; return 0;}
    else if(s.size()<t.size()) {cout<<"LESS"<<endl; return 0;}
    rep(i, s.size()){
        if(s[i]==t[i]) continue;
        if(s[i]-'0'>t[i]-'0') cout<<"GREATER"<<endl; 
        else cout<<"LESS"<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][] vectorA = new int[n][m];
		int[][] vectorB = new int[m][l];
		long[][] vectorC = new long[n][l];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				int elm =scan.nextInt();
				vectorA[i][j] = elm;
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				int elm = scan.nextInt();
				vectorB[i][j] = elm;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				long ans = 0;
				for(int k = 0; k < m; k++){
					ans += (long) vectorA[i][k] * (long) vectorB[k][j];
					
				}
				vectorC[i][j] = ans;
				System.out.printf(j != l - 1? "%d " : "%d\n", vectorC[i][j]);
			}
		}
	}
}

Measured memory_bytes: 68724