akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <fstream>
#include <math.h>
#include <iomanip>
#include <time.h>
#include <assert.h>
#include <stack>
#include <deque>
#include <bits/stdc++.h>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <sstream>  // istringstream buffer(myString);
// #include <boost/functional/hash.hpp>

using namespace std;

#define endl "\n";
#define bit(x, i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x; example: x=12;  1100 => 100 => 4
#define LL long long
#define ULL unsigned long long
#define inf 1000000007
#define mod 1000000007
#define PII pair<int, int>
#define V vector
#define VI vector<int>
#define VS vector<string>
#define ALL(x) x.begin(), x.end() //handy for function like "sort()"
#define pi 3.14159265358979323846
// set a to the maximum of a and b
#define REMAX(a,b) (a)=max((a),(b));
#define REMIN(a,b) (a)=min((a),(b));
// conversion
string removeZeros(string str) { return str.erase(0, min(str.find_first_not_of('0'), str.size()-1)); } // remove leading zeros
#define char2int(c) (c-'0')
#define int2char(i) (static_cast<char>(i))
#define bin2int(bin) (bitset< 1001 >(bin).to_ulong())
#define int2bin(i) removeZeros(bitset< 1001 >( i ).to_string())
// str.erase(0, min(str.find_first_not_of('0'), str.size()-1)); // remove leading zeros


// works for unordered_set, unordered_map..
#define HMAP unordered_map
#define SET unordered_set
#define HAS(umap, key) (umap.find(key) != umap.end())
#define COUNTER(m, j) if (HAS(m, j)) { m[j]++; } else { m[j] = 1; }
// loop
#define FOREACH(vec, i) for (auto i = vec.begin(); i!= vec.end(); i++)
// read line
#define READ_INTS(vec, n) vector<LL> vec(n); for (LL i=0; i<n; i++) { cin >> vec[i]; }; cin.ignore();
#define READ_DOUBLES(vec, n) vector<double> vec (n); FOREACH(vec, i) { cin >> *i; }; cin.ignore();
#define READ_STRING(vec) string vec; getline(cin, vec);
#define READ_INT(i) LL i; cin >> i; cin.ignore();
// #define SPLIT_STRINGS(vec, str) istringstream iss(str); vector<string> vec((istream_iterator<string>(iss)), istream_iterator<string>());
// debug
#define dd(var) cerr << #var << "=" << (var) << " | "
#define ddv(vec) FOREACH(vec, i) { cout << *i << " "; } cout << endl;
#define ddvv(vec) for(auto& i:vec) { for(auto& j:i) { cout <<  j << " "; }; cout << endl };

LL diff(int i, int j, vector<LL> &v) {
    return abs(v[i] - v[j]);
}

void solve() {
    READ_INT(t);
    READ_INTS(jumps, t);
    vector<LL> price(t);

    price[0] = 0;
    price[1] = diff(0, 1, jumps);

    for (LL i = 2; i < t; i++) {
        price[i] = min(price[i-1] + diff(i-1, i, jumps), price[i-2] + diff(i-2, i, jumps));
    }
    cout << price[t-1] << endl;
}


int main()
{  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
//   READ_INT(t);
//   for (LL i = 0; i < t; i++) {
    solve();
//   }
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

float ab(float x) {
   if (x>=0) return x;
   else       return -x;
}

int main(){
   int n,a[100],s,i,j;
   float m,d;
    
   scanf("%d",&n);
   s=0;
   for (i=0;i<n;i++) {
      scanf("%d",&a[i]);
      s+=a[i];
   }
   m=s*1.0/n;
   j=n-1;d=ab(m-a[n-1]);
   for (i=n-2;i>=0;i--) 
      if (ab(m-a[i])<=d) {
         j=i;d=ab(m-a[i]);
      }
  printf("%d\n",j);
   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main()
{
	int  ans=0,i;
	char S[10];
	//scanf("%s",S[10]);
	
	for(i=0; i<4; i++){
		scanf("%c",&S[i]);
		if(S[i] == '+')
			ans=ans+1;
		else
			ans=ans-1;
	}
	
	printf("%d",ans);
	
	return 0;
}


Measured memory_bytes: 128
def binarySearch(A,k):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right)//2
        if k == A[mid]:
            return True
        elif k > A[mid]:
            left = mid + 1
        else:
            right = mid

    return False



sum = 0
t = int(input())
A = list(map(int,input().split()))
b = int(input())
C = list(map(int,input().split()))

for res in C:
    if binarySearch(A,res):
        sum += 1

print(sum)



Measured memory_bytes: 16716
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        int itemCount = inpt[0];
        this.Amari = inpt[1];
        this.Items = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        long ans = GetAns(0, 0);
        Console.WriteLine(ans);
    }

    private Dictionary<int, Dictionary<int, long>> dic = new Dictionary<int, Dictionary<int, long>>();
    private long GetAns(int idx, int subAmari) {
        if(idx>=this.Items.Length) {
            if(subAmari==Amari) {
                return 1;
            }
            return 0;
        }

        if(!dic.ContainsKey(idx)) {
            dic.Add(idx, new Dictionary<int, long>());
        }
        if(dic[idx].ContainsKey(subAmari)) {
            return dic[idx][subAmari];
        }
        long ans = 0;
        ans += GetAns(idx + 1, (subAmari + this.Items[idx]) % 2);
        ans += GetAns(idx + 1, subAmari);
        dic[idx][subAmari] = ans;
        return ans;
    }

    private int[] Items;
    private int Amari;



	public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"
 
 
 
45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26 
 
 
";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	ll n;cin>>n;
	ll sum=0;
	map<ll,ll>mp;
	for(ll i=0;i<n;i++)
	{
		ll x;cin>>x;
		mp[x]++;
		sum+=x;
	}
	ll q;cin>>q;
	while(q--)
	{
		ll b,c;cin>>b>>c;
		sum-=b*mp[b];
		sum+=c*mp[b];
		mp[c]+=mp[b];
		mp[b]=0;
		cout<<sum<<endl;
	}
}


Measured memory_bytes: 9460
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)

using namespace std;

int table[10000][10000];

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n){
        int k;
        cin>>k;
        rep(j,k){
            int x;
            cin>>x;
            table[i][x-1]=1;
        }
    }
    //rep(i,n)rep(j,m)cout<<table[i][j]<<endl;
    int ans=0;
    rep(i,m){
        int counter=0;
        rep(j,n){
            if(table[j][i]==1)counter+=1;
        }
        //cout<<counter<<endl;
        if(counter==n){
            ans+=1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int N = int.Parse(str);
		int[] A = new int[100000];
		int[] B = new int[100000];
		for(var i=1;i<100000;i=i+2){
			if(IsPrime(i) && IsPrime((i+1)/2)){
				A[i] = 1;
			}
		}
		int ct = 0;
		for(var i=0;i<100000;i++){
			if(A[i] == 1){
				ct += 1;				
			}
			B[i] = ct;
		}
		for(var i=0;i<N;i++){
			string[] str2 = Console.ReadLine().Split();
			int a1 = int.Parse(str2[0]);
			int a2 = int.Parse(str2[1]);
			int ans = B[a2] - B[a1-1];
			Console.WriteLine(ans);
		}
	}
	
	public static bool IsPrime(int num)
	{
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false;

		double sqrtNum = Math.Sqrt(num);
		for (int i = 3; i <= sqrtNum; i += 2){
			if (num % i == 0) return false;
		}
		return true;
	}
}

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

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> R(A);
  vector<int> E(B);
  int rmin=100000;
  for(int i=0; i<A; i++){
    cin >> R[i];
    rmin = min(R[i],rmin);
  }
  int emin=100000;
  for(int i=0; i<B; i++){
    cin >> E[i];
    emin = min(E[i],emin);
  }
  int ans = rmin+emin;
  for(int i=0; i<M; i++){
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, R[x-1]+E[y-1]-c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[][] r = new int[N*(N-1)/2][4];
		int[] cnt = new int[N];
		int[] rnk = new int[N];
		for(int i=0; i<r.length; i++){
			for(int j=0; j<4; j++){
				int a=sc.nextInt();
				r[i][j]=a;
			}
		}
		for(int i=0; i<r.length; i++){
			for(int j=2; j<3; j++){
				if(r[i][j]>r[i][j+1]){
					cnt[r[i][0]-1]+=3;
				}else if(r[i][j]<r[i][j+1]){
					cnt[r[i][1]-1]+=3;
				}else{
					cnt[r[i][0]-1]+=1;
					cnt[r[i][1]-1]+=1;
				}
			}
		}
		int result=1;
		for(int i=0; i<N; i++){
			for(int j=0; j<N; j++){
				if(cnt[i]<cnt[j]){
					result++;
				}
			}
			rnk[i]=result;
			result=1;
		}
		for(int i=0; i<N; i++){
			System.out.println(rnk[i]);
		}
		// TODO Auto-generated method stub

	}
	
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int res = -1;
	for (int i = a; i < b + 1; i++) {
		if (c <= i && i <= d) {
			res++;
		}
	}
	cout << max(0, res) << endl;
}

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

int N;
double dp[305][305][305];
double rec(int i, int j, int k) {
  if (dp[i][j][k] >= 0) return dp[i][j][k];
  if (i == 0 && j == 0 && k == 0) return 0.0;
  double res = 0.0;
  if (i > 0) res += rec(i - 1, j, k) * i;
  if (j > 0) res += rec(i + 1, j - 1, k) * j;
  if (k > 0) res += rec(i, j + 1, k - 1) * k;
  res += N;
  res /= i + j + k;
  return dp[i][j][k] = res;
}

void Main() {
  cin >> N;
  int n1, n2, n3;
  n1 = n2 = n3 = 0;
  rep(i, N) {
    int a;
    cin >> a;
    if (a == 1)
      n1++;
    else if (a == 2)
      n2++;
    else
      n3++;
  }

  memset(dp, -1, sizeof(dp));
  cout << rec(n1, n2, n3) << endl;
  cout << endl;
}

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


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

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

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n, q;
  cin >> n >> q;
  vector< queue<int> > a(n);

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int t, x; cin >> t >> x;
      a[t].push(x);
    } else if (command == 1) {
      int t; cin >> t;
      if (!a[t].empty()) ans.push_back(a[t].front());
    } else {
      int t; cin >> t;
      if (!a[t].empty()) a[t].pop();
    }
  }
  for (auto a : ans) cout << a << endl;

  return 0;
}



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

int main(){
  string s;cin >> s;
  if( s.back() != 's' )
    cout << s << 's' << endl;
  else
    cout << s << "es" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >>n >>k;
    vi x(n);
    rep(i, n) {
        cin >> x[i];
    }
    ll sum = 0;
    rep(i, n) {
        sum += 2*min(x[i], k-x[i]);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int N, a;
  double p = 0;
  double result;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> a;
    p += 1./a;
  }

  result = 1/p;
  
  cout << setprecision(10) << result << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<pair<int,int>> vip;

#define ZOOM ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define ff it->first
#define ss it->second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define LOOP_IT(s) for(auto it=(s).begin();it!=(s).end();++it)


int main(int argc,char* argv[])
{
    ZOOM

    ll n,k,sum=0,ans=0;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;++i)
    {
        cin>>v[i];
        sum+=v[i];
    }
    sort(all(v));
    ll lim = max(n-k,0ll);
    for(ll i=n-1;i>=lim;--i)
    {
        ans+=v[i];
    }
    cout<<sum-ans;


    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int H,W;cin>>H>>W;
  vector<string> G(H);
  REP(i,0,H)cin>>G[i];

  set<int> V,H_;
  REP(i,0,H){
    bool flg=true;
    REP(j,0,W){
      if(G[i][j]=='#'){
        flg=false;
      }
    }
    if(flg){
      H_.insert(i);
    }
  }

  REP(j,0,W){
    bool flg=true;
    REP(i,0,H){
      if(G[i][j]=='#'){
        flg=false;
      }
    }
    if(flg){
      V.insert(j);
    }
  }

  REP(i,0,H){
    REP(j,0,W){
      if(!H_.count(i)&&!V.count(j)){
        cout<<G[i][j];
      }
    }
    if(!H_.count(i)){
       cout<<"\n";
    }
  }
  cout<<"\n";

}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    int B[n];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B, B + n);
    int cnt = 0;
    int i = 0;
    while (i < n) {
        if (A[i] == B[i]) {
            i++;
            continue;
        }
        int tgt_idx = find(A, A + n, B[i]) - A;
        int n_cycle = 1;
        while (tgt_idx != i) {
            int dst_idx = find(A, A + n, B[tgt_idx]) - A;
            cnt += A[tgt_idx] + A[dst_idx];
            swap(A[tgt_idx], A[dst_idx]);
            tgt_idx = dst_idx;
            n_cycle++;
        }
        if ((n_cycle - 3) * B[i] > (n_cycle + 1) * B[0]) {
            cnt -= (n_cycle - 3) * B[i] - (n_cycle + 1) * B[0];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int m1, d1;
  cin >> m1 >> d1;
  int m2, d2;
  cin >> m2 >> d2;
  if (m1 != m2) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n,m;
	cin >> n >> m;
	int l = 0, r = n;
	rep(i,m){
		int a,b;
		cin >> a >> b;
		l = max(l, a);
		r = min(r, b);
	}
	cout << max(0, r - l + 1) << endl;
}

Measured memory_bytes: 256
from collections import defaultdict

N=int(input())
alist=list(map(int,input().split()))

adic=defaultdict(int)
for a in alist:
  adic[a]+=1
#print(adic)

answer=0
for key in adic:
  if adic[key]<key:
    answer+=adic[key]
  else:
    answer+=adic[key]-key
    
print(answer)

Measured memory_bytes: 18672
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    vector<ll> A(N);
    int cnt = 0;
    rep(i,N) {
        int a; cin >> a;
        if (a <= 0) a = -a, cnt++;
        A[i] = a;
    }
    sort(A.begin(), A.end());
    ll res = 0;
    if (cnt > 0 && cnt % 2 == 1) A[0] = -A[0];
    rep(i,N) res += A[i];
    cout << res << endl;
}


Measured memory_bytes: 4024
n=int(input())
if n<3:
    print(0)
    exit()
if n==3:
    print(1)
    exit()
s=input()
s=[int(i)+1 for i in s]
l=[int(i) for i in s]
l1=[0]*(n+16) 
l2=[0]*(n+13)
l3=[0]*(n+12)
l2[n-1]=1 
l3[s[n-1]-1]=1 
k=3 
for i in range(n-2,-1,-1): 
    l2[i]=l2[i+1]
    if l3[s[i]-1]==0:
        l2[i]+=1 
        l3[s[i]-1]=1 
for j in range(1,k):
    l3=[0]*(n+18)
    l1[n-1]=0 
    for i in range(n-2,-1,-1) : 
        l1[i]=l1[i+1]
        l1[i]=l1[i]+l2[i+1]
        l1[i]=l1[i]-l3[s[i]-1]
        l3[s[i]-1]=l2[i+1]
    l2=l1[:]
print(l1[0])

Measured memory_bytes: 43504
#include <iostream>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
  ll k,sum=0;
  cin>>k;
  for(ll i=0;i<k+1;i++){
    if(i%3!=0&&i%5!=0)sum+=i;
  }
  cout<<sum<<endl;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const LL MOD = 1000000007;

class Combinations {
private:
  int max, mod;
  VLL fac, finv, inv;
public:
  Combinations(int _max, int _mod) : fac(_max), finv(_max), inv(_max) {
    max = _max;
    mod = _mod;
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    REP2(i, 2, max) {
      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 nCr(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;
  }
};

void solve(long long X, long long Y){
    if((X+Y) % 3 != 0) {
        cout << 0 << endl;
        return;
    }

    int cnt = (X+Y) / 3;

    if(X-cnt < 0 || Y-cnt < 0) {
        cout << 0 << endl;
        return;
    }

    Combinations comb(cnt+1, MOD);
    cout << comb.nCr(cnt, X-cnt) << endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 15872
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#define MAXN 100000
using namespace std;

int n,ans;
struct node
{
    int x,y;
    node(){}
    node(int a,int b)
    {
        x=a,y=b;
    }
    bool operator < (const node &a) const
    {
        return y>a.y;
    }
}Fack[MAXN+5];

int main()
{
    scanf("%d",&n);
    ans=n;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&Fack[i].x,&Fack[i].y);
    sort(Fack+1,Fack+n+1);
    for(int i=2;i<=n;i++)
    {
        int va=Fack[i].x-Fack[i-1].x-1;
        //printf("%d:%d ",i,va);
        ans+=min(Fack[i-1].y-Fack[i].y,va);
        //printf("%d\n",ans);
    }
    ans+=Fack[1].x-1;
    ans+=Fack[n].y;
    printf("%d\n",ans);
}


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

ll a[maxn];

int main(){
	int n;
	cin>>n;
    set<ll> st;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
	    st.insert(a[i]);
	}
    
    if(st.size() == n){
    	cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}

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

int main(){
    int k;
    cin >> k;
    int e=k/2;
    int o=k-e;
    cout << e*o <<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
X = []
for i in range(n):
    x, y = map(int, input().split())
    X.append((x - y, x + y))
X.sort(key=lambda x: x[1])
ter = -10**10
cnt = 0
for left, right in X:
    if ter <= left:
        ter = right
        cnt += 1
print(cnt)


Measured memory_bytes: 18252
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  int a[5],i,j,flag=0;

  for(i=0;i<6;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<5;i++){
    for(j=0;j<4;j++){
      if(a[5]<abs(a[i]-a[j])){
        flag = 1;
      }
    }
  }
  if(flag == 1){
    printf(":(\n");
  }else printf("Yay!\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, d, x;
    cin >> n >> d >> x;
    int a[1000];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        for(int j=1; j<=d; j+=a[i]){
            x++;
        }
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    int a, b;
    std::cin >> a >> b;

    for (int i = 0; i < 100000; i++) {
        if ((int)(i * 0.08) == a && (int)(i * 0.10) == b) {
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
readline = sys.stdin.readline
N,Q =  map(int,input().split())
graph = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,readline().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

val = [0 for i in range(N)]
for i in range(Q):
    a,b = map(int,readline().split())
    val[a-1] += b 

def dps(i,parent): 
    for j in graph[i]:
        if j == parent:
            continue
        val[j] += val[i]
        dps(j,i)
                
dps(0,-1)
print(*val)
    

Measured memory_bytes: 230900
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    int A,B,ans,tap;
    ans = 0;
    tap = 1;
    cin >>A>>B;
    REP(i,B){
        if(B<=tap){
            break;
        }
        ans++;
        tap = 1+ans*(A-1);
    }
    cout << ans << endl;
    return 0;
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  vector<int> x(5);
  rep(i, 5) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i+1 << endl;
      break;
    }
  }
}


Measured memory_bytes: 3612
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64, int64> pll;

const int INF = 0x3f3f3f3f;
char str[100000];

int main(){
	int K;
	scanf("%d %s",&K,str);
	int len = strlen(str);
	if(len > K){
		for (int i = 0; i < 3; ++i)
			str[K+i] = '.';
		str[K+3] = 0;
	}
	puts(str);


}



Measured memory_bytes: 3160
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] field = new int[h][w];
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        field[i][j] = sc.nextInt();
		    }
		}
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        field[i][j] -= sc.nextInt();
		        field[i][j] = Math.abs(field[i][j]);
		    }
		}
		ArrayList<HashSet<Integer>> list = new ArrayList<>();
		for (int i = 0; i < h * w; i++) {
		    list.add(new HashSet<>());
		}
		boolean[][][] ans = new boolean[h][w][(h + w) * 80 + 1];
		ans[0][0][field[0][0]] = true;
		for (int i = 0; i < h; i++) {
		    for (int j = 0; j < w; j++) {
		        if (j != 0) {
		            for (int k = 0; k < ans[i][j].length; k++) {
		                if (ans[i][j - 1][k]) {
		                    ans[i][j][k + field[i][j]] = true;
		                    ans[i][j][Math.abs(k - field[i][j])] = true;
		                }
		            }
		        }
		        if (i != 0) {
		            for (int k = 0; k < ans[i][j].length; k++) {
		                if (ans[i - 1][j][k]) {
		                    ans[i][j][k + field[i][j]] = true;
		                    ans[i][j][Math.abs(k - field[i][j])] = true;
		                }
		            }
		        }
		    }
		}
		for (int i = 0; i < ans[h - 1][w - 1].length; i++) {
		    if (ans[h - 1][w - 1][i]) {
		        System.out.println(i);
		        return;
		    }
		}
	}
}


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

#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    int n, s;
    cin >> n >> s;
    if (s > n) {
        cout << -1 << endl;
        return;
    }
    if (n == s) {
        cout << n + 1 << endl;
        return;
    }

    int K = (int)sqrt(max(n, s)) + 1;
    int ans = INF;
    for (int b = 2; b <= K + 2; ++b) {
        int sum = 0;
        int N = n;
        while (N > 0) {
            sum += N % b;
            N /= b;
        }
        if (sum == s) {
            ans = min(ans, b);
        }
    }

    for (int a1 = 1; a1 <= K + 2; ++a1) {
        if ((n - s) % a1 == 0) {}
        int b = (n - s) / a1 + 1;
        if (b >= 2) {
            int sum = 0;
            int N = n;
            while (N > 0) {
                sum += N % b;
                N /= b;
            }
            if (sum == s) {
                ans = min(ans, b);
            }
        }
    }

    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long
#define f(i,k,n) for(i=k;i<n;i++)
#define pll pair<ll,ll>
#define mp map<ll,pll>
#define mi mp::iterator
#define vll vector<ll>
 
using namespace std;

vll dp(100001,-1);

ll maxlen(vll v[],ll i){
    ll mx=0,j;
    
    if(dp[i]!=-1)
        return dp[i];
        
    f(j,0,(ll)v[i].size()){
        mx=max(mx,maxlen(v,v[i][j])+1);
    }
    
    dp[i]=mx;
    
    return dp[i];
}

int main(){
    
    ll n,m,i,j;
    
    cin>>n>>m;
    
    vll v[n+1],s;
    vector<bool> child(n+1,false);
    
    f(i,0,m){
        ll x,y;
        cin>>x>>y;
        
        v[x].push_back(y);
        child[y]=true;
    }
    
    f(i,1,n+1)
        if(child[i]==false)
            s.push_back(i);
    
    ll mx=0;
    
    f(i,0,(ll)s.size()){
            mx=max(mx,maxlen(v,s[i]));
    }
    
    cout<<mx;
    
    return 0;
}


Measured memory_bytes: 11136
def resolve():
    s = list(input())
    c = 0
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            if s[i] == "0":
                s[i+1] = "1"
            else:
                s[i+1] = "0"
            c += 1
    print(c)
resolve()

Measured memory_bytes: 9740
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


void dfs(int l, int r, int level, vector<vector<ll>> &ans) {
    if (l + 1 == r) return;
    int mid = (l + r) / 2;

    for (int x = l; x < mid; x++) {
        for (int y = mid; y < r; y++) {
            ans[x][y] = level;
            ans[y][x] = level;
        }
    }

    dfs(l, mid, level + 1, ans);
    dfs(mid, r, level + 1, ans);

}

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

    vector<vector<ll>> ans(n, vector<ll>(n));
    dfs(0, n, 1, ans);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (j != i + 1) cout << ' ';
            cout << ans[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 2432
import java.io.*;
import java.lang.*; 
import java.util.*; 
 
class Main{ 
public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
          String[] str = br.readLine().split(" ");
          Arrays.sort(str);
          int x = Integer.parseInt(str[0]);
          int y = Integer.parseInt(str[1]);
          int z = Integer.parseInt(str[2]);
        System.out.println(x + " " + y + " " + z);
 }
}
   

Measured memory_bytes: 17084
#include <cstdio>
 #include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
 #include <set>
 #include <map>
 #include <vector>
 #include <list>
 #include <algorithm>
 #include <cstring>
 #include <cmath>
 #include <string>
 #include <queue>
 #include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
 #include <cassert>
 #include <iomanip>        //do setprecision
 #include <ctime>
 #include <complex>
 using namespace std;

 #define FOR(i,b,e) for(int i=(b);i<(e);++i)
 #define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
 #define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
 #define REP(x, n) for(int x = 0; x < (n); ++x)

 #define ST first
 #define ND second
 #define PB push_back
 #define PF push_front
 #define MP make_pair
 #define LL long long
 #define ULL unsigned LL
 #define LD long double
 #define pii pair<int,int>
 #define pll pair<LL,LL>

 const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
 const int mod=1000000007;

 int main(){
	 int n,a[111]={},x,cnt=0;
	 cin>>n>>x;
	 REP(i,n)cin>>a[i];
	 sort(a,a+n);
	 FOR(i,0,n){
		 //cerr<<a[i]<<endl;
		 if(x>=a[i]){
			 x-=a[i];
			 cnt++;
		 }else x=0;
	 }
	 //cerr<<x<<endl;
	 if(x!=0)cnt--;
	 cout<<cnt<<endl;
   return 0;
 }


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

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

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

void YES() { cout << "Yes" << endl; }
void NO() { cout << "No" << endl; }

int T;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> T;
  while (T--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b || d < b) NO();
    else if (c >= b-1) YES();
    else {
      int g = __gcd(b, d);
      int mx = (b - g + a % g) % b;
      if (mx > c) NO();
      else YES();
    }
  }

  return 0;
}

Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

def small_lcm(x, y):
    if x is None or y is None:
        return None
    ans = x * y // gcd(x, y)
    return ans if ans <= m else None

def count_div2(a):
    ans = 0
    while a % 2 == 0:
        ans += 1
        a //= 2
    return ans

cds = list(map(count_div2, a))
for v in cds:
    if v != cds[0]:
        print(0)
        exit(0)

l = reduce(small_lcm, map(lambda x: x // 2, a))
if l is None:
    print(0)
    exit(0)
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)


Measured memory_bytes: 16344
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
      	int A = scn.nextInt();
      int B = scn.nextInt();
      if(A <= 9 && A >= 0 && B <= 9 && B >= 0){
      	System.out.println(A*B);
      }
      else{
        System.out.println(-1);
      }
			
		}
	}

Measured memory_bytes: 27080
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        for(int i = 0; i < 300; i++) {
          String line = sc.nextLine();
          String[] l = line.split(" ");
          int H = Integer.parseInt(l[0]);
          int W = Integer.parseInt(l[1]);
          if(H == 0 && W == 0) {
            break;
          }

          for(int h = 0; h < H; h++) {
            for(int w = 0; w < W; w++) {
              if(h == 0 || h == H -1 || w == 0 || w == W - 1) {
                System.out.print("#");
              } else {
                System.out.print(".");
              }
            }
            System.out.println();
          }
          System.out.println();
        }
    }
}

Measured memory_bytes: 37200
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    ll sum = 0;
    int dead_line = 0;
    REP(i,n-1) {
        sum += a[i];
        if (sum*2 < a[i+1]) dead_line = i+1;
    }

    cout << n-dead_line << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int c, K;
void f(int i, int k, int p, int64_t n)
  {if (i >= k) {++c; if (c == K) {cout << n << endl; exit(0);} else return;};
  for (int j = -1; j <= 1; ++j)
    if (0 <= p + j and p + j <= 9) f(i + 1, k, p + j, 10 * n + p + j);}
int main()
  {cin >> K;
  for (int i = 1; true; ++i) for (int j = 1; j <= 9; ++j) f(1, i, j, j);}

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

S = [0] * N
P = [0] * N
A = [[i] * 3 for i in range(1, N+1)]

for i in range(N):
    S[i], P[i] = input().strip().split()

for i in range(N):
    A[i][1]= S[i]
for i in range(N):
    A[i][2]= int(P[i])

A.sort(key=lambda x: x[2], reverse = True)
A.sort(key=lambda x: x[1])

for i in range(N):
    print(A[i][0])

Measured memory_bytes: 3064
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
s1, s2 = set(), set()
for i in range(0, n, 2):
	s1.add(a[i])
a.sort()
for i in range(0, n, 2):
	s2.add(a[i])
print(len(s1 ^ s2) // 2)

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

int main(){
  char s[200001];
  scanf("%s",s);
  int a=0,z=0;
  for(int i=0;i<strlen(s);i++){
    if(s[i]=='A'){
      a=i;
      for(int j=strlen(s)-1;j>i;j--){
        if(s[j]=='Z'){
          z=j;
          printf("%d\n",z-a+1);
          return 0;
        }
      }
    }
  }
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

string s,t;
int sa[100010],ta[100010];
int n,m;
int nxt[100010][52];
string b[20];
vector<int> ba[20];

int main(){
  cin>>s>>t;
  n=s.size();
  m=t.size();
  rep(i,n){
    if(s[i]>='A'&&s[i]<='Z')sa[i]=s[i]-'A';
    else sa[i]=s[i]-'a'+26;
  }
  rep(i,n){
    if(t[i]>='A'&&t[i]<='Z')ta[i]=t[i]-'A';
    else ta[i]=t[i]-'a'+26;
  }
  b[0]=t;
  rep(i,b[0].size()){
    if(b[0][i]>='A'&&b[0][i]<='Z')ba[0].push_back(b[0][i]-'A');
    else ba[0].push_back(b[0][i]-'a'+26);
  }
  repl(i,1,20){
    if(m*b[i-1].size()>n)break;
    rep(j,m){
      b[i]+=b[i-1];
      b[i]+=t[j];
    }
    b[i]+=b[i-1];
    rep(j,b[i].size()){
      if(b[i][j]>='A'&&b[i][j]<='Z')ba[i].push_back(b[i][j]-'A');
      else ba[i].push_back(b[i][j]-'a'+26);
    }
  }
  memset(nxt,-1,sizeof(nxt));
  for(int i=n-1;i>=0;i--){
    for(int j=0;j<52;j++){
      if(sa[i]==j)nxt[i][j]=i+1;
      else nxt[i][j]=nxt[i+1][j];
    }
  }
  rep(i,20){
    int crt=0;
    if(ba[i].size()==0){
      cout<<i<<endl;
      return 0;
    }
    rep(j,ba[i].size()){
      int nxti=nxt[crt][ba[i][j]];
      if(nxti<0){
        cout<<i<<endl;
        return 0;
      }
      crt=nxti;
    }
  }
  return 0;
}



Measured memory_bytes: 24848
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1005,ha=1e9+7;
 
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=ha) x-=ha;}
 
inline int ksm(int x,int y){
    int an=1;
    for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
    return an;
}
 
int jc[N],ni[N],f[N],n,a,b,c,d,ans,inv[N];
 
inline void init(){
    jc[0]=1;
    for(int i=1;i<=n;i++) jc[i]=jc[i-1]*(ll)i%ha;
    ni[n]=ksm(jc[n],ha-2);
    for(int i=n;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}
 
inline void dp(){
    f[0]=1;
    for(int i=a;i<=b;i++) // 最外层枚举 队伍的人数
        for(int m=i*c,j=min(i*d,n);j>=m;j--) // 第二层枚举 已经选好的人数
            for(int k=c,now=ksm(ni[i],c),M=j-c*i;k<=d&&M>=0;k++,M-=i,now=now*(ll)ni[i]%ha)
                /* 第三层枚举 这种人数的队伍选几个*/
                ADD(f[j],jc[j]*(ll)now%ha*(ll)ni[M]%ha*(ll)f[M]%ha*(ll)ni[k]%ha);
}
 
int main(){
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    init(),dp(),printf("%d\n",f[n]);
    return 0;
}

Measured memory_bytes: 256