akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
//using Edge = Pair<long, int>;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        //var hw = Input.ar;
        //var gred = Input.gred(hw[0]);
        var nm = Input.ar; //if (nm[0] == 1) { WriteLine(1);return; }
        var ar = new bool[nm[0] + 1];
        for (var i = 0; i < nm[1]; i++)
            ar[Input.num] = true;
        var dp = new long[nm[0] + 1];
        dp[0] = 1;
        dp[1] = ToInt64(!ar[1]);
        for (var i = 2; i <= nm[0]; i++)
            if (!ar[i])
            {
                dp[i] += dp[i - 1] + dp[i - 2];
                dp[i] %= Input.MOD;
            }
        WriteLine(dp[nm[0]]);

    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public static long numL => ToInt64(read);
    public static char[][] gred(int h)
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[] ar1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => num).ToArray();
    public static long[] arL1D(int n)
        => Enumerable.Repeat(0, n).Select(_ => numL).ToArray();
    public static string[] strs(int n)
        => Enumerable.Repeat(0, n).Select(_ => read).ToArray();
    public static int[][] ar2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => ar).ToArray();
    public static long[][] arL2D(int n)
        => Enumerable.Repeat(0, n).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public static string[] Make<T1, T2>(out T1 v1, out T2 v2)
    {
        var r = read.Split(' ');
        v1 = getValue<T1>(r[0]);
        v2 = getValue<T2>(r[1]);
        return r;
    }
    public static string[] Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3)
    {
        var r = Make(out v1, out v2);
        v3 = getValue<T3>(r[2]);
        return r;
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public const int MOD = 1000000007;
}

Measured memory_bytes: 15376
N, K = gets.split.map(&:to_i)
hs = gets.split.map(&:to_i)

INF = 1 << 60
dp = Array.new(N + K, INF)
dp[0] = 0
N.times do |i|
  n = dp[i]
  (1..K).each do |j|
    break if i + j >= N
    m = dp[i + j]
    cost = (hs[i] - hs[i + j]).abs
    dp[i + j] = n + cost if n + cost < m
  end
end
puts dp[N - 1]

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

int main(){
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        if(S[i] == T[i])cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

arr = [(1 + m) / 2 for m in p]
ans = 0
sum = 0
for i in range(n):
	sum += arr[i]
	if i >= k: sum -= arr[i - k] 
	ans = max(ans, sum)
print(ans)


Measured memory_bytes: 32020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long int;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> ball(n + 1, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i + 1];
    }
    int count = 0;
    for(int i = n; i >= 1; i--)
    {
        int total = 0;
        for(int j = i * 2; j <= n; j = j + i)
        {
            total += ball[j];
        }
        if(total % 2 != a[i])
        {
            ball[i] = 1;
            count++;
        }
    }
    cout << count << endl;
    for(int i = 1; i <= n; i++)
    {
        if(ball[i] == 1){
            cout << i << " ";
        }
    }
    cout << endl;
}

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


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");}
# define M_PI    3.14159265358979323846
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...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	int i, m, k, n;
	long long int sum = 0;
	c_p_c();

	cin>>n;
	for (int i = 1; i <=n; ++i)
	{
		/* code */
		if((i*(i+1)*1ll)/2 >= n){
			cout<<i<<endl;
			return 0;
		}
	}


	return 0;
	}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  char s[4];
  char temp;
  scanf("%s", s);
  if(s[2]=='\0'){
    printf("%s\n",s);
  }
  else{
    temp=s[0];
    s[0]=s[2];
    s[2]=temp;
    printf("%s\n",s);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    S[K-1] -= 'A' - 'a';
    cout << S << endl;
    return 0;
}


Measured memory_bytes: 256
//#define LOCAL

#include <cstdio>

#define M 500010
#define SENTINEL 2000000000
int s = 0, A[M], L[M], R[M];

void merge(int l, int m, int r) {
	int i, j, k, n1 = m-l, n2 = r-m;
	L[n1] = R[n2] = SENTINEL;
	for(i=0; i<n1; ++i) L[i] = A[l+i];
	for(i=0; i<n2; ++i) R[i] = A[m+i];
	i = j = 0;
	for(k=l; k<r; ++k) {
		if(L[i] <= R[j]) A[k] = L[i++];
		else A[k] = R[j++]; ++s;
	}
}

void mergeSort(int l, int r) {
	if(l+1 < r) {
		int m = (l+r)/2;
		mergeSort(l, m);
		mergeSort(m, r);
		merge(l, m, r);
	}
}

int main()
{
	#ifdef LOCAL
		freopen("E:\\Temp\\input.txt", "r", stdin);
		freopen("E:\\Temp\\output.txt", "w", stdout);
	#endif

	int i, n;
	scanf("%d", &n);
	for(i=0; i<n; ++i) scanf("%d", &A[i]);

	mergeSort(0, n);
	for(i=0; i<n; ++i) {
		if(i) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", s);

	return 0;
}

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

using ll=long long;
#define int ll

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

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

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

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

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

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

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

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

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

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

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

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

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

const int inf=LLONG_MAX/3;

signed main(){
	string s=readString();
	if(s.size()<4||s.substr(0,4)!="YAKI")
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 2304
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))

a_diff = [abs((t - hi * 0.006) - a) for hi in h]

x, x_ind = a_diff[0], 0
for i, e in enumerate(a_diff[1:]):
    if e < x:
        x, x_ind = e, i + 1

x_ind += 1
        
print(x_ind)


Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		int[][] like = new int[n][];
		for (int i = 0; i < n; i++) {
			int[] like2 = new int[sc.nextInt()];
			for (int j = 0; j < like2.length; j++) {
				like2[j] = sc.nextInt();
			}
			like[i] = like2;
		}

		int[] cnt = new int[food];

		for (int j = 0; j < like.length; j++) {
			for (int k = 0; k < like[j].length; k++) {
				cnt[like[j][k] - 1]++;
			}
		}
		
		int ans = 0;
		for (int i = 0; i < cnt.length; i++) {
			if (cnt[i] == n) {
				ans++;
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 22228
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

using Graph = std::vector<std::vector<int>>;
std::vector<int> dist; // dist.assign(n, -1);
std::vector<int> prev; // prev.assign(n, -1);

void bfs(const Graph &g, const int s) {
  std::queue<int> pool;
  dist[s] = 0;
  pool.push(s);

  while (not pool.empty()) {
    const int v = pool.front();
    pool.pop();

    for (auto w : g[v]) {
      if (dist[w] >= 0)
        continue;
      dist[w] = dist[v] + 1;
      prev[w] = v;
      pool.push(w);
    }
  }
}

int main() {
  int N, X, Y;
  std::cin >> N >> X >> Y;

  Graph g(N);
  for (int i = 0; i < N; ++i) {
    if (i + 1 < N)
      g[i].push_back(i + 1);
    if (i - 1 >= 0)
      g[i].push_back(i - 1);
  }
  g[X - 1].push_back(Y - 1);
  g[Y - 1].push_back(X - 1);

  std::vector<int> res(N, 0);

  for (int s = 0; s < N; ++s) {
    dist.assign(N, -1);
    prev.assign(N, -1);
    bfs(g, s);

    // std::cout << dist << std::endl;
    // std::cout << std::endl;

    for (auto &v : dist) {
      res[v] += 1;
    }
  }

  for (int i = 1; i < N; ++i)
    std::cout << res[i] / 2 << std::endl;

  return 0;
}


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

int main() {
	int a, b, c, n, i;
	vector<int> A;
	vector<vector<int> > B;
	cin >> n;
		for (i = 0; i < n; i++) {
			cin >> a >> b >> c;
			A.push_back(a);
			A.push_back(b);
			A.push_back(c);
			sort(A.begin(), A.end());
			B.push_back(A);
			A.clear();
		}
		for (i = 0; i < n; i++) {
			if (B[i][2] * B[i][2] == B[i][0] * B[i][0] + B[i][1] * B[i][1]) cout << "YES" << endl;
			else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]

min = 9
min_idx = 0
for i, n in enumerate(l):
    m = n % 10
    if m != 0 and m < min:
        min = m
        min_idx = i

sum = 0
for i, n in enumerate(l):
    if min_idx == i or n % 10 == 0:
        sum += n
    else:
        sum += (n // 10 + 1) * 10

print(sum)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    vector <int> a(5);
    int ans = 0;
    for(int i =0;i<5;i++) {
        cin >> a[i];
        if (a[i] == 0) {
            ans = i +1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define Nmax 100004
using namespace std;

int n,v[Nmax],x,y,T[Nmax],m;

int rad(int x){
    int rx = x;
    int sav = x;
    while (T[rx] != rx){
        rx = T[rx];
    }
    while (T[x]!=x){
        sav = T[x];
        T[x] = rx;
        x = sav;
    }
    return rx;
}

void _union(int x,int y){
    int rx = rad(x);
    int ry = rad(y);

    T[rx] = ry;
}


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

    for (int i=1;i<=n;i++){
        cin>>v[i];
        T[i] = i;
    }
    for (int i=1;i<=m;i++){
        cin>>x>>y;
        _union(x,y);
    }

    int nr = 0;
    for (int i=1;i<=n;i++){
        if(rad(i) == rad(v[i]))
            nr++;
    }

    cout<<nr;

    return 0;
}


Measured memory_bytes: 1024
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#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>
#include <climits>

using namespace std;

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

static const double EPS = 1e-8;
static const double PI = 3.141592653589;
static ll INF = 9999999;
int mod = 1000000007;

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define MIN(a,b)    (a) < (b) ? (a):(b)
#define MAX(a,b)    (a) > (b) ? (a):(b)
#define debug(x) cerr << #x << " = " << x << endl;
int dx[] = {1,-1,0,0,1,-1,1,-1};
int dy[] = {0,0,1,-1,-1,1,1,-1};


using namespace std;

int main() {
    int N;
    cin >> N;
    int a[1000];

    REP(i,2 * N){
        cin >> a[i];
    }
    sort(a, a + 2 * N);

    int ans = 0;
    REP(i, N){
        ans += a[i * 2];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  cout << (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES" : "NO") << endl;
  return 0;
}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL N;
	cin >> N;
	vector<LL> V(N);
	REP(i, N) {
		cin >> V[i];
	}

	bool r = true;
	for (int i = N - 1; i >= 1; --i) {
		if (V[i - 1] > V[i]) {
			V[i - 1] -= 1;
		}

		if (V[i - 1] > V[i]) {
			r = false;
			break;
		}
	}

	cout << (r ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;


const int MAXN=2e5+10;
int p[MAXN],sz[MAXN];
int find(int x){return p[x]=p[x]==x?x:find(p[x]);}
void join(int x, int y){p[find(x)]=find(y);}

int sg(ll x){return x<0?-1:x>0;}

ii frac(ll a, ll b){
	if(!a||!b)return {0,1};
	ll ms=sg(a)*sg(b)<0;
	a=abs(a); b=abs(b);
	ll g=__gcd(a,b); a/=g; b/=g;
	if(ms) a=-a;
	return {a,b};
}

ll MOD=1e9+7;

ll fpow(ll base, ll exp) {
	ll result = 1;
	while(exp){
		if(exp & 1) result = (result*base) % MOD;
		exp >>= 1;
		base = (base*base) % MOD;
	}
	return result;
}

vector<ll> g[MAXN];
ll n;

ll dp[MAXN];

ll solve(int pos){
	if(pos==n)return 1;
	ll &r=dp[pos];
	if(r>=0)return r;
	r=solve(pos+1);
	for(auto x:g[pos]){
		ll ws=(fpow(2,x)-1+MOD)%MOD;
		r=(r+ws*solve(pos+1))%MOD;
	}
	return r;
}

int main(){FIN;
	cin>>n;
	fore(i,0,n) p[i]=i;
	map<ii,int> mp;
	vector<ii> v;
	vector<ll> sz;
	
	map<ii,int> concha;
	ll z00=0,z01=0,z10=0;
	fore(i,0,n){
		ll a,b; cin>>a>>b;
		if(!a&&!b) z00++;
		else if(!a) z01++;
		else if(!b) z10++;
		else concha[frac(a,b)]++;
	}
	for(auto x:concha) v.pb(x.fst),sz.pb(x.snd);
	n=SZ(v);
	fore(i,0,n){
		ii f=v[i];
		if(mp.count(f)) join(mp[f],i);
		mp[frac(-v[i].snd,v[i].fst)]=i;
	}
	fore(i,0,n) g[find(i)].pb(sz[i]);
	memset(dp,-1,sizeof(dp));
	
	
	//elijo 01 o 10
	ll ws=(fpow(2,z10)+fpow(2,z01)-1+MOD)%MOD;	//solo puedo tomar 1
	
	ll ans=solve(0)*ws%MOD;
	
	//poner un 00, me anula todo
	if(z00) ans=(ans+z00+MOD)%MOD;

	ans=(ans-1+MOD)%MOD;

	cout<<ans<<"\n";
}

Measured memory_bytes: 61688
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
string s;
int main()
{
	//cwk;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) {
		puts("Yes");
	}else {
		puts("No");
	}

	return 0;
}


Measured memory_bytes: 256
// finish date: 2018/2/05

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int n;
    cin >> n;
    vi v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    vvi dp(n, vi(n, 0));
    map<int, int> mp;
    int ma = 2;

    rep(i, n) mp[v[i]] = i;
    rep(i, n) dp[0][i] = 2;

    FOR(i, 1, n) {
        FOR(j, i + 1, n) {
            if (mp.count(2 * v[i] - v[j])) {
                dp[i][j] = dp[mp[2 * v[i] - v[j]]][i] + 1;
            } else {
                dp[i][j] = 2;
            }
            ma = max(ma, dp[i][j]);
        }
    }

    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 101080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define rlp(i,a,b) for(int i=a;i>b;i--)
#define ft first
#define sd second
#define pii pair<int,int>
#define all(vect) vect.begin(),vect.end()
#define rall(vect) vect.rbegin(),rend() 
const int num = 200001;
typedef long long ll;
int main()
{
	int x;
	cin >> x;
	if(x>=30)
		cout << "Yes\n";
	else
		cout << "No\n";	



	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
 
using ll = long long;
using i_i = tuple<int, int>;

int main(){
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    bool x =  ((a[0]==5 && a[1] == 5 && a[2] == 7)||(a[0]==5 && a[1] == 7 && a[2] == 5)||(a[0]==7 && a[1] == 5 && a[2] == 5));
    cout << (x ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >>s;
  char a, b;
  a = s.at(0);
  
  if(s.at(1) == a){
    if(s.at(2) == s.at(3)&&s.at(2) != a) {cout << "Yes" <<endl;return 0;}
    else {cout << "No" <<endl; return 0;}
  }
  
  else{
    b = s.at(1);
    if(s.at(2) == a){
      if(s.at(3) == b) {cout << "Yes" <<endl;return 0;}
      else {cout << "No" <<endl;return 0;}
    }
    if(s.at(2) == b){
      if(s.at(3) == a) {cout << "Yes" <<endl;return 0;}
      else {cout <<"No"<<endl;return 0;}
    }
    else cout << "No" <<endl;
  }
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int count = 0;
    for(int i = a; i <= b; i++) {
        string x = to_string(i);
        string y = to_string(i);
        reverse(y.begin(), y.end());
        if(x == y) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    bool odd = false;
    for (int i=0;i<N;i++){
        int a;
        cin >> a;
        if (a%2 == 1) odd = true;
    }
    if (odd) cout << "first" << "\n";
    else cout << "second" << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    string s;
    ll n,ans[300001];
    cin>>n>>s;
    for(int i=1;i<n;i++)if(s[i]=='E')ans[0]++;
    for(int i=1;i<n;i++){
		if(s[i-1]=='E'&&s[i]=='E')ans[i]=ans[i-1]-1;
		if(s[i-1]=='E'&&s[i]=='W')ans[i]=ans[i-1];
		if(s[i-1]=='W'&&s[i]=='E')ans[i]=ans[i-1];
		if(s[i-1]=='W'&&s[i]=='W')ans[i]=ans[i-1]+1;
	}
	sort(ans,ans+n);
	cout<<ans[0]<<endl;
}


Measured memory_bytes: 3076
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int a[4],maxn,minn=0x7fffffff;
int main()
{
	cin>>a[1]>>a[2]>>a[3];
	for (int i=1;i<=3;i++)
	{
		maxn=max(maxn,a[i]);
		minn=min(minn,a[i]);
	}
	cout<<maxn-minn<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<algorithm>
#include<list>
#include<queue>

#define MAX 110

using namespace std;

class Node{
public:
  set<int> con;
};

typedef vector<Node> graph;
typedef list< vector<int> > forest;

void MakeForest(const graph &g, bool exist[MAX], forest &f){
  bool vis[MAX]={false};
  for(int x=0;x<MAX;++x){
    if(!vis[x]&&exist[x]){
      queue<int> q;
      bool tvis[MAX]={false};
      q.push(x);
      tvis[x]=true;
      while(!q.empty()){
	int now=q.front();q.pop();const set<int> &C=g[now].con;
	for(set<int>::iterator its=C.begin();its!=C.end();++its){
	  if(!tvis[*its]){tvis[*its]=true;q.push(*its);}
	}
      }
      vector<int> tmp;
      f.push_back( tmp );
      for(int i=0;i<MAX;++i){
	if(tvis[i]){
	  vis[i]=true;
	  f.back().push_back( i );
	}
      }
    }
  }
}

int Backtrack(int pos, int now, int &bans, bool vis[], int memo[], const graph &G){
  const set<int> &C = G[pos].con;
  int ret = now;
  if(vis[pos]){return now;}
  vis[pos]=true;
  if(now+memo[pos]<=bans)return bans;
  for(set<int>::iterator itc=C.begin();itc!=C.end();++itc){
    int nx = *itc;
    bans=max(bans,now+1);
    ret=max(ret,Backtrack(nx,now+1,bans,vis,memo,G) );
    bans=max(bans,ret);
  }
  vis[pos]=false;
  return ret;
}

int main()
{
  while(true){
    int ans = 2;
    int n;
    cin >> n;
    if( n == 0 )break;
    graph G(MAX);
    forest F;
    bool exist[MAX]={false,};
    for(int i = 0;  i < n ; ++i){
      int a,b;
      cin >> a >> b;
      exist[a]=exist[b]=true;
      G[a].con.insert(b);
      G[b].con.insert(a);
    }

    MakeForest(G,exist,F);

    int memo[MAX];
    for(int i=0;i<MAX;++i){
      memo[i]=MAX*MAX;
    }
    for(forest::iterator itf=F.begin();itf!=F.end();++itf){
      if((*itf).size()<=ans)continue;
      for(int i = 0; i < (*itf).size(); ++i){
	int st=(*itf)[i];
	bool vis[MAX]={false,};
	int btret = Backtrack( st, 0, ans, vis, memo, G );
	memo[st]=btret;
	ans=max(ans,btret);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 928
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int N = scanner.nextInt();
		calculate(N);
		
	}
	
	public static void calculate(int n) {
		String str = null;
		
		calc:
		for (int x = 0; x <= n; x++) {
			for (int y = 0; y <= n; y++) {
				if ( n == 4*x + 7*y) {
					str = "Yes";
					break calc;
				}
			}
			str ="No";
		}
		
		System.out.println(str);
	}
}

Measured memory_bytes: 23252
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    for (ll i = 0; i < s.size(); i += 2)
    {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
const int maxn=400005;

int S[maxn];
int n,q;

void update(int id,int i,int v,int l,int r) {
	if (l==r) S[id]=v;
	else {
		int m=l+r>>1;
		if (i<=m) update(id<<1,i,v,l,m);
		else update(id<<1|1,i,v,m+1,r);
		S[id]=min(S[id<<1],S[id<<1|1]);
	}
}

int query(int id,int ql,int qr,int l,int r) {
	if (ql==l && qr==r) return S[id];
	int m=l+r>>1;
	if (qr<=m) return query(id<<1,ql,qr,l,m);
	else if (ql>m) return query(id<<1|1,ql,qr,m+1,r);
	else return min(query(id<<1,ql,m,l,m),query(id<<1|1,m+1,qr,m+1,r));
}

int main() {
	cin>>n>>q;
	fill(S,S+maxn,0x7fffffff);
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		if (op) {
			int s,t; cin>>s>>t;
			cout<<query(1,s,t,0,n-1)<<'\n';
		}
		else {
			int i,x; cin>>i>>x;
			update(1,i,x,0,n-1);
		}
	}
}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)o.size())
#define run(x) for(int k=head[x];k;k=e[k].ne)
#define v e[k].t
#define all(a) o.begin(),o.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<int,int> pa;
const int N=5e3+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("dato.in","r",stdin);
	freopen("dato.out","w",stdout);
}
int n,m,cc;
il void ad(ll&a,ll b){a+=b;a%=mod;if(a<0)a+=mod;}
ll C[1010][1011],pw[N],phi[N],f[N],res=1;
struct edge{int t,ne;}e[N];
int head[N],cnt=1;
void adde(int a,int b){e[++cnt]=(edge){b,head[a]};head[a]=cnt;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int dfn[N],low[N],dex,st[N],top,inst[N],g[N][N];
void tarjan(int x,int fa){
	dfn[x]=low[x]=++dex;st[++top]=x;inst[x]=1;
	run(x)if(v!=fa){
		if(!dfn[v]){
			tarjan(v,x);gmin(low[x],low[v]);
			if(low[v]>=dfn[x]){
				vector<int>o;int nx;
				do{
					inst[nx=st[top--]]=0;
					o.pb(nx);
				}while(nx!=v);
				o.pb(x);int ce=0,cv=o.size();
				re(i,0,o.size())re(j,0,i)ce+=g[o[i]][o[j]];
				if(cv==ce)res=res*f[ce]%mod;else
				if(ce==cv-1)res=res*cc%mod;else
				res=res*C[cc+ce-1][cc-1]%mod;
			}
		}else if(inst[v])gmin(low[x],dfn[v]);
	}
}
int main(){
	read(n,m,cc);
	rep(i,0,1e3){
		C[i][0]=C[i][i]=1;
		rep(j,1,i-1)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}pw[0]=1;rep(i,1,m)pw[i]=pw[i-1]*cc%mod;
	rep(i,1,m)rep(j,1,i)if(gcd(i,j)==1)phi[i]++;
	rep(i,1,m){
		rep(j,1,i)if(i%j==0)ad(f[i],pw[j]*phi[i/j]);
		f[i]=f[i]*qpow(i,mod-2,mod)%mod;
	}rep(i,1,m){
		int x,y;read(x,y);g[x][y]=g[y][x]=1;
		adde(x,y);adde(y,x);
	}
	rep(i,1,n)if(!dfn[i])tarjan(i,0);
	cout<<res<<endl;
}

Measured memory_bytes: 10240
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(c,b/a) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int n,k; string s;
	cin>>n>>k>>s;
	s[k-1]=(char)((s[k-1]-'A')+'a');
	cout<<s;
	return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    int a, b;
    cin >> a >> b;
    
    if(a+b >= 24) {
        cout << (a+b) % 24 << endl;
    } else {
        cout << a+b << endl;
    }
    return 0;
}   
/** atcoder **/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a;
void solve()
{
    long long i,l=a.length(),ans1=0,ans2=0;
    string t1,t2;
    for (i=0;i<l;i++)
        if (i%2) t1.push_back('1');
        else t1.push_back('0');
    for (i=0;i<l;i++)
        if (i%2) t2.push_back('0');
        else t2.push_back('1');
    for (i=0;i<l;i++)
        if (a[i]!=t1[i]) ans1++;
    for (i=0;i<l;i++)
        if (a[i]!=t2[i]) ans2++;
    cout<<min(ans1,ans2)<<endl;
}
int main()
{
    while(cin>>a)
        solve();
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <random>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c[30],s[400][30];

int main(void){
	int d,i,j,n=26;
	std::vector<int> v(n);
	std::iota(v.begin(),v.end(),1);
	std::random_device seed_gen;
	std::mt19937 engine(seed_gen());
	std::shuffle(v.begin(), v.end(), engine);
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
		std::cout << v[i%26] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3728
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace AtCoder_Beginner_Contest_129
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static void Main(string[] args)
        {
            var N = Slist()[0];
            var W = Slist();
            var rui = new int[N ];
            rui[0] = W[0];
            for(int i=1;i<N;++i)
            {
                rui[i] = rui[i - 1] + W[i];
            }
            int min = int.MaxValue;
            for(int i=0;i<N;++i)
            {
                min = Math.Min(min, Math.Abs(rui[i] - (rui[N - 1] - rui[i])));
            }
            WriteLine(min);
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

bool isused[101];
string city[101];
int point[101];


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

	int N; cin >> N;
	for (int i = 1; i <= N; i++) cin >> city[i] >> point[i];

	for (int i = 0; i < N; i++) {
		int num = 0;
		string s("zzzzzzzzzzzzzzzzzzz");
		int p = -1;

		for (int j = 1; j <= N; j++) {
			if (!isused[j] && city[j] < s) {
				s = city[j];
				p = point[j];
				num = j;
			}
			else if (!isused[j] && city[j] == s) {
				if (p < point[j]) {
					s = city[j];
					p = point[j];
					num = j;
				}
			}
		}

		// 決まったら
		cout << num << endl;
		isused[num] = true;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


class SegmentTreeSUM(object):  # 1-indexed [l,r)
    def __init__(self, size):
        self.len = 1 << (size-1).bit_length()
        # print(self.len)
        self.array = [0 for _ in range(2 * self.len)]

    def update(self, i, x):  # 0-indexed
        i += self.len
        while i > 0:
            self.array[i] = self.array[i] + x
            i >>= 1
        # print(self.array)

    def get(self, i):  # 0-indexed
        return self.array[i + self.len]

    def get_sum(self, l, r):  # 0-indexed
        L = l+self.len
        R = r+self.len
        ANS = 0

        while L < R:
            if L & 1:
                ANS = ANS + self.array[L]
                L += 1

            if R & 1:
                R -= 1
                ANS = ANS + self.array[R]
            L >>= 1
            R >>= 1

        return ANS


N, Q = na()
c_array = na()

tree = SegmentTreeSUM(N)


q_array = []
for i in range(Q):
    l, r = na()
    q_array.append([i, l-1, r])

q_array = sorted(q_array, key=lambda x: x[2])
ans = [0] * Q
last_idx = [-1] * (N+1)
q_idx = 0
for i, c in enumerate(c_array):
    tree.update(i, 1)
    if last_idx[c] != -1:
        tree.update(last_idx[c], -1)
    last_idx[c] = i
    while(q_idx < Q and q_array[q_idx][2] == (i+1)):
        idx, l, r = q_array[q_idx]
        ans[idx] = tree.get_sum(l, r)
        q_idx += 1


print("\n".join(map(str, ans)))


Measured memory_bytes: 244672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
// a^n mod を計算する
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
// a^{-1} mod を計算する
ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 3000000;
const int MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int main() {
    ll X, Y;
    cin >> X >> Y;
    if ((2 * X - Y) % 3 != 0 || ((2 * Y - X) % 3 != 0)) {
        cout << "0\n";
        return 0;
    }
    ll a = (2 * X - Y) / 3;
    ll b = (2 * Y - X) / 3;
    ll mod = pow(10, 9) + 7;
    ll ans = 1;
    for (ll i = a + 1; i <= a + b; i++) {
        ans = (ans * i) % mod;
    }
    COMinit();
    cout << COM(a + b, a) << "\n";
    return 0;
}

Measured memory_bytes: 73904
#include <iostream>

using namespace std;

int main(){
    int x, y, i, j;
  while(true){
        cin >> x >> y;
        if(x==0 && y==0)
            break;
        for(i=0; i<x; i++){
            for(j=0; j<y; j++){
                if(i%2!=0){
                    if(j%2!=0){
                        cout << '#';
                    }else{
                        cout << '.';
                    }
                }   
                if(i%2==0){
                    if(j%2!=0){
                        cout << '.';
                    }else{
                        cout << '#'; 
                    }
                }
            }
        cout << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
//#include<cmath>
using namespace std;

int dic[2000000];

int h(string &s)
{
	int value = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A')
			value += 1;
		else if (s[i] == 'G')
			value += 2;
		else if (s[i] == 'C')
			value += 3;
		else
			value += 4;
		if (i + 1 != s.length())
			value *= 4;
	}
	return value;
}

int main(void)
{
	int n;
	string cmd, s;
	cin >> n;
	while (n--) {
		cin >> cmd >> s;
		if (cmd[0] == 'i') {
			dic[h(s)] = 1;
		}
		else {
			if (dic[h(s)])
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 8656
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    --a;
    --b;
    --c;
    --d;

    string s;
    cin >> s;

    if(c < b){
        bool flg = true;
        for(int i = a; i < c-1; ++i){
            if(s[i]=='#' && s[i+1]=='#') flg = false;
        }
        for(int i = b; i < d-1; ++i){
            if(s[i]=='#' && s[i+1]=='#') flg = false;
        }

        if(flg) puts("Yes");
        else puts("No");
        return 0;
    }
    
    if(b<c && c<d){
        bool flg = true;
        for(int i = a; i < d-1; ++i){
            if(s[i]=='#' && s[i+1]=='#') flg = false;
        }

        if(flg) puts("Yes");
        else puts("No");
        return 0;
    }

    if(d < c){
        bool flg1 = true;
        for(int i = a; i < c-1; ++i){
            if(s[i]=='#' && s[i+1]=='#') flg1 = false;
        }

        bool flg2 = false;
        for(int i = b-1; i <= d-1; ++i){
            if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') flg2 = true;
        }

        if(flg1 && flg2) puts("Yes");
        else puts("No");
    }

    return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
int max(int a,int b){
    if(a>b)return a;
    return b;
}
int min(int a,int b){
    if(a>b)return b;
    return a;
}
int main(){
    int n,top,bot,tot,temp;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        scanf("%d",&top);
        tot=bot=top;
        for(int i=1;i<n;i++){
            scanf("%d",&temp);
            tot+=temp;
            top=max(top,temp);
            bot=min(bot,temp);
        }
        printf("%d\n",(tot-top-bot)/(n-2));
    }
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
const int maxn=1e5+100;
const ll mod=1e9+7;
const int INF=1e7;

ll a[maxn],b[maxn];

int main()
{
    int x,y,n;
    scanf("%d",&n);
    for(int i=0;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
    }
    ll sum=0,last=0;;
    for(int i=0;i<n;i++){
        if(b[i]+last>=a[i]){
            last=b[i]+min(last-a[i],0ll);
            //last=max(last,0ll);
            sum+=a[i];
        }
        else{
            sum+=(last+b[i]);
            last=0;
        }
    }
    if(last>0)
        {
            sum+=min(last,a[n]);
        }
    cout<<sum<<endl;
    return 0;
}


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

LL n,a,b,h[100005];

bool Check(int v) {
	LL re=v,k=a-b;
	for(int i=1;i<=n;i++) 
		if(h[i]>v*b) re-=(h[i]-v*b+k-1)/k;
	return re>=0;
}

int main() {
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) 
		scanf("%lld",&h[i]);
	int l=0,r=1000000000,mid,ans;
	while(l<=r) {
		mid=l+r>>1;
		if(Check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&b<=c)
	{
		cout<<a+b;
	}
	else if(a<=b&&c<=b)
	{
		cout<<a+c;
	}
	else if(b<=a&&c<=a)
	{
		cout<<b+c;
	}
}

Measured memory_bytes: 256