akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
//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<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//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 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())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
int main(void){
	int N = 0;
	int a[300000];
	cin >> N;
	REP(i,N){
		cin >> a[i];
	}
	unsigned long S = 0;
	REP(i, N){
		S += a[i];
	}
	unsigned long x = 0;
	unsigned long y = 0;
	unsigned long ans = 18446744073709551615;
	REP(i, N-1)
	{
		x += a[i];
		ans = min(ans, 2 * x - S);
	}
	REP(i, N - 1)
	{
		y += a[N-i-1];
		ans = min(ans, 2 * y - S);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class T> inline int Digit_L(T n){
  int res=0;
  while(n){
    res++;
    n /= 10;
  }
  return res;
}
int N;
int main(){
  int N, i, res=0;
  rd(N);
  for(i=(1);i<(N+1);i++){
    res +=Digit_L(i)%2;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N;
// {
//   int N, res = 0;
//   rd(N);
//   rep(i,1,N+1) res += Digit(i)%2;
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

vector<vector<long long int>> combination_calc(2000,vector<long long int>(2000,-1));
long long int combination2(long long int n,long long int k){
    if(combination_calc[n][k]!=-1){
        return combination_calc[n][k];
    }else if(k==0){
        combination_calc[n][0]=1;
        return 1;
    }else if(k==n){
        combination_calc[n][n]=1;
        return 1;
    }else if(n<10000){
        combination_calc[n][k]=(combination2(n-1,k-1)+combination2(n-1,k))%MOD;
        return combination_calc[n][k];
    }else{
        return (combination2(n-1,k-1)+combination2(n-1,k))%MOD;
    }
}

int main(){
    INT(n,k);
    int red=n-k;
    ll ans=1;
    for(int i=1;i<=k;i++){
        ans=combination2(k-1,i-1);
        if(red>=i-1)ans*=combination2(red+1,i);
        else ans=0;
        ans%=MOD;
        out(ans);
    }
}

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


int main(){
    ll k,a,b,ans;
    cin>>k>>a>>b;
    if(b-a<2){
        ans=1+k;
    }
    else if(a+1>k){
        ans=1+k;
    }
    else{
        ll res=k-(a+1);
        if(res%2==0){
            ans=b+(b-a)*(res/2);
        }
        else ans=b+(b-a)*(res/2)+1;
    }
    cout<<ans<<endl;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2*1e5+10;
int w[N],d[N],cnt[20],res,n,st,sxr[N];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();rp(i,1,n-1){ri u=read()+1,v=read()+1,va=read();w[u]^=va;w[v]^=va;}rp(i,1,n)cnt[w[i]]++;
	rp(i,1,15)res+=cnt[i]/2,st|=(cnt[i]&1)<<(i-1);
	n=(1<<15)-1;
	rp(i,1,n)d[i]=d[i>>1]+(i&1);rp(i,1,n-1)d[i]-=1;
	rp(i,1,n){rp(j,0,14)if((i>>j)&1)sxr[i]^=(j+1);}
	rp(i,1,n)
	{
		if(!sxr[i])for(int k=(i-1)&i;k;k=(k-1)&i)if(!sxr[k])d[i]=min(d[i],d[k]+d[i^k]);
	}
	printf("%d",res+d[st]);
	return 0;
}


Measured memory_bytes: 896
int main(){
 
  int n, k;
  char s[50];
 
  scanf("%d %d",&n,&k);
 
  scanf("%s",s);
 
  if(n >= k){
    if(s[k-1] < 'a'){
      s[k-1] = s[k-1]+32;
    }else{
      s[k-1] = s[k-1]-32;
    }
  }
  printf("%s\n",s);
 
  return 0;
 
 
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 300010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    string s;
    cin >> n >> k >> s;
    vector<string> c;
    rep(i,min(k,16)){
        string t = s;
        reverse(all(t));
        string u = s+t;
        c.clear();
        rep(j,n+1){
            c.push_back(u.substr(j,n));
        }
        SORT(c);
        s = c[0];
        reverse(all(s));
    }
    PRINT(c[0]);
}


Measured memory_bytes: 40320
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <queue>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    priority_queue<pair<int, int>> q;
    rep(i,n) {
        q.push(make_pair(a[i], 1));
    }
    rep(i, m) {
        q.push(make_pair(c[i], b[i]));
    }

    ll ans = 0;
    rep(i, n) {
        auto P = q.top();
        q.pop();
        ans += P.first;
        if(P.second > 1) {
            P.second--;
            q.push(P);
        }
    }

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

Measured memory_bytes: 3572
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let x: usize = scan(tokens);
    let y: usize = scan(tokens);
    let mut cnt = vec![0; n];
    for i in 1..n {
        for j in i + 1..n + 1 {
            let mut d = diff(i, j);
            d = std::cmp::min(d, diff(i, x) + 1 + diff(y, j));
            d = std::cmp::min(d, diff(i, y) + 1 + diff(x, j));
            cnt[d] += 1;
        }
    }
    for d in 1..n {
        println!("{}", cnt[d]);
    }
}

fn diff(i: usize, j: usize) -> usize {
    if i <= j {
        j - i
    } else {
        i - j
    }
}


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var n, d, x int

	fmt.Scan(&n)
	fmt.Scanf("%d %d\n", &d, &x)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	ret := 0
	for i := 0; i < n; i++ {
		for j := 0; a[i]*j+1 <= d; j++ {
			ret++
		}
	}

	fmt.Println(ret + x)
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }

    public static int[] ReadInts()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }

    public static void Main()
    {
        var N = ReadInt();
        var M = ReadInt();
        var a = ReadInts();
        var point = new int[N];
        for (int i = 0; i < M; i++)
        {
            var b = ReadInts();
            var wrong = 0;
            for (int j = 0; j < N; j++)
            {
                if (a[i] == b[j])
                {
                    point[j] += 1;
                }
                else
                {
                    wrong++;
                }
            }
            point[a[i] - 1] += wrong;
        }
        foreach (var item in point)
        {
            Console.WriteLine(item);
        }
    }
}


Measured memory_bytes: 18280
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 10**9 + 7
# N = int(input())
# A = list(map(int,input().split()))
ls = []
N, K = map(int,input().split())
for k in range(K):
    _ = input()
    A = list(map(int,input().split()))
    ls+=A
print (N-len(set(ls)))



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

struct box {
    bool red;
    int num;
};

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

    vector<box> boxes(N);
    for (int i = 0; i < N; i++) {
        boxes[i].red = false;
        boxes[i].num = 1;
    }
    boxes[0].red = true;

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        if (boxes[x - 1].red && boxes[x - 1].num == 1) {
            boxes[x - 1].red = false;
            boxes[x - 1].num--;
            boxes[y - 1].red = true;
            boxes[y - 1].num++;
        } else if (boxes[x - 1].red) {
            boxes[x - 1].num--;
            boxes[y - 1].red = true;
            boxes[y - 1].num++;
        } else {
            boxes[x - 1].num--;
            boxes[y - 1].num++;
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (boxes[i].red) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 4048
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		byte[] cc = sc.next().getBytes();
		int[][] dp = new int[n + 1][n + 1];
		for (int i = n - 1; i >= 0; i--)
			for (int j = i + 1; j < n; j++)
				if (cc[i] == cc[j])
					dp[i][j] = dp[i + 1][j + 1] + 1;
		int ans = 0;
		for (int i = 0; i < n; i++)
			for (int j = i + 1 + ans; j < n; j++)
				ans = Math.max(ans, Math.min(dp[i][j], j - i));
		println(ans);
	}
}


Measured memory_bytes: 143992
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b = nm()
    print(max(a + b, a - b, a * b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9152
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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 long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int cnt = 0;
    REP(i,s.size()){
        if(s[i]=='x') ++cnt;
    }
    if(cnt > 7) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

#define ll long long int

int main()
{
    ll n,fl=0,a,b,c;
    cin>>n;
    a=(n%10);
    n=n/10;
    b=n%10;
    n=n/10;
    c=n;
    if(a==7 || b==7 || c==7)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

int main(){
  cin >> x >> k >> d;
  x=abs(x);
  q=x/d;

  if(q<k){
    x-=q*d;
    k-=q;
    if(k%2==0){
      cout << x << endl;
    }else {
      cout << abs(x-d) << endl;
    }
    return 0;
  }else{
    cout << abs(x-k*d) << endl;
    return 0;
  }
}

Measured memory_bytes: 3640
s = str(input())

a = []
b = []

if s[0] == '1':
    c = '0'
else:
    c = '1'

if len(s) % 2 == 1:
    s = s + c
    

for i in range(int(len(s)/2)):
    a.append(s[i * 2])
    b.append(s[i * 2 -1])

print(a.count(c) + b.count(s[0]))

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

int main(){
    cin>>A;
    string B1;
    cin>>B1;
    int dotPos=-1;
    int p=100;
    int B=0;
    for(int i=0;i<B1.size();i++){
        if(B1.at(i)=='.'){
            dotPos=i;
            continue;
        }
        B+=stoi(B1.substr(i,1))*p;
        p/=10;
    }
    cout<<(A*B)/100;
    //B=floor(B1*100);
 
    //cout<<(ll)(A*B)/100;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 998244353
int n, k; 
 
int main() {
	io
	cin>>n>>k;
	if(k>=n) cout<<"unsafe";
	else cout<<"safe";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    int N;
    cin>>N;
    int a,b,c;
    int i;
    for(i=0;i<N;i++){
        cin>>a>>b>>c;
        if(a+b>c&&a+c>b&&b+c>a&&(a*a+b*b==c*c||a*a+c*c==b*b||b*b+c*c==a*a)){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    cin >> s;
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        string t;
        cin >> t;
        t += t;
        ans += (search(t.begin(), t.end(), s.begin(), s.end()) != t.end());
    }
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

#define MAX 250
#define MAX_R 1050
#define INF 1e8

int G1[MAX][MAX], G2[MAX][MAX];
int dp[MAX_R][MAX];

int main(){
  int N, M;

  while(cin >> N >> M ,(N | M)){
    fill(G1[0], G1[MAX], INF);
    fill(G2[0], G2[MAX], INF);

    int x, y, t;
    char ch;
    for(int i = 0 ; i < M ; i++){
      cin >> x >> y >> t >> ch;
      x--, y--;
      if(ch == 'L'){
        G1[x][y] = G1[y][x] = t;
      }else{
        G2[x][y] = G2[y][x] = t;
      }
    }
    
    for(int i = 0 ; i < N ; i++){
      G1[i][i] = G2[i][i] = 0;
    }
    
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          G1[i][j] = min(G1[i][j], G1[i][k]+G1[k][j]);
          G2[i][j] = min(G2[i][j], G2[i][k]+G2[k][j]);
        }
      }
    }

    int R, z[MAX_R];
    for(int i = 0 ; i < MAX_R ; i++){
      for(int j = 0 ; j < MAX ; j++){
        dp[i][j] = INF;
      }
    }

    cin >> R;
    for(int i = 0 ; i < R ; i++){
      cin >> z[i]; z[i]--;
    }

    int now = z[0];
    dp[0][now] = 0;
    for(int r = 1 ; r < R ; r++){
      int next = z[r];
      for(int j = 0 ; j < N ; j++){
        for(int i = 0 ; i < N ; i++){
          dp[r][j] = min(dp[r][j], dp[r-1][i] + G1[now][i] + G2[i][j] + G1[j][next]);
        }
        dp[r][j]=min(dp[r][j], dp[r-1][j] + G1[now][next]);
      }
      now = next; 
    }

    int ans = INF;
    for(int i = 0 ; i < N ; i++){
      ans = min(ans, dp[R-1][i]);
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2672
#include<iostream>

using namespace std;

int main(void){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx;
    int h = ty - sy;
    for(int i = 0; i < w; i++) cout << "R";
    for(int i = 0; i < h; i++) cout << "U";
    for(int i = 0; i < w; i++) cout << "L";
    for(int i = 0; i < h; i++) cout << "D";
    cout << "D";
    for(int i = 0; i < w; i++) cout << "R";
    cout << "RU";
    for(int i = 0; i < h; i++) cout << "U";
    cout << "LU";
    for(int i = 0; i < w; i++) cout << "L";
    cout << "LD";
    for(int i = 0; i < h; i++) cout << "D";
    cout << "R" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    double input, time, height;

    while(cin >> input){
        time = input / 9.8;
        height = 4.9 * time * time;
        rep(i, 10000){
            if(height < 5 * i - 5){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
namespace FastIO{const char* ln="\n";struct Reader{char buf[1<<20],*s,*t;bool EOF_FLG;Reader():s(buf),t(buf),EOF_FLG(false) {};char gt() {return s==t&&((t=(s=buf)+fread(buf,1,1<<20,stdin))==s)?EOF:(*s++);}Reader& operator>>(char* str) {if(EOF_FLG)return *str=0,*this;while((*str=gt())!=' '&&*str!='\n'&&*str!=EOF)++str;if(*str==EOF)EOF_FLG=true;*str=0;return *this;}template<typename T>Reader&operator>>(T&x) {if(EOF_FLG)return *this;char c=0,d;while(c!=EOF&&(c<'0'||c>'9'))d=c,c=gt();if(c==EOF){EOF_FLG=true;return *this;}else x=0;while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=gt();if(d=='-')x=-x;return *this;}}in;struct Writer{char buf[1<<20],*s,*t;Writer():s(buf),t(buf+(1<<20)){}~Writer(){fwrite(buf,1,s-buf,stdout);}void pt(char c){(s==t)?(fwrite(s=buf,1,1<<20,stdout),*s++=c):(*s++=c);}template<typename T>Writer&operator<<(T x){if(!x)return pt('0'),*this;if(x<0)pt('-'),x=-x;char a[40],t=0;while(x)a[t++]=x%10,x/=10;while(t--)pt(a[t]+'0');return *this;}Writer&operator<<(const char*s) {while(*s)pt(*s++);return *this;}}out;}using namespace FastIO;
namespace ZDY{
    #define ll long long
    #define db double
    #define sht short
    #define MB template <class T>
    #define Fur(i,x,y) for(int i=x;i<=y;i++)
    #define fur(i,x,y) for(i=x;i<=y;i++)
    #define Fdr(i,x,y) for(int i=x;i>=y;i--)
    #define fdr(i,x,y) for(i=x;i>=y;i--)
    #define clr(x,y) memset(x,y,sizeof(x))
    #define cpy(x,y) memcpy(x,y,sizeof(x))
    #define fin(s) freopen(s".in","r",stdin)
    #define fout(s) freopen(s".out","w",stdout)
    #define l2(n) (int(log2(n)))
    #define fl(i,x) for(int i=head[x],to;to=e[i].to,i;i=e[i].nxt)
    #define fcin ios::sync_with_stdio(false)
    MB T ABS(T x){return x>0?x:-x;}
    MB T MAX(T x,T y){return x>=y?x:y;}
    MB T MIN(T x,T y){return x<=y?x:y;}
    MB T GCD(T x,T y){return y?GCD(y,x%y):x;}
    void SWAP(int &x,int &y){x^=y;y^=x;x^=y;}
}using namespace ZDY;using namespace std;
#define N 1000001
#define int ll
#define inf 40010000000
int n,m,q,a[N],b[N];
int qm(int x,int p,int q){return MIN(ABS(x-p)+ABS(p-q),ABS(x-q)+ABS(p-q));}
signed main(){
    in>>n>>m>>q;
    Fur(i,1,n)in>>a[i];a[0]=-inf;a[n+1]=inf;
    Fur(i,1,m)in>>b[i];b[0]=-inf;b[m+1]=inf;
    int x,la,lb,ra,rb,p;
    while(q--){
        in>>x;
        p=upper_bound(a,a+n+2,x)-a;
        la=a[p-1];ra=a[p];
        p=upper_bound(b,b+m+2,x)-b;
        lb=b[p-1];rb=b[p];
        //printf("%d %d\n%d %d\n",la,lb,ra,rb);
        int ans=MIN(MIN(qm(x,la,lb),qm(x,ra,rb)),MIN(qm(x,la,rb),qm(x,ra,lb)));
        out<<ans<<ln;
    }
}

Measured memory_bytes: 9600
#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;
    string s;
    cin >> s;
    ll n = s.size();
    ll ans = n;
    for(i = 0;i < n-1;++i){
        if(s.at(i) != s.at(i+1)){
            ll tmp = max(i+1, n-(i+1));
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    // Here your code !
    int H,W,i,k;
    while(1)
    {
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0)
        {
            return 0;
        }
        for(i = 0;i < H;i++)
        {
            for(k = 0;k < W;k++)
            {
                if(i == 0 || i == H-1)
                {
                    printf("#");
                }
                else
                if(k != 0 && k != W-1)
                {
                    printf(".");
                }
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

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

const ll MOD = 1e9+7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        if (res < 0) res += mod;
        a = a * a % mod;
        if (a < 0) a += mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll num = modpow(2, N, MOD);

    num --;

    ll numerator = 1;
    for (int i = 1; i <= A; i++) {
        numerator *= N-A+i;
        numerator %= MOD;
        if (numerator < 0) numerator += MOD;
    } //numeratorは分子

    ll factorial = 1;
    for (int i = 1; i <= A; i++) {
        factorial *= i;
        factorial %= MOD;
        if (factorial < 0) factorial += MOD;
    }
    ll inverse = modpow(factorial, MOD-2, MOD);

    ll nCa = numerator * inverse % MOD;
    if (nCa < 0) nCa += MOD;

    numerator = 1;
    for (int i = 1; i <= B; i++) {
        numerator *= N-B+i;
        numerator %= MOD;
        if (numerator < 0) numerator += MOD;
    } //numeratorは分子

    factorial = 1;
    for (int i = 1; i <= B; i++) {
        factorial *= i;
        factorial %= MOD;
        if (factorial < 0) factorial += MOD;
    }
    inverse = modpow(factorial, MOD-2, MOD);
    ll nCb = numerator * inverse % MOD;
    if (nCb < 0) nCb += MOD;

    ll ans = (num - nCa - nCb) % MOD;
    if (ans < 0) ans += MOD;
    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 < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n;
    cin>>n;
    rep(i,n){
        string w1,w2;
        cin>>w1>>w2;
        int n1=w1.size(),n2=w2.size();
        int dp[n1+1][n2+1];
        memset(dp,0,sizeof(dp));
        for (int i=1;i<n1+1;i++){
            for (int j=1;j<n2+1;j++){
                if (w1[i-1]==w2[j-1]){
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        cout<<dp[n1][n2]<<endl;
    }

    

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001

int N,st,e;
vi adj[maxn];
int par[maxn];
int mxdist = 0,mxnode;

void dfs(int x,int p,int d){
	par[x] = p;
	if (d > mxdist){
		mxnode = x;
		mxdist = d;
	}
	
	aFOR(i,adj[x]){
		if (i != p){
			dfs(i,x,d + 1);
		}
	}
}
bool inbody[maxn];

int main(){
	fast;
	
	cin>>N;
	
	FOR(i,1,N-1){
		int a,b;
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	
	dfs(1,-1,0);
	mxdist = 0;
	
	st = mxnode;
	dfs(mxnode,-1,0);
	e = mxnode;
	
	vi body;
	
	int a = e;
	
	while (a != st){
		inbody[a] = 1;
		body.pb(a);
		a = par[a];
	}
	inbody[st] = 1;
	body.pb(st);
	
	reverse(all(body));
	
	FOR(i,1,N){
		if (!inbody[i]){
			if (adj[i].size() != 1){
				cout<<-1;
				return 0;
			}
		}
	}
	vi res,ans;
	
	int count = 1;
	
	aFOR(i,body){
		int num = 0;
		aFOR(j,adj[i]) if (!inbody[j]){
			num++;
		}
		res.pb(count + num);
		aFOR(j,adj[i]) if (!inbody[j]){
			res.pb(count);
			count++;
		}	
		count++;

	}
	vi res2;
	
	FOR(i,1,N) res2.pb(0);
	FOR(i,0,N-1){
		res2[res[i] - 1] = i + 1;
	}
	
	ans = res2;

	reverse(all(body));
	res.clear();
	
	count = 1;
	
	aFOR(i,body){
		int num = 0;
		aFOR(j,adj[i]) if (!inbody[j]){
			num++;
		}
		res.pb(count + num);
		aFOR(j,adj[i]) if (!inbody[j]){
			res.pb(count);
			count++;
		}	
		count++;

	}
	
	res2.clear();
	
	FOR(i,1,N) res2.pb(0);
	FOR(i,0,N-1){
		res2[res[i] - 1] = i + 1;
	}
	
	ans = min(ans,res2);
	aFOR(i,ans){
		cout<<i<<' ';
	}
}



Measured memory_bytes: 14708
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int m;
    cin >> m;
    vector<int> w(m);
    for(int i = 0; i < m; i++) cin >> w[i];
    vector<int> result;
    set_union(v.begin(), v.end(), w.begin(), w.end(), back_inserter(result));
    for(int i = 0; i < result.size(); i++) cout << result[i] << endl;
    return 0;
}




Measured memory_bytes: 6580
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
int N,M;
vector<vector<int>>graph(N);
int dp[100010];
int rec(int v){
    if(dp[v]!=-1)return dp[v];
    int res=0;
    for(auto& nx:graph[v]){
        res=max(res,rec(nx)+1);
    }
    return dp[v]=res;
}

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

rep(i,N)dp[i]=-1;
graph.assign(N,vector<int>());

rep(i,M){
    int x,y;
    cin>>x>>y;
    x--,y--;
    graph[x].push_back(y);
}
int ans=0;
rep(i,N){
ans=max(ans,rec(i));
}
cout<<ans<<endl;



 return 0;
}
/*
4 5
1 2
1 3
3 2
2 4
3 4

3


6 3
2 3
4 5
5 6

2


5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3

3

*/

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

using namespace std;
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size):data(size,-1){}
    bool unite(int x,int y) {
        x=root(x);y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y) {
        return root(x)==root(y);
    }
    int root(int x) {
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};


int main() {
	int n = ri();
	int x[n];
	int y[n];
	for (int i = 0; i < n; i++) x[i] = ri() - 1, y[i] = ri() - 1;
	UnionFind uni1(200000);
	for (int i = 0; i < n; i++) uni1.unite(x[i], y[i] + 100000);
	map<int, set<int> > ma;//枚举x，y坐标，加入对应的矩中
	for (int i = 0; i < 200000; i++) ma[uni1.root(i)].insert(i);
	int64_t all = 0;
	for (auto &i : ma) {
		int x = 0;
		int y = 0;
		for (auto j : i.second) if (j < 100000) x++; else y++;
		all += (int64_t) x * y;
	}
	cout << all - n << std::endl;


	return 0;
}


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

vector<vector<int> > adj;
vector<int> x;

void NO() { cout << "IMPOSSIBLE\n"; exit(0); }

int dfs(int i) {
    int dp[x[i]+1];
    dp[0] = 0;
    fill(dp+1, dp+x[i]+1, 1<<30);
    for (int j : adj[i]) {
        int a = x[j], b = dfs(j);
        for (int s = x[i]; s >= 0; s--) {
            int val = 1<<30;
            if (s >= a) val = min(val, dp[s-a]+b);
            if (s >= b) val = min(val, dp[s-b]+a);
            dp[s] = val;
        }
    }
    int ans = *min_element(dp, dp+x[i]+1);
    if (ans == 1<<30) NO();
    return ans;
}

int main() {
    int n; cin >> n;
    adj.resize(n);
    for (int i = 1; i < n; i++) { int p; cin >> p; adj[p-1].push_back(i); }
    x.resize(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    dfs(0);
    cout << "POSSIBLE\n";
}


Measured memory_bytes: 5760
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	cout << (N + 1) / 2 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        int ans[5050] = {0};
        for(int i = 0; i < n; i++){
            scanf("%d",&ans[i]);
        }
        long long int mx = -300000000;
        for(int i = 0; i < n; i++){
            long long int sum = 0;
            for(int j = i; j < n; j++){
                sum += ans[j];
                if(sum > mx) mx = sum;
            }
        }
        printf("%lld\n",mx);
    }
	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
    int k;cin>>k;
	if(k%2==0) {cout<<-1;return;}
    int curr=7;
    if(k==7||k==1) {cout<<1;return;}
    for(int i=2;i<=1e7;i++){
        int val=(((curr%k)*(10%k))%k+(7%k))%k;
        if(val==0) {cout<<i;return;}
        curr=val;
    }
    cout<<-1;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

int main(){
    int x,n; cin >> x >> n;
    vector<int> mark(102,0);
    int in;
    rep(i,n){
        cin >> in;
        mark.at(in) = 1;
    }
    int diff = 0;
   while(true){
        if(mark.at(x - diff) == 0){
            cout << x - diff << endl;
            return 0;
        }
        else if (mark.at(x + diff) == 0){
            cout << x + diff << endl;
            return 0;
        }
        diff ++;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

int main(void) {
    int N;
    cin >> N;
    vector<string> S(2);
    cin >> S[0];
    cin >> S[1];

    int64_t ans = 3;
    if(S[0][0] != S[1][0]) {
        ans *= 2;
    }
    for(int i=1; i<N; i++) {
        if(S[0][i] == S[1][i]) {
            if(S[0][i-1] == S[1][i-1]) {
                ans = (ans * 2) % MOD;
            }
        } else if(S[0][i-1] == S[1][i-1]) {
            ans = (ans*2) % MOD;
        } else if(S[0][i-1] != S[0][i]) {
            ans = (ans * 3) % MOD;
        }
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

struct Point {
	double x;
	double y;
	Point(double x, double y) :x(x), y(y) {}
	Point() :x(0), y(0) {}
};

struct Rectangle {
	Point topLeft;
	Point bottomRight;
	Rectangle(Point topLeft, Point bottomRight) :topLeft(topLeft), bottomRight(bottomRight) {}
	Rectangle(){}
};

int compress(vector<double> &x, unordered_map<double, int>& zip, vector<double>& unzip) {
	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	unzip.resize(x.size());
	for (size_t i = 0; i < x.size(); i++)
	{
		zip[x[i]] = i;
		unzip[i] = x[i];
	}
	return zip.size();
}

double solve(const vector<Rectangle> rectangles) {
	vector<double> xs;
	unordered_map<double, int> xZip;
	vector<double> xUnzip;
	vector<double> ys;
	unordered_map<double, int> yZip;
	vector<double> yUnzip;

	for (auto &r : rectangles) {
		xs.push_back(r.topLeft.x);
		xs.push_back(r.bottomRight.x);
		ys.push_back(r.topLeft.y);
		ys.push_back(r.bottomRight.y);
	}
	vector<vector<bool> > checker(ys.size(), vector<bool>(xs.size(), false));
	compress(xs, xZip, xUnzip);
	compress(ys, yZip, yUnzip);

	for (auto &r : rectangles) {
		for (int y = yZip[r.topLeft.y]; y < yZip[r.bottomRight.y]; ++y) {
			for (int x = xZip[r.topLeft.x]; x < xZip[r.bottomRight.x]; ++x) {
				checker[y][x] = true;
			}
		}
	}

	double res = 0.0;
	for (int y = 0; y < yUnzip.size()-1 ; ++y) for (int x = 0; x < xUnzip.size()-1; ++x) if (checker[y][x]) {
		res += (yUnzip[y + 1] - yUnzip[y]) * (xUnzip[x + 1] - xUnzip[x]);
	}
	return res;
	
}

int main(void) {
	int cnt = 0;
	while (1) {
		++cnt;
		vector<Rectangle> rectangles;
		int n; cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; ++i) {
			double x, y, r;
			cin >> x >> y >> r;
			rectangles.push_back(Rectangle(Point(x - r, y - r), Point(x + r, y + r)));
		}
		cout << fixed << setprecision(2) << cnt << " " <<  solve(rectangles) << endl;
	}
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, a;
  cin>>n;
  int ans=0;
  REP(i, n){
    cin>>a;
    if(i&1){
      continue;
    }
    if(a&1){
      ++ans;
    }
  }
  cout<<ans<<'\n';
  return 0;
}


Measured memory_bytes: 3632
#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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i, 0, n)cin >> a[i];
  ll ans = inf;
  rep(i, -100, 101){
      ll tempans = 0;
      rep(j, 0, n){
          tempans += (a[j]-i)*(a[j]-i);
      }
      ans = min(ans, tempans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	string s1, s2;
	cin >> s1;
	cin >> s2;
	int ans = 0;

	for (int i = 0; i < s1.size(); i++) {
		if (s1[i] != s2[i])ans++;
	}

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3852
#include<iostream>
int main() {
	int a, b, c;
	int g = 0;
	std::cin >> a >> b >> c;
	for (int i = a; i <= b; ++i) {
		if (c%i == 0)++g;
	}
	std::cout << g << std::endl;
	return 0;
}

Measured memory_bytes: 1164
#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 x, y;
  cin >> x >> y;
  bool ok = false;
  for (int i = 0; i <= x; i++) {
    int total = i * 2 + (x - i) * 4;
    if (total == y) ok = true;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	cout<<max({c,d,e})<<endl;
	return 0;
	
}

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

int main(){
int a;
cin >> a;
int b;
cin >> b;
int c;
cin >> c;
if(a==b&&a!=c)cout<<"Yes"<<endl;
else if(a==c&&a!=b)cout<<"Yes"<<endl;
else if(c==b&&a!=c)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 1e2+10;

int main(int argc, char const *argv[])
{
    int n, p[MAX_N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; ++i) {
        if (min(min(p[i-1],p[i]),p[i+1])!=p[i] && max(max(p[i-1], p[i]), p[i+1])!=p[i]) ans++;
    }

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

Measured memory_bytes: 256
N = int(input())
footing = list(map(int, input().split()))

dp = [10 ** 10] * N
dp[0] = 0

# give
for i in range(N-1):
    if dp[i+1] > dp[i] + abs(footing[i+1] - footing[i]):
        dp[i+1] = dp[i] + abs(footing[i+1] - footing[i])

    if i < N-2:
        if dp[i+2] > dp[i] + abs(footing[i+2] - footing[i]):
            dp[i+2] = dp[i] + abs(footing[i+2] - footing[i])

print(dp[N-1])

Measured memory_bytes: 13908
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { x: i32, a: i32, b: i32 }
    let diff = a-b;
    if diff < 0 {
        if diff.abs() > x {
            println!("dangerous");
        } else {
            println!("safe");
        }
    } else {
        println!("delicious");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MAXN   1000001
using namespace std;

typedef long long ll;

int spf[MAXN];

void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        spf[i] = i;

    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {

        if (spf[i] == i)
        {

            for (int j=i*i; j<MAXN; j+=i)


                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}


int main(){
	ios::sync_with_stdio(false); cin.tie(0);
    sieve();
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++)
        cin>>ar[i];

    map<int,int> mp;
    int gcd=0;
    for(int i=0;i<n;i++){
        gcd=__gcd(gcd,ar[i]);
        int temp=ar[i];
        map<int,int> mp1;
        while(temp!=1){
            mp1[spf[temp]]++;
            //cout<<temp<<endl;
            while(temp%spf[temp]==0 && temp>1){
                temp/=spf[temp];
                mp1[spf[temp]]++;
               // cout<<temp<<endl;
            }

        }
        for(auto it: mp1)
            mp[it.first]++;
    }
    int flag=1;
    

    for(auto it: mp)
        if(it.second>1 && it.first!=1){
            flag=0;break;
        }
    if(flag && gcd==1){
        cout<<"pairwise coprime"<<endl;
        return 0;
    }
    if(flag)
        cout<<"pairwise coprime"<<endl;
    else if(gcd==1)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;
}



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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (1) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }
}


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


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

//  int64_t ans = 0;
//  for( int i=1; i<N; ++i) {
//    ans += i % (i+1);
//  }
//  cout << ans << endl;
  cout << (N-1) * (N) / 2 << endl;

}


Measured memory_bytes: 256
n,m = map(int,input().split())
a_all = []
b_all = []
for i in range(m):
    a,b = map(int,input().split())
    a_all.append(a-1)
    b_all.append(b-1)
for j in range(n):
    c = list()
    for k in range(m):
        if a_all[k] == j:
            c.append(b_all[k])
        if b_all[k] == j:
            c.append(a_all[k])
    print(len(c))

Measured memory_bytes: 3064