akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();
        char c[] = sc.nextString().toCharArray();
        int d[]=new int[1000];
        for (int i = 0; i < c.length; i++) {
			d[c[i]]++;
		}
        int x=0;
        for (int i = 0; i < d.length; i++) {
			if(d[i]==2)x++;
		}

        out.println(x==2?"Yes":"No");
        out.flush();
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());
  
  long long N,M;
  cin>>N>>M;

  vector< pair <long long,long long> > E(N);
  for(int i=0;i<N;i++){
    cin>>E.at(i).first>>E.at(i).second;
  }

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

  //for(int i=0;i<N;i++) cout<<E.at(i).first<<','<<E.at(i).second<<endl;

  long long ans=0;
  long long num;
  long long i=0;
  while(num<M){
    num += E.at(i).second;
    ans += E.at(i).first*E.at(i).second;
    i++;
  }
  //cout<<num<<','<<ans<<','<<i<<endl;
  ans = ans-(num-M)*E.at(i-1).first;
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    while(1){
        int n; cin >> n;
        if(!n) break;
        vector<int> k(n);
        for(int i = 0; i < n; i++) cin >> k[i];

        int cnt = 0;
        for(int i = 0; i < n; i++) cnt = max(cnt, k[i]);
        if(cnt < 2){
            cout << "NA" << endl;
            continue;
        }

        int tmp = 0;
        for(int i = 0; i < n; i++) if(k[i] != 0) tmp++;
        cout << tmp + 1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <cstdio>
#include <map>

using namespace std;

int n;
long long sum[200001] = {};
map<long long, long long>mp;

int main()
{
  mp[0] = 1;
  long long a;
  long long ans = 0;
  scanf("%d", &n);
  for ( int i = 1; i <= n; i++) {
    cin >> a;
    sum[i] = sum[i - 1] + a;

    if ( mp.count(sum[i]) == 0) {
      mp[sum[i]] = 1;
    } else {
      ans += mp[sum[i]];
      mp[sum[i]]++;
    }
     
  }

  printf("%lld\n", ans);

  return (0);
}


Measured memory_bytes: 14336
n = gets.chomp.to_i

a = []
max1 = 0
max2 = 0

for i in 1..n do
    line = gets.chomp.to_i
    a.push(line)
    if max1 <= line
        max2 = max1
        max1 = line
    elsif max2 <= line
        max2 = line
    end
end

for i in 1..n do 
    if a[i-1] == max1
        puts max2
    else
        puts max1
    end
end

Measured memory_bytes: 4732
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define Jrep(j,n) for(int j=0;j<(n);j++)
#define Jreps(j,n) for(int j=1;j<=(n);j++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;

using namespace std;    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    vector<int> dp(100010,INF);
    cin>>n>>k;
    int h[100010];
    reps(i,n){
	cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3;i<=n;i++){
	for(int j=1;j<=k;j++){
	    if(i-j==0) break;
	    dp[i]=min(abs(h[i]-h[i-j])+dp[i-j],dp[i]);
	}
    }
    cout<<dp[n]<<'\n';
    return 0;
}


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

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int i=0; i<N+1; i++) {
        for (int j=0; j<N-i+1; j++) {
            if (10000*i+5000*j+1000*(N-i-j)==Y) {
                cout << i << " " << j << " " << N-i-j << endl;
                exit(0);
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3628
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, a, b = [int(i) for i in input().split()]

if bin(a ^ b).count('1') % 2 == 0:
    print('NO')
    exit()

def dfs(i, a, b):
    if i == 1:
        return [a, b]
    d = (a ^ b) & -(a ^ b)
    ad = ((a & (~d ^ d - 1)) >> 1) + (a & d - 1)
    bd = ((b & (~d ^ d - 1)) >> 1) + (b & d - 1)
    c = ad ^ 1

    res1 = dfs(i - 1, ad, c)
    res2 = dfs(i - 1, bd, c)
    ans1 = [((r & ~(d - 1)) << 1) + (r & d - 1) + (d & a) for r in res1]
    ans2 = [((r & ~(d - 1)) << 1) + (r & d - 1) + (d & b) for r in res2[::-1]]
    return ans1 + ans2

print('YES')
print(*dfs(n, a, b))

Measured memory_bytes: 15212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, k;    cin >> n >> k;
    vector<ll> p(n), c(n);
    rep(i, n)  cin >> p[i], p[i]--;
    rep(i, n)  cin >> c[i];
   
    ll res=-LINF;
    rep(i, n){
        ll v=i, c_sum=0, c_cnt=0;

        while(true){
            c_sum += c[v];
            c_cnt += 1;
            v = p[v];
            if(v==i) break;
        }
        ll sum=0, cnt=0;
        while(true){
            cnt += 1;
            sum += c[v];
            if(cnt>k) break;
            res = max(max(0LL, (k-cnt)/c_cnt*c_sum)+sum, res);
            v = p[v];
            if(v==i) break;
        }
        
    }
    cout << res << endl;
}


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

int main()
{
  int A, B;
  
  cin >> A >> B;
  
  int ans = 0;
  int s[5];
  
  for ( int i = A; i < B + 1; i++ ) {
    s[0] = i % 10;
    s[1] = i / 10 % 10;
    s[3] = i / 1000 % 10;
    s[4] = i / 10000 % 10;
    if (s[0] == s[4] && s[1] == s[3]) {
      ans++;
    }
  }
  
  cout << ans << endl;
    
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string N;
	cin >> N;
	int M;
	M = N.length();
	vector<vl> DP(M + 1);
	rep(i, M + 1) {
		DP[i].resize(2, InfLL);
	}
	DP[0][0] = 0;
	rep(i, M) {
		int j = M - i - 1;
		ll n = (ll)N[j] - (ll)'0';

		DP[i + 1][0] = min(DP[i + 1][0], DP[i][0] + (ll)n);
		DP[i + 1][0] = min(DP[i + 1][0], DP[i][1] + (ll)n);
		DP[i + 1][1] = min(DP[i + 1][1], DP[i][1] + (ll)9 - (ll)n);
		if (n != 0)
			DP[i + 1][1] = min(DP[i + 1][1], DP[i][0] + (ll)11 - (ll)n);
	}
	ll ans = min(DP[M][0], DP[M][1]);
	cout << ans << endl;
	return 0;
}

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

int main(){
    int r,D,x,ans;
    cin >> r >> D >> x;
    ans = x;
    for (int i = 0;i < 10; i++){
        ans = (r*ans) - D;
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back



int main(){
    int n;
    while(cin>>n){
        int data[100000]={};
        if(n==0)break;
        
        rep(i,n){
            char ch;
            int a,aa,aaa,b,bb,bbb;
            cin>>a>>ch>>aa>>ch>>aaa>>b>>ch>>bb>>ch>>bbb;
            data[a*60*60+aa*60+aaa]+=1;
            data[b*60*60+bb*60+bbb]-=1;
        }
        for(int i=1;i<90000;i++){
            data[i]=data[i]+data[i-1];
        }
        
        int ans=-1;
        rep(i,90000){
            ans=max(ans,data[i]);
        }
        cout<<ans<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1556
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n;
	cin>>n;
	vd a(n+1);
	for(ll i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	vvd dp(n+1,vd(n+1));
	dp[0][0]=1.0;
	for(ll i=1;i<=n;++i)
	{
		dp[i][0]=dp[i-1][0]*a[i];
	}
	for(ll i=1;i<=n;++i)
	{
		for(ll j=1;j<=i;++j)
		{
			dp[i][j]=dp[i-1][j]*a[i]+dp[i-1][j-1]*(1-a[i]);
		}
	}
	ld prob=0;
	for(ll i=0;i<=n/2;++i)
	{
		prob+=dp[n][i];
	}
	cout<<fixed<<setprecision(10)<<prob<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 141056
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	ok := true
	if b%2 == 1 {
		ok = false
	}
	if a*2 > b || b > a*4 {
		ok = false
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1772
class Arrow
  attr_reader :source, :sink, :label

  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end

def push(queue, label)
  size = queue.size
  index = queue.index{|entry| entry[0] >= label} || size
  return queue[index][1] if index < size && queue[index][0] == label

  return nil if index > 0 && !label.start_with?(queue[index - 1][0])
  queue.slice!(index..-1) if index < size && !queue[index][0].start_with?(label)

  nodes = {}
  queue.insert(index, [label.dup, nodes])
  nodes
end

def calc(n, arrows, start, goal)
  ins = Array.new(n){[]}
  arrows.each do |arrow|
    ins[arrow.sink] << arrow.source
  end

  reachable_from = {}
  stack = [goal]
  until stack.empty?
    node = stack.pop
    reachable_from[node] = true
    ins[node].each do |source|
      stack << source unless reachable_from[source]
    end
  end

  return nil unless reachable_from[start]
  arrows.select!{|arrow| reachable_from[arrow.sink]}

  outs = Array.new(n){[]}
  arrows.each do |arrow|
    outs[arrow.source] << arrow
  end

  limit = n * arrows.map{|arrow| arrow.label.size}.max

  result = ''
  queue = [['', {start => true}]]
  until queue.empty?
    label, nodes = queue.shift
    result << label
    return result if nodes[goal]
    return nil if result.size > limit

    size = label.size
    queue.each do |key, value|
      key.slice!(0...size)
    end

    nodes.each do |node, _|
      outs[node].each do |arrow|
        new_nodes = push(queue, arrow.label)
        new_nodes[arrow.sink] = true if new_nodes
      end
    end
  end
  nil
end

loop do
  n, a, s, g = gets.split.map(&:to_i)
  break if n == 0

  arrows = (0...a).map{
    x, y, lab = gets.split
    Arrow.new(x.to_i, y.to_i, lab)
  }

  puts calc(n, arrows, s, g) || 'NO'
end

Measured memory_bytes: 9796
#include <iostream>
#include <vector>
#include <algorithm>


int main()
{
	int n;
	std::vector<int> S;
	int q;
	std::vector<int> T;
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		std::cin >> a;
		S.push_back(a);
	}
	std::cin >> q;
	for (int i = 0; i < q; i++)
	{
		int a;
		std::cin >> a;
		T.push_back(a);
	}

	int ans  = 0;
	for (int i = 0; i < q; i++)
	{
		if (*std::lower_bound(S.begin(), S.end(), T.at(i)) == T.at(i))
			++ans;
	}
	std::cout << ans << '\n';
}


Measured memory_bytes: 3468
import java.util.*

fun main(args: Array<String>) {
    val x = readLine()!!
    var ans = x.length
    val stack = ArrayDeque<Char>()
    for (c in x) {
        if (c == 'S') {
            stack.addFirst(c)
            continue
        }

        if (stack.isNotEmpty()) {
            stack.removeFirst()
            ans -= 2
        }
    }
    println(ans)
}


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

int main() {
    int t,d,l;
    while (cin >> t >> d >> l, t+d+l) {
        int ans = 0;
        int keep_wave = 0;
        for (int i = 0; i < t; i++) {
            int x; cin >> x;
            if (keep_wave > 0) {
                ans++;
                keep_wave--;
            }
            if (x >= l) keep_wave = d;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MaxN = 102;
const int MaxVal = 1e5+2;
const int INF = 1e9+7;
int profit[MaxN], weight[MaxN];
int dp[MaxN][MaxVal];
int N,W;

int rec(int pos, int rem){

    if(rem==0) return 0;
    if(rem<=0 || pos>=N) return INF;
    auto &ret = dp[pos][rem];
    if(ret!=-1) return ret;
    return ret = min( rec(pos+1,rem-profit[pos]) + weight[pos] ,rec(pos+1,rem) );


}

void read(){

    cin>>N>>W;
    memset(dp,-1,sizeof dp);
    for(int i=0; i<N; i++)
        cin>>weight[i]>>profit[i];
}


void solve(){

    read();
    int res = 0;
    for(int i=0; i<MaxVal; i++){
        int ret = rec(0,i);
        if(ret<=W) res = i;
    }

    cout<< res <<"\n";
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 43428
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A,B;
  cin>>A>>B;
  if(A==1){if(B==2){cout<<3<<endl;}else{cout<<2<<endl;}}
  else if(A==2){if(B==3){cout<<1<<endl;}else{cout<<3<<endl;}}
  else{if(B==1){cout<<2<<endl;}else{cout<<1<<endl;}}
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Main m = new Main();
		String num_ = br.readLine();
		int[] num = m.splitIntChange(num_);
		int cir = num[0]*2+num[1]*2;
		int squ = num[0]*num[1];
		System.out.println(squ+" "+cir);
	}
	
	public int[] splitIntChange(String str){
		String[] str_ = str.split(" ");
		int strlen = str_.length;
		int[] numarray = new int[strlen];
		
		for(int i = 0;i < strlen;i++){
			numarray[i] = Integer.parseInt(str_[i]); 
		}
		
		return numarray;
	}
}

Measured memory_bytes: 16892
#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

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

	ll n; read(n);
	ll ans = 0;

	for (ll i = 1; i <= n; i++) {	
		ans += i * (n - i + 1);
	}

	rep(i, 0, n - 1) {
		ll u, v; read(u, v);
		if (u > v) swap(u, v);
		ans -= u * (n + 1 - v);
	}
	write(ans);
}


Measured memory_bytes: 3644
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
} //aとbの最大公約数
int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
} //char型の数字をint型に変えてくれる。


//cout << setprecision(123)<<ans;
//int a=atoi(S.c_str());
//string S=to_string(a);
//int &a=b;
int main(){
  string s;
  cin>>s;
  char a=s[0],b=s[1],c=s[2];
  if(a!=b||b!=c||c!=a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

vector<int> cycle(vector<int>& pre, int s){
    vector<int> ans;
    while(s != -1){
        ans.push_back(s);
        s = pre[s];
    }
    return ans;
}

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

    int n, m;
    cin >> n >> m;
    auto edge = initVec2<int>(n, 0);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a].push_back(b);
    }

    vector<int> ans;
    int len = INF;
    rep(i, n){
        vector<int> pre(n, INF);
        queue<P> q;
        q.emplace(i, -1);
        while(not q.empty()){
            int v = q.front().first;
            int p = q.front().second;
            q.pop();

            if(pre[v] != INF){
                continue;
            }
            pre[v] = p;

            bool ok = false;
            for(int u : edge[v]){
                if(u == i){
                    ok = true;
                }
                q.emplace(u, v);
            }

            if(ok){
                auto tmp = cycle(pre, v);
                if(len > SZ(tmp)){
                    len = SZ(tmp);
                    ans = tmp;
                }
                break;
            }
        }
    }

    if(len == INF){
        cout << -1 << endl;
    }else{
        cout << len << endl;
        rep(i, len){
            cout << ans[i] + 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 384
N = int(input())
X = []
for i in range(N):
    x = map(int, input().split())
    X.append(x)

r = 'Yes'

cur = [0, 0]
now = 0
for t, x, y in X:
    td = t - now
    d = abs(x - cur[0]) + abs(y - cur[1])
    # print(td, d)
    if d > td or d % 2 != td % 2:
        r = 'No'

    cur[0], cur[1] = x, y
    now = t

print(r)

Measured memory_bytes: 48784
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, k;
	cin >> n >> k;

	cout << n-k+1 << '\n';
	return 0;
}



Measured memory_bytes: 256
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7


Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

n,k = Ri()
a = Ri()
a.sort()


ans  = 0
for i in range(k):
    ans+=a[i]

print(ans)

Measured memory_bytes: 63404
# ABC063C - Bugged
def main():
    n = int(input())
    lst = list(map(int, [input().rstrip() for _ in range(n)]))
    total = sum(lst)
    if total % 10 != 0:
        print(total)
    else:
        ans = 0
        for i in set(lst):
            if (total - i) % 10 != 0:
                ans = max(ans, total - i)
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main()
{
	int t, wa=0 ,tle=0, ac=0 ,re=0; cin>>t;

	for(int i=0; i< t;++i)
	{
		string s; cin>>s;
		if(s == "AC") ac++;
		else if(s == "RE") re++;
		else if(s == "TLE") tle++;
		else wa++;

	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;




}

Measured memory_bytes: 3588
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;

int me(int x, int n)
{
    int res = 1;
    while(n) {
        if(n & 1)
            res = (1LL * res * x) % mod;
        x = (1LL * x * x) % mod;
        n >>= 1;
    }
    return res;
}

int fac[N], inv[N];

void fact() 
{
   fac[0] = 1;
   rep(i, 1, N) {
      fac[i] = (1LL * fac[i-1] * i) % mod;
   }

   inv[N-1] = me(fac[N-1], mod-2);
   for(int i=N-1; i>0; i--) {
      inv[i-1] = (1LL * inv[i] * i) % mod;
   }
}

void solve()
{
    fact();

    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);

    int total = me(2, n);
    total = (total - 1 + mod) % mod;

    int da = 1;

    for(int i=n; i>=(n-a+1); i--) {
        da = (1LL * da * i) % mod;
    }

    da = (1LL * da * inv[a]) % mod;

    int db = 1;

    for(int i=n; i>=(n-b+1); i--) {
        db = (1LL * db * i) % mod;
    }

    db = (1LL * db * inv[b]) % mod;

    total = (total - da + mod) % mod;
    total = (total - db + mod) % mod;

    lprin(total);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5376
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int cnt = 0, rest;

    for (int r = 0; r <= N / R; r++) {
        rest = (N - r * R);
        for (int g = 0; g <= rest / G; g++) {
            if ((rest - g * G) % B == 0) {
                cnt += 1;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = []
for i in range(n):
	stemp = input()
	s.append(stemp)
m = int(input())
t = []
for i in range(m):
	ttemp = input()
	t.append(ttemp)

total = []
i = 0
while i < n:
	counter = 0
	for k in range(n):
		if s[k] == s[i]:
			counter += 1
	for k in range(m):
		if t[k] == s[i]:
			counter += -1
	total.append(counter)
	i += 1

if max(total) >= 0:
	print(max(total))
else:
	print('0')

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m,l[100010],r[100010],s[510][510],ok[510];
int main(){
	n=read();m=read();int i,j,flag=0,k,ans=0;
	for(i=1;i<=m;i++) l[i]=read(),r[i]=read();
	for(i=1;i<=n;i++){
		ok[i]=1;
		s[i][i]=1;
		for(j=m;j>=1;j--){
			if(!s[i][l[j]]&&!s[i][r[j]]) continue;
			if(s[i][l[j]]&&s[i][r[j]]){
				ok[i]=0;break;
			}
			s[i][l[j]]=s[i][r[j]]=1;
		}
	}
	for(i=1;i<n;i++){
		if(!ok[i]) continue;
		for(j=i+1;j<=n;j++){
			if(!ok[j]) continue;
			flag=0;
			for(k=1;k<=n;k++) flag|=s[i][k]&s[j][k];
			ans+=(flag==0);
		}
	}
	cout<<ans;
} 

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
#ifdef __linux
#define LLD "%lld"
#else
#define LLD "%I64d"
#endif

#define NMAX 100000

int n,m;
int rep[NMAX+1000];
ll s[NMAX+1000];

int find(int p){
	int r,i,t;
	ll sum=0;

	for(r=p;rep[r];r=rep[r])sum+=s[r];
	for(i=p;i!=r;i=t){
		t=rep[i];
		rep[i]=r;
		ll tmp=s[i];
		s[i]=sum;
		sum-=tmp;
	}
	return r;
}

void un(int a,int b,ll d){
	int rb=find(b);
	rep[rb]=a;
	s[rb]=d-s[b];
	find(b);
}

bool check(){
	int i;

	for(i=0;i<m;i++){
		int l,r,d;
		scanf("%d%d%d",&l,&r,&d);
		if(find(l)==find(r)){
			if(s[r]-s[l]!=d){
				return false;
			}
		}else{
			un(l,r,d);
		}
	}
	return true;
}

int main(){
	scanf("%d%d",&n,&m);
	if(check())printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll NUM = pow(10,9) + 7;

int main(){
	int N;
	cin >> N;
	string S;
	cin >> S;
	for(int i(0);i<2*N;i += 2){
		if(S[i] == 'B') S[i] = 'W';
		else S[i] = 'B';
	}
	if(S[0] == 'B'){
		cout << 0 << endl;
		return 0;
	}
	int l_n(0);
	ll ans(1);
	for(int i(0);i<2*N;i++){
		if(S[i] == 'W') l_n++;
		else{
			if(l_n <= 0){
				cout << 0 << endl;
				return 0;
			}else{
				ans = (ans * l_n)%NUM;
				l_n--; 
			}
		}
	}
	if(l_n != 0){
		cout << 0 << endl;
		return 0;
	}
	for(int i(1);i<=N;++i) ans = (ans*i)%NUM;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n,n;){
		vector<vector<pii>> g(n);
		rep(i,n-1){
			int a,b,t; cin>>a>>b>>t; a--,b--;
			g[a].emplace_back(b,t);
			g[b].emplace_back(a,t);
		}
		
		vi leaf(n);
		repi(i,1,n) leaf[i]=g[i].size()==1;
		
		int sum=0;
		rep(i,n) rep(j,g[i].size()){
			if(leaf[i] || leaf[g[i][j].first])
				continue;
			sum+=g[i][j].second;
		}
		
		vvi d(n,vi(n,INFTY));
		rep(i,n){
			d[i][i]=0;
			rep(j,g[i].size())
				d[i][g[i][j].first]=g[i][j].second;
		}
		rep(k,n) rep(i,n) rep(j,n)
			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		
		vi par(n);
		rep(i,n) if(leaf[i]) par[g[i][0].first]=1;
		int mx=0;
		rep(i,n) if(par[i]) mx=max(mx,d[0][i]);
		
		cout<<sum-mx<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
n=int(input())
a=list(map(int,input().split()))

import collections
c=collections.Counter(a)


#print(c.most_common())
cnt=0
for i in c.most_common():
   # print(i)
    if i[0]<i[1]:
      cnt=cnt+i[1]-i[0]
    if i[0]>i[1]:
      cnt=cnt+i[1]
print(cnt)      

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

bool check(string& s){
  int n = s.size();
  for(int i=0;i<n;i++){
    if( s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T'){
      return false;
    }
  }
  return true;
}

int main(void){
  string S;
  cin >> S;
  
  int n = S.size();
  string lc = "";
  for(int i=0;i<n;i++){
    for(int j=1;j<=n-i;j++){
      string sub = S.substr(i,j);
      //cout << sub << endl;
      if( check(sub) && sub.size() > lc.size()){
        lc = sub;
      }
    }
  }

  cout << lc.size() << endl;
}


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

/**
 * [IPC - Contest III]
 * @author Rodrigo Moreira Pires de Andrade
 * @version 13/04/2020
*/

using namespace std;

// Functions and class come here..


int main() {

    // Solve the problem here ..
    int A, B, sum = 0;

    cin >> A >> B;

    for(int i = 0; i < 2; i++) {
        if(A > B) {
            sum += A;
            A--;
        } else {
            sum += B;
            B--;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
   long h,w,a,b;
   int i,c,n;
    
   scanf("%d %ld %ld",&n,&h,&w);
   for (c=i=0;i<n;i++) {
      scanf("%ld %ld",&a,&b);
      if (a>=h && b>=w) c++;
   }
   printf("%d\n",c);
   return 0;
}


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

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

	while(cin>>a){
		b=a%60;
		c=((a-b)/60)%60;
		d=((a-b)/60-c)/60;
		cout<<d<<':'<<c<<':'<<b<<endl;
	
	}
	return 0;
}

Measured memory_bytes: 1160
from sys import stdin
S=(stdin.readline().rstrip())
while 1:
    cnt=4
    for i in ["dream","dreamer","erase","eraser"]:
        if S[-len(i):] == i:
            S = S[:(len(S)-len(i))]
        else:
            cnt-=1
            
    if S == "":
        print("YES")
        break
        
    if cnt == 0:
        print("NO")
        break

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int a,b,c;
  string s1,s2;
  cin>>a;
  cin>>s1;
  int ans=0;
  for(int i=1;i<a;i++){
    bool alfa[30]={};
    bool alfa2[30]={};
    for(int j=0;j<i;j++){
      alfa[s1[j]-'a']=true;
    }
    for(int j=i;j<a;j++)
      alfa2[s1[j]-'a']=true;
    int cnt=0;int cnt2=0;
    for(int j=0;j<26;j++){
      if(alfa[j]&&alfa2[j])cnt++;
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		int ans = p + q + r - Math.max(p, Math.max(q, r));

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 21844
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n,c=0;
	cin>>n;
	rep(i,n){
		int a;cin>>a;
		if(a%2&&i%2==0)c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3660
#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 EPS (1e-8)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define EQV(a,b) ( EQ(a.real(), b.real()) && EQ(a.imag(), b.imag()) )

typedef complex<double> p;

double cross(p a, p b) {
	return (a.real() * b.imag() - a.imag() * b.real());
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		p point[5];
		REP(i, 5) {
			double a, b;
			scanf("%lf %lf", &a, &b);
			point[i] = p(a, b);
		}
		int cnt[2] = {};
		
		REP(i, 3) {
			p v[2];
			v[0] = point[(i + 1) % 3] - point[i];
			v[1] = point[3] - point[i];
			if (cross(v[0], v[1]) < -EPS) cnt[0]++;
			
			v[1] = point[4] - point[i];
			if (cross(v[0], v[1]) < -EPS) cnt[1]++;
		}
		bool flag[2];
		REP(i, 2) flag[i] = cnt[i] == 0 || cnt[i] == 3;
		if (flag[0] == !flag[1]) puts("OK");
		else puts("NG");
	}
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define ll long long int
#define lim 100010

int main(void){
	ll a,b;
	scanf("%lld%lld",&a,&b);
	if(a>0){
		printf("Positive");
	}else if(a==0){
		printf("Zero");
	}else{
		if(b>=0){
			printf("Zero");
		}else{
			if((b-a+1)%2==0)printf("Positive");
			else printf("Negative");
		}
	}
	
	return 0;
}

Measured memory_bytes: 384
# coding: utf-8
from math import pi, cos, sin
    
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def __str__(self):
        return str(self.x) + " " + str(self.y)
        
    def __add__(self, p):
        return Point(self.x + p.x, self.y + p.y)
    
    def __sub__(self, p):
        return Point(self.x - p.x, self.y - p.y)
    
    def __mul__(self, scala):
        return Point(self.x * scala, self.y * scala)
        
    def __div__(self, scala):
        return Point(self.x / scala, self.y / scala)
        
    def __truediv__(self, scala):
        return self.__div__(scala)
    
    def rotate(self, theta: float, origin: "Point"):
        if origin == None:
            origin = Point(0, 0)
        _self = self - origin
        x = _self.x * cos(theta) - _self.y * sin(theta)
        y = _self.x * sin(theta) + _self.y * cos(theta)        
        return Point(x, y) + origin


def dump(points: [Point]):
    for p in points:
        print(p)
        

def koch(points: [Point], n: int) -> [Point]:
    if n <= 0: return points
    if len(points) <= 1: return points
    
    _points = __koch(points)
    return koch(_points[0:2], n - 1) + \
        koch(_points[1:3], n - 1)[1:] + \
        koch(_points[2:4], n - 1)[1:] + \
        koch(_points[3:5], n - 1)[1:]


def tertile(pair: [Point, Point]) -> [Point, Point, Point, Point]:
    t1 = pair[0] + (pair[1] - pair[0]) / 3;
    t2 = pair[0] + (pair[1] - pair[0]) * 2 / 3;
    return [pair[0], t1, t2, pair[1]];
    

def __koch(pair: [Point, Point]) -> [Point, Point, Point, Point, Point]:
    four = tertile(pair)
    mid = four[1].rotate(-pi/3, four[2])
    return four[:2] + [mid] + four[2:]
        
def main():
    points = [Point(0, 0), Point(100, 0)]
    dump(koch(points, int(input())))
    

if __name__ == "__main__":
    main()



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

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

vector<int> G[10];
set<int> check;
bool path;
int cnt;

int n, m;

void debug(void) {
	cout<<endl;
	for(int i=0;i<n;i++) {
		for(int j=0;j<G[i].size();j++) {
			cout<<G[i][j]<<" ";
		}cout<<endl;
	}cout<<endl;

	return ;
}

void dfs(int v, set<int> check) {
	check.insert(v);
	if(check.size() == n) {
		cnt++;
		return ;
	}

	for(int j=0;j<G[v].size();j++) {
		if(check.count(G[v][j])) continue;

		dfs(G[v][j], check);
	}

	return ;
}

int main(void){
	cin>>n>>m;
	for(int i=0;i<m;i++) {
		int a, b; cin>>a>>b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	//debug();

	dfs(0, check);
	//for(int i=0;i<G[0].size();i++) {
	//	dfs(G[0][i]);
	//}

	cout<< cnt <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007LL
#define ll long long
using namespace std;
int su[214514],a[214514];
signed main(){
	int n,k;
	cin>>n>>k;
	int ma = 0;
	double ans = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		a[i]++;
	}
	for(int i=1;i<=n;i++){
		su[i] = su[i-1] + a[i];
	}
	for(int i=k;i<=n;i++){
		ma = max( ma, su[i]-su[i-k] );
	}
	ans = ma * 0.5;
	cout<<setprecision(16)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define $$ long long int
#define pb push_back
#define db pop_back
#define q2(n) (n%2)==0
#define vp vector<pair <$$,$$> >
#define vctr vector<$$>
#define in(a) scanf("%lld",&a)
#define out(a) printf("%lld ",a)
#define loop(i,m,p) for ($$ i = m; i < p; i++)
#define loopn(i,m,p) for ($$ i = p-1; i >=m; --i)

using namespace std;


int main()
{
	$$ a,b;
	cin>>a>>b;
	if (a==0)
	{
		if (b<100)
		{
			cout<<b<<endl;
		}
		else{

			$$ k=b/100;
			cout<<(b+k)<<endl;
		}
		

	}
	else if (a==1)
	{
		if (b<100)
		{
			cout<<b*100<<endl;
		}
		else{

			$$ k=b/100;
			cout<<(b+k)*100<<endl;
		}
	}
	else{
		if (b<100)
		{
			cout<<b*10000<<endl;
		}
		else{

			$$ k=b/100;
			cout<<(b+k)*10000<<endl;
		}
	}

 




return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll      	long long int
#define PI      	acos(-1)
#define read    	freopen("in.txt","r",stdin)
#define uu      	first
#define vv      	second
#define write   	freopen("out.txt","w",stdout)
#define pii     	pair<int,int>
#define pll         pair<ll,ll>
#define INF     	1e9
#define EPS     	1e-8
#define MAX     	1000006
#define MOD     	1000000007
#define fastRead 	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
string str;
vector<int>v;
ll dp[20000][2][200];
int d , n;

void process() {

    for(int i =0 ; i < str.size() ; i++ ) {

        v.push_back(str[i]-'0');
    }

    n = v.size();
//    for(int i =0 ; i < v.size() ; i++ ) {
//        cout<<v[i]<<" ";
//    }

}

ll solve(int id , int isSmall , int rem) {

    if( id== n ) {
        if( rem ==0 ) return 1;
        return 0;
    }

    ll &ret = dp[id][isSmall][rem];
    if( ret != -1) return ret;

    ret = 0;

    int till ;
    if( isSmall) till = 9;
    else till = v[id];

    for(int i =0 ; i <= till ; i++ ) {

        if( isSmall || i < till) {

            ret = (ret + solve(id +1 , 1 , (rem + i)%d ) %MOD) %MOD;
        }
        else ret = (ret + solve(id+1 , 0 , (rem+ i)%d ) %MOD) %MOD;
    }

    return ret;

}


int main()
{
    cin>>str>>d;
    process();
    memset(dp , - 1, sizeof dp);
    cout<<(solve(0 , 0 , 0) + MOD-1)%MOD<<endl;
    return 0;

}


Measured memory_bytes: 63872
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#pragma warning(disable:4996)
using namespace std;

int main() {
	int a, b;

	cin >> a >> b;
	int n = a / 2019;
	a -= (n * 2019);
	b -= (n * 2019);

	if (b >= 2019)
		cout << "0" << endl;
	else {
		int min = 2019;
		int now;
		for (int i = a + 1; i <= b; i++) {
			for (int j = a; j < i; j++) {

				now = j * i % 2019;
				min = now > min ? min : now;
			}
		}
		cout << min << endl;
	}
	//cout << (i-1)*i % 2019 << endl;

	return 0;
}

Measured memory_bytes: 256