akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,A,B,ans=0;
  cin>>N>>A>>B;
  ll X[N];
  REP(i,N) cin>>X[i];
  
  RREP(i,N-1){
    ans+=min(B,A*(X[i]-X[i-1]));
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 105
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;
const int M = 4;
ll dp[maxn][M][M][M];
int n;

int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    cin >> n;
    dp[0][3][3][3] = 1;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < M; j++)
        {
            for(int k = 0; k < M; k++)
            {
                for(int l = 0; l < M; l++)
                {
                    for(int m = 0; m < M; m++)
                    {                                           // A G C
                        if(k == 0 && l == 1 && m == 2)continue; // 0 1 2
                        if(k == 1 && l == 0 && m == 2)continue; // 1 0 2
                        if(k == 0 && l == 2 && m == 1)continue; // 0 2 1
                        if(j == 0 && k == 1 && m == 2)continue; // 0 ? 1 2
                        if(j == 0 && l == 1 && m == 2)continue; // 0 1 ? 2

                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= mod;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < M; i++)
    {
        for(int j = 0; j < M; j++)
        {
            for(int k = 0; k < M; k++)
            {
                ans += dp[n][i][j][k];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

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

        BigInteger two = BigInteger.valueOf(2);
        Scanner sc = new Scanner(System.in);

        BigInteger k = sc.nextBigInteger();
        BigInteger a = sc.nextBigInteger();
        BigInteger b = sc.nextBigInteger();

        if ((a.add(BigInteger.ONE)).compareTo(b) >= 0) {
            System.out.println(k.add(BigInteger.ONE));
            return;
        }

        if (k.compareTo(BigInteger.ONE.add(a)) < 0) {
            System.out.println(k.add(BigInteger.ONE));
            return;
        }

        BigInteger bis = b;
        k = k.subtract(BigInteger.ONE.add(a));

        if (k.remainder(two).equals(BigInteger.ONE)) {
            bis = bis.add(BigInteger.ONE);
            k = k.subtract(BigInteger.ONE);
        }

        bis = bis.add(b.subtract(a).multiply(k.divide(two)));
        System.out.println(bis);
    }
}

Measured memory_bytes: 21844
//      https://www.youtube.com/watch?v=hziG9Nr6KHU

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;	// 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define shesh               "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define mest(a,b)           memset(a,b,sizeof(a))

int main(){
    fast;
    ll t,n,m,i,j,k,l,flag,len,shit,res,ans,temp,q,a,b,d,c;
    cin>>n>>a>>b>>c>>d;
    string s;
    n--,a--,b--,c--,d--;
    cin>>s;
    for(i=b,flag=0;i<d-1&&!flag;i++){
        if(s[i]=='#' && s[i+1]=='#'){
            flag++;
        }
    }
    for(i=a;i<c-1&&!flag;i++){
        if(s[i]=='#' && s[i+1]=='#'){
            flag++;
        }
    }
    if(flag){
        cout<<"No";
        return 0;
    }
    if(c<d){
        cout<<"Yes";
        return 0;
    }
    for(i=b-1,temp=0;i<=d+1;i++){
        if(s[i]!='#'){
            temp++;
        }else temp=0;
        if(temp==3){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 592
const input = require('fs').readFileSync('/dev/stdin', 'UTF-8')

function main (input) {
  const list = input.split(' ').map(v => v * 1);
  const min1 = Math.min.apply(null, list);
  const list2 = list.filter(v => v !== min1);
  const min2 = list2.length === 0 ? min1 : Math.min.apply(null, list2);
  
  console.log(min1 + min2)
}

main(input);

Measured memory_bytes: 7372
n,m,x = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]

ans = float("INF")

for i in range(2**n):
    count = [0]*m
    c = 0
    for j in range(n):
        if (i >> j) & 1:
            c += l[j][0]
            for k in range(1,m+1):
                count[k-1] += l[j][k]
    check = True
    for j in count:
        if j < x:
            check = False
            break
    if check:
        ans = min(ans,c)
if ans == float("INF"):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9228
#include<iostream>
using namespace std;
int main(){
	int x,y,n,i,i2,i3,ans=0,tf=0;
	char map[100][100];
	cin>>y>>x>>n;
	for(i=0;i<y;i++)for(i2=0;i2<x;i2++)cin>>map[i2][i];
	for(i=0;i<y;i++){
		for(i2=0;i2<x;i2++){
			if(map[i2][i]=='.'){
				tf=0;
				for(i3=1;i3<n;i3++){
					if(map[i2+i3][i]!='.'){
						tf=1;
						break;
					}
				}
				if(tf==0){
					ans++;
					//cout<<"→ "<<i2<<' '<<i<<endl;
				}
				tf=0;
				for(i3=1;i3<n;i3++){
					if(map[i2][i+i3]!='.'){
						tf=1;
						break;
					}
				}
				if(tf==0){
					ans++;
					//cout<<"↓ "<<i2<<' '<<i<<endl;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n; 
    cin>>n;
    string s="";
    while(n>0){
     char a='a'; 
     ll ans=n%26;
     ans--; 
     if(ans<0){
       ans=25;
       n/=26;
       n--;
     }
     else{ 
     n/=26;
     }
     a+=ans; 
     s+=a; 
    }
    reverse(s.begin(),s.end());
    cout<<s; 
    //printclock;
    return 0;
}
    

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

int main() {
	int N, score;
	vector<int> V, C;

	cin >> N;

	int temp;
	for(int i = 0; i < N; i++) {
		cin >> temp;
		V.push_back(temp);
	}

	for(int i = 0; i < N; i++) {
		cin >> temp;
		C.push_back(temp);
	}

	score = 0;
	for(int i = 0; i < N; i++) {
		if(V[i] > C[i])
			score += V[i] - C[i];
	}

	cout << score << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
monsters = gets.split(" ").map {|s| s.to_i}

remaining_monsters = monsters
while(remaining_monsters.size > 1) do
  previous_remaining_monsters = remaining_monsters
  remaining_monsters = []

  weekest = previous_remaining_monsters.min

  remaining_monsters.push(weekest)
  previous_remaining_monsters
  .reject {|monster| monster == weekest }
  .each { |monster|
    rest = monster % weekest
    if rest != 0 then
      remaining_monsters.push(rest)
    end
  }
end

puts(remaining_monsters[0])


Measured memory_bytes: 10884
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let a: Vec<_> = s.map(|a| a.parse::<i32>().unwrap() - 1).collect();
	let mut visit = vec![false; n];
	let mut cur = 0;
	let mut ans = 0;
	while !visit[cur] {
		visit[cur] = true;
		cur = a[cur] as usize;
		ans += 1;
		if cur == 1 {
			println!("{}", ans);
			return;
		}
	}
	println!("-1");
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<algorithm>
using namespace std;
const int MR=2000000;

long long p(int a,int k){
	long long ans=1,t=a;
	for(int i=0;i<k;i++){
		ans*=t;
	}
	return ans;
}

int main(){
	char s[11];
	int n;
	long long a[10];
	cin.getline(s,11);
	n=strlen(s);
	for(int i=0;i<n;i++)a[n-1-i]=s[i]-'0';
	
	if(n==1){ cout<<a[0]<<endl;return 0; }
	long long ans=0;
	for(int i=0;i<n;i++){
		ans+=a[i]*(9*p(5,i)-1)/4;
	}
	ans*=p(2,n-2);
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

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

  int edges[3];
  for (int i = 0; i < num_problems; ++i) {
    cin >> edges[0] >> edges[1] >> edges[2];
    sort(edges, edges + 3);
    cout <<
        (edges[0] * edges[0] + edges[1] * edges[1] == edges[2] * edges[2] ?
         "YES" : "NO") <<
        endl;
  }

  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    string word[n];
    map<string, ll> mp;
    for (ll i = 0; i < n; i++) {
        cin >> word[i];
        mp[word[i]]++;
    }
    for (ll i = 0; i < n - 1;i++){
        if(word[i][word[i].size()-1]!=word[i+1][0]){
            cout << "No" << endl;
            return 0;
        }
    }
    for (auto i:mp){
        if(i.second>=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    ll n; cin >> n;
    int res = sqrt(n);
    cout << res * res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string s,t; cin >> s;
	int ans = mod, count = 0, min = 0, num[26] = { 0 };
	t = s;
	for (int i = 0; i < s.size(); i++) num[s[i] - 'a']++;
	for (int i = 0; i < 26; i++) {
		min = 0;
		if (num[i] != 0) {
			s = t;
			while (true) {
				string tmp;
				count = 0;
				for (int j = 0; j < s.size(); j++) {
					if (s[j] == (char)('a' + i)) count++;
				}
				if (count == s.size()) {
					if (min < ans) {
						ans = min;
					}
					break;
				}
				for (int j = 0; j < s.size() - 1; j++) {
					if (s[j] == (char)('a' + i)) tmp.push_back((char)('a' + i));
					else if (s[j + 1] == (char)('a' + i)) tmp.push_back((char)('a' + i));
					else tmp.push_back(s[j]);
				}
				min++;
				s = tmp;
				//cout << s << endl;
			}
		}
	}
	cout << ans << endl;
}


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


void solve(long long N, long long A, long long B){
    const ll AB = A + B;
    ll ans = N / AB * A + min(A, N % AB);
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(N, A, B);
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main() {
  stack<int> cars;
  string line;
  while (getline(cin, line)) {
    int car = atoi(line.c_str());
    if (car == 0) {
      cout << cars.top() << endl;
      cars.pop();
    } else {
      cars.push(car);
    }
  }

  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long h, n, a[100100], i, sum=0;
    cin >> h >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    if(sum>=h) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 4005
#define MOD 998244353

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];
int dp[SIZE][SIZE];
int cnt[SIZE][2];

int main()
{
	scanf("%s",&str);
	int n=strlen(str);
	for(int i=0;i<n;i++)
	{
		if(str[i]=='0') cnt[i][0]=2;
		else if(str[i]=='2') cnt[i][1]=2;
		else cnt[i][0]=cnt[i][1]=1;
		if(i>0)
		{
			cnt[i][0]+=cnt[i-1][0];
			cnt[i][1]+=cnt[i-1][1];
		}
	}
	dp[0][0]=1;
	int zero=cnt[n-1][0],one=cnt[n-1][1];
	for(int i=0;i<=zero;i++)
	{
		for(int j=0;j<=one;j++)
		{
			if(dp[i][j]==0) continue;
			int to=min(i+j,n-1);
			int z=cnt[to][0]-i,o=cnt[to][1]-j;
			if(z>0)
			{
				dp[i+1][j]+=dp[i][j];
				if(dp[i+1][j]>=MOD) dp[i+1][j]-=MOD;
			}
			if(o>0)
			{
				dp[i][j+1]+=dp[i][j];
				if(dp[i][j+1]>=MOD) dp[i][j+1]-=MOD;
			}
		}
	}
	printf("%d\n",dp[zero][one]);
	return 0;
}


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

int main() {
    int A, B, C, D;
    
    cin >> A >> B >> C >> D;
    
    if(A+B > C+D){
        cout << "Left" << endl;
    }else if(A+B < C+D){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int K, X;
    cin >> K >> X;

    int min_P, max_P;
    min_P = X-K+1;
    max_P = X+K-1;

    FOR(i, min_P, max_P){
        cout << i << " ";
    }

    cout << "\n";
}

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

namespace ConsoleApp11
{
    class Class74
    {
        static void Main()
        {
            var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = nx[0], X = nx[1];

            var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int gcd = 0;
            for(int i = 0; i < n; i++)
            {
                gcd = GCD(gcd, Math.Abs(X - x[i]));
            }

            Console.WriteLine(gcd);
        }
        static int GCD(int a,int b)
        {
            return b == 0 ? a : GCD(b, a % b);
        }
    }
}


Measured memory_bytes: 19680
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    ll K, A, B;
    cin >> K >> A >> B;

    //叩き続けたほうが良い時
    ll ans = 0;
    if(A >= B || B - A == 1){
        ans = 1 + K;
        cout << ans << endl;
    }else{
        K -= A - 1;
        ans = (B - A) * (K / 2) + A;
        if(K % 2 > 0){
            ans++;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)


func check(K int,A int,B int) bool {
	for i := A; i <= B; i++ {
		if (i % K == 0) {
			return true
		}
	}
	return false
}

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
    sc.Scan()
    return sc.Text()
}

func nextInt() int {
    sc.Scan()
    hoge := sc.Text()
    i, e := strconv.Atoi(hoge)
    if e != nil {
        panic(e)
    }
    return i
}



func main() {
	sc.Split(bufio.ScanWords)
	K := nextInt()
	A, B := nextInt(), nextInt()
	if  check(K, A, B) {
		fmt.Print("OK")
	} else {
		fmt.Print("NG")
	}

}

Measured memory_bytes: 1760
# 0が一つでもあれば、すべて正の数にできる
# そうでない場合、負の数の数が奇数の場合、負の数を一つ（最も絶対値が小さい）だけ残す

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

ans = 0
minabs = 10 ** 9 + 1
haszero = False
minuscnt = 0
for i in range(len(A)):
  if A[i] == 0:
    haszero = True
  elif A[i] < 0:
    minuscnt += 1
  ans += abs(A[i])
  if abs(A[i]) < minabs:
    minabs = abs(A[i])
    
if haszero:
  print(ans)
elif minuscnt % 2 == 1:
  print(ans - minabs * 2)
else:
  print(ans)

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

int main(void)
{
	int n,t,sum=0;
	cin >> n >> t;

	int array[n];

	cin >> array[0];
	for (int i=1;i<n;i++) {
		cin >> array[i];
		if (array[i]-array[i-1] < t) {
			sum += t-(array[i]-array[i-1]);
		}
	}
	int ans=0;

	cout <<  n*t - sum << endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
answer = 1
zero_check = 0 in a

for i in range(n):
    answer = a[i] * answer
    if zero_check:
        print(0)
        break
    elif answer > 1000000000000000000:
        print(-1)
        break
else:
    print(answer)


Measured memory_bytes: 21600
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    pp = list(map(int, input().split()))

    c = 0
    for p1,p2 in zip(pp, sorted(pp)):
        if p1 != p2:
            c += 1

    if c == 2 or c == 0:
        print("YES")
    else:
        print("NO")

if __name__ == '__main__':
    main()


Measured memory_bytes: 65260
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

int cnt[100010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,maxV = 0;
	int A[110], B[110];
	cin >> N;
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];
	REP(turnP, N) {
		int tmpV = 0;
		REP(j, turnP+1) {
			tmpV += A[j];
		}
		REPL(j, turnP,N) {
			tmpV += B[j];
		}
		maxV = max(maxV, tmpV);
	}

	cout << maxV << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        var sc = new Scanner(System.in);
    
        int n = Integer.parseInt(sc.next());
    
        var a = new int[60001];
        for(int x = 1; x <= 100; x++){
            for(int y = 1; y <= 100; y++){
                for(int z = 1; z <= 100; z++){
                    int b = x*x + y*y + z*z + x*y + y*z + z*x;
                    a[b]++;
                }
            }
        }
        
        var pw = new PrintWriter(System.out);
        for(int i = 1; i <= n; i++){
            pw.println(a[i]);
        }
        pw.flush();
    }
}

Measured memory_bytes: 36988
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#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))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//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; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vi H(N); REP(i,N) cin >> H[i];

  int cnt = 0;
  int ans = 0;
  //bool down = false;
  int prev = H[0];
  FOR(i,1,N) {
    if (prev >= H[i]) {
      //down = true;
      cnt++;
      chmax(ans,cnt);
    }
    else {
      cnt = 0;
    }
    prev = H[i];
  }

  cout << ans << endl;
}

Measured memory_bytes: 768
//Do what you can't.

import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main{
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    int a=in.nextInt(),b=in.nextInt(),c=in.nextInt();
    if (b-a==c-b)
      w.println("YES");
    else
      w.println("NO");

    w.close();
  }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
        throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
          return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
          throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
        c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
        return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}

Measured memory_bytes: 21204
a,b,m=map(int,input().split())
a=list(map(int,input().split()))

b=list(map(int,input().split()))
x=[]
for i in range(m):
    x.append(list(map(int,input().split())))

ans=min(a)+min(b)
for i in range(m):
    ans=min(ans,a[x[i][0]-1]+b[x[i][1]-1]-x[i][2])
print(ans)

Measured memory_bytes: 38564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define pd(a,n) for(int i=0;i<n;i++)cout<<a[i]<<((i==n-1)?"\n":" ");cout<<endl;
#define pdd(a,n,m)for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define mp make_pair
#define pb push_back
#define ll long long
//#define __int64 lng long
#define P pair<int,int>
#define PP pair<P,int>

int n;
int dp[1111];

int main(){
  dp[1]=1,dp[2]=2;
  cin>>n;
  for(int i=3;i<=n;i++)dp[i]=dp[i-1]+dp[i-2];
  cout<<dp[n]<<endl;
  
  return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;
#define RPT(n) for (int i = 0; i < n; i++)

// ABC101-B - Digit Sums
int S(int n)
{
    int cur = n;
    int ret = 0;
    do
    {
        ret += cur % 10;
        cur /= 10;
    } while (cur > 0);

    return ret;
}

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

    string ans = (N % S(N) == 0) ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
ll a[100005];
int main()
{
	ios;
	ll n,m,i,lcm,f=0,d=0;
	cin>>n>>m;
	lcm=1;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		lcm=(lcm*(a[i]/2))/(__gcd(lcm,a[i]/2));
	}
	for(i=1;i<=n;i++)
	{
		if((lcm/(a[i]/2))%2==0)
		{
			cout<<0<<endl;
			exit(0);
		}
	}
	if(m>=lcm)
		d=(m-lcm)/(2*lcm)+1;
	cout<<d<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int a,b,h;
    cin>>a>>b>>h;
    cout<<(a+b)*h/2<<endl;
    
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n, t;
  cin >> n >> t;
  vector<ll> v(n);
  rep(i, 0, n) cin >> v[i];

  ll ans = 0;
  rep(i, 0, n-1){
    if(v[i]+t > v[i+1]) ans += v[i+1] - v[i];
    else ans += t;
  } 
  cout << ans + t << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
using namespace std;
#define int long long

int T[10000010]={};
signed main() {
  int N,C,K;
  cin>>N>>C>>K;
  for(int i=0;i<N;i++) cin>>T[i];
  sort(T,T+N);
  int ans=0;
  int cur=0;
  while(cur<N){
    int nex=cur;
    while(nex<N&&nex-cur<C&&T[nex]-T[cur]<=K)nex++;
    ans++;
    cur=nex;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define ll long long
#define rep(i, a, b) for(int i = a; i < b; i++)
using namespace std;

int main() {
  int h, w, cntw = 0;
  cin >> h >> w;
  vector<vector<int>> v(h+2, vector<int>(w+2, -2));
  queue<pair<int,int>> q;
  rep(i, 1, h+1) {
    rep(j, 1, w+1) {
      char c;
      cin >> c;
      if(c == '#') {
        v[i][j] = -2;
      } else {
        v[i][j] = -1;
        cntw++;
      }
    }
  }
  q.push(make_pair(1, 1));
  while(!q.empty()) {
    pair<int, int> f = q.front();
    q.pop();
    int x = f.first, y = f.second;
    if(v[x+1][y] == -1) {
      v[x+1][y] = v[x][y] + 1;
      q.push(make_pair(x+1, y));
    }
      if(v[x-1][y] == -1) {
      v[x-1][y] = v[x][y] + 1;
      q.push(make_pair(x-1, y));
    }
      if(v[x][y+1] == -1) {
      v[x][y+1] = v[x][y] + 1;
      q.push(make_pair(x, y+1));
    }
      if(v[x][y-1] == -1) {
      v[x][y-1] = v[x][y] + 1;
      q.push(make_pair(x, y-1));
    }
  }
  if(v[h][w] == -1) cout << -1 << "\n";
  else cout << cntw - v[h][w] - 2 << "\n";
}

Measured memory_bytes: 3580
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 2e5 + 5;

int N, K;
char S[MAXN];

void input()
{
    read(N); read(K);
    scanf("%s", S + 1);
}

void solve()
{
    std::deque<int> A;
    int flip = 0;

    for (int i = 1; i <= N; ++i) {
        A.push_back(S[i] - 'A');
    }
    for (int i = 1; i <= N * 2; ++i) {
        if (flip ^ A.front()) {
            A.pop_front();
            A.push_back(!flip);
            flip ^= 1;
        } else
            A.front() ^= 1;
        if (i == K) {
            for (auto x: A) {
                putchar((x ^ flip) + 'A');
            }
            return;
        }
    }

    K -= N * 2;
    if (N & 1) {
        K -= (A.front() ^ flip);
        putchar((K & 1) + 'A');
        for (int i = 1; i < N; ++i) {
            putchar((i & 1) + 'A');
        }
    } else {
        for (int i = 1; i <= N; ++i) {
            putchar((i & 1) + 'A');
        }
    }
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 吝啬原则：除非别无他法，不要编写庞大的程序。
//     -- UNIX哲学基础第六条，《UNIX编程艺术》by ESR


Measured memory_bytes: 1536
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void printer2(int *, int, int);
int partition(int *, int, int);

int main(){
  int i, n;
  int *A;

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

  i = partition(A, 0, n);

  printer2(A, n, i);

  return 0;
}

void printer2(int *array, int n, int x){
  int i;
  for(i=0; i<n; i++){
    if(i == x) printf("[%d]",array[i]);
    else printf("%d",array[i]);

    if(i != n-1) printf(" ");
    else printf("\n");
  }
}

int partition(int *A, int p, int r){
  int i=p-1, j, temp,  x=A[r-1];

  for(j=p; j<r-1; j++){
    if(A[j] <= x){
      i ++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = temp;

  return i+1;
}



Measured memory_bytes: 2192
#include <stdio.h>

#define N 100

struct pair{
	int n;
	char m;
};

struct pair bubble[N],sel[N];
int n,count=0;

void Bubble(){
	int i,j;
	struct pair tmp;
	for(i=0;i<n-1;i++){
		for(j=n-1;j>i;j--){
			if(bubble[j].n < bubble[j-1].n){
				tmp=bubble[j];
				bubble[j] = bubble[j-1];
				bubble[j-1] = tmp;
				count++;
			}
		}
	}
}

void Select(){
	int i,minj,j;
	struct pair tmp;
	for(i = 0;i < n -1; i++){
		minj = i;
		for(j = i+1; j< n;j ++){
			if(sel[j].n < sel[minj].n){
				minj = j;
			}
		}
		if(minj != i){
			tmp = sel[minj];
			sel[minj] = sel[i];
			sel[i] = tmp;
			count++;
		}
	}

}

void print(){
	int i;
	for(i=0;i<n-1;i++){
		printf("%c%d ",bubble[i].m,bubble[i].n);
	}
	printf("%c%d\nStable\n",bubble[i].m,bubble[i].n);
	int flag=0;
	for(i=0;i<n-1;i++){
		if(sel[i].m != bubble[i].m) flag = 1;
		printf("%c%d ",sel[i].m,sel[i].n);
	}
	if(flag)printf("%c%d\nNot stable\n",sel[i].m,sel[i].n);
	else{printf("%c%d\nStable\n",sel[i].m,sel[i].n);}
}

int main(){
	int i;
	struct pair card[N];
	char space;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%c%d%c",&card[i].m,&card[i].n,&space);
		bubble[i] = sel[i] = card[i];
	}
	Bubble();
	Select();
	print();
	return 0;
}

Measured memory_bytes: 2756
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=1,mx=a[0];
	for(int i=1;i<n;i++){
		if(a[i]>=mx) ans++;
		mx=max(mx,a[i]);
	}
	cout<<ans;
	re 0;
}

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO

    int n;
    cin >> n;

    int a, bef = 1, ans = 0;
    for(int i = 0; i < n; i++) {
        cin >> a;
        if(a == bef) {
            bef++;
        }else {
            ans++;
        }
    }
    cout << (bef == 1 ? -1 : ans);
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll x; cin >> x;
    ll ans = 0;
    ll now = 100;
    while(now < x) {
        now = now + now/100;
        ans++;
    }
    cout << ans << endl;
    //cout << 16. / log10(1.1) << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main (void)
{
	int n;
	int a=1;
	int b;
	scanf("%d",&n);
	for(a=1;a<=n;a++){
		if(a % 3 == 0 ||  a % 10 == 3){
			printf(" %d",a);
		}
		else{
			b = a;
		while(1){
		b/=10;
		if( b % 10 == 3){
			printf(" %d",a);
		}
		if(b/10 ==0 || b%10 == 3){
			break;
		}
		}
	}
		}
		printf("\n");
		return 0;
}

Measured memory_bytes: 600
import java.util.*;


public class Main {
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
        //int a = sc.nextInt();
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        System.out.println(a<b&&b<c?"Yes":"No");
    
    }
}


Measured memory_bytes: 26196
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
int POW[31];

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 30; i++){

		POW[i] = POW[i-1]*2;
	}

	int min_POW = BIG_NUM;
	int L,R,mid,tmp,tmp_max;

	scanf("%d",&N);

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

		scanf("%d",&tmp);

		tmp_max = 0;
		L = 0,R = 30,mid = (L+R)/2;

		while(L <= R){

			if(tmp%POW[mid] == 0){

				tmp_max = mid;
				L = mid+1;
			}else{

				R = mid-1;
			}
			mid = (L+R)/2;
		}

		min_POW = min(min_POW,tmp_max);
	}

	printf("%d\n",min_POW);

	return 0;
}


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

namespace AtCoder
{
    class Program
    {

        static void Main()
        {
            //ここから

            long[] str = ReadLineToLongArray();
            long a = str[0];
            long b = str[1];
            long c = str[2];
            long k = str[3];

            long ans = 0;

            if (k % 2 == 0)
            {
                ans=  a - b;
            }
            else
            {
                ans = b - a;
            }

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }



        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }



    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define rkc ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
#define fl(i,a,b) for(ll i=a;i<b;i++)
#define rfl(i,a,b) for(ll i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define test ll t;cin>>t;while(t--)
#define lld long double
#define vpp vector<pair<ll,ll>>
#define ff first
#define ss second
const ll M = 1e9 + 7;
const double pi  =3.141592653589793238463;
int main()
{
    rkc;
    ll k,x;
    cin>>k>>x;
    fl(i,x-k+1,x+k)cout<<i<<" ";
}

Measured memory_bytes: 256
N = int(input())
count = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        if count >= 3:
            print("Yes")
            break
    else:
        count = 0
if count < 3:
    print("No")


Measured memory_bytes: 9156
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>

using  namespace std;
using namespace boost;

int main() {
    int X, Y;
    cin >> X >> Y;
    if (X % Y == 0) {
        cout << "-1";
    } else{
        cout << X;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
        #pragma GCC optimize ("Ofast")
        #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
         
         
        #include <iostream>
        #include <iomanip>
        #include <sstream>
        #include <cstring>
        #include <vector>
        #include <deque>
        #include <queue>
        #include <set>
        #include <map>
        #include <valarray>
        #include <iterator>
        #include <functional>
        #include <limits>
        #include <algorithm>
        #include <numeric>
        #include <cmath>
        #include <cassert>
        #include <unordered_map>
        #include <unordered_set>
        #include <stack>
        using namespace std;
        #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
         #define trace(x) cerr << #x << ": " << x << " " << endl;
     
        typedef int64_t ll;
     
        #define endl '\n'
        #define int ll
        ll mod=1e9+7;
        ll mod1=1e9+5;
        ll power(ll a,ll b)
        {
            if(b==0) return 1;
            else if(b%2==0)
                return power((((a%mod)*(a%mod))%mod),b/2)%mod;
            else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
        }
        #define PI 3.14159265
     int32_t main()
        {

       
        double a,b,x;
        cin>>a>>b>>x;
        double p=(2*x)/(a*a)-b;
        if(p<0)
        {
            p=(2*x)/(a*b);
            double ans=atan(p/b);

        double val = (ans * (double)180) / PI;
        cout<<setprecision(10)<<fixed<<90-val;;
        return 0;
        }
        p=b-p;
        double ans=atan(a/p);

        double val = (ans * (double)180) / PI;
        cout<<setprecision(10)<<fixed<<90-val;; 
        
        }

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define $ template <tyepename T>

int main(){
    ios::sync_with_stdio(false);
	int n;
	string st;
	int k;
	cin >> n >> st >> k;
	for(int i=0; i<n; i++){
		if(st[k-1]!=st[i])
			cout << "*";
		else
			cout << st[i];
	}
    cout << endl;
}

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

int main()
{ //freopen("in.txt","r",stdin);
 //freopen("out.txt","w",stdout);
 int a,b;
 cin>>a>>b;
  if(a>b)
   cout<<a+a-1;
   else if(b>a)
   cout<<b+b-1;
   else
 cout<<a+b;
  
}

Measured memory_bytes: 256